summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-02-15 11:15:47 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2008-02-15 11:15:47 +0000
commit6ac2c1cc0cd1253ba2014d459010032127f185ec (patch)
tree6348de9de19e7394800a983c8c614566d22b870b /src/mesa
parentc04a7f8929d674971a472ffa4d3a31200c22aa5a (diff)
parent6d3831b11d9f5aaba61cc2fb8ade61437ad7c335 (diff)
Merge commit 'origin/gallium-0.1' into gallium-0.1
Conflicts: src/gallium/drivers/softpipe/sp_quad_fs.c src/gallium/drivers/softpipe/sp_state.h src/gallium/drivers/softpipe/sp_state_fs.c
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/Makefile16
-rw-r--r--src/mesa/drivers/dri/intel_winsys/Makefile38
-rw-r--r--src/mesa/drivers/dri/intel_winsys/SConscript41
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c357
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h149
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_batchpool.c424
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_batchpool.h37
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_context.c304
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_context.h158
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_lock.c102
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_reg.h53
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_screen.c537
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_screen.h113
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c252
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h47
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys.h73
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c154
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c302
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_softpipe.c81
-rw-r--r--src/mesa/drivers/dri/intel_winsys/server/i830_common.h226
-rw-r--r--src/mesa/drivers/dri/intel_winsys/server/i830_dri.h63
-rw-r--r--src/mesa/drivers/dri/intel_winsys/server/intel.h331
-rw-r--r--src/mesa/drivers/dri/intel_winsys/server/intel_dri.c1306
-rw-r--r--src/mesa/drivers/x11/xm_api.c2
-rw-r--r--src/mesa/drivers/x11/xm_dd.c2
-rw-r--r--src/mesa/drivers/x11/xm_surface.c8
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c2
-rw-r--r--src/mesa/drivers/x11/xmesaP.h4
-rw-r--r--src/mesa/pipe/Makefile28
-rw-r--r--src/mesa/pipe/Makefile.template63
-rw-r--r--src/mesa/pipe/README.portability43
-rw-r--r--src/mesa/pipe/SConscript9
-rw-r--r--src/mesa/pipe/cell/Makefile12
-rw-r--r--src/mesa/pipe/cell/common.h220
-rw-r--r--src/mesa/pipe/cell/ppu/Makefile76
-rw-r--r--src/mesa/pipe/cell/ppu/cell_batch.c217
-rw-r--r--src/mesa/pipe/cell/ppu/cell_batch.h58
-rw-r--r--src/mesa/pipe/cell/ppu/cell_clear.c76
-rw-r--r--src/mesa/pipe/cell/ppu/cell_clear.h43
-rw-r--r--src/mesa/pipe/cell/ppu/cell_context.c287
-rw-r--r--src/mesa/pipe/cell/ppu/cell_context.h135
-rw-r--r--src/mesa/pipe/cell/ppu/cell_draw_arrays.c164
-rw-r--r--src/mesa/pipe/cell/ppu/cell_draw_arrays.h42
-rw-r--r--src/mesa/pipe/cell/ppu/cell_flush.c84
-rw-r--r--src/mesa/pipe/cell/ppu/cell_flush.h38
-rw-r--r--src/mesa/pipe/cell/ppu/cell_render.c210
-rw-r--r--src/mesa/pipe/cell/ppu/cell_render.h39
-rw-r--r--src/mesa/pipe/cell/ppu/cell_spu.c155
-rw-r--r--src/mesa/pipe/cell/ppu/cell_spu.h82
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state.h115
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_blend.c109
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_clip.c84
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_derived.c192
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_emit.c103
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_emit.h36
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_fs.c171
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_rasterizer.c106
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_sampler.c84
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_surface.c71
-rw-r--r--src/mesa/pipe/cell/ppu/cell_state_vertex.c63
-rw-r--r--src/mesa/pipe/cell/ppu/cell_surface.c179
-rw-r--r--src/mesa/pipe/cell/ppu/cell_surface.h42
-rw-r--r--src/mesa/pipe/cell/ppu/cell_texture.c252
-rw-r--r--src/mesa/pipe/cell/ppu/cell_texture.h80
-rw-r--r--src/mesa/pipe/cell/ppu/cell_vbuf.c294
-rw-r--r--src/mesa/pipe/cell/ppu/cell_vbuf.h38
-rw-r--r--src/mesa/pipe/cell/ppu/cell_vertex_shader.c120
-rw-r--r--src/mesa/pipe/cell/ppu/cell_winsys.c40
-rw-r--r--src/mesa/pipe/cell/ppu/cell_winsys.h50
-rw-r--r--src/mesa/pipe/cell/spu/Makefile72
-rw-r--r--src/mesa/pipe/cell/spu/spu_blend.c62
-rw-r--r--src/mesa/pipe/cell/spu/spu_blend.h37
-rw-r--r--src/mesa/pipe/cell/spu/spu_colorpack.h110
-rw-r--r--src/mesa/pipe/cell/spu/spu_exec.c1948
-rw-r--r--src/mesa/pipe/cell/spu/spu_exec.h172
-rw-r--r--src/mesa/pipe/cell/spu/spu_main.c567
-rw-r--r--src/mesa/pipe/cell/spu/spu_main.h177
-rw-r--r--src/mesa/pipe/cell/spu/spu_render.c301
-rw-r--r--src/mesa/pipe/cell/spu/spu_render.h38
-rw-r--r--src/mesa/pipe/cell/spu/spu_texture.c217
-rw-r--r--src/mesa/pipe/cell/spu/spu_texture.h47
-rw-r--r--src/mesa/pipe/cell/spu/spu_tile.c83
-rw-r--r--src/mesa/pipe/cell/spu/spu_tile.h73
-rw-r--r--src/mesa/pipe/cell/spu/spu_tri.c926
-rw-r--r--src/mesa/pipe/cell/spu/spu_tri.h37
-rw-r--r--src/mesa/pipe/cell/spu/spu_util.c165
-rw-r--r--src/mesa/pipe/cell/spu/spu_vertex_fetch.c393
-rw-r--r--src/mesa/pipe/cell/spu/spu_vertex_shader.c231
-rw-r--r--src/mesa/pipe/cell/spu/spu_vertex_shader.h61
-rw-r--r--src/mesa/pipe/cell/spu/spu_ztest.h135
-rw-r--r--src/mesa/pipe/cso_cache/cso_cache.c181
-rw-r--r--src/mesa/pipe/cso_cache/cso_cache.h107
-rw-r--r--src/mesa/pipe/cso_cache/cso_hash.c388
-rw-r--r--src/mesa/pipe/cso_cache/cso_hash.h62
-rw-r--r--src/mesa/pipe/draw/Makefile2
-rw-r--r--src/mesa/pipe/draw/draw_clip.c488
-rw-r--r--src/mesa/pipe/draw/draw_context.c293
-rw-r--r--src/mesa/pipe/draw/draw_context.h142
-rw-r--r--src/mesa/pipe/draw/draw_cull.c150
-rw-r--r--src/mesa/pipe/draw/draw_debug.c113
-rw-r--r--src/mesa/pipe/draw/draw_flatshade.c205
-rw-r--r--src/mesa/pipe/draw/draw_offset.c186
-rw-r--r--src/mesa/pipe/draw/draw_prim.c482
-rw-r--r--src/mesa/pipe/draw/draw_private.h346
-rw-r--r--src/mesa/pipe/draw/draw_stipple.c238
-rw-r--r--src/mesa/pipe/draw/draw_twoside.c203
-rw-r--r--src/mesa/pipe/draw/draw_unfilled.c204
-rw-r--r--src/mesa/pipe/draw/draw_validate.c185
-rw-r--r--src/mesa/pipe/draw/draw_vbuf.c567
-rw-r--r--src/mesa/pipe/draw/draw_vbuf.h106
-rw-r--r--src/mesa/pipe/draw/draw_vertex.c79
-rw-r--r--src/mesa/pipe/draw/draw_vertex.h106
-rw-r--r--src/mesa/pipe/draw/draw_vertex_cache.c196
-rw-r--r--src/mesa/pipe/draw/draw_vertex_fetch.c510
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c327
-rw-r--r--src/mesa/pipe/draw/draw_vf.c428
-rw-r--r--src/mesa/pipe/draw/draw_vf.h223
-rw-r--r--src/mesa/pipe/draw/draw_vf_generic.c585
-rw-r--r--src/mesa/pipe/draw/draw_vf_sse.c614
-rw-r--r--src/mesa/pipe/draw/draw_wide_prims.c432
-rw-r--r--src/mesa/pipe/failover/Makefile21
-rw-r--r--src/mesa/pipe/failover/fo_context.c155
-rw-r--r--src/mesa/pipe/failover/fo_context.h114
-rw-r--r--src/mesa/pipe/failover/fo_state.c457
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c137
-rw-r--r--src/mesa/pipe/failover/fo_winsys.h45
-rw-r--r--src/mesa/pipe/i915simple/Makefile38
-rw-r--r--src/mesa/pipe/i915simple/SConscript29
-rw-r--r--src/mesa/pipe/i915simple/i915_batch.h54
-rw-r--r--src/mesa/pipe/i915simple/i915_blit.c162
-rw-r--r--src/mesa/pipe/i915simple/i915_blit.h55
-rw-r--r--src/mesa/pipe/i915simple/i915_clear.c47
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c320
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h304
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.c901
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.h117
-rw-r--r--src/mesa/pipe/i915simple/i915_debug_fp.c366
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c81
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc.h213
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc_emit.c375
-rw-r--r--src/mesa/pipe/i915simple/i915_fpc_translate.c1135
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_emit.c215
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c254
-rw-r--r--src/mesa/pipe/i915simple/i915_reg.h978
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c694
-rw-r--r--src/mesa/pipe/i915simple/i915_state.h50
-rw-r--r--src/mesa/pipe/i915simple/i915_state_derived.c177
-rw-r--r--src/mesa/pipe/i915simple/i915_state_dynamic.c308
-rw-r--r--src/mesa/pipe/i915simple/i915_state_emit.c374
-rw-r--r--src/mesa/pipe/i915simple/i915_state_immediate.c221
-rw-r--r--src/mesa/pipe/i915simple/i915_state_inlines.h230
-rw-r--r--src/mesa/pipe/i915simple/i915_state_sampler.c231
-rw-r--r--src/mesa/pipe/i915simple/i915_strings.c83
-rw-r--r--src/mesa/pipe/i915simple/i915_surface.c191
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.c536
-rw-r--r--src/mesa/pipe/i915simple/i915_texture.h17
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h115
-rw-r--r--src/mesa/pipe/i965simple/Makefile66
-rw-r--r--src/mesa/pipe/i965simple/SConscript55
-rw-r--r--src/mesa/pipe/i965simple/brw_batch.h59
-rw-r--r--src/mesa/pipe/i965simple/brw_blit.c218
-rw-r--r--src/mesa/pipe/i965simple/brw_blit.h33
-rw-r--r--src/mesa/pipe/i965simple/brw_cc.c269
-rw-r--r--src/mesa/pipe/i965simple/brw_clip.c206
-rw-r--r--src/mesa/pipe/i965simple/brw_clip.h170
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_line.c245
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_point.c47
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_state.c92
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_tri.c566
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_unfilled.c477
-rw-r--r--src/mesa/pipe/i965simple/brw_clip_util.c351
-rw-r--r--src/mesa/pipe/i965simple/brw_context.c245
-rw-r--r--src/mesa/pipe/i965simple/brw_context.h690
-rw-r--r--src/mesa/pipe/i965simple/brw_curbe.c368
-rw-r--r--src/mesa/pipe/i965simple/brw_defines.h852
-rw-r--r--src/mesa/pipe/i965simple/brw_draw.c239
-rw-r--r--src/mesa/pipe/i965simple/brw_draw.h55
-rw-r--r--src/mesa/pipe/i965simple/brw_draw_upload.c299
-rw-r--r--src/mesa/pipe/i965simple/brw_eu.c130
-rw-r--r--src/mesa/pipe/i965simple/brw_eu.h888
-rw-r--r--src/mesa/pipe/i965simple/brw_eu_debug.c90
-rw-r--r--src/mesa/pipe/i965simple/brw_eu_emit.c1080
-rw-r--r--src/mesa/pipe/i965simple/brw_eu_util.c126
-rw-r--r--src/mesa/pipe/i965simple/brw_flush.c80
-rw-r--r--src/mesa/pipe/i965simple/brw_gs.c196
-rw-r--r--src/mesa/pipe/i965simple/brw_gs.h75
-rw-r--r--src/mesa/pipe/i965simple/brw_gs_emit.c148
-rw-r--r--src/mesa/pipe/i965simple/brw_gs_state.c89
-rw-r--r--src/mesa/pipe/i965simple/brw_misc_state.c486
-rw-r--r--src/mesa/pipe/i965simple/brw_reg.h76
-rw-r--r--src/mesa/pipe/i965simple/brw_sf.c351
-rw-r--r--src/mesa/pipe/i965simple/brw_sf.h122
-rw-r--r--src/mesa/pipe/i965simple/brw_sf_emit.c382
-rw-r--r--src/mesa/pipe/i965simple/brw_sf_state.c180
-rw-r--r--src/mesa/pipe/i965simple/brw_shader_info.c49
-rw-r--r--src/mesa/pipe/i965simple/brw_state.c424
-rw-r--r--src/mesa/pipe/i965simple/brw_state.h158
-rw-r--r--src/mesa/pipe/i965simple/brw_state_batch.c113
-rw-r--r--src/mesa/pipe/i965simple/brw_state_cache.c443
-rw-r--r--src/mesa/pipe/i965simple/brw_state_pool.c137
-rw-r--r--src/mesa/pipe/i965simple/brw_state_upload.c202
-rw-r--r--src/mesa/pipe/i965simple/brw_strings.c72
-rw-r--r--src/mesa/pipe/i965simple/brw_structs.h1348
-rw-r--r--src/mesa/pipe/i965simple/brw_surface.c210
-rw-r--r--src/mesa/pipe/i965simple/brw_tex_layout.c353
-rw-r--r--src/mesa/pipe/i965simple/brw_tex_layout.h15
-rw-r--r--src/mesa/pipe/i965simple/brw_urb.c186
-rw-r--r--src/mesa/pipe/i965simple/brw_util.c104
-rw-r--r--src/mesa/pipe/i965simple/brw_util.h43
-rw-r--r--src/mesa/pipe/i965simple/brw_vs.c120
-rw-r--r--src/mesa/pipe/i965simple/brw_vs.h82
-rw-r--r--src/mesa/pipe/i965simple/brw_vs_emit.c1332
-rw-r--r--src/mesa/pipe/i965simple/brw_vs_state.c102
-rw-r--r--src/mesa/pipe/i965simple/brw_winsys.h205
-rw-r--r--src/mesa/pipe/i965simple/brw_wm.c210
-rw-r--r--src/mesa/pipe/i965simple/brw_wm.h142
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_decl.c383
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_glsl.c1079
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_iz.c214
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_sampler_state.c273
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_state.c194
-rw-r--r--src/mesa/pipe/i965simple/brw_wm_surface_state.c304
-rw-r--r--src/mesa/pipe/llvm/Makefile85
-rw-r--r--src/mesa/pipe/llvm/gallivm.cpp327
-rw-r--r--src/mesa/pipe/llvm/gallivm.h103
-rw-r--r--src/mesa/pipe/llvm/gallivm_builtins.cpp567
-rw-r--r--src/mesa/pipe/llvm/gallivm_cpu.cpp202
-rw-r--r--src/mesa/pipe/llvm/gallivm_p.h110
-rw-r--r--src/mesa/pipe/llvm/instructions.cpp889
-rw-r--r--src/mesa/pipe/llvm/instructions.h152
-rw-r--r--src/mesa/pipe/llvm/instructionssoa.cpp46
-rw-r--r--src/mesa/pipe/llvm/instructionssoa.h66
-rw-r--r--src/mesa/pipe/llvm/llvm_base_shader.cpp833
-rw-r--r--src/mesa/pipe/llvm/llvm_builtins.c115
-rw-r--r--src/mesa/pipe/llvm/llvm_entry.c163
-rw-r--r--src/mesa/pipe/llvm/loweringpass.cpp17
-rw-r--r--src/mesa/pipe/llvm/loweringpass.h15
-rw-r--r--src/mesa/pipe/llvm/storage.cpp364
-rw-r--r--src/mesa/pipe/llvm/storage.h133
-rw-r--r--src/mesa/pipe/llvm/storagesoa.cpp208
-rw-r--r--src/mesa/pipe/llvm/storagesoa.h90
-rw-r--r--src/mesa/pipe/llvm/tgsitollvm.cpp1208
-rw-r--r--src/mesa/pipe/llvm/tgsitollvm.h20
-rw-r--r--src/mesa/pipe/p_compiler.h116
-rw-r--r--src/mesa/pipe/p_context.h221
-rw-r--r--src/mesa/pipe/p_debug.h86
-rw-r--r--src/mesa/pipe/p_defines.h270
-rw-r--r--src/mesa/pipe/p_format.h421
-rw-r--r--src/mesa/pipe/p_inlines.h112
-rw-r--r--src/mesa/pipe/p_shader_tokens.h806
-rw-r--r--src/mesa/pipe/p_state.h322
-rw-r--r--src/mesa/pipe/p_thread.h54
-rw-r--r--src/mesa/pipe/p_util.h408
-rw-r--r--src/mesa/pipe/p_winsys.h160
-rw-r--r--src/mesa/pipe/pipebuffer/Makefile23
-rw-r--r--src/mesa/pipe/pipebuffer/linked_list.h91
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.h202
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.c299
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.h117
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_malloc.c127
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr.h126
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c131
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c593
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c288
-rw-r--r--src/mesa/pipe/pipebuffer/pb_winsys.c170
-rw-r--r--src/mesa/pipe/softpipe/Makefile53
-rw-r--r--src/mesa/pipe/softpipe/SConscript42
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.c73
-rw-r--r--src/mesa/pipe/softpipe/sp_clear.h43
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c333
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h152
-rw-r--r--src/mesa/pipe/softpipe/sp_draw_arrays.c164
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.c73
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.h35
-rw-r--r--src/mesa/pipe/softpipe/sp_fs_exec.c112
-rw-r--r--src/mesa/pipe/softpipe/sp_fs_llvm.c200
-rw-r--r--src/mesa/pipe/softpipe/sp_fs_sse.c192
-rw-r--r--src/mesa/pipe/softpipe/sp_headers.h82
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.c1244
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_setup.h79
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_vbuf.c222
-rw-r--r--src/mesa/pipe/softpipe/sp_prim_vbuf.h38
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.c118
-rw-r--r--src/mesa/pipe/softpipe/sp_quad.h70
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_alpha_test.c108
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_blend.c749
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_bufloop.c72
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_colormask.c110
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_coverage.c88
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_depth_test.c276
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_earlyz.c88
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_fs.c208
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_occlusion.c85
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_output.c90
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stencil.c352
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stipple.c94
-rw-r--r--src/mesa/pipe/softpipe/sp_query.c107
-rw-r--r--src/mesa/pipe/softpipe/sp_query.h39
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h184
-rw-r--r--src/mesa/pipe/softpipe/sp_state_blend.c98
-rw-r--r--src/mesa/pipe/softpipe/sp_state_clip.c83
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c190
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c156
-rw-r--r--src/mesa/pipe/softpipe/sp_state_rasterizer.c62
-rw-r--r--src/mesa/pipe/softpipe/sp_state_sampler.c89
-rw-r--r--src/mesa/pipe/softpipe/sp_state_surface.c109
-rw-r--r--src/mesa/pipe/softpipe/sp_state_vertex.c64
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c159
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.h42
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.c916
-rw-r--r--src/mesa/pipe/softpipe/sp_tex_sample.h17
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.c166
-rw-r--r--src/mesa/pipe/softpipe/sp_texture.h71
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c585
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.h104
-rw-r--r--src/mesa/pipe/softpipe/sp_winsys.h57
-rw-r--r--src/mesa/pipe/tgsi/Makefile3
-rw-r--r--src/mesa/pipe/tgsi/exec/Makefile3
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.c2465
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.h243
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_sse2.c2377
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_sse2.h26
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_build.c1371
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_build.h320
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_dump.c1581
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_dump.h28
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_parse.c319
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_parse.h121
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_util.c274
-rw-r--r--src/mesa/pipe/tgsi/util/tgsi_util.h70
-rw-r--r--src/mesa/pipe/util/p_debug.c76
-rw-r--r--src/mesa/pipe/util/p_tile.c699
-rw-r--r--src/mesa/pipe/util/p_tile.h81
-rw-r--r--src/mesa/pipe/util/p_util.c73
-rw-r--r--src/mesa/pipe/xlib/brw_aub.c392
-rw-r--r--src/mesa/pipe/xlib/brw_aub.h114
-rw-r--r--src/mesa/pipe/xlib/fakeglx.c3188
-rw-r--r--src/mesa/pipe/xlib/glxapi.c1408
-rw-r--r--src/mesa/pipe/xlib/glxapi.h228
-rw-r--r--src/mesa/pipe/xlib/glxheader.h62
-rw-r--r--src/mesa/pipe/xlib/realglx.c180
-rw-r--r--src/mesa/pipe/xlib/realglx.h326
-rw-r--r--src/mesa/pipe/xlib/xfonts.c377
-rw-r--r--src/mesa/pipe/xlib/xfonts.h41
-rw-r--r--src/mesa/pipe/xlib/xm_api.c1380
-rw-r--r--src/mesa/pipe/xlib/xm_image.c133
-rw-r--r--src/mesa/pipe/xlib/xm_image.h77
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c466
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.c589
-rw-r--r--src/mesa/pipe/xlib/xm_winsys_aub.h67
-rw-r--r--src/mesa/pipe/xlib/xmesaP.h176
-rw-r--r--src/mesa/ppc/rtasm/spe_asm.c351
-rw-r--r--src/mesa/ppc/rtasm/spe_asm.h310
-rw-r--r--src/mesa/sources84
-rw-r--r--src/mesa/state_tracker/st_atom_shader.c2
-rw-r--r--src/mesa/state_tracker/st_cache.c4
-rw-r--r--src/mesa/state_tracker/st_cache.h2
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c117
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c2
-rw-r--r--src/mesa/state_tracker/st_cb_feedback.c6
-rw-r--r--src/mesa/state_tracker/st_cb_program.c4
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c4
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c2
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c2
-rw-r--r--src/mesa/state_tracker/st_context.c4
-rw-r--r--src/mesa/state_tracker/st_debug.c4
-rw-r--r--src/mesa/state_tracker/st_draw.c4
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c2
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c6
-rw-r--r--src/mesa/state_tracker/st_program.c4
371 files changed, 833 insertions, 91106 deletions
diff --git a/src/mesa/Makefile b/src/mesa/Makefile
index 720f1b2e02..561608fedd 100644
--- a/src/mesa/Makefile
+++ b/src/mesa/Makefile
@@ -12,16 +12,16 @@ GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
PIPE_LIB = \
- $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \
- $(TOP)/src/mesa/pipe/i965simple/libi965simple.a
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/i965simple/libi965simple.a
ifeq ($(CONFIG_NAME), linux-cell)
-CELL_LIB = $(TOP)/src/mesa/pipe/cell/ppu/libcell.a
-CELL_LIB_SPU = $(TOP)/src/mesa/pipe/cell/spu/g3d_spu.a
+CELL_LIB = $(TOP)/src/gallium/drivers/cell/ppu/libcell.a
+CELL_LIB_SPU = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a
endif
ifeq ($(CONFIG_NAME), linux-llvm)
-LLVM_LIB = $(TOP)/src/mesa/pipe/llvm/libgallivm.a
+LLVM_LIB = $(TOP)/src/gallium/aux/llvm/libgallivm.a
endif
.SUFFIXES : .cpp
@@ -71,7 +71,7 @@ libmesa.a: $(SOLO_OBJECTS)
fi
linux-solo: depend subdirs libmesa.a
- cd drivers/dri ; $(MAKE)
+ cd $(TOP)/src/gallium/winsys/dri ; $(MAKE)
#####################################################################
@@ -165,7 +165,6 @@ depend: $(ALL_SOURCES)
subdirs:
@ (cd x86 ; $(MAKE))
@ (cd x86-64 ; $(MAKE))
- (cd pipe ; $(MAKE))
install: default
$(INSTALL) -d $(INSTALL_DIR)/include/GL
@@ -178,7 +177,7 @@ install: default
$(INSTALL) $(TOP)/$(LIB_DIR)/libOSMesa* $(INSTALL_DIR)/$(LIB_DIR); \
fi
@if [ "${DRIVER_DIRS}" = "dri" ] ; then \
- cd drivers/dri ; $(MAKE) install ; \
+ cd $(TOP)/gallium/winsys/dri ; $(MAKE) install ; \
fi
## NOT INSTALLED YET:
@@ -198,7 +197,6 @@ clean:
(cd drivers/dri && $(MAKE) clean)
(cd x86 && $(MAKE) clean)
(cd x86-64 && $(MAKE) clean)
- (cd pipe ; $(MAKE) clean )
include depend
diff --git a/src/mesa/drivers/dri/intel_winsys/Makefile b/src/mesa/drivers/dri/intel_winsys/Makefile
deleted file mode 100644
index 9ae0f01325..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i915tex_dri.so
-
-MINIGLX_SOURCES = server/intel_dri.c
-
-PIPE_DRIVERS = \
- $(TOP)/src/mesa/pipe/softpipe/libsoftpipe.a \
- $(TOP)/src/mesa/pipe/i915simple/libi915simple.a
-
-DRIVER_SOURCES = \
- intel_winsys_pipe.c \
- intel_winsys_softpipe.c \
- intel_winsys_i915.c \
- intel_batchbuffer.c \
- intel_swapbuffers.c \
- intel_context.c \
- intel_lock.c \
- intel_screen.c \
- intel_batchpool.c
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(COMMON_BM_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../intel $(shell pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-include ../Makefile.template
-
-intel_tex_layout.o: ../intel/intel_tex_layout.c
-
-symlinks:
diff --git a/src/mesa/drivers/dri/intel_winsys/SConscript b/src/mesa/drivers/dri/intel_winsys/SConscript
deleted file mode 100644
index a7cc10450e..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/SConscript
+++ /dev/null
@@ -1,41 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-env.Append(CPPPATH = [
- '../intel',
- 'server'
-])
-
-#MINIGLX_SOURCES = server/intel_dri.c
-
-pipe_drivers = [
- softpipe,
- i915simple
-]
-
-DRIVER_SOURCES = [
- 'intel_winsys_pipe.c',
- 'intel_winsys_softpipe.c',
- 'intel_winsys_i915.c',
- 'intel_batchbuffer.c',
- 'intel_swapbuffers.c',
- 'intel_context.c',
- 'intel_lock.c',
- 'intel_screen.c',
- 'intel_batchpool.c',
-]
-
-sources = \
- COMMON_GALLIUM_SOURCES + \
- COMMON_BM_SOURCES + \
- DRIVER_SOURCES
-
-# DRIVER_DEFINES = -I../intel $(shell pkg-config libdrm --atleast-version=2.3.1 \
-# && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-env.SharedLibrary(
- target ='i915tex_dri.so',
- source = sources,
- LIBS = pipe_drivers + env['LIBS'],
-) \ No newline at end of file
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c
deleted file mode 100644
index 49e04d81ec..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <errno.h>
-#include "intel_batchbuffer.h"
-#include "intel_context.h"
-#include "intel_screen.h"
-#include "intel_reg.h"
-#include "drm.h"
-
-/* Relocations in kernel space:
- * - pass dma buffer seperately
- * - memory manager knows how to patch
- * - pass list of dependent buffers
- * - pass relocation list
- *
- * Either:
- * - get back an offset for buffer to fire
- * - memory manager knows how to fire buffer
- *
- * Really want the buffer to be AGP and pinned.
- *
- */
-
-/* Cliprect fence: The highest fence protecting a dma buffer
- * containing explicit cliprect information. Like the old drawable
- * lock but irq-driven. X server must wait for this fence to expire
- * before changing cliprects [and then doing sw rendering?]. For
- * other dma buffers, the scheduler will grab current cliprect info
- * and mix into buffer. X server must hold the lock while changing
- * cliprects??? Make per-drawable. Need cliprects in shared memory
- * -- beats storing them with every cmd buffer in the queue.
- *
- * ==> X server must wait for this fence to expire before touching the
- * framebuffer with new cliprects.
- *
- * ==> Cliprect-dependent buffers associated with a
- * cliprect-timestamp. All of the buffers associated with a timestamp
- * must go to hardware before any buffer with a newer timestamp.
- *
- * ==> Dma should be queued per-drawable for correct X/GL
- * synchronization. Or can fences be used for this?
- *
- * Applies to: Blit operations, metaops, X server operations -- X
- * server automatically waits on its own dma to complete before
- * modifying cliprects ???
- */
-
-static void
-intel_dump_batchbuffer(uint offset, uint * ptr, uint count)
-{
- int i;
- printf("\n\n\nSTART BATCH (%d dwords):\n", count / 4);
- for (i = 0; i < count / 4; i += 1)
- printf("\t0x%08x\n", ptr[i]);
- printf("END BATCH\n\n\n");
-}
-
-
-void
-intel_batchbuffer_reset(struct intel_batchbuffer *batch)
-{
- int i;
-
- if (batch->map) {
- driBOUnmap(batch->buffer);
- batch->map = NULL;
- }
-
- /*
- * Get a new, free batchbuffer.
- */
- batch->size = BATCH_SZ;
- driBOData(batch->buffer, batch->size, NULL, 0);
-
- driBOResetList(&batch->list);
-
- /*
- * Unreference buffers previously on the relocation list.
- */
- for (i = 0; i < batch->nr_relocs; i++) {
- struct buffer_reloc *r = &batch->reloc[i];
- driBOUnReference(r->buf);
- }
-
- batch->list_count = 0;
- batch->nr_relocs = 0;
- batch->flags = 0;
-
- /*
- * We don't refcount the batchbuffer itself since we can't destroy it
- * while it's on the list.
- */
-
- driBOAddListItem(&batch->list, batch->buffer,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_EXE);
-
-
- batch->map = driBOMap(batch->buffer, DRM_BO_FLAG_WRITE, 0);
- batch->ptr = batch->map;
-}
-
-
-/*======================================================================
- * Public functions
- */
-struct intel_batchbuffer *
-intel_batchbuffer_alloc(struct intel_context *intel)
-{
- struct intel_batchbuffer *batch = calloc(sizeof(*batch), 1);
-
- batch->intel = intel;
-
- driGenBuffers(intel->intelScreen->batchPool, "batchbuffer", 1,
- &batch->buffer, 4096,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, 0);
- batch->last_fence = NULL;
- driBOCreateList(20, &batch->list);
- intel_batchbuffer_reset(batch);
- return batch;
-}
-
-
-void
-intel_batchbuffer_free(struct intel_batchbuffer *batch)
-{
- if (batch->last_fence) {
- driFenceFinish(batch->last_fence,
- DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW,
- GL_FALSE);
- driFenceUnReference(batch->last_fence);
- batch->last_fence = NULL;
- }
- if (batch->map) {
- driBOUnmap(batch->buffer);
- batch->map = NULL;
- }
- driBOUnReference(batch->buffer);
- batch->buffer = NULL;
- free(batch);
-}
-
-
-static void
-intel_batch_ioctl(struct intel_context *intel,
- uint start_offset, uint used, boolean allow_unlock)
-{
- drmI830BatchBuffer batch;
-
- batch.start = start_offset;
- batch.used = used;
- batch.cliprects = NULL; /* unused */
- batch.num_cliprects = 0;
- batch.DR1 = 0;
- batch.DR4 = 0; /* still need this ? */
-
- DBG(IOCTL, "%s: 0x%x..0x%x DR4: %x cliprects: %d\n",
- __FUNCTION__,
- batch.start,
- batch.start + batch.used * 4, batch.DR4, batch.num_cliprects);
-
- if (drmCommandWrite(intel->driFd, DRM_I830_BATCHBUFFER, &batch,
- sizeof(batch))) {
- printf("DRM_I830_BATCHBUFFER: %d\n", -errno);
- UNLOCK_HARDWARE(intel);
- exit(1);
- }
-}
-
-
-/* TODO: Push this whole function into bufmgr.
- */
-static void
-do_flush_locked(struct intel_batchbuffer *batch,
- uint used, boolean allow_unlock)
-{
- uint *ptr;
- uint i, fenceFlags;
- struct _DriFenceObject *fo;
-
- driBOValidateList(batch->intel->driFd, &batch->list);
-
- /* Apply the relocations. This nasty map indicates to me that the
- * whole task should be done internally by the memory manager, and
- * that dma buffers probably need to be pinned within agp space.
- */
- ptr = (uint *) driBOMap(batch->buffer, DRM_BO_FLAG_WRITE,
- DRM_BO_HINT_ALLOW_UNFENCED_MAP);
-
- for (i = 0; i < batch->nr_relocs; i++) {
- struct buffer_reloc *r = &batch->reloc[i];
-
- ptr[r->offset / 4] = driBOOffset(r->buf) + r->delta;
- }
-
- if (0)
- intel_dump_batchbuffer(0, ptr, used);
-
- driBOUnmap(batch->buffer);
- batch->map = NULL;
-
- intel_batch_ioctl(batch->intel,
- driBOOffset(batch->buffer),
- used, allow_unlock);
-
- /*
- * Kernel fencing. The flags tells the kernel that we've
- * programmed an MI_FLUSH.
- */
- fenceFlags = DRM_I915_FENCE_FLAG_FLUSHED;
- fo = driFenceBuffers(batch->intel->driFd, "Batch fence", fenceFlags);
-
- /*
- * User space fencing.
- */
- driBOFence(batch->buffer, fo);
-
- if (driFenceType(fo) == DRM_FENCE_TYPE_EXE) {
- /*
- * Oops. We only validated a batch buffer. This means we
- * didn't do any proper rendering. Discard this fence object.
- */
- driFenceUnReference(fo);
- }
- else {
- driFenceUnReference(batch->last_fence);
- batch->last_fence = fo;
- for (i = 0; i < batch->nr_relocs; i++) {
- struct buffer_reloc *r = &batch->reloc[i];
- driBOFence(r->buf, fo);
- }
- }
-}
-
-
-struct _DriFenceObject *
-intel_batchbuffer_flush(struct intel_batchbuffer *batch)
-{
- struct intel_context *intel = batch->intel;
- uint used = batch->ptr - batch->map;
- const boolean was_locked = intel->locked;
-
- if (used == 0)
- return batch->last_fence;
-
-#define MI_FLUSH ((0 << 29) | (4 << 23))
-
- /* Add the MI_BATCH_BUFFER_END. Always add an MI_FLUSH - this is a
- * performance drain that we would like to avoid.
- */
- if (used & 4) {
- ((int *) batch->ptr)[0] = MI_FLUSH;
- ((int *) batch->ptr)[1] = 0;
- ((int *) batch->ptr)[2] = MI_BATCH_BUFFER_END;
- used += 12;
- }
- else {
- ((int *) batch->ptr)[0] = MI_FLUSH;
- ((int *) batch->ptr)[1] = MI_BATCH_BUFFER_END;
- used += 8;
- }
-
- driBOUnmap(batch->buffer);
- batch->ptr = NULL;
- batch->map = NULL;
-
- /* TODO: Just pass the relocation list and dma buffer up to the
- * kernel.
- */
- if (!was_locked)
- LOCK_HARDWARE(intel);
-
- do_flush_locked(batch, used, GL_FALSE);
-
- if (!was_locked)
- UNLOCK_HARDWARE(intel);
-
- /* Reset the buffer:
- */
- intel_batchbuffer_reset(batch);
- return batch->last_fence;
-}
-
-
-void
-intel_batchbuffer_finish(struct intel_batchbuffer *batch)
-{
- struct _DriFenceObject *fence = intel_batchbuffer_flush(batch);
- if (fence) {
- driFenceReference(fence);
- driFenceFinish(fence,
- DRM_FENCE_TYPE_EXE | DRM_I915_FENCE_TYPE_RW,
- GL_FALSE);
- driFenceUnReference(fence);
- }
-}
-
-
-/* This is the only way buffers get added to the validate list.
- */
-boolean
-intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
- struct _DriBufferObject *buffer,
- uint flags, uint mask, uint delta)
-{
- assert(batch->nr_relocs < MAX_RELOCS);
-
- driBOAddListItem(&batch->list, buffer, flags, mask);
-
- {
- struct buffer_reloc *r = &batch->reloc[batch->nr_relocs++];
- driBOReference(buffer);
- r->buf = buffer;
- r->offset = batch->ptr - batch->map;
- r->delta = delta;
- *(uint *) batch->ptr = 0x12345678;
- }
-
- batch->ptr += 4;
- return GL_TRUE;
-}
-
-
-void
-intel_batchbuffer_data(struct intel_batchbuffer *batch,
- const void *data, uint bytes, uint flags)
-{
- assert((bytes & 3) == 0);
- intel_batchbuffer_require_space(batch, bytes, flags);
- memcpy(batch->ptr, data, bytes);
- batch->ptr += bytes;
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h b/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h
deleted file mode 100644
index 82feafa21f..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_batchbuffer.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_BATCHBUFFER_H
-#define INTEL_BATCHBUFFER_H
-
-#include "pipe/p_compiler.h"
-#include "dri_bufmgr.h"
-
-struct intel_context;
-
-#define BATCH_SZ 16384
-#define BATCH_RESERVED 16
-
-#define MAX_RELOCS 4096
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS 0x2
-
-struct buffer_reloc
-{
- struct _DriBufferObject *buf;
- uint offset;
- uint delta; /* not needed? */
-};
-
-struct intel_batchbuffer
-{
- struct bufmgr *bm;
- struct intel_context *intel;
-
- struct _DriBufferObject *buffer;
- struct _DriFenceObject *last_fence;
- uint flags;
-
- drmBOList list;
- uint list_count;
- ubyte *map;
- ubyte *ptr;
-
- struct buffer_reloc reloc[MAX_RELOCS];
- uint nr_relocs;
- uint size;
-};
-
-struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context *intel);
-
-void intel_batchbuffer_free(struct intel_batchbuffer *batch);
-
-
-void intel_batchbuffer_finish(struct intel_batchbuffer *batch);
-
-struct _DriFenceObject *intel_batchbuffer_flush(struct intel_batchbuffer
- *batch);
-
-void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
-
-
-/* Unlike bmBufferData, this currently requires the buffer be mapped.
- * Consider it a convenience function wrapping multiple
- * intel_buffer_dword() calls.
- */
-void intel_batchbuffer_data(struct intel_batchbuffer *batch,
- const void *data, uint bytes, uint flags);
-
-void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
- uint bytes);
-
-boolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
- struct _DriBufferObject *buffer,
- uint flags,
- uint mask, uint offset);
-
-/* Inline functions - might actually be better off with these
- * non-inlined. Certainly better off switching all command packets to
- * be passed as structs rather than dwords, but that's a little bit of
- * work...
- */
-static INLINE uint
-intel_batchbuffer_space(struct intel_batchbuffer *batch)
-{
- return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
-}
-
-
-static INLINE void
-intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, uint dword)
-{
- assert(batch->map);
- assert(intel_batchbuffer_space(batch) >= 4);
- *(uint *) (batch->ptr) = dword;
- batch->ptr += 4;
-}
-
-static INLINE void
-intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
- uint sz, uint flags)
-{
- assert(sz < batch->size - 8);
- if (intel_batchbuffer_space(batch) < sz ||
- (batch->flags != 0 && flags != 0 && batch->flags != flags))
- intel_batchbuffer_flush(batch);
-
- batch->flags |= flags;
-}
-
-/* Here are the crusty old macros, to be removed:
- */
-#define BATCH_LOCALS
-
-#define BEGIN_BATCH(n, flags) do { \
- intel_batchbuffer_require_space(intel->batch, (n)*4, flags); \
-} while (0)
-
-#define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
-
-#define OUT_RELOC(buf,flags,mask,delta) do { \
- assert((delta) >= 0); \
- intel_batchbuffer_emit_reloc(intel->batch, buf, flags, mask, delta); \
-} while (0)
-
-#define ADVANCE_BATCH() do { } while(0)
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchpool.c b/src/mesa/drivers/dri/intel_winsys/intel_batchpool.c
deleted file mode 100644
index 33b56817f6..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_batchpool.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-/**
- * XXX NOTE: there are no intel dependencies in this file.
- * Rename to dri_batchpool.c?
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "imports.h"
-#include "glthread.h"
-#include "dri_bufpool.h"
-#include "dri_bufmgr.h"
-#include "intel_batchpool.h"
-
-
-typedef struct
-{
- drmMMListHead head;
- struct _BPool *parent;
- struct _DriFenceObject *fence;
- unsigned long start;
- int unfenced;
- int mapped;
-} BBuf;
-
-typedef struct _BPool
-{
- _glthread_Mutex mutex;
- unsigned long bufSize;
- unsigned poolSize;
- unsigned numFree;
- unsigned numTot;
- unsigned numDelayed;
- unsigned checkDelayed;
- drmMMListHead free;
- drmMMListHead delayed;
- drmMMListHead head;
- drmBO kernelBO;
- void *virtual;
- BBuf *bufs;
-} BPool;
-
-
-static BPool *
-createBPool(int fd, unsigned long bufSize, unsigned numBufs, unsigned flags,
- unsigned checkDelayed)
-{
- BPool *p = (BPool *) malloc(sizeof(*p));
- BBuf *buf;
- int i;
-
- if (!p)
- return NULL;
-
- p->bufs = (BBuf *) malloc(numBufs * sizeof(*p->bufs));
- if (!p->bufs) {
- free(p);
- return NULL;
- }
-
- DRMINITLISTHEAD(&p->free);
- DRMINITLISTHEAD(&p->head);
- DRMINITLISTHEAD(&p->delayed);
-
- p->numTot = numBufs;
- p->numFree = numBufs;
- p->bufSize = bufSize;
- p->numDelayed = 0;
- p->checkDelayed = checkDelayed;
-
- _glthread_INIT_MUTEX(p->mutex);
-
- if (drmBOCreate(fd, 0, numBufs * bufSize, 0, NULL, drm_bo_type_dc,
- flags, DRM_BO_HINT_DONT_FENCE, &p->kernelBO)) {
- free(p->bufs);
- free(p);
- return NULL;
- }
- if (drmBOMap(fd, &p->kernelBO, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0,
- &p->virtual)) {
- drmBODestroy(fd, &p->kernelBO);
- free(p->bufs);
- free(p);
- return NULL;
- }
-
- /*
- * We unmap the buffer so that we can validate it later. Note that this is
- * just a synchronizing operation. The buffer will have a virtual mapping
- * until it is destroyed.
- */
-
- drmBOUnmap(fd, &p->kernelBO);
-
- buf = p->bufs;
- for (i = 0; i < numBufs; ++i) {
- buf->parent = p;
- buf->fence = NULL;
- buf->start = i * bufSize;
- buf->mapped = 0;
- buf->unfenced = 0;
- DRMLISTADDTAIL(&buf->head, &p->free);
- buf++;
- }
-
- return p;
-}
-
-
-static void
-pool_checkFree(BPool * p, int wait)
-{
- drmMMListHead *list, *prev;
- BBuf *buf;
- int signaled = 0;
- int i;
-
- list = p->delayed.next;
-
- if (p->numDelayed > 3) {
- for (i = 0; i < p->numDelayed; i += 3) {
- list = list->next;
- }
- }
-
- prev = list->prev;
- for (; list != &p->delayed; list = prev, prev = list->prev) {
-
- buf = DRMLISTENTRY(BBuf, list, head);
-
- if (!signaled) {
- if (wait) {
- driFenceFinish(buf->fence, DRM_FENCE_TYPE_EXE, 1);
- signaled = 1;
- }
- else {
- signaled = driFenceSignaled(buf->fence, DRM_FENCE_TYPE_EXE);
- }
- }
-
- if (!signaled)
- break;
-
- driFenceUnReference(buf->fence);
- buf->fence = NULL;
- DRMLISTDEL(list);
- p->numDelayed--;
- DRMLISTADD(list, &p->free);
- p->numFree++;
- }
-}
-
-static void *
-pool_create(struct _DriBufferPool *pool,
- unsigned long size, unsigned flags, unsigned hint,
- unsigned alignment)
-{
- BPool *p = (BPool *) pool->data;
-
- drmMMListHead *item;
-
- if (alignment && (alignment != 4096))
- return NULL;
-
- _glthread_LOCK_MUTEX(p->mutex);
-
- if (p->numFree == 0)
- pool_checkFree(p, GL_TRUE);
-
- if (p->numFree == 0) {
- fprintf(stderr, "Out of fixed size buffer objects\n");
- BM_CKFATAL(-ENOMEM);
- }
-
- item = p->free.next;
-
- if (item == &p->free) {
- fprintf(stderr, "Fixed size buffer pool corruption\n");
- }
-
- DRMLISTDEL(item);
- --p->numFree;
-
- _glthread_UNLOCK_MUTEX(p->mutex);
- return (void *) DRMLISTENTRY(BBuf, item, head);
-}
-
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
-
- _glthread_LOCK_MUTEX(p->mutex);
-
- if (buf->fence) {
- DRMLISTADDTAIL(&buf->head, &p->delayed);
- p->numDelayed++;
- }
- else {
- buf->unfenced = 0;
- DRMLISTADD(&buf->head, &p->free);
- p->numFree++;
- }
-
- if ((p->numDelayed % p->checkDelayed) == 0)
- pool_checkFree(p, 0);
-
- _glthread_UNLOCK_MUTEX(p->mutex);
- return 0;
-}
-
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, void **virtual)
-{
-
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
-
- _glthread_LOCK_MUTEX(p->mutex);
-
- /*
- * Currently Mesa doesn't have any condition variables to resolve this
- * cleanly in a multithreading environment.
- * We bail out instead.
- */
-
- if (buf->mapped) {
- fprintf(stderr, "Trying to map already mapped buffer object\n");
- BM_CKFATAL(-EINVAL);
- }
-
-#if 0
- if (buf->unfenced && !(hint & DRM_BO_HINT_ALLOW_UNFENCED_MAP)) {
- fprintf(stderr, "Trying to map an unfenced buffer object 0x%08x"
- " 0x%08x %d\n", hint, flags, buf->start);
- BM_CKFATAL(-EINVAL);
- }
-
-#endif
-
- if (buf->fence) {
- _glthread_UNLOCK_MUTEX(p->mutex);
- return -EBUSY;
- }
-
- buf->mapped = GL_TRUE;
- *virtual = (unsigned char *) p->virtual + buf->start;
- _glthread_UNLOCK_MUTEX(p->mutex);
- return 0;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, int lazy)
-{
- BBuf *buf = (BBuf *) private;
- driFenceFinish(buf->fence, 0x0, lazy);
- return 0;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- BBuf *buf = (BBuf *) private;
-
- buf->mapped = 0;
- return 0;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
-
- return p->kernelBO.offset + buf->start;
-}
-
-static unsigned
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- BPool *p = (BPool *) pool->data;
-
- return p->kernelBO.flags;
-}
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- BPool *p = (BPool *) pool->data;
-
- return p->bufSize;
-}
-
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
-
- _glthread_LOCK_MUTEX(p->mutex);
- if (buf->fence) {
- driFenceUnReference(buf->fence);
- }
- buf->fence = fence;
- buf->unfenced = 0;
- driFenceReference(buf->fence);
- _glthread_UNLOCK_MUTEX(p->mutex);
-
- return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
-
- return &p->kernelBO;
-}
-
-static int
-pool_validate(struct _DriBufferPool *pool, void *private)
-{
- BBuf *buf = (BBuf *) private;
- BPool *p = buf->parent;
- _glthread_LOCK_MUTEX(p->mutex);
- buf->unfenced = GL_TRUE;
- _glthread_UNLOCK_MUTEX(p->mutex);
- return 0;
-}
-
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
- BPool *p = (BPool *) pool->data;
-
- /*
- * Wait on outstanding fences.
- */
-
- _glthread_LOCK_MUTEX(p->mutex);
- while ((p->numFree < p->numTot) && p->numDelayed) {
- _glthread_UNLOCK_MUTEX(p->mutex);
- sched_yield();
- pool_checkFree(p, GL_TRUE);
- _glthread_LOCK_MUTEX(p->mutex);
- }
-
- drmBODestroy(pool->fd, &p->kernelBO);
- free(p->bufs);
- _glthread_UNLOCK_MUTEX(p->mutex);
- free(p);
- free(pool);
-}
-
-
-struct _DriBufferPool *
-driBatchPoolInit(int fd, unsigned flags,
- unsigned long bufSize,
- unsigned numBufs, unsigned checkDelayed)
-{
- struct _DriBufferPool *pool;
-
- pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
- if (!pool)
- return NULL;
-
- pool->data = createBPool(fd, bufSize, numBufs, flags, checkDelayed);
- if (!pool->data)
- return NULL;
-
- pool->fd = fd;
- pool->map = &pool_map;
- pool->unmap = &pool_unmap;
- pool->destroy = &pool_destroy;
- pool->offset = &pool_offset;
- pool->flags = &pool_flags;
- pool->size = &pool_size;
- pool->create = &pool_create;
- pool->fence = &pool_fence;
- pool->kernel = &pool_kernel;
- pool->validate = &pool_validate;
- pool->waitIdle = &pool_waitIdle;
- pool->setstatic = NULL;
- pool->takeDown = &pool_takedown;
- return pool;
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_batchpool.h b/src/mesa/drivers/dri/intel_winsys/intel_batchpool.h
deleted file mode 100644
index f6a95723bc..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_batchpool.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_BATCHPOOL_H
-#define INTEL_BATCHPOOL_H
-
-extern struct _DriBufferPool *driBatchPoolInit(int fd, unsigned flags,
- unsigned long bufSize,
- unsigned numBufs,
- unsigned checkDelayed);
-
-
-#endif /* INTEL_BATCHPOOL_H */
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.c b/src/mesa/drivers/dri/intel_winsys/intel_context.c
deleted file mode 100644
index c033f2a592..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_context.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i830_dri.h"
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-#include "intel_winsys.h"
-#include "intel_batchbuffer.h"
-
-#include "state_tracker/st_public.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-
-#include "utils.h"
-
-
-#ifdef DEBUG
-int __intel_debug = 0;
-#endif
-
-
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_window_pos
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_NV_vertex_program
-#include "extension_helper.h"
-
-
-/**
- * Extension strings exported by the intel driver.
- *
- * \note
- * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
- * old i830-specific driver.
- */
-const struct dri_extension card_extensions[] = {
- {"GL_ARB_multisample", GL_ARB_multisample_functions},
- {"GL_ARB_multitexture", NULL},
- {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
- {"GL_ARB_texture_border_clamp", NULL},
- {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
- {"GL_ARB_texture_cube_map", NULL},
- {"GL_ARB_texture_env_add", NULL},
- {"GL_ARB_texture_env_combine", NULL},
- {"GL_ARB_texture_env_dot3", NULL},
- {"GL_ARB_texture_mirrored_repeat", NULL},
- {"GL_ARB_texture_rectangle", NULL},
- {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
- {"GL_ARB_pixel_buffer_object", NULL},
- {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
- {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
- {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
- {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
- {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
- {"GL_EXT_blend_subtract", NULL},
- {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
- {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
- {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
- {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
- {"GL_EXT_packed_depth_stencil", NULL},
- {"GL_EXT_pixel_buffer_object", NULL},
- {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
- {"GL_EXT_stencil_wrap", NULL},
- {"GL_EXT_texture_edge_clamp", NULL},
- {"GL_EXT_texture_env_combine", NULL},
- {"GL_EXT_texture_env_dot3", NULL},
- {"GL_EXT_texture_filter_anisotropic", NULL},
- {"GL_EXT_texture_lod_bias", NULL},
- {"GL_3DFX_texture_compression_FXT1", NULL},
- {"GL_APPLE_client_storage", NULL},
- {"GL_MESA_pack_invert", NULL},
- {"GL_MESA_ycbcr_texture", NULL},
- {"GL_NV_blend_square", NULL},
- {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
- {"GL_NV_vertex_program1_1", NULL},
- {"GL_SGIS_generate_mipmap", NULL },
- {NULL, NULL}
-};
-
-
-
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- {"ioctl", DEBUG_IOCTL},
- {"bat", DEBUG_BATCH},
- {"lock", DEBUG_LOCK},
- {"swap", DEBUG_SWAP},
- {NULL, 0}
-};
-#endif
-
-
-
-GLboolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate)
-{
- struct intel_context *intel = CALLOC_STRUCT(intel_context);
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *saPriv = intelScreen->sarea;
- int fthrottle_mode;
- GLboolean havePools;
- struct pipe_context *pipe;
- struct st_context *st_share = NULL;
-
- if (sharedContextPrivate) {
- st_share = ((struct intel_context *) sharedContextPrivate)->st;
- }
-
- driContextPriv->driverPrivate = intel;
- intel->intelScreen = intelScreen;
- intel->driScreen = sPriv;
- intel->sarea = saPriv;
-
- driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
- intel->driScreen->myNum, "i915");
-
-
- /*
- * memory pools
- */
- DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- havePools = intelCreatePools(sPriv);
- DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- if (!havePools)
- return GL_FALSE;
-
-
- /* Dri stuff */
- intel->hHWContext = driContextPriv->hHWContext;
- intel->driFd = sPriv->fd;
- intel->driHwLock = (drmLock *) & sPriv->pSAREA->lock;
-
- fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
- intel->iw.irq_seq = -1;
- intel->irqsEmitted = 0;
-
- intel->batch = intel_batchbuffer_alloc(intel);
- intel->last_swap_fence = NULL;
- intel->first_swap_fence = NULL;
-
-#ifdef DEBUG
- __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
-#endif
-
- /*
- * Pipe-related setup
- */
- if (!getenv("INTEL_HW")) {
- pipe = intel_create_softpipe( intel, intelScreen->winsys );
- }
- else {
- switch (intel->intelScreen->deviceID) {
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
- case PCI_CHIP_I945_GME:
- case PCI_CHIP_G33_G:
- case PCI_CHIP_Q33_G:
- case PCI_CHIP_Q35_G:
- case PCI_CHIP_I915_G:
- case PCI_CHIP_I915_GM:
- pipe = intel_create_i915simple( intel, intelScreen->winsys );
- break;
- default:
- fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
- intel->intelScreen->deviceID, __FUNCTION__);
-
- pipe = intel_create_softpipe( intel, intelScreen->winsys );
- break;
- }
- }
-
- pipe->priv = intel;
-
- intel->st = st_create_context(pipe, visual, st_share);
-
- return GL_TRUE;
-}
-
-
-void
-intelDestroyContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
-
- assert(intel); /* should never be null */
- if (intel) {
- st_flush(intel->st, PIPE_FLUSH_WAIT);
-
- intel_batchbuffer_free(intel->batch);
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- if (intel->first_swap_fence) {
- driFenceFinish(intel->first_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(intel->first_swap_fence);
- intel->first_swap_fence = NULL;
- }
-
- if (intel->intelScreen->dummyContext == intel)
- intel->intelScreen->dummyContext = NULL;
-
- st_destroy_context(intel->st);
- free(intel);
- }
-}
-
-
-GLboolean
-intelUnbindContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
- st_flush(intel->st, 0x0);
- /* XXX make_current(NULL)? */
- return GL_TRUE;
-}
-
-
-GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv)
-{
- if (driContextPriv) {
- struct intel_context *intel = intel_context(driContextPriv);
- struct intel_framebuffer *draw_fb = intel_framebuffer(driDrawPriv);
- struct intel_framebuffer *read_fb = intel_framebuffer(driReadPriv);
-
- assert(draw_fb->stfb);
- assert(read_fb->stfb);
-
- /* This is for situations in which we need a rendering context but
- * there may not be any currently bound.
- */
- intel->intelScreen->dummyContext = intel;
-
- st_make_current(intel->st, draw_fb->stfb, read_fb->stfb);
-
- if ((intel->driDrawable != driDrawPriv) ||
- (intel->lastStamp != driDrawPriv->lastStamp)) {
- intel->driDrawable = driDrawPriv;
- intelUpdateWindowSize(driDrawPriv);
- intel->lastStamp = driDrawPriv->lastStamp;
- }
-
- /* The size of the draw buffer will have been updated above.
- * If the readbuffer is a different window, check/update its size now.
- */
- if (driReadPriv != driDrawPriv) {
- intelUpdateWindowSize(driReadPriv);
- }
-
- }
- else {
- st_make_current(NULL, NULL, NULL);
- }
-
- return GL_TRUE;
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_context.h b/src/mesa/drivers/dri/intel_winsys/intel_context.h
deleted file mode 100644
index b01370c049..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_context.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_CONTEXT_H
-#define INTEL_CONTEXT_H
-
-
-#include "drm.h"
-#include "intel_screen.h"
-#include "i915_drm.h"
-
-
-struct pipe_context;
-struct intel_context;
-struct _DriBufferObject;
-struct st_context;
-
-
-#define INTEL_MAX_FIXUP 64
-
-/**
- * Intel rendering context, contains a state tracker and intel-specific info.
- */
-struct intel_context
-{
- struct st_context *st;
-
- struct _DriFenceObject *last_swap_fence;
- struct _DriFenceObject *first_swap_fence;
-
- struct intel_batchbuffer *batch;
-
- boolean locked;
- char *prevLockFile;
- int prevLockLine;
-
- uint irqsEmitted;
- drm_i915_irq_wait_t iw;
-
- drm_context_t hHWContext;
- drmLock *driHwLock;
- int driFd;
-
- __DRIdrawablePrivate *driDrawable;
- __DRIscreenPrivate *driScreen;
- struct intel_screen *intelScreen;
- drmI830Sarea *sarea;
-
- uint lastStamp;
-
- /**
- * Configuration cache
- */
- driOptionCache optionCache;
-};
-
-
-
-/**
- * Intel framebuffer.
- */
-struct intel_framebuffer
-{
- struct st_framebuffer *stfb;
-
- /* other fields TBD */
- int other;
-};
-
-
-
-
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
-extern char *__progname;
-
-
-
-/* ================================================================
- * Debugging:
- */
-#ifdef DEBUG
-extern int __intel_debug;
-
-#define DEBUG_SWAP 0x1
-#define DEBUG_LOCK 0x2
-#define DEBUG_IOCTL 0x4
-#define DEBUG_BATCH 0x8
-
-#define DBG(flag, ...) do { \
- if (__intel_debug & (DEBUG_##flag)) \
- printf(__VA_ARGS__); \
-} while(0)
-
-#else
-#define DBG(flag, ...)
-#endif
-
-
-
-#define PCI_CHIP_845_G 0x2562
-#define PCI_CHIP_I830_M 0x3577
-#define PCI_CHIP_I855_GM 0x3582
-#define PCI_CHIP_I865_G 0x2572
-#define PCI_CHIP_I915_G 0x2582
-#define PCI_CHIP_I915_GM 0x2592
-#define PCI_CHIP_I945_G 0x2772
-#define PCI_CHIP_I945_GM 0x27A2
-#define PCI_CHIP_I945_GME 0x27AE
-#define PCI_CHIP_G33_G 0x29C2
-#define PCI_CHIP_Q35_G 0x29B2
-#define PCI_CHIP_Q33_G 0x29D2
-
-
-/** Cast wrapper */
-static INLINE struct intel_context *
-intel_context(__DRIcontextPrivate *driContextPriv)
-{
- return (struct intel_context *) driContextPriv->driverPrivate;
-}
-
-
-/** Cast wrapper */
-static INLINE struct intel_framebuffer *
-intel_framebuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- return (struct intel_framebuffer *) driDrawPriv->driverPrivate;
-}
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_lock.c b/src/mesa/drivers/dri/intel_winsys/intel_lock.c
deleted file mode 100644
index 70aa7ea5f4..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_lock.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "main/glheader.h"
-#include "glapi/glthread.h"
-#include <GL/internal/glcore.h>
-#include "state_tracker/st_public.h"
-#include "intel_context.h"
-#include "i830_dri.h"
-
-
-
-_glthread_DECLARE_STATIC_MUTEX( lockMutex );
-
-
-static void
-intelContendedLock(struct intel_context *intel, uint flags)
-{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- __DRIscreenPrivate *sPriv = intel->driScreen;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *sarea = intel->sarea;
-
- drmGetLock(intel->driFd, intel->hHWContext, flags);
-
- DBG(LOCK, "%s - got contended lock\n", __progname);
-
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- if (dPriv)
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-
- if (sarea->width != intelScreen->front.width ||
- sarea->height != intelScreen->front.height) {
-
- intelUpdateScreenRotation(sPriv, sarea);
- }
-}
-
-
-/* Lock the hardware and validate our state.
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
- char __ret = 0;
-
- _glthread_LOCK_MUTEX(lockMutex);
- assert(!intel->locked);
-
- DRM_CAS(intel->driHwLock, intel->hHWContext,
- (DRM_LOCK_HELD|intel->hHWContext), __ret);
-
- if (__ret)
- intelContendedLock( intel, 0 );
-
- DBG(LOCK, "%s - locked\n", __progname);
-
- intel->locked = 1;
-}
-
-
-/* Unlock the hardware using the global current context
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
- assert(intel->locked);
- intel->locked = 0;
-
- DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
-
- _glthread_UNLOCK_MUTEX(lockMutex);
-
- DBG(LOCK, "%s - unlocked\n", __progname);
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_reg.h b/src/mesa/drivers/dri/intel_winsys/intel_reg.h
deleted file mode 100644
index f37c24fda9..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_reg.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef _INTEL_REG_H_
-#define _INTEL_REG_H_
-
-
-#define BR00_BITBLT_CLIENT 0x40000000
-#define BR00_OP_COLOR_BLT 0x10000000
-#define BR00_OP_SRC_COPY_BLT 0x10C00000
-#define BR13_SOLID_PATTERN 0x80000000
-
-#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
-#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
-#define XY_COLOR_BLT_WRITE_RGB (1<<20)
-
-#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
-#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
-#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
-
-#define MI_WAIT_FOR_EVENT ((0x3<<23))
-#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
-#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
-
-#define MI_BATCH_BUFFER_END (0xA<<23)
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.c b/src/mesa/drivers/dri/intel_winsys/intel_screen.c
deleted file mode 100644
index 9e31c013a9..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_screen.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "utils.h"
-#include "vblank.h"
-#include "xmlpool.h"
-
-#include "intel_context.h"
-#include "intel_screen.h"
-#include "intel_batchbuffer.h"
-#include "intel_batchpool.h"
-#include "intel_swapbuffers.h"
-#include "intel_winsys.h"
-
-#include "i830_dri.h"
-#include "dri_bufpool.h"
-
-#include "pipe/p_context.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_cb_fbo.h"
-
-
-
-PUBLIC const char __driConfigOptions[] =
- DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
- DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
- DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
- DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
- DRI_CONF_FORCE_S3TC_ENABLE(false)
- DRI_CONF_ALLOW_LARGE_TEXTURES(1)
- DRI_CONF_SECTION_END DRI_CONF_END;
-
-const uint __driNConfigOptions = 4;
-
-#ifdef USE_NEW_INTERFACE
-static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-#endif /*USE_NEW_INTERFACE */
-
-extern const struct dri_extension card_extensions[];
-
-
-
-
-static void
-intelPrintDRIInfo(struct intel_screen * intelScreen,
- __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
-{
- fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->front.size, intelScreen->front.offset,
- intelScreen->front.pitch);
- fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
-}
-
-
-#if 0
-static void
-intelPrintSAREA(const drmI830Sarea * sarea)
-{
- fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
- sarea->height);
- fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
- fprintf(stderr,
- "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->front_offset, sarea->front_size,
- (unsigned) sarea->front_handle);
- fprintf(stderr,
- "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->back_offset, sarea->back_size,
- (unsigned) sarea->back_handle);
- fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->depth_offset, sarea->depth_size,
- (unsigned) sarea->depth_handle);
- fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
- fprintf(stderr, "SAREA: rotation: %d\n", sarea->rotation);
- fprintf(stderr,
- "SAREA: rotated offset: 0x%08x size: 0x%x\n",
- sarea->rotated_offset, sarea->rotated_size);
- fprintf(stderr, "SAREA: rotated pitch: %d\n", sarea->rotated_pitch);
-}
-#endif
-
-
-/**
- * Use the information in the sarea to update the screen parameters
- * related to screen rotation. Needs to be called locked.
- */
-void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->front.map) {
- drmUnmap(intelScreen->front.map, intelScreen->front.size);
- intelScreen->front.map = NULL;
- }
-
- if (intelScreen->front.buffer)
- driDeleteBuffers(1, &intelScreen->front.buffer);
-
- intelScreen->front.width = sarea->width;
- intelScreen->front.height = sarea->height;
- intelScreen->front.offset = sarea->front_offset;
- intelScreen->front.pitch = sarea->pitch * intelScreen->front.cpp;
- intelScreen->front.size = sarea->front_size;
- intelScreen->front.handle = sarea->front_handle;
-
- assert( sarea->front_size >=
- intelScreen->front.pitch * intelScreen->front.height );
-
- if (!sarea->front_handle)
- return;
-
- if (drmMap(sPriv->fd,
- sarea->front_handle,
- intelScreen->front.size,
- (drmAddress *) & intelScreen->front.map) != 0) {
- fprintf(stderr, "drmMap(frontbuffer) failed!\n");
- return;
- }
-
- if (intelScreen->staticPool) {
- driGenBuffers(intelScreen->staticPool, "static region", 1,
- &intelScreen->front.buffer, 64,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_MOVE |
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
-
- driBOSetStatic(intelScreen->front.buffer,
- intelScreen->front.offset,
- intelScreen->front.pitch * intelScreen->front.height,
- intelScreen->front.map, 0);
- }
-}
-
-
-boolean
-intelCreatePools(__DRIscreenPrivate * sPriv)
-{
- unsigned batchPoolSize = 1024*1024;
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->havePools)
- return GL_TRUE;
-
- intelScreen->staticPool = driDRMStaticPoolInit(sPriv->fd);
- if (!intelScreen->staticPool)
- return GL_FALSE;
-
- batchPoolSize /= BATCH_SZ;
- intelScreen->batchPool = driBatchPoolInit(sPriv->fd,
- DRM_BO_FLAG_EXE |
- DRM_BO_FLAG_MEM_TT |
- DRM_BO_FLAG_MEM_LOCAL,
- BATCH_SZ,
- batchPoolSize, 5);
- if (!intelScreen->batchPool) {
- fprintf(stderr, "Failed to initialize batch pool - possible incorrect agpgart installed\n");
- return GL_FALSE;
- }
-
- intelScreen->havePools = GL_TRUE;
-
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- return GL_TRUE;
-}
-
-
-static boolean
-intelInitDriver(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen;
- I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
-
- PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
- (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->
- getProcAddress("glxEnableExtension"));
- void *const psc = sPriv->psc->screenConfigs;
-
- if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
- fprintf(stderr,
- "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- intelScreen = CALLOC_STRUCT(intel_screen);
- if (!intelScreen)
- return GL_FALSE;
-
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- sPriv->private = (void *) intelScreen;
-
- intelScreen->sarea = (drmI830Sarea *) (((GLubyte *) sPriv->pSAREA) +
- gDRIPriv->sarea_priv_offset);
- intelScreen->deviceID = gDRIPriv->deviceID;
- intelScreen->front.cpp = gDRIPriv->cpp;
- intelScreen->drmMinor = sPriv->drmMinor;
-
- assert(gDRIPriv->bitsPerPixel == 16 ||
- gDRIPriv->bitsPerPixel == 32);
-
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- if (0)
- intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
-
- if (glx_enable_extension != NULL) {
- (*glx_enable_extension) (psc, "GLX_SGI_swap_control");
- (*glx_enable_extension) (psc, "GLX_SGI_video_sync");
- (*glx_enable_extension) (psc, "GLX_MESA_swap_control");
- (*glx_enable_extension) (psc, "GLX_MESA_swap_frame_usage");
- (*glx_enable_extension) (psc, "GLX_SGI_make_current_read");
- }
-
- intelScreen->winsys = intel_create_pipe_winsys(sPriv->fd);
-
- return GL_TRUE;
-}
-
-
-static void
-intelDestroyScreen(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- /* intelUnmapScreenRegions(intelScreen); */
-
- if (intelScreen->havePools) {
- driPoolTakeDown(intelScreen->staticPool);
- driPoolTakeDown(intelScreen->batchPool);
- }
- FREE(intelScreen);
- sPriv->private = NULL;
-}
-
-
-/**
- * This is called when we need to set up GL rendering to a new X window.
- */
-static boolean
-intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
- __DRIdrawablePrivate * driDrawPriv,
- const __GLcontextModes * visual, boolean isPixmap)
-{
- if (isPixmap) {
- return GL_FALSE; /* not implemented */
- }
- else {
- enum pipe_format colorFormat, depthFormat, stencilFormat;
- struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer);
-
- if (!intelfb)
- return GL_FALSE;
-
- if (visual->redBits == 5)
- colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
- else
- colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
-
- if (visual->depthBits == 16)
- depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (visual->depthBits == 24)
- depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- depthFormat = PIPE_FORMAT_NONE;
-
- if (visual->stencilBits == 8)
- stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- stencilFormat = PIPE_FORMAT_NONE;
-
- intelfb->stfb = st_create_framebuffer(visual,
- colorFormat,
- depthFormat,
- stencilFormat,
- driDrawPriv->w,
- driDrawPriv->h,
- (void*) intelfb);
- if (!intelfb->stfb) {
- free(intelfb);
- return GL_FALSE;
- }
-
- driDrawPriv->driverPrivate = (void *) intelfb;
- return GL_TRUE;
- }
-}
-
-static void
-intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(driDrawPriv);
- assert(intelfb->stfb);
- st_unreference_framebuffer(&intelfb->stfb);
- free(intelfb);
-}
-
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
-{
- if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
- || (sInfo == NULL)) {
- return -1;
- }
-
- return 0;
-}
-
-
-static void
-intelSetTexOffset(__DRIcontext *pDRICtx, int texname,
- unsigned long long offset, int depth, uint pitch)
-{
- abort();
-#if 0
- struct intel_context *intel = (struct intel_context*)
- ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
- struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
- struct st_texture_object *stObj = st_texture_object(tObj);
-
- if (!stObj)
- return;
-
- if (stObj->pt)
- st->pipe->texture_release(intel->st->pipe, &stObj->pt);
-
- stObj->imageOverride = GL_TRUE;
- stObj->depthOverride = depth;
- stObj->pitchOverride = pitch;
-
- if (offset)
- stObj->textureOffset = offset;
-#endif
-}
-
-
-static const struct __DriverAPIRec intelAPI = {
- .InitDriver = intelInitDriver,
- .DestroyScreen = intelDestroyScreen,
- .CreateContext = intelCreateContext,
- .DestroyContext = intelDestroyContext,
- .CreateBuffer = intelCreateBuffer,
- .DestroyBuffer = intelDestroyBuffer,
- .SwapBuffers = intelSwapBuffers,
- .MakeCurrent = intelMakeCurrent,
- .UnbindContext = intelUnbindContext,
- .GetSwapInfo = intelGetSwapInfo,
- .GetMSC = driGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .WaitForSBC = NULL,
- .SwapBuffersMSC = NULL,
- .CopySubBuffer = intelCopySubBuffer,
- .setTexOffset = intelSetTexOffset,
-};
-
-
-static __GLcontextModes *
-intelFillInModes(unsigned pixel_bits, unsigned depth_bits,
- unsigned stencil_bits, boolean have_back_buffer)
-{
- __GLcontextModes *modes;
- __GLcontextModes *m;
- unsigned num_modes;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- GLenum fb_format;
- GLenum fb_type;
-
- /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
- * support pageflipping at all.
- */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- u_int8_t depth_bits_array[3];
- u_int8_t stencil_bits_array[3];
-
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
-
- /* Just like with the accumulation buffer, always provide some modes
- * with a stencil buffer. It will be a sw fallback, but some apps won't
- * care about that.
- */
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24)
- stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- num_modes = depth_buffer_factor * back_buffer_factor * 4;
-
- if (pixel_bits == 16) {
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
- }
- else {
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- modes =
- (*dri_interface->createContextModes) (num_modes,
- sizeof(__GLcontextModes));
- m = modes;
- if (!driFillInModes(&m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, GLX_TRUE_COLOR)) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
- if (!driFillInModes(&m, fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, GLX_DIRECT_COLOR)) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
-
- /* Mark the visual as slow if there are "fake" stencil bits.
- */
- for (m = modes; m != NULL; m = m->next) {
- if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
- m->visualRating = GLX_SLOW_CONFIG;
- }
- }
-
- return modes;
-}
-
-
-/**
- * This is the bootstrap function for the driver. libGL supplies all of the
- * requisite information about the system, and the driver initializes itself.
- * This routine also fills in the linked list pointed to by \c driver_modes
- * with the \c __GLcontextModes that the driver can support for windows or
- * pbuffers.
- *
- * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
- * failure.
- */
-PUBLIC void *
-__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn,
- __DRIscreen * psc,
- const __GLcontextModes * modes,
- const __DRIversion * ddx_version,
- const __DRIversion * dri_version,
- const __DRIversion * drm_version,
- const __DRIframebuffer * frame_buffer,
- drmAddress pSAREA, int fd,
- int internal_api_version,
- const __DRIinterfaceMethods * interface,
- __GLcontextModes ** driver_modes)
-{
- __DRIscreenPrivate *psp;
- static const __DRIversion ddx_expected = { 1, 7, 0 };
- static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 1, 7, 0 };
-
- dri_interface = interface;
-
- if (!driCheckDriDdxDrmVersions2("i915",
- dri_version, &dri_expected,
- ddx_version, &ddx_expected,
- drm_version, &drm_expected)) {
- return NULL;
- }
-
- psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
- ddx_version, dri_version, drm_version,
- frame_buffer, pSAREA, fd,
- internal_api_version, &intelAPI);
-
- if (psp != NULL) {
- I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
- *driver_modes = intelFillInModes(dri_priv->cpp * 8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8, 1);
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create
- * is called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions(NULL, card_extensions, GL_FALSE);
- }
-
- return (void *) psp;
-}
-
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_screen.h b/src/mesa/drivers/dri/intel_winsys/intel_screen.h
deleted file mode 100644
index 3396f9e564..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_screen.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _INTEL_SCREEN_H_
-#define _INTEL_SCREEN_H_
-
-#include "dri_util.h"
-#include "i830_common.h"
-#include "xmlconfig.h"
-#include "dri_bufpool.h"
-
-#include "pipe/p_compiler.h"
-
-
-struct intel_screen
-{
- struct {
- drm_handle_t handle;
-
- /* We create a static dri buffer for the frontbuffer.
- */
- struct _DriBufferObject *buffer;
-
- char *map; /* memory map */
- int offset; /* from start of video mem, in bytes */
- int pitch; /* row stride, in bytes */
- int width;
- int height;
- int size;
- int cpp; /* for front and back buffers */
- } front;
-
- int deviceID;
- int drmMinor;
-
- drmI830Sarea *sarea;
-
- /**
- * Configuration cache with default values for all contexts
- */
- driOptionCache optionCache;
-
- struct _DriBufferPool *batchPool;
- struct _DriBufferPool *staticPool; /** for the X screen/framebuffer */
- boolean havePools;
-
- /**
- * Temporary(?) context to use for SwapBuffers or other situations in
- * which we need a rendering context, but none is currently bound.
- */
- struct intel_context *dummyContext;
-
- struct pipe_winsys *winsys;
-};
-
-
-
-/** cast wrapper */
-static INLINE struct intel_screen *
-intel_screen(__DRIscreenPrivate *sPriv)
-{
- return (struct intel_screen *) sPriv->private;
-}
-
-
-extern void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea);
-
-
-extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv);
-
-
-extern boolean
-intelCreatePools(__DRIscreenPrivate *sPriv);
-
-extern boolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate);
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c
deleted file mode 100644
index 454cd71f6c..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-#include "intel_batchbuffer.h"
-#include "intel_reg.h"
-#include "intel_winsys.h"
-
-#include "pipe/p_context.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
-
-
-/**
- * Display a colorbuffer surface in an X window.
- * Used for SwapBuffers and flushing front buffer rendering.
- *
- * \param dPriv the window/drawable to display into
- * \param surf the surface to display
- * \param rect optional subrect of surface to display (may be NULL).
- */
-void
-intelDisplaySurface(__DRIdrawablePrivate *dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t *rect)
-{
- struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
- struct intel_context *intel = intelScreen->dummyContext;
-
- DBG(SWAP, "%s\n", __FUNCTION__);
-
- if (!intel) {
- /* XXX this is where some kind of extra/meta context could be useful */
- return;
- }
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, TRUE);
- driFenceUnReference(intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- intel->last_swap_fence = intel->first_swap_fence;
- intel->first_swap_fence = NULL;
-
- /* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
- * should work regardless.
- */
- LOCK_HARDWARE(intel);
- /* if this drawable isn't currently bound the LOCK_HARDWARE done on the
- * current context (which is what intelScreenContext should return) might
- * not get a contended lock and thus cliprects not updated (tests/manywin)
- */
- if (intel_context(dPriv->driContextPriv) != intel)
- DRI_VALIDATE_DRAWABLE_INFO(intel->driScreen, dPriv);
-
-
- if (dPriv && dPriv->numClipRects) {
- const int srcWidth = surf->width;
- const int srcHeight = surf->height;
- const int nbox = dPriv->numClipRects;
- const drm_clip_rect_t *pbox = dPriv->pClipRects;
- const int pitch = intelScreen->front.pitch / intelScreen->front.cpp;
- const int cpp = intelScreen->front.cpp;
- const int srcpitch = surf->pitch;
- int BR13, CMD;
- int i;
-
- ASSERT(surf->buffer);
- ASSERT(surf->cpp == cpp);
-
- DBG(SWAP, "screen pitch %d src surface pitch %d\n",
- pitch, surf->pitch);
-
- if (cpp == 2) {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24);
- CMD = XY_SRC_COPY_BLT_CMD;
- }
- else {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25);
- CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB);
- }
-
- for (i = 0; i < nbox; i++, pbox++) {
- drm_clip_rect_t box;
- drm_clip_rect_t sbox;
-
- if (pbox->x1 > pbox->x2 ||
- pbox->y1 > pbox->y2 ||
- pbox->x2 > intelScreen->front.width ||
- pbox->y2 > intelScreen->front.height) {
- /* invalid cliprect, skip it */
- continue;
- }
-
- box = *pbox;
-
- if (rect) {
- /* intersect cliprect with user-provided src rect */
- drm_clip_rect_t rrect;
-
- rrect.x1 = dPriv->x + rect->x1;
- rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y;
- rrect.x2 = rect->x2 + rrect.x1;
- rrect.y2 = rect->y2 + rrect.y1;
- if (rrect.x1 > box.x1)
- box.x1 = rrect.x1;
- if (rrect.y1 > box.y1)
- box.y1 = rrect.y1;
- if (rrect.x2 < box.x2)
- box.x2 = rrect.x2;
- if (rrect.y2 < box.y2)
- box.y2 = rrect.y2;
-
- if (box.x1 > box.x2 || box.y1 > box.y2)
- continue;
- }
-
- /* restrict blit to size of actually rendered area */
- if (box.x2 - box.x1 > srcWidth)
- box.x2 = srcWidth + box.x1;
- if (box.y2 - box.y1 > srcHeight)
- box.y2 = srcHeight + box.y1;
-
- DBG(SWAP, "box x1 x2 y1 y2 %d %d %d %d\n",
- box.x1, box.x2, box.y1, box.y2);
-
- sbox.x1 = box.x1 - dPriv->x;
- sbox.y1 = box.y1 - dPriv->y;
-
- assert(box.x1 < box.x2);
- assert(box.y1 < box.y2);
-
- /* XXX this could be done with pipe->surface_copy() */
- BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH(CMD);
- OUT_BATCH(BR13);
- OUT_BATCH((box.y1 << 16) | box.x1);
- OUT_BATCH((box.y2 << 16) | box.x2);
-
- OUT_RELOC(intelScreen->front.buffer,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
- OUT_BATCH((sbox.y1 << 16) | sbox.x1);
- OUT_BATCH((srcpitch * cpp) & 0xffff);
- OUT_RELOC(dri_bo(surf->buffer),
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
-
- ADVANCE_BATCH();
- }
-
- if (intel->first_swap_fence)
- driFenceUnReference(intel->first_swap_fence);
- intel->first_swap_fence = intel_batchbuffer_flush(intel->batch);
- driFenceReference(intel->first_swap_fence);
- }
-
- UNLOCK_HARDWARE(intel);
-
- if (intel->lastStamp != dPriv->lastStamp) {
- intelUpdateWindowSize(dPriv);
- intel->lastStamp = dPriv->lastStamp;
- }
-}
-
-
-
-/**
- * This will be called whenever the currently bound window is moved/resized.
- */
-void
-intelUpdateWindowSize(__DRIdrawablePrivate *dPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(dPriv);
- assert(intelfb->stfb);
- st_resize_framebuffer(intelfb->stfb, dPriv->w, dPriv->h);
-}
-
-
-
-void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, NULL);
- }
-}
-
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = w;
- rect.y2 = h;
-
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, &rect);
- }
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h b/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h
deleted file mode 100644
index 7ae5fd15a5..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_swapbuffers.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_SWAPBUFFERS_H
-#define INTEL_SWAPBUFFERS_H
-
-
-struct pipe_surface;
-
-
-extern void intelDisplaySurface(__DRIdrawablePrivate * dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t * rect);
-
-extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
-
-extern void intelCopySubBuffer(__DRIdrawablePrivate * dPriv,
- int x, int y, int w, int h);
-
-extern void intelUpdateWindowSize(__DRIdrawablePrivate *dPriv);
-
-
-#endif /* INTEL_SWAPBUFFERS_H */
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h b/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
deleted file mode 100644
index ffc40782be..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_WINSYS_H
-#define INTEL_WINSYS_H
-
-#include "pipe/p_state.h"
-
-struct intel_context;
-struct pipe_context;
-struct pipe_winsys;
-struct pipe_buffer;
-struct _DriBufferObject;
-
-struct pipe_winsys *
-intel_create_pipe_winsys( int fd );
-
-void
-intel_destroy_pipe_winsys( struct pipe_winsys *winsys );
-
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys );
-
-struct pipe_context *
-intel_create_i915simple( struct intel_context *intel,
- struct pipe_winsys *winsys );
-
-
-struct intel_buffer {
- struct pipe_buffer base;
- struct _DriBufferObject *driBO;
-};
-
-static INLINE struct intel_buffer *
-intel_buffer( struct pipe_buffer *buf )
-{
- return (struct intel_buffer *)buf;
-}
-
-static INLINE struct _DriBufferObject *
-dri_bo( struct pipe_buffer *buf )
-{
- return intel_buffer(buf)->driBO;
-}
-
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
deleted file mode 100644
index 1ba6a9e1b2..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <stdlib.h>
-#include <xf86drm.h>
-#include "dri_bufpool.h"
-#include "dri_bufmgr.h"
-
-#include "intel_context.h"
-#include "intel_batchbuffer.h"
-#include "intel_winsys.h"
-
-#include "pipe/p_util.h"
-#include "pipe/i915simple/i915_winsys.h"
-
-
-struct intel_i915_winsys {
- struct i915_winsys winsys; /**< batch buffer funcs */
- struct intel_context *intel;
-};
-
-
-/* Turn a i915simple winsys into an intel/i915simple winsys:
- */
-static inline struct intel_i915_winsys *
-intel_i915_winsys( struct i915_winsys *sws )
-{
- return (struct intel_i915_winsys *)sws;
-}
-
-
-/* Simple batchbuffer interface:
- */
-
-static unsigned *intel_i915_batch_start( struct i915_winsys *sws,
- unsigned dwords,
- unsigned relocs )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
-
- /* XXX: check relocs.
- */
- if (intel_batchbuffer_space( intel->batch ) >= dwords * 4) {
- /* XXX: Hmm, the driver can't really do much with this pointer:
- */
- return (unsigned *)intel->batch->ptr;
- }
- else
- return NULL;
-}
-
-static void intel_i915_batch_dword( struct i915_winsys *sws,
- unsigned dword )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
- intel_batchbuffer_emit_dword( intel->batch, dword );
-}
-
-static void intel_i915_batch_reloc( struct i915_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
- unsigned flags = DRM_BO_FLAG_MEM_TT;
- unsigned mask = DRM_BO_MASK_MEM;
-
- if (access_flags & I915_BUFFER_ACCESS_WRITE) {
- flags |= DRM_BO_FLAG_WRITE;
- mask |= DRM_BO_FLAG_WRITE;
- }
-
- if (access_flags & I915_BUFFER_ACCESS_READ) {
- flags |= DRM_BO_FLAG_READ;
- mask |= DRM_BO_FLAG_READ;
- }
-
- intel_batchbuffer_emit_reloc( intel->batch,
- dri_bo( buf ),
- flags, mask,
- delta );
-}
-
-
-
-static void intel_i915_batch_flush( struct i915_winsys *sws )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
-
- intel_batchbuffer_flush( intel->batch );
-// if (0) intel_i915_batch_wait_idle( sws );
-}
-
-
-static void intel_i915_batch_finish( struct i915_winsys *sws )
-{
- struct intel_context *intel = intel_i915_winsys(sws)->intel;
- intel_batchbuffer_finish( intel->batch );
-}
-
-
-/**
- * Create i915 hardware rendering context.
- */
-struct pipe_context *
-intel_create_i915simple( struct intel_context *intel,
- struct pipe_winsys *winsys )
-{
- struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
-
- /* Fill in this struct with callbacks that i915simple will need to
- * communicate with the window system, buffer manager, etc.
- */
- iws->winsys.batch_start = intel_i915_batch_start;
- iws->winsys.batch_dword = intel_i915_batch_dword;
- iws->winsys.batch_reloc = intel_i915_batch_reloc;
- iws->winsys.batch_flush = intel_i915_batch_flush;
- iws->winsys.batch_finish = intel_i915_batch_finish;
- iws->intel = intel;
-
- /* Create the i915simple context:
- */
- return i915_create( winsys,
- &iws->winsys,
- intel->intelScreen->deviceID );
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
deleted file mode 100644
index 789a386500..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_pipe.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <stdlib.h>
-#include <xf86drm.h>
-#include "dri_bufpool.h"
-#include "dri_bufmgr.h"
-
-#include "intel_context.h"
-#include "intel_winsys.h"
-#include "intel_swapbuffers.h"
-#include "intel_batchbuffer.h"
-
-#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"
-
-
-
-struct intel_pipe_winsys {
- struct pipe_winsys winsys;
- struct _DriBufferPool *regionPool;
-};
-
-
-
-/* Turn a pipe winsys into an intel/pipe winsys:
- */
-static inline struct intel_pipe_winsys *
-intel_pipe_winsys( struct pipe_winsys *winsys )
-{
- return (struct intel_pipe_winsys *)winsys;
-}
-
-
-/* Most callbacks map direcly onto dri_bufmgr operations:
- */
-static void *intel_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags )
-{
- unsigned drm_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- drm_flags |= DRM_BO_FLAG_WRITE;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- drm_flags |= DRM_BO_FLAG_READ;
-
- return driBOMap( dri_bo(buf), drm_flags, 0 );
-}
-
-static void intel_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnmap( dri_bo(buf) );
-}
-
-
-static void
-intel_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnReference( dri_bo(buf) );
-}
-
-
-/* Pipe has no concept of pools. We choose the tex/region pool
- * for all buffers.
- * Grabs the hardware lock!
- */
-static struct pipe_buffer *
-intel_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size )
-{
- struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
- struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
- unsigned flags = 0;
-
- buffer->base.refcount = 1;
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- if (usage & (PIPE_BUFFER_USAGE_VERTEX /*| IWS_BUFFER_USAGE_LOCAL*/)) {
- flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
- } else {
- flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
- }
-
- if (usage & PIPE_BUFFER_USAGE_GPU_READ)
- flags |= DRM_BO_FLAG_READ;
-
- if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
- flags |= DRM_BO_FLAG_WRITE;
-
- /* drm complains if we don't set any read/write flags.
- */
- if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
- flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
-
-#if 0
- if (flags & IWS_BUFFER_USAGE_EXE)
- flags |= DRM_BO_FLAG_EXE;
-
- if (usage & IWS_BUFFER_USAGE_CACHED)
- flags |= DRM_BO_FLAG_CACHED;
-#endif
-
- driGenBuffers( iws->regionPool,
- "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
-
- driBOData( buffer->driBO, size, NULL, 0 );
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-intel_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
-{
- struct intel_buffer *buffer = CALLOC_STRUCT( intel_buffer );
- struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
-
- driGenUserBuffer( iws->regionPool,
- "pipe user buffer", &buffer->driBO, ptr, bytes);
-
- return &buffer->base;
-}
-
-
-/* The state tracker (should!) keep track of whether the fake
- * frontbuffer has been touched by any rendering since the last time
- * we copied its contents to the real frontbuffer. Our task is easy:
- */
-static void
-intel_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct intel_context *intel = (struct intel_context *) context_private;
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
- intelDisplaySurface(dPriv, surf, NULL);
-}
-
-
-static struct pipe_surface *
-intel_i915_surface_alloc(struct pipe_winsys *winsys)
-{
- struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface);
- if (surf) {
- surf->refcount = 1;
- surf->winsys = winsys;
- }
- return surf;
-}
-
-
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-/**
- * Copied from xm_winsys.c
- */
-static int
-intel_i915_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags)
-{
- const unsigned alignment = 64;
- int ret;
-
- surf->width = width;
- surf->height = height;
- surf->format = format;
- surf->cpp = pf_get_size(format);
- surf->pitch = round_up(width, alignment / surf->cpp);
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->pitch * surf->cpp * height);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-
-static void
-intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
-}
-
-
-
-static void
-intel_printf( struct pipe_winsys *winsys, const char *fmtString, ... )
-{
- va_list args;
- va_start( args, fmtString );
- vfprintf(stderr, fmtString, args);
- va_end( args );
-}
-
-static const char *
-intel_get_name( struct pipe_winsys *winsys )
-{
- return "Intel/DRI/ttm";
-}
-
-
-struct pipe_winsys *
-intel_create_pipe_winsys( int fd )
-{
- struct intel_pipe_winsys *iws = CALLOC_STRUCT( intel_pipe_winsys );
-
- /* Fill in this struct with callbacks that pipe will need to
- * communicate with the window system, buffer manager, etc.
- *
- * Pipe would be happy with a malloc based memory manager, but
- * the SwapBuffers implementation in this winsys driver requires
- * that rendering be done to an appropriate _DriBufferObject.
- */
- iws->winsys.buffer_create = intel_buffer_create;
- iws->winsys.user_buffer_create = intel_user_buffer_create;
- iws->winsys.buffer_map = intel_buffer_map;
- iws->winsys.buffer_unmap = intel_buffer_unmap;
- iws->winsys.buffer_destroy = intel_buffer_destroy;
- iws->winsys.flush_frontbuffer = intel_flush_frontbuffer;
- iws->winsys.printf = intel_printf;
- iws->winsys.get_name = intel_get_name;
- iws->winsys.surface_alloc = intel_i915_surface_alloc;
- iws->winsys.surface_alloc_storage = intel_i915_surface_alloc_storage;
- iws->winsys.surface_release = intel_i915_surface_release;
-
- if (fd)
- iws->regionPool = driDRMPoolInit(fd);
-
- return &iws->winsys;
-}
-
-
-void
-intel_destroy_pipe_winsys( struct pipe_winsys *winsys )
-{
- struct intel_pipe_winsys *iws = intel_pipe_winsys(winsys);
- if (iws->regionPool) {
- driPoolTakeDown(iws->regionPool);
- }
- free(iws);
-}
-
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_softpipe.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_softpipe.c
deleted file mode 100644
index cec3437831..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_softpipe.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "intel_context.h"
-#include "intel_winsys.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_format.h"
-#include "pipe/softpipe/sp_winsys.h"
-
-
-struct intel_softpipe_winsys {
- struct softpipe_winsys sws;
- struct intel_context *intel;
-};
-
-/**
- * Return list of surface formats supported by this driver.
- */
-static boolean
-intel_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- switch(format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-
-/**
- * Create rendering context which uses software rendering.
- */
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys )
-{
- struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
-
- /* Fill in this struct with callbacks that softpipe will need to
- * communicate with the window system, buffer manager, etc.
- */
- isws->sws.is_format_supported = intel_is_format_supported;
- isws->intel = intel;
-
- /* Create the softpipe context:
- */
- return softpipe_create( winsys, &isws->sws );
-}
diff --git a/src/mesa/drivers/dri/intel_winsys/server/i830_common.h b/src/mesa/drivers/dri/intel_winsys/server/i830_common.h
deleted file mode 100644
index d4d58886ce..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/server/i830_common.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/**************************************************************************
-
-Copyright 2001 VA Linux Systems Inc., Fremont, California.
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_common.h,v 1.1 2002/09/11 00:29:32 dawes Exp $ */
-
-#ifndef _I830_COMMON_H_
-#define _I830_COMMON_H_
-
-
-#define I830_NR_TEX_REGIONS 255 /* maximum due to use of chars for next/prev */
-#define I830_LOG_MIN_TEX_REGION_SIZE 14
-
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_I830_INIT 0x00
-#define DRM_I830_FLUSH 0x01
-#define DRM_I830_FLIP 0x02
-#define DRM_I830_BATCHBUFFER 0x03
-#define DRM_I830_IRQ_EMIT 0x04
-#define DRM_I830_IRQ_WAIT 0x05
-#define DRM_I830_GETPARAM 0x06
-#define DRM_I830_SETPARAM 0x07
-#define DRM_I830_ALLOC 0x08
-#define DRM_I830_FREE 0x09
-#define DRM_I830_INIT_HEAP 0x0a
-#define DRM_I830_CMDBUFFER 0x0b
-#define DRM_I830_DESTROY_HEAP 0x0c
-#define DRM_I830_SET_VBLANK_PIPE 0x0d
-#define DRM_I830_GET_VBLANK_PIPE 0x0e
-
-typedef struct {
- enum {
- I830_INIT_DMA = 0x01,
- I830_CLEANUP_DMA = 0x02,
- I830_RESUME_DMA = 0x03
- } func;
- unsigned int mmio_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
- unsigned int back_pitch;
- unsigned int depth_pitch;
- unsigned int cpp;
- unsigned int chipset;
-} drmI830Init;
-
-typedef struct {
- drmTextureRegion texList[I830_NR_TEX_REGIONS+1];
- int last_upload; /* last time texture was uploaded */
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int ctxOwner; /* last context to upload state */
- int texAge;
- int pf_enabled; /* is pageflipping allowed? */
- int pf_active;
- int pf_current_page; /* which buffer is being displayed? */
- int perf_boxes; /* performance boxes to be displayed */
- int width, height; /* screen size in pixels */
-
- drm_handle_t front_handle;
- int front_offset;
- int front_size;
-
- drm_handle_t back_handle;
- int back_offset;
- int back_size;
-
- drm_handle_t depth_handle;
- int depth_offset;
- int depth_size;
-
- drm_handle_t tex_handle;
- int tex_offset;
- int tex_size;
- int log_tex_granularity;
- int pitch;
- int rotation; /* 0, 90, 180 or 270 */
- int rotated_offset;
- int rotated_size;
- int rotated_pitch;
- int virtualX, virtualY;
-
- unsigned int front_tiled;
- unsigned int back_tiled;
- unsigned int depth_tiled;
- unsigned int rotated_tiled;
- unsigned int rotated2_tiled;
-
- int pipeA_x;
- int pipeA_y;
- int pipeA_w;
- int pipeA_h;
- int pipeB_x;
- int pipeB_y;
- int pipeB_w;
- int pipeB_h;
-
- /* Triple buffering */
- drm_handle_t third_handle;
- int third_offset;
- int third_size;
- unsigned int third_tiled;
-} drmI830Sarea;
-
-/* Flags for perf_boxes
- */
-#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
-#define I830_BOX_FLIP 0x2 /* populated by kernel */
-#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
-#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
-#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
-
-
-typedef struct {
- int start; /* agp offset */
- int used; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830BatchBuffer;
-
-typedef struct {
- char *buf; /* agp offset */
- int sz; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830CmdBuffer;
-
-typedef struct {
- int *irq_seq;
-} drmI830IrqEmit;
-
-typedef struct {
- int irq_seq;
-} drmI830IrqWait;
-
-typedef struct {
- int param;
- int *value;
-} drmI830GetParam;
-
-#define I830_PARAM_IRQ_ACTIVE 1
-#define I830_PARAM_ALLOW_BATCHBUFFER 2
-
-typedef struct {
- int param;
- int value;
-} drmI830SetParam;
-
-#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
-#define I830_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
-#define I830_SETPARAM_ALLOW_BATCHBUFFER 3
-
-
-/* A memory manager for regions of shared memory:
- */
-#define I830_MEM_REGION_AGP 1
-
-typedef struct {
- int region;
- int alignment;
- int size;
- int *region_offset; /* offset from start of fb or agp */
-} drmI830MemAlloc;
-
-typedef struct {
- int region;
- int region_offset;
-} drmI830MemFree;
-
-typedef struct {
- int region;
- int size;
- int start;
-} drmI830MemInitHeap;
-
-typedef struct {
- int region;
-} drmI830MemDestroyHeap;
-
-#define DRM_I830_VBLANK_PIPE_A 1
-#define DRM_I830_VBLANK_PIPE_B 2
-
-typedef struct {
- int pipe;
-} drmI830VBlankPipe;
-
-#endif /* _I830_DRM_H_ */
diff --git a/src/mesa/drivers/dri/intel_winsys/server/i830_dri.h b/src/mesa/drivers/dri/intel_winsys/server/i830_dri.h
deleted file mode 100644
index c2a3af8cbf..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/server/i830_dri.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.4 2002/10/30 12:52:18 alanh Exp $ */
-
-#ifndef _I830_DRI_H
-#define _I830_DRI_H
-
-#include "xf86drm.h"
-#include "i830_common.h"
-
-#define I830_MAX_DRAWABLES 256
-
-#define I830_MAJOR_VERSION 1
-#define I830_MINOR_VERSION 7
-#define I830_PATCHLEVEL 2
-
-#define I830_REG_SIZE 0x80000
-
-typedef struct _I830DRIRec {
- drm_handle_t regs;
- drmSize regsSize;
-
- drmSize unused1; /* backbufferSize */
- drm_handle_t unused2; /* backbuffer */
-
- drmSize unused3; /* depthbufferSize */
- drm_handle_t unused4; /* depthbuffer */
-
- drmSize unused5; /* rotatedSize */
- drm_handle_t unused6; /* rotatedbuffer */
-
- drm_handle_t unused7; /* textures */
- int unused8; /* textureSize */
-
- drm_handle_t unused9; /* agp_buffers */
- drmSize unused10; /* agp_buf_size */
-
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int bitsPerPixel;
-
- int unused11[8]; /* was front/back/depth/rotated offset/pitch */
-
- int unused12; /* logTextureGranularity */
- int unused13; /* textureOffset */
-
- int irq;
- int sarea_priv_offset;
-} I830DRIRec, *I830DRIPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830ConfigPrivRec, *I830ConfigPrivPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830DRIContextRec, *I830DRIContextPtr;
-
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/server/intel.h b/src/mesa/drivers/dri/intel_winsys/server/intel.h
deleted file mode 100644
index 6ea72499c1..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/server/intel.h
+++ /dev/null
@@ -1,331 +0,0 @@
-#ifndef _INTEL_H_
-#define _INTEL_H_
-
-#include "xf86drm.h" /* drm_handle_t, etc */
-
-/* Intel */
-#ifndef PCI_CHIP_I810
-#define PCI_CHIP_I810 0x7121
-#define PCI_CHIP_I810_DC100 0x7123
-#define PCI_CHIP_I810_E 0x7125
-#define PCI_CHIP_I815 0x1132
-#define PCI_CHIP_I810_BRIDGE 0x7120
-#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
-#define PCI_CHIP_I810_E_BRIDGE 0x7124
-#define PCI_CHIP_I815_BRIDGE 0x1130
-#endif
-
-#define PCI_CHIP_845_G 0x2562
-#define PCI_CHIP_I830_M 0x3577
-
-#ifndef PCI_CHIP_I855_GM
-#define PCI_CHIP_I855_GM 0x3582
-#define PCI_CHIP_I855_GM_BRIDGE 0x3580
-#endif
-
-#ifndef PCI_CHIP_I865_G
-#define PCI_CHIP_I865_G 0x2572
-#define PCI_CHIP_I865_G_BRIDGE 0x2570
-#endif
-
-#ifndef PCI_CHIP_I915_G
-#define PCI_CHIP_I915_G 0x2582
-#define PCI_CHIP_I915_G_BRIDGE 0x2580
-#endif
-
-#ifndef PCI_CHIP_I915_GM
-#define PCI_CHIP_I915_GM 0x2592
-#define PCI_CHIP_I915_GM_BRIDGE 0x2590
-#endif
-
-#ifndef PCI_CHIP_E7221_G
-#define PCI_CHIP_E7221_G 0x258A
-/* Same as I915_G_BRIDGE */
-#define PCI_CHIP_E7221_G_BRIDGE 0x2580
-#endif
-
-#ifndef PCI_CHIP_I945_G
-#define PCI_CHIP_I945_G 0x2772
-#define PCI_CHIP_I945_G_BRIDGE 0x2770
-#endif
-
-#ifndef PCI_CHIP_I945_GM
-#define PCI_CHIP_I945_GM 0x27A2
-#define PCI_CHIP_I945_GM_BRIDGE 0x27A0
-#endif
-
-#define IS_I810(pI810) (pI810->Chipset == PCI_CHIP_I810 || \
- pI810->Chipset == PCI_CHIP_I810_DC100 || \
- pI810->Chipset == PCI_CHIP_I810_E)
-#define IS_I815(pI810) (pI810->Chipset == PCI_CHIP_I815)
-#define IS_I830(pI810) (pI810->Chipset == PCI_CHIP_I830_M)
-#define IS_845G(pI810) (pI810->Chipset == PCI_CHIP_845_G)
-#define IS_I85X(pI810) (pI810->Chipset == PCI_CHIP_I855_GM)
-#define IS_I852(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I852_GM || pI810->variant == I852_GME))
-#define IS_I855(pI810) (pI810->Chipset == PCI_CHIP_I855_GM && (pI810->variant == I855_GM || pI810->variant == I855_GME))
-#define IS_I865G(pI810) (pI810->Chipset == PCI_CHIP_I865_G)
-
-#define IS_I915G(pI810) (pI810->Chipset == PCI_CHIP_I915_G || pI810->Chipset == PCI_CHIP_E7221_G)
-#define IS_I915GM(pI810) (pI810->Chipset == PCI_CHIP_I915_GM)
-#define IS_I945G(pI810) (pI810->Chipset == PCI_CHIP_I945_G)
-#define IS_I945GM(pI810) (pI810->Chipset == PCI_CHIP_I945_GM)
-#define IS_I9XX(pI810) (IS_I915G(pI810) || IS_I915GM(pI810) || IS_I945G(pI810) || IS_I945GM(pI810))
-
-#define IS_MOBILE(pI810) (IS_I830(pI810) || IS_I85X(pI810) || IS_I915GM(pI810) || IS_I945GM(pI810))
-
-#define I830_GMCH_CTRL 0x52
-
-#define I830_GMCH_MEM_MASK 0x1
-#define I830_GMCH_MEM_64M 0x1
-#define I830_GMCH_MEM_128M 0
-
-#define I830_GMCH_GMS_MASK 0x70
-#define I830_GMCH_GMS_DISABLED 0x00
-#define I830_GMCH_GMS_LOCAL 0x10
-#define I830_GMCH_GMS_STOLEN_512 0x20
-#define I830_GMCH_GMS_STOLEN_1024 0x30
-#define I830_GMCH_GMS_STOLEN_8192 0x40
-
-#define I855_GMCH_GMS_MASK (0x7 << 4)
-#define I855_GMCH_GMS_DISABLED 0x00
-#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4)
-#define I855_GMCH_GMS_STOLEN_4M (0x2 << 4)
-#define I855_GMCH_GMS_STOLEN_8M (0x3 << 4)
-#define I855_GMCH_GMS_STOLEN_16M (0x4 << 4)
-#define I855_GMCH_GMS_STOLEN_32M (0x5 << 4)
-#define I915G_GMCH_GMS_STOLEN_48M (0x6 << 4)
-#define I915G_GMCH_GMS_STOLEN_64M (0x7 << 4)
-
-typedef unsigned char Bool;
-#define TRUE 1
-#define FALSE 0
-
-#define PIPE_NONE 0<<0
-#define PIPE_CRT 1<<0
-#define PIPE_TV 1<<1
-#define PIPE_DFP 1<<2
-#define PIPE_LFP 1<<3
-#define PIPE_CRT2 1<<4
-#define PIPE_TV2 1<<5
-#define PIPE_DFP2 1<<6
-#define PIPE_LFP2 1<<7
-
-typedef struct _I830MemPool *I830MemPoolPtr;
-typedef struct _I830MemRange *I830MemRangePtr;
-typedef struct _I830MemRange {
- long Start;
- long End;
- long Size;
- unsigned long Physical;
- unsigned long Offset; /* Offset of AGP-allocated portion */
- unsigned long Alignment;
- drm_handle_t Key;
- unsigned long Pitch; // add pitch
- I830MemPoolPtr Pool;
-} I830MemRange;
-
-typedef struct _I830MemPool {
- I830MemRange Total;
- I830MemRange Free;
- I830MemRange Fixed;
- I830MemRange Allocated;
-} I830MemPool;
-
-typedef struct {
- int tail_mask;
- I830MemRange mem;
- unsigned char *virtual_start;
- int head;
- int tail;
- int space;
-} I830RingBuffer;
-
-typedef struct _I830Rec {
- unsigned char *MMIOBase;
- unsigned char *FbBase;
- int cpp;
- uint32_t aper_size;
- unsigned int bios_version;
-
- /* These are set in PreInit and never changed. */
- long FbMapSize;
- long TotalVideoRam;
- I830MemRange StolenMemory; /* pre-allocated memory */
- long BIOSMemorySize; /* min stolen pool size */
- int BIOSMemSizeLoc;
-
- /* These change according to what has been allocated. */
- long FreeMemory;
- I830MemRange MemoryAperture;
- I830MemPool StolenPool;
- long allocatedMemory;
-
- /* Regions allocated either from the above pools, or from agpgart. */
- /* for single and dual head configurations */
- I830MemRange FrontBuffer;
- I830MemRange FrontBuffer2;
- I830MemRange Scratch;
- I830MemRange Scratch2;
-
- I830RingBuffer *LpRing;
-
- I830MemRange BackBuffer;
- I830MemRange DepthBuffer;
- I830MemRange TexMem;
- int TexGranularity;
- I830MemRange ContextMem;
- int drmMinor;
- Bool have3DWindows;
-
- Bool NeedRingBufferLow;
- Bool allowPageFlip;
- Bool disableTiling;
-
- int Chipset;
- unsigned long LinearAddr;
- unsigned long MMIOAddr;
-
- drmSize registerSize; /**< \brief MMIO register map size */
- drm_handle_t registerHandle; /**< \brief MMIO register map handle */
- // IOADDRESS ioBase;
- int irq; /**< \brief IRQ number */
- int GttBound;
-
- drm_handle_t ring_map;
- unsigned int Fence[8];
-
-} I830Rec;
-
-/*
- * 12288 is set as the maximum, chosen because it is enough for
- * 1920x1440@32bpp with a 2048 pixel line pitch with some to spare.
- */
-#define I830_MAXIMUM_VBIOS_MEM 12288
-#define I830_DEFAULT_VIDEOMEM_2D (MB(32) / 1024)
-#define I830_DEFAULT_VIDEOMEM_3D (MB(64) / 1024)
-
-/* Flags for memory allocation function */
-#define FROM_ANYWHERE 0x00000000
-#define FROM_POOL_ONLY 0x00000001
-#define FROM_NEW_ONLY 0x00000002
-#define FROM_MASK 0x0000000f
-
-#define ALLOCATE_AT_TOP 0x00000010
-#define ALLOCATE_AT_BOTTOM 0x00000020
-#define FORCE_GAPS 0x00000040
-
-#define NEED_PHYSICAL_ADDR 0x00000100
-#define ALIGN_BOTH_ENDS 0x00000200
-#define FORCE_LOW 0x00000400
-
-#define ALLOC_NO_TILING 0x00001000
-#define ALLOC_INITIAL 0x00002000
-
-#define ALLOCATE_DRY_RUN 0x80000000
-
-/* Chipset registers for VIDEO BIOS memory RW access */
-#define _855_DRAM_RW_CONTROL 0x58
-#define _845_DRAM_RW_CONTROL 0x90
-#define DRAM_WRITE 0x33330000
-
-#define KB(x) ((x) * 1024)
-#define MB(x) ((x) * KB(1024))
-
-#define GTT_PAGE_SIZE KB(4)
-#define ROUND_TO(x, y) (((x) + (y) - 1) / (y) * (y))
-#define ROUND_DOWN_TO(x, y) ((x) / (y) * (y))
-#define ROUND_TO_PAGE(x) ROUND_TO((x), GTT_PAGE_SIZE)
-#define ROUND_TO_MB(x) ROUND_TO((x), MB(1))
-#define PRIMARY_RINGBUFFER_SIZE KB(128)
-
-
-/* Ring buffer registers, p277, overview p19
- */
-#define LP_RING 0x2030
-#define HP_RING 0x2040
-
-#define RING_TAIL 0x00
-#define TAIL_ADDR 0x000FFFF8
-#define I830_TAIL_MASK 0x001FFFF8
-
-#define RING_HEAD 0x04
-#define HEAD_WRAP_COUNT 0xFFE00000
-#define HEAD_WRAP_ONE 0x00200000
-#define HEAD_ADDR 0x001FFFFC
-#define I830_HEAD_MASK 0x001FFFFC
-
-#define RING_START 0x08
-#define START_ADDR 0x03FFFFF8
-#define I830_RING_START_MASK 0xFFFFF000
-
-#define RING_LEN 0x0C
-#define RING_NR_PAGES 0x001FF000
-#define I830_RING_NR_PAGES 0x001FF000
-#define RING_REPORT_MASK 0x00000006
-#define RING_REPORT_64K 0x00000002
-#define RING_REPORT_128K 0x00000004
-#define RING_NO_REPORT 0x00000000
-#define RING_VALID_MASK 0x00000001
-#define RING_VALID 0x00000001
-#define RING_INVALID 0x00000000
-
-
-/* Fence/Tiling ranges [0..7]
- */
-#define FENCE 0x2000
-#define FENCE_NR 8
-
-#define I915G_FENCE_START_MASK 0x0ff00000
-
-#define I830_FENCE_START_MASK 0x07f80000
-
-#define FENCE_START_MASK 0x03F80000
-#define FENCE_X_MAJOR 0x00000000
-#define FENCE_Y_MAJOR 0x00001000
-#define FENCE_SIZE_MASK 0x00000700
-#define FENCE_SIZE_512K 0x00000000
-#define FENCE_SIZE_1M 0x00000100
-#define FENCE_SIZE_2M 0x00000200
-#define FENCE_SIZE_4M 0x00000300
-#define FENCE_SIZE_8M 0x00000400
-#define FENCE_SIZE_16M 0x00000500
-#define FENCE_SIZE_32M 0x00000600
-#define FENCE_SIZE_64M 0x00000700
-#define I915G_FENCE_SIZE_1M 0x00000000
-#define I915G_FENCE_SIZE_2M 0x00000100
-#define I915G_FENCE_SIZE_4M 0x00000200
-#define I915G_FENCE_SIZE_8M 0x00000300
-#define I915G_FENCE_SIZE_16M 0x00000400
-#define I915G_FENCE_SIZE_32M 0x00000500
-#define I915G_FENCE_SIZE_64M 0x00000600
-#define I915G_FENCE_SIZE_128M 0x00000700
-#define FENCE_PITCH_1 0x00000000
-#define FENCE_PITCH_2 0x00000010
-#define FENCE_PITCH_4 0x00000020
-#define FENCE_PITCH_8 0x00000030
-#define FENCE_PITCH_16 0x00000040
-#define FENCE_PITCH_32 0x00000050
-#define FENCE_PITCH_64 0x00000060
-#define FENCE_VALID 0x00000001
-
-#include <mmio.h>
-
-# define MMIO_IN8(base, offset) \
- *(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
-# define MMIO_IN32(base, offset) \
- read_MMIO_LE32(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
-# define MMIO_OUT32(base, offset, val) \
- *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = CPU_TO_LE32(val)
-
-
- /* Memory mapped register access macros */
-#define INREG8(addr) MMIO_IN8(MMIO, addr)
-#define INREG(addr) MMIO_IN32(MMIO, addr)
-#define OUTREG8(addr, val) MMIO_OUT8(MMIO, addr, val)
-#define OUTREG(addr, val) MMIO_OUT32(MMIO, addr, val)
-
-#define DSPABASE 0x70184
-
-#endif
diff --git a/src/mesa/drivers/dri/intel_winsys/server/intel_dri.c b/src/mesa/drivers/dri/intel_winsys/server/intel_dri.c
deleted file mode 100644
index e49c4214ad..0000000000
--- a/src/mesa/drivers/dri/intel_winsys/server/intel_dri.c
+++ /dev/null
@@ -1,1306 +0,0 @@
-/**
- * \file server/intel_dri.c
- * \brief File to perform the device-specific initialization tasks typically
- * done in the X server.
- *
- * Here they are converted to run in the client (or perhaps a standalone
- * process), and to work with the frame buffer device rather than the X
- * server infrastructure.
- *
- * Copyright (C) 2006 Dave Airlie (airlied@linux.ie)
-
- Permission is hereby granted, free of charge, to any person obtaining a
- copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sub license, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial portions
- of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR
- ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "driver.h"
-#include "drm.h"
-
-#include "intel.h"
-#include "i830_dri.h"
-
-#include "memops.h"
-#include "pciaccess.h"
-
-static size_t drm_page_size;
-static int nextTile = 0;
-#define xf86DrvMsg(...) do {} while(0)
-
-static const int pitches[] = {
- 128 * 8,
- 128 * 16,
- 128 * 32,
- 128 * 64,
- 0
-};
-
-static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea);
-
-static unsigned long
-GetBestTileAlignment(unsigned long size)
-{
- unsigned long i;
-
- for (i = KB(512); i < size; i <<= 1)
- ;
-
- if (i > MB(64))
- i = MB(64);
-
- return i;
-}
-
-static void SetFenceRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- int i;
- unsigned char *MMIO = ctx->MMIOAddress;
-
- for (i = 0; i < 8; i++) {
- OUTREG(FENCE + i * 4, pI830->Fence[i]);
- // if (I810_DEBUG & DEBUG_VERBOSE_VGA)
- fprintf(stderr,"Fence Register : %x\n", pI830->Fence[i]);
- }
-}
-
-/* Tiled memory is good... really, really good...
- *
- * Need to make it less likely that we miss out on this - probably
- * need to move the frontbuffer away from the 'guarenteed' alignment
- * of the first memory segment, or perhaps allocate a discontigous
- * framebuffer to get more alignment 'sweet spots'.
- */
-static void
-SetFence(const DRIDriverContext *ctx, I830Rec *pI830,
- int nr, unsigned int start, unsigned int pitch,
- unsigned int size)
-{
- unsigned int val;
- unsigned int fence_mask = 0;
- unsigned int fence_pitch;
-
- if (nr < 0 || nr > 7) {
- fprintf(stderr,
- "SetFence: fence %d out of range\n",nr);
- return;
- }
-
- pI830->Fence[nr] = 0;
-
- if (IS_I9XX(pI830))
- fence_mask = ~I915G_FENCE_START_MASK;
- else
- fence_mask = ~I830_FENCE_START_MASK;
-
- if (start & fence_mask) {
- fprintf(stderr,
- "SetFence: %d: start (0x%08x) is not %s aligned\n",
- nr, start, (IS_I9XX(pI830)) ? "1MB" : "512k");
- return;
- }
-
- if (start % size) {
- fprintf(stderr,
- "SetFence: %d: start (0x%08x) is not size (%dk) aligned\n",
- nr, start, size / 1024);
- return;
- }
-
- if (pitch & 127) {
- fprintf(stderr,
- "SetFence: %d: pitch (%d) not a multiple of 128 bytes\n",
- nr, pitch);
- return;
- }
-
- val = (start | FENCE_X_MAJOR | FENCE_VALID);
-
- if (IS_I9XX(pI830)) {
- switch (size) {
- case MB(1):
- val |= I915G_FENCE_SIZE_1M;
- break;
- case MB(2):
- val |= I915G_FENCE_SIZE_2M;
- break;
- case MB(4):
- val |= I915G_FENCE_SIZE_4M;
- break;
- case MB(8):
- val |= I915G_FENCE_SIZE_8M;
- break;
- case MB(16):
- val |= I915G_FENCE_SIZE_16M;
- break;
- case MB(32):
- val |= I915G_FENCE_SIZE_32M;
- break;
- case MB(64):
- val |= I915G_FENCE_SIZE_64M;
- break;
- default:
- fprintf(stderr,
- "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
- return;
- }
- } else {
- switch (size) {
- case KB(512):
- val |= FENCE_SIZE_512K;
- break;
- case MB(1):
- val |= FENCE_SIZE_1M;
- break;
- case MB(2):
- val |= FENCE_SIZE_2M;
- break;
- case MB(4):
- val |= FENCE_SIZE_4M;
- break;
- case MB(8):
- val |= FENCE_SIZE_8M;
- break;
- case MB(16):
- val |= FENCE_SIZE_16M;
- break;
- case MB(32):
- val |= FENCE_SIZE_32M;
- break;
- case MB(64):
- val |= FENCE_SIZE_64M;
- break;
- default:
- fprintf(stderr,
- "SetFence: %d: illegal size (%d kByte)\n", nr, size / 1024);
- return;
- }
- }
-
- if (IS_I9XX(pI830))
- fence_pitch = pitch / 512;
- else
- fence_pitch = pitch / 128;
-
- switch (fence_pitch) {
- case 1:
- val |= FENCE_PITCH_1;
- break;
- case 2:
- val |= FENCE_PITCH_2;
- break;
- case 4:
- val |= FENCE_PITCH_4;
- break;
- case 8:
- val |= FENCE_PITCH_8;
- break;
- case 16:
- val |= FENCE_PITCH_16;
- break;
- case 32:
- val |= FENCE_PITCH_32;
- break;
- case 64:
- val |= FENCE_PITCH_64;
- break;
- default:
- fprintf(stderr,
- "SetFence: %d: illegal pitch (%d)\n", nr, pitch);
- return;
- }
-
- pI830->Fence[nr] = val;
-}
-
-static Bool
-MakeTiles(const DRIDriverContext *ctx, I830Rec *pI830, I830MemRange *pMem)
-{
- int pitch, ntiles, i;
-
- pitch = pMem->Pitch * ctx->cpp;
- /*
- * Simply try to break the region up into at most four pieces of size
- * equal to the alignment.
- */
- ntiles = ROUND_TO(pMem->Size, pMem->Alignment) / pMem->Alignment;
- if (ntiles >= 4) {
- return FALSE;
- }
-
- for (i = 0; i < ntiles; i++, nextTile++) {
- SetFence(ctx, pI830, nextTile, pMem->Start + i * pMem->Alignment,
- pitch, pMem->Alignment);
- }
- return TRUE;
-}
-
-static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- int i;
-
- /* Clear out */
- for (i = 0; i < 8; i++)
- pI830->Fence[i] = 0;
-
- nextTile = 0;
-
- if (pI830->BackBuffer.Alignment >= KB(512)) {
- if (MakeTiles(ctx, pI830, &(pI830->BackBuffer))) {
- fprintf(stderr,
- "Activating tiled memory for the back buffer.\n");
- } else {
- fprintf(stderr,
- "MakeTiles failed for the back buffer.\n");
- pI830->allowPageFlip = FALSE;
- }
- }
-
- if (pI830->DepthBuffer.Alignment >= KB(512)) {
- if (MakeTiles(ctx, pI830, &(pI830->DepthBuffer))) {
- fprintf(stderr,
- "Activating tiled memory for the depth buffer.\n");
- } else {
- fprintf(stderr,
- "MakeTiles failed for the depth buffer.\n");
- }
- }
-
- return;
-}
-
-static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- struct pci_device host_bridge, ig_dev;
- uint32_t gmch_ctrl;
- int memsize = 0;
- int range;
- uint32_t aper_size;
- uint32_t membase2 = 0;
-
- memset(&host_bridge, 0, sizeof(host_bridge));
- memset(&ig_dev, 0, sizeof(ig_dev));
-
- ig_dev.dev = 2;
-
- pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL);
-
- if (IS_I830(pI830) || IS_845G(pI830)) {
- if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) {
- aper_size = 0x80000000;
- } else {
- aper_size = 0x40000000;
- }
- } else {
- if (IS_I9XX(pI830)) {
- int ret;
- ret = pci_device_cfg_read_u32(&ig_dev, &membase2, 0x18);
- if (membase2 & 0x08000000)
- aper_size = 0x8000000;
- else
- aper_size = 0x10000000;
-
- fprintf(stderr,"aper size is %08X %08x %d\n", aper_size, membase2, ret);
- } else
- aper_size = 0x8000000;
- }
-
- pI830->aper_size = aper_size;
-
-
- /* We need to reduce the stolen size, by the GTT and the popup.
- * The GTT varying according the the FbMapSize and the popup is 4KB */
- range = (ctx->shared.fbSize / (1024*1024)) + 4;
-
- if (IS_I85X(pI830) || IS_I865G(pI830) || IS_I9XX(pI830)) {
- switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
- case I855_GMCH_GMS_STOLEN_1M:
- memsize = MB(1) - KB(range);
- break;
- case I855_GMCH_GMS_STOLEN_4M:
- memsize = MB(4) - KB(range);
- break;
- case I855_GMCH_GMS_STOLEN_8M:
- memsize = MB(8) - KB(range);
- break;
- case I855_GMCH_GMS_STOLEN_16M:
- memsize = MB(16) - KB(range);
- break;
- case I855_GMCH_GMS_STOLEN_32M:
- memsize = MB(32) - KB(range);
- break;
- case I915G_GMCH_GMS_STOLEN_48M:
- if (IS_I9XX(pI830))
- memsize = MB(48) - KB(range);
- break;
- case I915G_GMCH_GMS_STOLEN_64M:
- if (IS_I9XX(pI830))
- memsize = MB(64) - KB(range);
- break;
- }
- } else {
- switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
- case I830_GMCH_GMS_STOLEN_512:
- memsize = KB(512) - KB(range);
- break;
- case I830_GMCH_GMS_STOLEN_1024:
- memsize = MB(1) - KB(range);
- break;
- case I830_GMCH_GMS_STOLEN_8192:
- memsize = MB(8) - KB(range);
- break;
- case I830_GMCH_GMS_LOCAL:
- memsize = 0;
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Local memory found, but won't be used.\n");
- break;
- }
- }
- if (memsize > 0) {
- fprintf(stderr,
- "detected %d kB stolen memory.\n", memsize / 1024);
- } else {
- fprintf(stderr,
- "no video memory detected.\n");
- }
- return memsize;
-}
-
-static int AgpInit(const DRIDriverContext *ctx, I830Rec *info)
-{
- unsigned long mode = 0x4;
-
- if (drmAgpAcquire(ctx->drmFD) < 0) {
- fprintf(stderr, "[gart] AGP not available\n");
- return 0;
- }
-
- if (drmAgpEnable(ctx->drmFD, mode) < 0) {
- fprintf(stderr, "[gart] AGP not enabled\n");
- drmAgpRelease(ctx->drmFD);
- return 0;
- }
- else
- fprintf(stderr, "[gart] AGP enabled at %dx\n", ctx->agpmode);
-
- return 1;
-}
-
-/*
- * Allocate memory from the given pool. Grow the pool if needed and if
- * possible.
- */
-static unsigned long
-AllocFromPool(const DRIDriverContext *ctx, I830Rec *pI830,
- I830MemRange *result, I830MemPool *pool,
- long size, unsigned long alignment, int flags)
-{
- long needed, start, end;
-
- if (!result || !pool || !size)
- return 0;
-
- /* Calculate how much space is needed. */
- if (alignment <= GTT_PAGE_SIZE)
- needed = size;
- else {
- start = ROUND_TO(pool->Free.Start, alignment);
- end = ROUND_TO(start + size, alignment);
- needed = end - pool->Free.Start;
- }
- if (needed > pool->Free.Size) {
- return 0;
- }
-
- result->Start = ROUND_TO(pool->Free.Start, alignment);
- pool->Free.Start += needed;
- result->End = pool->Free.Start;
-
- pool->Free.Size = pool->Free.End - pool->Free.Start;
- result->Size = result->End - result->Start;
- result->Pool = pool;
- result->Alignment = alignment;
- return needed;
-}
-
-static unsigned long AllocFromAGP(const DRIDriverContext *ctx, I830Rec *pI830, long size, unsigned long alignment, I830MemRange *result)
-{
- unsigned long start, end;
- unsigned long newApStart, newApEnd;
- int ret;
- if (!result || !size)
- return 0;
-
- if (!alignment)
- alignment = 4;
-
- start = ROUND_TO(pI830->MemoryAperture.Start, alignment);
- end = ROUND_TO(start + size, alignment);
- newApStart = end;
- newApEnd = pI830->MemoryAperture.End;
-
- ret=drmAgpAlloc(ctx->drmFD, size, 0, &(result->Physical), (drm_handle_t *)&(result->Key));
-
- if (ret)
- {
- fprintf(stderr,"drmAgpAlloc failed %d\n", ret);
- return 0;
- }
- pI830->allocatedMemory += size;
- pI830->MemoryAperture.Start = newApStart;
- pI830->MemoryAperture.End = newApEnd;
- pI830->MemoryAperture.Size = newApEnd - newApStart;
- // pI830->FreeMemory -= size;
- result->Start = start;
- result->End = start + size;
- result->Size = size;
- result->Offset = start;
- result->Alignment = alignment;
- result->Pool = NULL;
-
- return size;
-}
-
-unsigned long
-I830AllocVidMem(const DRIDriverContext *ctx, I830Rec *pI830,
- I830MemRange *result, I830MemPool *pool, long size,
- unsigned long alignment, int flags)
-{
- unsigned long ret;
-
- if (!result)
- return 0;
-
- /* Make sure these are initialised. */
- result->Size = 0;
- result->Key = -1;
-
- if (!size) {
- return 0;
- }
-
- if (pool->Free.Size < size) {
- ret = AllocFromAGP(ctx, pI830, size, alignment, result);
- }
- else {
- ret = AllocFromPool(ctx, pI830, result, pool, size, alignment, flags);
- if (ret == 0)
- ret = AllocFromAGP(ctx, pI830, size, alignment, result);
- }
- return ret;
-}
-
-static Bool BindAgpRange(const DRIDriverContext *ctx, I830MemRange *mem)
-{
- if (!mem)
- return FALSE;
-
- if (mem->Key == -1)
- return TRUE;
-
- return !drmAgpBind(ctx->drmFD, mem->Key, mem->Offset);
-}
-
-/* simple memory allocation routines needed */
-/* put ring buffer in low memory */
-/* need to allocate front, back, depth buffers aligned correctly,
- allocate ring buffer,
-*/
-
-/* */
-static Bool
-I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- unsigned long size, ret;
- unsigned long lines, lineSize, align;
-
- /* allocate ring buffer */
- memset(pI830->LpRing, 0, sizeof(I830RingBuffer));
- pI830->LpRing->mem.Key = -1;
-
- size = PRIMARY_RINGBUFFER_SIZE;
-
- ret = I830AllocVidMem(ctx, pI830, &pI830->LpRing->mem, &pI830->StolenPool, size, 0x1000, 0);
-
- if (ret != size)
- {
- fprintf(stderr,"unable to allocate ring buffer %ld\n", ret);
- return FALSE;
- }
-
- pI830->LpRing->tail_mask = pI830->LpRing->mem.Size - 1;
-
-
- /* allocate front buffer */
- memset(&(pI830->FrontBuffer), 0, sizeof(pI830->FrontBuffer));
- pI830->FrontBuffer.Key = -1;
- pI830->FrontBuffer.Pitch = ctx->shared.virtualWidth;
-
- align = KB(512);
-
- lineSize = ctx->shared.virtualWidth * ctx->cpp;
- lines = (ctx->shared.virtualHeight + 15) / 16 * 16;
- size = lineSize * lines;
- size = ROUND_TO_PAGE(size);
-
- align = GetBestTileAlignment(size);
-
- ret = I830AllocVidMem(ctx, pI830, &pI830->FrontBuffer, &pI830->StolenPool, size, align, 0);
- if (ret < size)
- {
- fprintf(stderr,"unable to allocate front buffer %ld\n", ret);
- return FALSE;
- }
-
- memset(&(pI830->BackBuffer), 0, sizeof(pI830->BackBuffer));
- pI830->BackBuffer.Key = -1;
- pI830->BackBuffer.Pitch = ctx->shared.virtualWidth;
-
- ret = I830AllocVidMem(ctx, pI830, &pI830->BackBuffer, &pI830->StolenPool, size, align, 0);
- if (ret < size)
- {
- fprintf(stderr,"unable to allocate back buffer %ld\n", ret);
- return FALSE;
- }
-
- memset(&(pI830->DepthBuffer), 0, sizeof(pI830->DepthBuffer));
- pI830->DepthBuffer.Key = -1;
- pI830->DepthBuffer.Pitch = ctx->shared.virtualWidth;
-
- ret = I830AllocVidMem(ctx, pI830, &pI830->DepthBuffer, &pI830->StolenPool, size, align, 0);
- if (ret < size)
- {
- fprintf(stderr,"unable to allocate depth buffer %ld\n", ret);
- return FALSE;
- }
-
- memset(&(pI830->ContextMem), 0, sizeof(pI830->ContextMem));
- pI830->ContextMem.Key = -1;
- size = KB(32);
-
- ret = I830AllocVidMem(ctx, pI830, &pI830->ContextMem, &pI830->StolenPool, size, align, 0);
- if (ret < size)
- {
- fprintf(stderr,"unable to allocate context buffer %ld\n", ret);
- return FALSE;
- }
-
-#if 0
- memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem));
- pI830->TexMem.Key = -1;
-
- size = 32768 * 1024;
- ret = AllocFromAGP(ctx, pI830, size, align, &pI830->TexMem);
- if (ret < size)
- {
- fprintf(stderr,"unable to allocate texture memory %ld\n", ret);
- return FALSE;
- }
-#endif
-
- return TRUE;
-}
-
-static Bool
-I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- if (!BindAgpRange(ctx, &pI830->LpRing->mem))
- return FALSE;
- if (!BindAgpRange(ctx, &pI830->FrontBuffer))
- return FALSE;
- if (!BindAgpRange(ctx, &pI830->BackBuffer))
- return FALSE;
- if (!BindAgpRange(ctx, &pI830->DepthBuffer))
- return FALSE;
- if (!BindAgpRange(ctx, &pI830->ContextMem))
- return FALSE;
-#if 0
- if (!BindAgpRange(ctx, &pI830->TexMem))
- return FALSE;
-#endif
- return TRUE;
-}
-
-static void SetupDRIMM(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- unsigned long aperEnd = ROUND_DOWN_TO(pI830->aper_size, GTT_PAGE_SIZE) / GTT_PAGE_SIZE;
- unsigned long aperStart = ROUND_TO(pI830->aper_size - KB(32768), GTT_PAGE_SIZE) / GTT_PAGE_SIZE;
-
- fprintf(stderr, "aper size is %08X\n", ctx->shared.fbSize);
- if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) {
- fprintf(stderr,
- "DRM MM Initialization Failed\n");
- } else {
- fprintf(stderr,
- "DRM MM Initialized at offset 0x%lx length %d page\n", aperStart, aperEnd-aperStart);
- }
-
-}
-
-static Bool
-I830CleanupDma(const DRIDriverContext *ctx)
-{
- drmI830Init info;
-
- memset(&info, 0, sizeof(drmI830Init));
- info.func = I830_CLEANUP_DMA;
-
- if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
- &info, sizeof(drmI830Init))) {
- fprintf(stderr, "I830 Dma Cleanup Failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static Bool
-I830InitDma(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- I830RingBuffer *ring = pI830->LpRing;
- drmI830Init info;
-
- memset(&info, 0, sizeof(drmI830Init));
- info.func = I830_INIT_DMA;
-
- info.ring_start = ring->mem.Start + pI830->LinearAddr;
- info.ring_end = ring->mem.End + pI830->LinearAddr;
- info.ring_size = ring->mem.Size;
-
- info.mmio_offset = (unsigned int)ctx->MMIOStart;
-
- info.sarea_priv_offset = sizeof(drm_sarea_t);
-
- info.front_offset = pI830->FrontBuffer.Start;
- info.back_offset = pI830->BackBuffer.Start;
- info.depth_offset = pI830->DepthBuffer.Start;
- info.w = ctx->shared.virtualWidth;
- info.h = ctx->shared.virtualHeight;
- info.pitch = ctx->shared.virtualWidth;
- info.back_pitch = pI830->BackBuffer.Pitch;
- info.depth_pitch = pI830->DepthBuffer.Pitch;
- info.cpp = ctx->cpp;
-
- if (drmCommandWrite(ctx->drmFD, DRM_I830_INIT,
- &info, sizeof(drmI830Init))) {
- fprintf(stderr,
- "I830 Dma Initialization Failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static int I830CheckDRMVersion( const DRIDriverContext *ctx,
- I830Rec *pI830 )
-{
- drmVersionPtr version;
-
- version = drmGetVersion(ctx->drmFD);
-
- if (version) {
- int req_minor, req_patch;
-
- req_minor = 4;
- req_patch = 0;
-
- if (version->version_major != 1 ||
- version->version_minor < req_minor ||
- (version->version_minor == req_minor &&
- version->version_patchlevel < req_patch)) {
- /* Incompatible drm version */
- fprintf(stderr,
- "[dri] I830DRIScreenInit failed because of a version "
- "mismatch.\n"
- "[dri] i915.o kernel module version is %d.%d.%d "
- "but version 1.%d.%d or newer is needed.\n"
- "[dri] Disabling DRI.\n",
- version->version_major,
- version->version_minor,
- version->version_patchlevel,
- req_minor,
- req_patch);
- drmFreeVersion(version);
- return 0;
- }
-
- pI830->drmMinor = version->version_minor;
- drmFreeVersion(version);
- }
- return 1;
-}
-
-static void
-I830SetRingRegs(const DRIDriverContext *ctx, I830Rec *pI830)
-{
- unsigned int itemp;
- unsigned char *MMIO = ctx->MMIOAddress;
-
- OUTREG(LP_RING + RING_LEN, 0);
- OUTREG(LP_RING + RING_TAIL, 0);
- OUTREG(LP_RING + RING_HEAD, 0);
-
- if ((long)(pI830->LpRing->mem.Start & I830_RING_START_MASK) !=
- pI830->LpRing->mem.Start) {
- fprintf(stderr,
- "I830SetRingRegs: Ring buffer start (%lx) violates its "
- "mask (%x)\n", pI830->LpRing->mem.Start, I830_RING_START_MASK);
- }
- /* Don't care about the old value. Reserved bits must be zero anyway. */
- itemp = pI830->LpRing->mem.Start & I830_RING_START_MASK;
- OUTREG(LP_RING + RING_START, itemp);
-
- if (((pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES) !=
- pI830->LpRing->mem.Size - 4096) {
- fprintf(stderr,
- "I830SetRingRegs: Ring buffer size - 4096 (%lx) violates its "
- "mask (%x)\n", pI830->LpRing->mem.Size - 4096,
- I830_RING_NR_PAGES);
- }
- /* Don't care about the old value. Reserved bits must be zero anyway. */
- itemp = (pI830->LpRing->mem.Size - 4096) & I830_RING_NR_PAGES;
- itemp |= (RING_NO_REPORT | RING_VALID);
- OUTREG(LP_RING + RING_LEN, itemp);
-
- pI830->LpRing->head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;
- pI830->LpRing->tail = INREG(LP_RING + RING_TAIL);
- pI830->LpRing->space = pI830->LpRing->head - (pI830->LpRing->tail + 8);
- if (pI830->LpRing->space < 0)
- pI830->LpRing->space += pI830->LpRing->mem.Size;
-
- SetFenceRegs(ctx, pI830);
-
- /* RESET THE DISPLAY PIPE TO POINT TO THE FRONTBUFFER - hacky
- hacky hacky */
- OUTREG(DSPABASE, pI830->FrontBuffer.Start + pI830->LinearAddr);
-
-}
-
-static Bool
-I830SetParam(const DRIDriverContext *ctx, int param, int value)
-{
- drmI830SetParam sp;
-
- memset(&sp, 0, sizeof(sp));
- sp.param = param;
- sp.value = value;
-
- if (drmCommandWrite(ctx->drmFD, DRM_I830_SETPARAM, &sp, sizeof(sp))) {
- fprintf(stderr, "I830 SetParam Failed\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-static Bool
-I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
- fprintf(stderr,
- "[drm] Mapping front buffer\n");
-
- if (drmAddMap(ctx->drmFD,
- (drm_handle_t)(sarea->front_offset + pI830->LinearAddr),
- sarea->front_size,
- DRM_FRAME_BUFFER, /*DRM_AGP,*/
- 0,
- &sarea->front_handle) < 0) {
- fprintf(stderr,
- "[drm] drmAddMap(front_handle) failed. Disabling DRI\n");
- return FALSE;
- }
- ctx->shared.hFrameBuffer = sarea->front_handle;
- ctx->shared.fbSize = sarea->front_size;
- fprintf(stderr, "[drm] Front Buffer = 0x%08x\n",
- sarea->front_handle);
-
- if (drmAddMap(ctx->drmFD,
- (drm_handle_t)(sarea->back_offset),
- sarea->back_size, DRM_AGP, 0,
- &sarea->back_handle) < 0) {
- fprintf(stderr,
- "[drm] drmAddMap(back_handle) failed. Disabling DRI\n");
- return FALSE;
- }
- fprintf(stderr, "[drm] Back Buffer = 0x%08x\n",
- sarea->back_handle);
-
- if (drmAddMap(ctx->drmFD,
- (drm_handle_t)sarea->depth_offset,
- sarea->depth_size, DRM_AGP, 0,
- &sarea->depth_handle) < 0) {
- fprintf(stderr,
- "[drm] drmAddMap(depth_handle) failed. Disabling DRI\n");
- return FALSE;
- }
- fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n",
- sarea->depth_handle);
-
-#if 0
- if (drmAddMap(ctx->drmFD,
- (drm_handle_t)sarea->tex_offset,
- sarea->tex_size, DRM_AGP, 0,
- &sarea->tex_handle) < 0) {
- fprintf(stderr,
- "[drm] drmAddMap(tex_handle) failed. Disabling DRI\n");
- return FALSE;
- }
- fprintf(stderr, "[drm] textures = 0x%08x\n",
- sarea->tex_handle);
-#endif
- return TRUE;
-}
-
-
-static void
-I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
-#if 1
- if (sarea->front_handle) {
- drmRmMap(ctx->drmFD, sarea->front_handle);
- sarea->front_handle = 0;
- }
-#endif
- if (sarea->back_handle) {
- drmRmMap(ctx->drmFD, sarea->back_handle);
- sarea->back_handle = 0;
- }
- if (sarea->depth_handle) {
- drmRmMap(ctx->drmFD, sarea->depth_handle);
- sarea->depth_handle = 0;
- }
- if (sarea->tex_handle) {
- drmRmMap(ctx->drmFD, sarea->tex_handle);
- sarea->tex_handle = 0;
- }
-}
-
-static Bool
-I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
- if (drmAddMap(ctx->drmFD,
- (drm_handle_t)pI830->LpRing->mem.Start,
- pI830->LpRing->mem.Size, DRM_AGP, 0,
- &pI830->ring_map) < 0) {
- fprintf(stderr,
- "[drm] drmAddMap(ring_map) failed. Disabling DRI\n");
- return FALSE;
- }
- fprintf(stderr, "[drm] ring buffer = 0x%08x\n",
- pI830->ring_map);
-
- if (I830InitDma(ctx, pI830) == FALSE) {
- return FALSE;
- }
-
- /* init to zero to be safe */
-
- I830DRIMapScreenRegions(ctx, pI830, sarea);
- SetupDRIMM(ctx, pI830);
-
- if (ctx->pciDevice != PCI_CHIP_845_G &&
- ctx->pciDevice != PCI_CHIP_I830_M) {
- I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 );
- }
-
- /* Okay now initialize the dma engine */
- {
- pI830->irq = drmGetInterruptFromBusID(ctx->drmFD,
- ctx->pciBus,
- ctx->pciDevice,
- ctx->pciFunc);
-
- if (drmCtlInstHandler(ctx->drmFD, pI830->irq)) {
- fprintf(stderr,
- "[drm] failure adding irq handler\n");
- pI830->irq = 0;
- return FALSE;
- }
- else
- fprintf(stderr,
- "[drm] dma control initialized, using IRQ %d\n",
- pI830->irq);
- }
-
- fprintf(stderr, "[dri] visual configs initialized\n");
-
- return TRUE;
-}
-
-static Bool
-I830ClearScreen(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea)
-{
- /* need to drmMap front and back buffers and zero them */
- drmAddress map_addr;
- int ret;
-
- ret = drmMap(ctx->drmFD,
- sarea->front_handle,
- sarea->front_size,
- &map_addr);
-
- if (ret)
- {
- fprintf(stderr, "Unable to map front buffer\n");
- return FALSE;
- }
-
- drimemsetio((char *)map_addr,
- 0,
- sarea->front_size);
- drmUnmap(map_addr, sarea->front_size);
-
-
- ret = drmMap(ctx->drmFD,
- sarea->back_handle,
- sarea->back_size,
- &map_addr);
-
- if (ret)
- {
- fprintf(stderr, "Unable to map back buffer\n");
- return FALSE;
- }
-
- drimemsetio((char *)map_addr,
- 0,
- sarea->back_size);
- drmUnmap(map_addr, sarea->back_size);
-
- return TRUE;
-}
-
-static Bool
-I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830)
-
-{
- I830DRIPtr pI830DRI;
- drmI830Sarea *pSAREAPriv;
- int err;
-
- drm_page_size = getpagesize();
-
- pI830->registerSize = ctx->MMIOSize;
- /* This is a hack for now. We have to have more than a 4k page here
- * because of the size of the state. However, the state should be
- * in a per-context mapping. This will be added in the Mesa 3.5 port
- * of the I830 driver.
- */
- ctx->shared.SAREASize = SAREA_MAX;
-
- /* Note that drmOpen will try to load the kernel module, if needed. */
- ctx->drmFD = drmOpen("i915", NULL );
- if (ctx->drmFD < 0) {
- fprintf(stderr, "[drm] drmOpen failed\n");
- return 0;
- }
-
- if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
- fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
- ctx->drmFD, ctx->pciBusID, strerror(-err));
- return 0;
- }
-
- if (drmAddMap( ctx->drmFD,
- 0,
- ctx->shared.SAREASize,
- DRM_SHM,
- DRM_CONTAINS_LOCK,
- &ctx->shared.hSAREA) < 0)
- {
- fprintf(stderr, "[drm] drmAddMap failed\n");
- return 0;
- }
-
- fprintf(stderr, "[drm] added %d byte SAREA at 0x%08x\n",
- ctx->shared.SAREASize, ctx->shared.hSAREA);
-
- if (drmMap( ctx->drmFD,
- ctx->shared.hSAREA,
- ctx->shared.SAREASize,
- (drmAddressPtr)(&ctx->pSAREA)) < 0)
- {
- fprintf(stderr, "[drm] drmMap failed\n");
- return 0;
-
- }
-
- memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
- fprintf(stderr, "[drm] mapped SAREA 0x%08x to %p, size %d\n",
- ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
-
-
- if (drmAddMap(ctx->drmFD,
- ctx->MMIOStart,
- ctx->MMIOSize,
- DRM_REGISTERS,
- DRM_READ_ONLY,
- &pI830->registerHandle) < 0) {
- fprintf(stderr, "[drm] drmAddMap mmio failed\n");
- return 0;
- }
- fprintf(stderr,
- "[drm] register handle = 0x%08x\n", pI830->registerHandle);
-
-
- if (!I830CheckDRMVersion(ctx, pI830)) {
- return FALSE;
- }
-
- /* Create a 'server' context so we can grab the lock for
- * initialization ioctls.
- */
- if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
- fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
- return 0;
- }
-
- DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
-
- /* Initialize the SAREA private data structure */
- pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) +
- sizeof(drm_sarea_t));
- memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
-
- pI830->StolenMemory.Size = I830DetectMemory(ctx, pI830);
- pI830->StolenMemory.Start = 0;
- pI830->StolenMemory.End = pI830->StolenMemory.Size;
-
- pI830->MemoryAperture.Start = pI830->StolenMemory.End;
- pI830->MemoryAperture.End = KB(40000);
- pI830->MemoryAperture.Size = pI830->MemoryAperture.End - pI830->MemoryAperture.Start;
-
- pI830->StolenPool.Fixed = pI830->StolenMemory;
- pI830->StolenPool.Total = pI830->StolenMemory;
- pI830->StolenPool.Free = pI830->StolenPool.Total;
- pI830->FreeMemory = pI830->StolenPool.Total.Size;
-
- if (!AgpInit(ctx, pI830))
- return FALSE;
-
- if (I830AllocateMemory(ctx, pI830) == FALSE)
- {
- return FALSE;
- }
-
- if (I830BindMemory(ctx, pI830) == FALSE)
- {
- return FALSE;
- }
-
- pSAREAPriv->rotated_offset = -1;
- pSAREAPriv->rotated_size = 0;
- pSAREAPriv->rotated_pitch = ctx->shared.virtualWidth;
-
- pSAREAPriv->front_offset = pI830->FrontBuffer.Start;
- pSAREAPriv->front_size = pI830->FrontBuffer.Size;
- pSAREAPriv->width = ctx->shared.virtualWidth;
- pSAREAPriv->height = ctx->shared.virtualHeight;
- pSAREAPriv->pitch = ctx->shared.virtualWidth;
- pSAREAPriv->virtualX = ctx->shared.virtualWidth;
- pSAREAPriv->virtualY = ctx->shared.virtualHeight;
- pSAREAPriv->back_offset = pI830->BackBuffer.Start;
- pSAREAPriv->back_size = pI830->BackBuffer.Size;
- pSAREAPriv->depth_offset = pI830->DepthBuffer.Start;
- pSAREAPriv->depth_size = pI830->DepthBuffer.Size;
-#if 0
- pSAREAPriv->tex_offset = pI830->TexMem.Start;
- pSAREAPriv->tex_size = pI830->TexMem.Size;
-#endif
- pSAREAPriv->log_tex_granularity = pI830->TexGranularity;
-
- ctx->driverClientMsg = malloc(sizeof(I830DRIRec));
- ctx->driverClientMsgSize = sizeof(I830DRIRec);
- pI830DRI = (I830DRIPtr)ctx->driverClientMsg;
- pI830DRI->deviceID = pI830->Chipset;
- pI830DRI->regsSize = I830_REG_SIZE;
- pI830DRI->width = ctx->shared.virtualWidth;
- pI830DRI->height = ctx->shared.virtualHeight;
- pI830DRI->mem = ctx->shared.fbSize;
- pI830DRI->cpp = ctx->cpp;
-
- pI830DRI->bitsPerPixel = ctx->bpp;
- pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t);
-
- err = I830DRIDoMappings(ctx, pI830, pSAREAPriv);
- if (err == FALSE)
- return FALSE;
-
- I830SetupMemoryTiling(ctx, pI830);
-
- /* Quick hack to clear the front & back buffers. Could also use
- * the clear ioctl to do this, but would need to setup hw state
- * first.
- */
- I830ClearScreen(ctx, pI830, pSAREAPriv);
-
- I830SetRingRegs(ctx, pI830);
-
- return TRUE;
-}
-
-
-/**
- * \brief Validate the fbdev mode.
- *
- * \param ctx display handle.
- *
- * \return one on success, or zero on failure.
- *
- * Saves some registers and returns 1.
- *
- * \sa radeonValidateMode().
- */
-static int i830ValidateMode( const DRIDriverContext *ctx )
-{
- return 1;
-}
-
-/**
- * \brief Examine mode returned by fbdev.
- *
- * \param ctx display handle.
- *
- * \return one on success, or zero on failure.
- *
- * Restores registers that fbdev has clobbered and returns 1.
- *
- * \sa i810ValidateMode().
- */
-static int i830PostValidateMode( const DRIDriverContext *ctx )
-{
- I830Rec *pI830 = ctx->driverPrivate;
-
- I830SetRingRegs(ctx, pI830);
- return 1;
-}
-
-
-/**
- * \brief Initialize the framebuffer device mode
- *
- * \param ctx display handle.
- *
- * \return one on success, or zero on failure.
- *
- * Fills in \p info with some default values and some information from \p ctx
- * and then calls I810ScreenInit() for the screen initialization.
- *
- * Before exiting clears the framebuffer memory accessing it directly.
- */
-static int i830InitFBDev( DRIDriverContext *ctx )
-{
- I830Rec *pI830 = calloc(1, sizeof(I830Rec));
- int i;
-
- {
- int dummy = ctx->shared.virtualWidth;
-
- switch (ctx->bpp / 8) {
- case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
- case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
- case 3:
- case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
- }
-
- ctx->shared.virtualWidth = dummy;
- ctx->shared.Width = ctx->shared.virtualWidth;
- }
-
-
- for (i = 0; pitches[i] != 0; i++) {
- if (pitches[i] >= ctx->shared.virtualWidth) {
- ctx->shared.virtualWidth = pitches[i];
- break;
- }
- }
-
- ctx->driverPrivate = (void *)pI830;
-
- pI830->LpRing = calloc(1, sizeof(I830RingBuffer));
- pI830->Chipset = ctx->chipset;
- pI830->LinearAddr = ctx->FBStart;
-
- if (!I830ScreenInit( ctx, pI830 ))
- return 0;
-
-
- return 1;
-}
-
-
-/**
- * \brief The screen is being closed, so clean up any state and free any
- * resources used by the DRI.
- *
- * \param ctx display handle.
- *
- * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
- * private data.
- */
-static void i830HaltFBDev( DRIDriverContext *ctx )
-{
- drmI830Sarea *pSAREAPriv;
- I830Rec *pI830 = ctx->driverPrivate;
-
- if (pI830->irq) {
- drmCtlUninstHandler(ctx->drmFD);
- pI830->irq = 0; }
-
- I830CleanupDma(ctx);
-
- pSAREAPriv = (drmI830Sarea *)(((char*)ctx->pSAREA) +
- sizeof(drm_sarea_t));
-
- I830DRIUnmapScreenRegions(ctx, pI830, pSAREAPriv);
- drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
- drmClose(ctx->drmFD);
-
- if (ctx->driverPrivate) {
- free(ctx->driverPrivate);
- ctx->driverPrivate = 0;
- }
-}
-
-
-extern void i810NotifyFocus( int );
-
-/**
- * \brief Exported driver interface for Mini GLX.
- *
- * \sa DRIDriverRec.
- */
-const struct DRIDriverRec __driDriver = {
- i830ValidateMode,
- i830PostValidateMode,
- i830InitFBDev,
- i830HaltFBDev,
- NULL,//I830EngineShutdown,
- NULL, //I830EngineRestore,
-#ifndef _EMBEDDED
- 0,
-#else
- i810NotifyFocus,
-#endif
-};
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c
index 08c98eab48..18b033666f 100644
--- a/src/mesa/drivers/x11/xm_api.c
+++ b/src/mesa/drivers/x11/xm_api.c
@@ -85,7 +85,7 @@
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
-#include "pipe/softpipe/sp_context.h"
+#include "softpipe/sp_context.h"
#include "pipe/p_defines.h"
/**
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index 8ae243ae66..34287effe1 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -53,7 +53,7 @@
#include "tnl/tnl.h"
#include "tnl/t_context.h"
-#include "pipe/softpipe/sp_context.h"
+#include "softpipe/sp_context.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_draw.h"
diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c
index 5533158ece..81616b92d9 100644
--- a/src/mesa/drivers/x11/xm_surface.c
+++ b/src/mesa/drivers/x11/xm_surface.c
@@ -45,10 +45,10 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/softpipe/sp_context.h"
-#include "pipe/softpipe/sp_clear.h"
-#include "pipe/softpipe/sp_tile_cache.h"
-#include "pipe/softpipe/sp_surface.h"
+#include "softpipe/sp_context.h"
+#include "softpipe/sp_clear.h"
+#include "softpipe/sp_tile_cache.h"
+#include "softpipe/sp_surface.h"
#include "state_tracker/st_context.h"
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index a690df2772..2edc697693 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -38,7 +38,7 @@
#include "main/macros.h"
#include "pipe/p_winsys.h"
-#include "pipe/softpipe/sp_winsys.h"
+#include "softpipe/sp_winsys.h"
/**
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 4709d63394..fd2dfcd79a 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -37,8 +37,8 @@
#include "xm_image.h"
#endif
#include "state_tracker/st_cb_fbo.h"
-#include "pipe/softpipe/sp_context.h"
-#include "pipe/softpipe/sp_surface.h"
+#include "softpipe/sp_context.h"
+#include "softpipe/sp_surface.h"
extern _glthread_Mutex _xmesa_lock;
diff --git a/src/mesa/pipe/Makefile b/src/mesa/pipe/Makefile
deleted file mode 100644
index d880d090c1..0000000000
--- a/src/mesa/pipe/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-TOP = ../../..
-include $(TOP)/configs/current
-
-
-ifeq ($(CONFIG_NAME), linux-cell)
-CELL_DIR = cell
-endif
-
-ifeq ($(CONFIG_NAME), linux-llvm)
-LLVM_DIR = llvm
-endif
-
-SUBDIRS = softpipe i915simple i965simple failover pipebuffer $(CELL_DIR) $(LLVM_DIR)
-
-
-default: subdirs
-
-
-subdirs:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
- fi \
- done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
diff --git a/src/mesa/pipe/Makefile.template b/src/mesa/pipe/Makefile.template
deleted file mode 100644
index 8e84f8eb2d..0000000000
--- a/src/mesa/pipe/Makefile.template
+++ /dev/null
@@ -1,63 +0,0 @@
-# -*-makefile-*-
-
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
-#
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/mesa/pipe \
- -I$(TOP)/src/mesa \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template
- $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/mesa/pipe/README.portability b/src/mesa/pipe/README.portability
deleted file mode 100644
index c70ca774da..0000000000
--- a/src/mesa/pipe/README.portability
+++ /dev/null
@@ -1,43 +0,0 @@
- CROSS-PLATFORM PORTABILITY GUIDELINES FOR GALLIUM3D
-
-
-= General Considerations =
-
-The state tracker and winsys driver support a rather limited number of
-platforms. However, the pipe drivers are meant to run in a wide number of
-platforms. Hence the pipe drivers, the auxiliary modules, and all public
-headers in general, should stricly follow these guidelines to ensure
-
-
-= Compiler Support =
-
-* Include the p_compiler.h.
-
-* Don't use the 'inline' keyword, use the INLINE macro in p_compiler.h instead.
-
-* Cast explicitly when converting to integer types of smaller sizes.
-
-* Cast explicitly when converting between float, double and integral types.
-
-* Don't use named struct initializers.
-
-* Don't use variable number of macro arguments. Use static inline functions
-instead.
-
-
-= Standard Library =
-
-* Avoid including standard library headers. Most standard library functions are
-not available in Windows Kernel Mode. Use the appropriate p_*.h include.
-
-== Memory Allocation ==
-
-* 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.
-
-== Debugging ==
-
-TODO
-
diff --git a/src/mesa/pipe/SConscript b/src/mesa/pipe/SConscript
deleted file mode 100644
index d9c20e0100..0000000000
--- a/src/mesa/pipe/SConscript
+++ /dev/null
@@ -1,9 +0,0 @@
-Import('*')
-
-#env = env.Clone()
-
-SConscript([
- 'softpipe/SConscript',
- 'i915simple/SConscript',
- 'i965simple/SConscript',
-])
diff --git a/src/mesa/pipe/cell/Makefile b/src/mesa/pipe/cell/Makefile
deleted file mode 100644
index 47aef7b05f..0000000000
--- a/src/mesa/pipe/cell/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Cell Gallium driver Makefile
-
-
-default:
- ( cd spu ; make )
- ( cd ppu ; make )
-
-
-
-clean:
- ( cd spu ; make clean )
- ( cd ppu ; make clean )
diff --git a/src/mesa/pipe/cell/common.h b/src/mesa/pipe/cell/common.h
deleted file mode 100644
index 4de514c358..0000000000
--- a/src/mesa/pipe/cell/common.h
+++ /dev/null
@@ -1,220 +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.
- *
- **************************************************************************/
-
-/**
- * Types and tokens which are common to the SPU and PPU code.
- */
-
-
-#ifndef CELL_COMMON_H
-#define CELL_COMMON_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
-#include "pipe/p_format.h"
-
-
-/** The standard assert macro doesn't seem to work reliably */
-#define ASSERT(x) \
- if (!(x)) { \
- ubyte *p = NULL; \
- fprintf(stderr, "%s:%d: %s(): assertion %s failed.\n", \
- __FILE__, __LINE__, __FUNCTION__, #x); \
- *p = 0; \
- exit(1); \
- }
-
-
-/** for sanity checking */
-#define ASSERT_ALIGN16(ptr) \
- ASSERT((((unsigned long) (ptr)) & 0xf) == 0);
-
-
-/** round up value to next multiple of 4 */
-#define ROUNDUP4(k) (((k) + 0x3) & ~0x3)
-
-/** round up value to next multiple of 8 */
-#define ROUNDUP8(k) (((k) + 0x7) & ~0x7)
-
-/** round up value to next multiple of 16 */
-#define ROUNDUP16(k) (((k) + 0xf) & ~0xf)
-
-
-#define CELL_MAX_SPUS 6
-
-#define TILE_SIZE 32
-
-
-/**
- * The low byte of a mailbox word contains the command opcode.
- * Remaining higher bytes are command specific.
- */
-#define CELL_CMD_OPCODE_MASK 0xff
-
-#define CELL_CMD_EXIT 1
-#define CELL_CMD_CLEAR_SURFACE 2
-#define CELL_CMD_FINISH 3
-#define CELL_CMD_RENDER 4
-#define CELL_CMD_BATCH 5
-#define CELL_CMD_RELEASE_VERTS 6
-#define CELL_CMD_STATE_FRAMEBUFFER 10
-#define CELL_CMD_STATE_DEPTH_STENCIL 11
-#define CELL_CMD_STATE_SAMPLER 12
-#define CELL_CMD_STATE_TEXTURE 13
-#define CELL_CMD_STATE_VERTEX_INFO 14
-#define CELL_CMD_STATE_VIEWPORT 15
-#define CELL_CMD_STATE_VS_ARRAY_INFO 16
-#define CELL_CMD_STATE_BLEND 17
-#define CELL_CMD_VS_EXECUTE 18
-
-
-#define CELL_NUM_BUFFERS 4
-#define CELL_BUFFER_SIZE (4*1024) /**< 16KB would be the max */
-
-#define CELL_BUFFER_STATUS_FREE 10
-#define CELL_BUFFER_STATUS_USED 20
-
-
-
-/**
- * Tell SPUs about the framebuffer size, location
- */
-struct cell_command_framebuffer
-{
- uint64_t opcode; /**< CELL_CMD_FRAMEBUFFER */
- int width, height;
- void *color_start, *depth_start;
- enum pipe_format color_format, depth_format;
-};
-
-
-/**
- * Clear framebuffer to the given value/color.
- */
-struct cell_command_clear_surface
-{
- uint64_t opcode; /**< CELL_CMD_CLEAR_SURFACE */
- uint surface; /**< Temporary: 0=color, 1=Z */
- uint value;
-};
-
-
-/**
- * Array info used by the vertex shader's vertex puller.
- */
-struct cell_array_info
-{
- uint64_t base; /**< Base address of the 0th element. */
- uint attr; /**< Attribute that this state is for. */
- uint pitch; /**< Byte pitch from one entry to the next. */
- uint format; /**< Pipe format of each entry. */
-} ALIGN16_ATTRIB;
-
-
-struct cell_shader_info
-{
- unsigned num_outputs;
-
- uint64_t declarations;
- unsigned num_declarations;
- uint64_t instructions;
- unsigned num_instructions;
- uint64_t uniforms;
- uint64_t immediates;
- unsigned num_immediates;
-} ALIGN16_ATTRIB;
-
-
-#define SPU_VERTS_PER_BATCH 64
-struct cell_command_vs
-{
- uint64_t opcode; /**< CELL_CMD_VS_EXECUTE */
- struct cell_shader_info shader;
- unsigned num_elts;
- unsigned elts[SPU_VERTS_PER_BATCH];
- uint64_t vOut[SPU_VERTS_PER_BATCH];
- float plane[12][4];
- unsigned nr_planes;
- unsigned nr_attrs;
-} ALIGN16_ATTRIB;
-
-
-struct cell_command_render
-{
- uint64_t opcode; /**< CELL_CMD_RENDER */
- uint prim_type; /**< PIPE_PRIM_x */
- uint num_verts;
- uint vertex_size; /**< bytes per vertex */
- uint num_indexes;
- uint vertex_buf; /**< which cell->buffer[] contains the vertex data */
- float xmin, ymin, xmax, ymax; /* XXX another dummy field */
- uint min_index;
- boolean inline_verts;
-};
-
-
-struct cell_command_release_verts
-{
- uint64_t opcode; /**< CELL_CMD_RELEASE_VERTS */
- uint vertex_buf; /**< in [0, CELL_NUM_BUFFERS-1] */
-};
-
-
-struct cell_command_texture
-{
- void *start; /**< Address in main memory */
- uint width, height;
-};
-
-
-/** XXX unions don't seem to work */
-/* XXX this should go away; all commands should be placed in batch buffers */
-struct cell_command
-{
-#if 0
- struct cell_command_framebuffer fb;
- struct cell_command_clear_surface clear;
- struct cell_command_render render;
-#endif
- struct cell_command_vs vs;
-} ALIGN16_ATTRIB;
-
-
-/** This is the object passed to spe_create_thread() */
-struct cell_init_info
-{
- unsigned id;
- unsigned num_spus;
- struct cell_command *cmd;
-
- /** Buffers for command batches, vertex/index data */
- ubyte *buffers[CELL_NUM_BUFFERS];
- uint *buffer_status; /**< points at cell_context->buffer_status */
-} ALIGN16_ATTRIB;
-
-
-#endif /* CELL_COMMON_H */
diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile
deleted file mode 100644
index 50060f5cd3..0000000000
--- a/src/mesa/pipe/cell/ppu/Makefile
+++ /dev/null
@@ -1,76 +0,0 @@
-# Gallium3D Cell driver: PPU code
-
-# This makefile builds the g3dcell.a library which gets pulled into
-# the main libGL.so library
-
-
-TOP = ../../../../..
-include $(TOP)/configs/linux-cell
-
-
-#PROG = gl4
-
-CELL_LIB = libcell.a
-
-SPU_CODE_MODULE = ../spu/g3d_spu.a
-
-
-SOURCES = \
- cell_batch.c \
- cell_clear.c \
- cell_context.c \
- cell_draw_arrays.c \
- cell_flush.c \
- cell_state_blend.c \
- cell_state_clip.c \
- cell_state_derived.c \
- cell_state_emit.c \
- cell_state_fs.c \
- cell_state_rasterizer.c \
- cell_state_sampler.c \
- cell_state_surface.c \
- cell_state_vertex.c \
- cell_spu.c \
- cell_surface.c \
- cell_texture.c \
- cell_vbuf.c \
- cell_vertex_shader.c \
- cell_winsys.c
-
-
-OBJECTS = $(SOURCES:.c=.o) \
-
-INCLUDE_DIRS = -I$(TOP)/src/mesa
-
-
-.c.o:
- $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
-
-
-
-default: $(CELL_LIB)
-
-
-$(CELL_LIB): $(OBJECTS) $(SPU_CODE_MODULE)
-# ar -ru $(CELL_LIB) $(OBJECTS) $(SPU_CODE_MODULE)
- ar -ru $(CELL_LIB) $(OBJECTS)
-
-#$(PROG): $(PPU_OBJECTS)
-# $(CC) -o $(PROG) $(PPU_OBJECTS) $(SPU_CODE_MODULE) $(PPU_LFLAGS)
-
-
-
-clean:
- rm -f *.o *~ $(CELL_LIB)
-
-
-
-depend: $(SOURCES)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDE_DIRS) $(SOURCES) 2> /dev/null
-
-include depend
-
-
-
diff --git a/src/mesa/pipe/cell/ppu/cell_batch.c b/src/mesa/pipe/cell/ppu/cell_batch.c
deleted file mode 100644
index f45e5f25b6..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_batch.c
+++ /dev/null
@@ -1,217 +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.
- *
- **************************************************************************/
-
-
-#include "cell_context.h"
-#include "cell_batch.h"
-#include "cell_spu.h"
-
-
-
-uint
-cell_get_empty_buffer(struct cell_context *cell)
-{
- uint buf = 0, tries = 0;
-
- /* Find a buffer that's marked as free by all SPUs */
- while (1) {
- uint spu, num_free = 0;
-
- for (spu = 0; spu < cell->num_spus; spu++) {
- if (cell->buffer_status[spu][buf][0] == CELL_BUFFER_STATUS_FREE) {
- num_free++;
-
- if (num_free == cell->num_spus) {
- /* found a free buffer, now mark status as used */
- for (spu = 0; spu < cell->num_spus; spu++) {
- cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
- }
- /*
- printf("PPU: ALLOC BUFFER %u\n", buf);
- */
- return buf;
- }
- }
- else {
- break;
- }
- }
-
- /* try next buf */
- buf = (buf + 1) % CELL_NUM_BUFFERS;
-
- tries++;
- if (tries == 100) {
- /*
- printf("PPU WAITING for buffer...\n");
- */
- }
- }
-}
-
-
-void
-cell_batch_flush(struct cell_context *cell)
-{
- static boolean flushing = FALSE;
- uint batch = cell->cur_batch;
- const uint size = cell->buffer_size[batch];
- uint spu, cmd_word;
-
- assert(!flushing);
-
- if (size == 0)
- return;
-
- flushing = TRUE;
-
- assert(batch < CELL_NUM_BUFFERS);
-
- /*
- printf("cell_batch_dispatch: buf %u at %p, size %u\n",
- batch, &cell->batch_buffer[batch][0], size);
- */
-
- /*
- * Build "BATCH" command and sent to all SPUs.
- */
- cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16);
-
- for (spu = 0; spu < cell->num_spus; spu++) {
- assert(cell->buffer_status[spu][batch][0] == CELL_BUFFER_STATUS_USED);
- send_mbox_message(cell_global.spe_contexts[spu], cmd_word);
- }
-
- /* When the SPUs are done copying the buffer into their locals stores
- * they'll write a BUFFER_STATUS_FREE message into the buffer_status[]
- * array indicating that the PPU can re-use the buffer.
- */
-
- batch = cell_get_empty_buffer(cell);
-
- cell->buffer_size[batch] = 0; /* empty */
- cell->cur_batch = batch;
-
- flushing = FALSE;
-}
-
-
-uint
-cell_batch_free_space(const struct cell_context *cell)
-{
- uint free = CELL_BUFFER_SIZE - cell->buffer_size[cell->cur_batch];
- return free;
-}
-
-
-/**
- * Append data to current batch.
- */
-void
-cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
-{
- uint size;
-
- ASSERT(bytes % 8 == 0);
- ASSERT(bytes <= CELL_BUFFER_SIZE);
- ASSERT(cell->cur_batch >= 0);
-
-#ifdef ASSERT
- {
- uint spu;
- for (spu = 0; spu < cell->num_spus; spu++) {
- ASSERT(cell->buffer_status[spu][cell->cur_batch][0]
- == CELL_BUFFER_STATUS_USED);
- }
- }
-#endif
-
- size = cell->buffer_size[cell->cur_batch];
-
- if (size + bytes > CELL_BUFFER_SIZE) {
- cell_batch_flush(cell);
- size = 0;
- }
-
- ASSERT(size + bytes <= CELL_BUFFER_SIZE);
-
- memcpy(cell->buffer[cell->cur_batch] + size, data, bytes);
-
- cell->buffer_size[cell->cur_batch] = size + bytes;
-}
-
-
-void *
-cell_batch_alloc(struct cell_context *cell, uint bytes)
-{
- return cell_batch_alloc_aligned(cell, bytes, 1);
-}
-
-
-void *
-cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
- uint alignment)
-{
- void *pos;
- uint size, padbytes;
-
- ASSERT(bytes % 8 == 0);
- ASSERT(bytes <= CELL_BUFFER_SIZE);
- ASSERT(alignment > 0);
- ASSERT(cell->cur_batch >= 0);
-
-#ifdef ASSERT
- {
- uint spu;
- for (spu = 0; spu < cell->num_spus; spu++) {
- ASSERT(cell->buffer_status[spu][cell->cur_batch][0]
- == CELL_BUFFER_STATUS_USED);
- }
- }
-#endif
-
- size = cell->buffer_size[cell->cur_batch];
-
- padbytes = (alignment - (size % alignment)) % alignment;
-
- if (padbytes + size + bytes > CELL_BUFFER_SIZE) {
- cell_batch_flush(cell);
- size = 0;
- }
- else {
- size += padbytes;
- }
-
- ASSERT(size % alignment == 0);
- ASSERT(size + bytes <= CELL_BUFFER_SIZE);
-
- pos = (void *) (cell->buffer[cell->cur_batch] + size);
-
- cell->buffer_size[cell->cur_batch] = size + bytes;
-
- return pos;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_batch.h b/src/mesa/pipe/cell/ppu/cell_batch.h
deleted file mode 100644
index a6eee0a8b1..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_batch.h
+++ /dev/null
@@ -1,58 +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 CELL_BATCH_H
-#define CELL_BATCH_H
-
-#include "pipe/p_compiler.h"
-
-
-struct cell_context;
-
-
-extern uint
-cell_get_empty_buffer(struct cell_context *cell);
-
-extern void
-cell_batch_flush(struct cell_context *cell);
-
-extern uint
-cell_batch_free_space(const struct cell_context *cell);
-
-extern void
-cell_batch_append(struct cell_context *cell, const void *data, uint bytes);
-
-extern void *
-cell_batch_alloc(struct cell_context *cell, uint bytes);
-
-extern void *
-cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
- uint alignment);
-
-
-#endif /* CELL_BATCH_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_clear.c b/src/mesa/pipe/cell/ppu/cell_clear.c
deleted file mode 100644
index 07b908eec5..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_clear.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Authors
- * Brian Paul
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdint.h>
-#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
-#include "pipe/cell/common.h"
-#include "cell_clear.h"
-#include "cell_context.h"
-#include "cell_batch.h"
-#include "cell_flush.h"
-#include "cell_spu.h"
-
-
-void
-cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- struct cell_context *cell = cell_context(pipe);
- uint surfIndex;
-
- if (cell->dirty)
- cell_update_derived(cell);
-
-
- if (!cell->cbuf_map[0])
- cell->cbuf_map[0] = pipe_surface_map(ps);
-
- if (ps == cell->framebuffer.zsbuf) {
- surfIndex = 1;
- }
- else {
- surfIndex = 0;
- }
-
-
- {
- struct cell_command_clear_surface *clr
- = (struct cell_command_clear_surface *)
- cell_batch_alloc(cell, sizeof(*clr));
- clr->opcode = CELL_CMD_CLEAR_SURFACE;
- clr->surface = surfIndex;
- clr->value = clearValue;
- }
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_clear.h b/src/mesa/pipe/cell/ppu/cell_clear.h
deleted file mode 100644
index ff47d43f4c..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_clear.h
+++ /dev/null
@@ -1,43 +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 CELL_CLEAR_H
-#define CELL_CLEAR_H
-
-
-struct pipe_context;
-struct pipe_surface;
-
-
-extern void
-cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
-
-
-
-#endif /* CELL_CLEAR_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c
deleted file mode 100644
index bbe1fd7a11..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_context.c
+++ /dev/null
@@ -1,287 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Authors
- * Brian Paul
- */
-
-
-#include <stdio.h>
-
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-#include "pipe/p_util.h"
-#include "pipe/p_winsys.h"
-#include "pipe/cell/common.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.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"
-#include "cell_texture.h"
-#include "cell_vbuf.h"
-
-
-
-static boolean
-cell_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- /*struct cell_context *cell = cell_context( pipe );*/
-
- switch (type) {
- case PIPE_TEXTURE:
- /* cell supports all texture formats, XXX for now anyway */
- return TRUE;
- case PIPE_SURFACE:
- /* cell supports all (off-screen) surface formats, XXX for now */
- return TRUE;
- default:
- assert(0);
- return FALSE;
- }
-}
-
-
-static int cell_get_param(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 8;
- case PIPE_CAP_NPOT_TEXTURES:
- return 1;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 1;
- case PIPE_CAP_GLSL:
- return 1;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 1;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 1;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 12; /* max 2Kx2K */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 12; /* max 2Kx2K */
- default:
- return 0;
- }
-}
-
-static float cell_get_paramf(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 255.0; /* arbitrary */
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0; /* arbitrary */
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 0.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0; /* arbitrary */
-
- default:
- return 0;
- }
-}
-
-
-static const char *
-cell_get_name( struct pipe_context *pipe )
-{
- return "Cell";
-}
-
-static const char *
-cell_get_vendor( struct pipe_context *pipe )
-{
- return "Tungsten Graphics, Inc.";
-}
-
-
-
-static void
-cell_destroy_context( struct pipe_context *pipe )
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell_spu_exit(cell);
-
- align_free(cell);
-}
-
-
-static struct draw_context *
-cell_draw_create(struct cell_context *cell)
-{
- struct draw_context *draw = draw_create();
-
- 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;
- }
-
- return draw;
-}
-
-
-struct pipe_context *
-cell_create_context(struct pipe_winsys *winsys, 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);
- if (!cell)
- return NULL;
-
- memset(cell, 0, sizeof(*cell));
-
- cell->winsys = cws;
- cell->pipe.winsys = winsys;
- cell->pipe.destroy = cell_destroy_context;
-
- /* queries */
- cell->pipe.is_format_supported = cell_is_format_supported;
- cell->pipe.get_name = cell_get_name;
- cell->pipe.get_vendor = cell_get_vendor;
- cell->pipe.get_param = cell_get_param;
- cell->pipe.get_paramf = cell_get_paramf;
-
-
- /* state setters */
- cell->pipe.create_blend_state = cell_create_blend_state;
- cell->pipe.bind_blend_state = cell_bind_blend_state;
- cell->pipe.delete_blend_state = cell_delete_blend_state;
-
- cell->pipe.create_sampler_state = cell_create_sampler_state;
- cell->pipe.bind_sampler_state = cell_bind_sampler_state;
- cell->pipe.delete_sampler_state = cell_delete_sampler_state;
-
- cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
- cell->pipe.bind_depth_stencil_alpha_state = cell_bind_depth_stencil_alpha_state;
- cell->pipe.delete_depth_stencil_alpha_state = cell_delete_depth_stencil_alpha_state;
-
- cell->pipe.create_rasterizer_state = cell_create_rasterizer_state;
- cell->pipe.bind_rasterizer_state = cell_bind_rasterizer_state;
- cell->pipe.delete_rasterizer_state = cell_delete_rasterizer_state;
-
- cell->pipe.create_fs_state = cell_create_fs_state;
- cell->pipe.bind_fs_state = cell_bind_fs_state;
- cell->pipe.delete_fs_state = cell_delete_fs_state;
-
- cell->pipe.create_vs_state = cell_create_vs_state;
- cell->pipe.bind_vs_state = cell_bind_vs_state;
- cell->pipe.delete_vs_state = cell_delete_vs_state;
-
- cell->pipe.set_blend_color = cell_set_blend_color;
- cell->pipe.set_clip_state = cell_set_clip_state;
- cell->pipe.set_constant_buffer = cell_set_constant_buffer;
-
- cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
-
- cell->pipe.set_polygon_stipple = cell_set_polygon_stipple;
- cell->pipe.set_scissor_state = cell_set_scissor_state;
- cell->pipe.set_viewport_state = cell_set_viewport_state;
-
- cell->pipe.set_vertex_buffer = cell_set_vertex_buffer;
- cell->pipe.set_vertex_element = cell_set_vertex_element;
-
- 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;
-
- /* textures */
- cell->pipe.texture_create = cell_texture_create;
- cell->pipe.texture_release = cell_texture_release;
- cell->pipe.get_tex_surface = cell_get_tex_surface;
-
- cell->pipe.set_sampler_texture = cell_set_sampler_texture;
-
-#if 0
- cell->pipe.begin_query = cell_begin_query;
- cell->pipe.end_query = cell_end_query;
- cell->pipe.wait_query = cell_wait_query;
-#endif
-
- cell_init_surface_functions(cell);
-
- cell->draw = cell_draw_create(cell);
-
- cell_init_vbuf(cell);
- draw_set_rasterize_stage(cell->draw, cell->vbuf);
-
- /*
- * SPU stuff
- */
- cell->num_spus = 6;
-
- 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;
- }
- }
-
- return &cell->pipe;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h
deleted file mode 100644
index 3b63419b5e..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_context.h
+++ /dev/null
@@ -1,135 +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 CELL_CONTEXT_H
-#define CELL_CONTEXT_H
-
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/draw/draw_vertex.h"
-#include "pipe/draw/draw_vbuf.h"
-#include "cell_winsys.h"
-#include "pipe/cell/common.h"
-
-
-struct cell_vbuf_render;
-
-struct cell_vertex_shader_state
-{
- struct pipe_shader_state shader;
- void *draw_data;
-};
-
-
-struct cell_fragment_shader_state
-{
- struct pipe_shader_state shader;
- void *data;
-};
-
-
-struct cell_context
-{
- struct pipe_context pipe;
-
- struct cell_winsys *winsys;
-
- const struct pipe_blend_state *blend;
- const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct pipe_depth_stencil_alpha_state *depth_stencil;
- const struct pipe_rasterizer_state *rasterizer;
- const struct cell_vertex_shader_state *vs;
- const struct cell_fragment_shader_state *fs;
-
- struct pipe_blend_color blend_color;
- struct pipe_clip_state clip;
- struct pipe_constant_buffer constants[2];
- struct pipe_framebuffer_state framebuffer;
- struct pipe_poly_stipple poly_stipple;
- struct pipe_scissor_state scissor;
- struct cell_texture *texture[PIPE_MAX_SAMPLERS];
- struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
- struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
-
- ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS];
- ubyte *zsbuf_map;
-
- struct pipe_surface *tex_surf;
- uint *tex_map;
-
- uint dirty;
-
- /** The primitive drawing context */
- struct draw_context *draw;
- struct draw_stage *render_stage;
-
- /** For post-transformed vertex buffering: */
- struct cell_vbuf_render *vbuf_render;
- struct draw_stage *vbuf;
-
- struct vertex_info vertex_info;
-
- /** Mapped constant buffers */
- void *mapped_constants[PIPE_SHADER_TYPES];
-
-
- uint num_spus;
-
- /** Buffers for command batches, vertex/index data */
- uint buffer_size[CELL_NUM_BUFFERS];
- ubyte buffer[CELL_NUM_BUFFERS][CELL_BUFFER_SIZE] ALIGN16_ATTRIB;
-
- int cur_batch; /**< which buffer is being filled w/ commands */
-
- /** [4] to ensure 16-byte alignment for each status word */
- uint buffer_status[CELL_MAX_SPUS][CELL_NUM_BUFFERS][4] ALIGN16_ATTRIB;
-
-};
-
-
-
-
-static INLINE struct cell_context *
-cell_context(struct pipe_context *pipe)
-{
- return (struct cell_context *) pipe;
-}
-
-
-extern struct pipe_context *
-cell_create_context(struct pipe_winsys *ws, struct cell_winsys *cws);
-
-extern void
-cell_vertex_shader_queue_flush(struct draw_context *draw);
-
-
-
-
-#endif /* CELL_CONTEXT_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c b/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
deleted file mode 100644
index 717cd8370f..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.c
+++ /dev/null
@@ -1,164 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- * Keith Whitwell
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-#include "pipe/p_winsys.h"
-
-#include "cell_context.h"
-#include "cell_draw_arrays.h"
-#include "cell_state.h"
-
-#include "pipe/draw/draw_context.h"
-
-
-
-static void
-cell_map_constant_buffers(struct cell_context *sp)
-{
- struct pipe_winsys *ws = sp->pipe.winsys;
- uint i;
- for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
- sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- }
-
- draw_set_mapped_constant_buffer(sp->draw,
- sp->mapped_constants[PIPE_SHADER_VERTEX]);
-}
-
-static void
-cell_unmap_constant_buffers(struct cell_context *sp)
-{
- struct pipe_winsys *ws = sp->pipe.winsys;
- uint i;
- for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
- ws->buffer_unmap(ws, sp->constants[i].buffer);
- sp->mapped_constants[i] = NULL;
- }
-}
-
-
-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.
- * Basically, map the vertex buffers (and drawing surfaces), then hand off
- * the drawing to the 'draw' module.
- *
- * 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)
-{
- struct cell_context *sp = cell_context(pipe);
- struct draw_context *draw = sp->draw;
- unsigned i;
-
- /* first, check that the primitive is not malformed. It is the
- * state tracker's responsibility to do send only correctly formed
- * primitives down. It currently isn't doing that though...
- */
-#if 1
- count = draw_trim_prim( mode, count );
-#else
- if (!draw_validate_prim( mode, count ))
- assert(0);
-#endif
-
- if (sp->dirty)
- cell_update_derived( sp );
-
-#if 0
- cell_map_surfaces(sp);
-#endif
- cell_map_constant_buffers(sp);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (sp->vertex_buffer[i].buffer) {
- void *buf = pipe->winsys->buffer_map(pipe->winsys,
- sp->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys,
- indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
-
- /* draw! */
- draw_arrays(draw, mode, start, count);
-
- /*
- * unmap vertex/index buffers - will cause draw module to flush
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (sp->vertex_buffer[i].buffer) {
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
- }
- }
- if (indexBuffer) {
- draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
- }
-
- /* Note: leave drawing surfaces mapped */
- cell_unmap_constant_buffers(sp);
-
- return TRUE;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h b/src/mesa/pipe/cell/ppu/cell_draw_arrays.h
deleted file mode 100644
index d5df4aa05f..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_draw_arrays.h
+++ /dev/null
@@ -1,42 +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 CELL_DRAW_ARRAYS_H
-#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);
-
-
-
-#endif /* CELL_DRAW_ARRAYS_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_flush.c b/src/mesa/pipe/cell/ppu/cell_flush.c
deleted file mode 100644
index f62bc4650c..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_flush.c
+++ /dev/null
@@ -1,84 +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.
- *
- **************************************************************************/
-
-
-#include "cell_context.h"
-#include "cell_batch.h"
-#include "cell_flush.h"
-#include "cell_spu.h"
-#include "cell_render.h"
-#include "pipe/draw/draw_context.h"
-
-
-void
-cell_flush(struct pipe_context *pipe, unsigned flags)
-{
- struct cell_context *cell = cell_context(pipe);
-
- if (flags & PIPE_FLUSH_SWAPBUFFERS)
- flags |= PIPE_FLUSH_WAIT;
-
- draw_flush( cell->draw );
- cell_flush_int(pipe, flags);
-}
-
-
-/** internal flush */
-void
-cell_flush_int(struct pipe_context *pipe, unsigned flags)
-{
- static boolean flushing = FALSE; /* recursion catcher */
- struct cell_context *cell = cell_context(pipe);
- uint i;
-
- ASSERT(!flushing);
- flushing = TRUE;
-
- if (flags & PIPE_FLUSH_WAIT) {
- uint64_t *cmd = (uint64_t *) cell_batch_alloc(cell, sizeof(uint64_t));
- *cmd = CELL_CMD_FINISH;
- }
-
- cell_batch_flush(cell);
-
-#if 0
- /* Send CMD_FINISH to all SPUs */
- for (i = 0; i < cell->num_spus; i++) {
- send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_FINISH);
- }
-#endif
-
- if (flags & PIPE_FLUSH_WAIT) {
- /* Wait for ack */
- for (i = 0; i < cell->num_spus; i++) {
- uint k = wait_mbox_message(cell_global.spe_contexts[i]);
- assert(k == CELL_CMD_FINISH);
- }
- }
-
- flushing = FALSE;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_flush.h b/src/mesa/pipe/cell/ppu/cell_flush.h
deleted file mode 100644
index eda351b1cb..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_flush.h
+++ /dev/null
@@ -1,38 +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 CELL_FLUSH
-#define CELL_FLUSH
-
-extern void
-cell_flush(struct pipe_context *pipe, unsigned flags);
-
-extern void
-cell_flush_int(struct pipe_context *pipe, unsigned flags);
-
-#endif
diff --git a/src/mesa/pipe/cell/ppu/cell_render.c b/src/mesa/pipe/cell/ppu/cell_render.c
deleted file mode 100644
index 4ab277a4b2..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_render.c
+++ /dev/null
@@ -1,210 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Last stage of 'draw' pipeline: send tris to SPUs.
- * \author Brian Paul
- */
-
-#include "cell_context.h"
-#include "cell_render.h"
-#include "cell_spu.h"
-#include "pipe/p_util.h"
-#include "pipe/draw/draw_private.h"
-
-
-struct render_stage {
- struct draw_stage stage; /**< This must be first (base class) */
-
- struct cell_context *cell;
-};
-
-
-static INLINE struct render_stage *
-render_stage(struct draw_stage *stage)
-{
- return (struct render_stage *) stage;
-}
-
-
-static void render_begin( struct draw_stage *stage )
-{
-#if 0
- struct render_stage *render = render_stage(stage);
- struct cell_context *sp = render->cell;
- const struct pipe_shader_state *fs = &render->cell->fs->shader;
- render->quad.nr_attrs = render->cell->nr_frag_attrs;
-
- render->firstFpInput = fs->input_semantic_name[0];
-
- sp->quad.first->begin(sp->quad.first);
-#endif
-}
-
-
-static void render_end( struct draw_stage *stage )
-{
-}
-
-
-static void reset_stipple_counter( struct draw_stage *stage )
-{
- struct render_stage *render = render_stage(stage);
- /*render->cell->line_stipple_counter = 0;*/
-}
-
-
-static void
-render_point(struct draw_stage *stage, struct prim_header *prim)
-{
-}
-
-
-static void
-render_line(struct draw_stage *stage, struct prim_header *prim)
-{
-}
-
-
-/** Write a vertex into the prim buffer */
-static void
-save_vertex(struct cell_prim_buffer *buf, uint pos,
- const struct vertex_header *vert)
-{
- uint attr, j;
-
- for (attr = 0; attr < 2; attr++) {
- for (j = 0; j < 4; j++) {
- buf->vertex[pos][attr][j] = vert->data[attr][j];
- }
- }
-
- /* update bounding box */
- if (vert->data[0][0] < buf->xmin)
- buf->xmin = vert->data[0][0];
- if (vert->data[0][0] > buf->xmax)
- buf->xmax = vert->data[0][0];
- if (vert->data[0][1] < buf->ymin)
- buf->ymin = vert->data[0][1];
- if (vert->data[0][1] > buf->ymax)
- buf->ymax = vert->data[0][1];
-}
-
-
-static void
-render_tri(struct draw_stage *stage, struct prim_header *prim)
-{
- struct render_stage *rs = render_stage(stage);
- struct cell_context *cell = rs->cell;
- struct cell_prim_buffer *buf = &cell->prim_buffer;
- uint i;
-
- if (buf->num_verts + 3 > CELL_MAX_VERTS) {
- cell_flush_prim_buffer(cell);
- }
-
- i = buf->num_verts;
- assert(i+2 <= CELL_MAX_VERTS);
- save_vertex(buf, i+0, prim->v[0]);
- save_vertex(buf, i+1, prim->v[1]);
- save_vertex(buf, i+2, prim->v[2]);
- buf->num_verts += 3;
-}
-
-
-/**
- * Send the a RENDER command to all SPUs to have them render the prims
- * in the current prim_buffer.
- */
-void
-cell_flush_prim_buffer(struct cell_context *cell)
-{
- uint i;
-
- if (cell->prim_buffer.num_verts == 0)
- return;
-
- for (i = 0; i < cell->num_spus; i++) {
- struct cell_command_render *render = &cell_global.command[i].render;
- render->prim_type = PIPE_PRIM_TRIANGLES;
- render->num_verts = cell->prim_buffer.num_verts;
- render->vertex_size = cell->vertex_info->size * 4;
- render->xmin = cell->prim_buffer.xmin;
- render->ymin = cell->prim_buffer.ymin;
- render->xmax = cell->prim_buffer.xmax;
- render->ymax = cell->prim_buffer.ymax;
- render->vertex_data = &cell->prim_buffer.vertex;
- ASSERT_ALIGN16(render->vertex_data);
- send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_RENDER);
- }
-
- cell->prim_buffer.num_verts = 0;
-
- cell->prim_buffer.xmin = 1e100;
- cell->prim_buffer.ymin = 1e100;
- cell->prim_buffer.xmax = -1e100;
- cell->prim_buffer.ymax = -1e100;
-
- /* XXX temporary, need to double-buffer the prim buffer until we get
- * a real command buffer/list system.
- */
- cell_flush(&cell->pipe, 0x0);
-}
-
-
-
-static void render_destroy( struct draw_stage *stage )
-{
- FREE( stage );
-}
-
-
-/**
- * Create a new draw/render stage. This will be plugged into the
- * draw module as the last pipeline stage.
- */
-struct draw_stage *cell_draw_render_stage( struct cell_context *cell )
-{
- struct render_stage *render = CALLOC_STRUCT(render_stage);
-
- render->cell = cell;
- render->stage.draw = cell->draw;
- render->stage.begin = render_begin;
- render->stage.point = render_point;
- render->stage.line = render_line;
- render->stage.tri = render_tri;
- render->stage.end = render_end;
- render->stage.reset_stipple_counter = reset_stipple_counter;
- render->stage.destroy = render_destroy;
-
- /*
- render->quad.coef = render->coef;
- render->quad.posCoef = &render->posCoef;
- */
-
- return &render->stage;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_render.h b/src/mesa/pipe/cell/ppu/cell_render.h
deleted file mode 100644
index 826dcbafeb..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_render.h
+++ /dev/null
@@ -1,39 +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 CELL_RENDER_H
-#define CELL_RENDER_H
-
-struct cell_context;
-struct draw_stage;
-
-extern void
-cell_flush_prim_buffer(struct cell_context *cell);
-
-extern struct draw_stage *cell_draw_render_stage( struct cell_context *cell );
-
-#endif /* CELL_RENDER_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c
deleted file mode 100644
index 7c83a47e57..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_spu.c
+++ /dev/null
@@ -1,155 +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.
- *
- **************************************************************************/
-
-
-#include <pthread.h>
-
-#include "cell_spu.h"
-#include "pipe/p_format.h"
-#include "pipe/p_state.h"
-#include "pipe/cell/common.h"
-
-
-/*
-helpful headers:
-/opt/ibm/cell-sdk/prototype/src/include/ppu/cbe_mfc.h
-*/
-
-
-struct cell_global_info cell_global;
-
-
-/**
- * Write a 1-word message to the given SPE mailbox.
- */
-void
-send_mbox_message(spe_context_ptr_t ctx, unsigned int msg)
-{
- spe_in_mbox_write(ctx, &msg, 1, SPE_MBOX_ALL_BLOCKING);
-}
-
-
-/**
- * Wait for a 1-word message to arrive in given mailbox.
- */
-uint
-wait_mbox_message(spe_context_ptr_t ctx)
-{
- do {
- unsigned data;
- int count = spe_out_mbox_read(ctx, &data, 1);
-
- if (count == 1) {
- return data;
- }
-
- if (count < 0) {
- /* error */ ;
- }
- } while (1);
-}
-
-
-static void *cell_thread_function(void *arg)
-{
- struct cell_init_info *init = (struct cell_init_info *) arg;
- unsigned entry = SPE_DEFAULT_ENTRY;
-
- ASSERT_ALIGN16(init);
-
- if (spe_context_run(cell_global.spe_contexts[init->id], &entry, 0,
- init, NULL, NULL) < 0) {
- fprintf(stderr, "spe_context_run() failed\n");
- exit(1);
- }
-
- pthread_exit(NULL);
-}
-
-
-/**
- * Create the SPU threads
- */
-void
-cell_start_spus(struct cell_context *cell)
-{
- uint i, j;
-
- assert(cell->num_spus <= MAX_SPUS);
-
- ASSERT_ALIGN16(&cell_global.command[0]);
- ASSERT_ALIGN16(&cell_global.command[1]);
-
- ASSERT_ALIGN16(&cell_global.inits[0]);
- ASSERT_ALIGN16(&cell_global.inits[1]);
-
- 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].cmd = &cell_global.command[i];
- for (j = 0; j < CELL_NUM_BUFFERS; j++) {
- cell_global.inits[i].buffers[j] = cell->buffer[j];
- }
- cell_global.inits[i].buffer_status = &cell->buffer_status[0][0][0];
-
- cell_global.spe_contexts[i] = spe_context_create(0, NULL);
- if (!cell_global.spe_contexts[i]) {
- fprintf(stderr, "spe_context_create() failed\n");
- exit(1);
- }
-
- if (spe_program_load(cell_global.spe_contexts[i], &g3d_spu)) {
- fprintf(stderr, "spe_program_load() failed\n");
- exit(1);
- }
-
- pthread_create(&cell_global.spe_threads[i], NULL, &cell_thread_function,
- &cell_global.inits[i]);
- }
-}
-
-
-/**
- * Tell all the SPUs to stop/exit.
- */
-void
-cell_spu_exit(struct cell_context *cell)
-{
- uint i;
-
- for (i = 0; i < cell->num_spus; i++) {
- send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_EXIT);
- }
-
- /* wait for threads to exit */
- for (i = 0; i < cell->num_spus; i++) {
- void *value;
- pthread_join(cell_global.spe_threads[i], &value);
- cell_global.spe_threads[i] = 0;
- cell_global.spe_contexts[i] = 0;
- }
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_spu.h b/src/mesa/pipe/cell/ppu/cell_spu.h
deleted file mode 100644
index 19eff94f96..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_spu.h
+++ /dev/null
@@ -1,82 +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 CELL_SPU
-#define CELL_SPU
-
-
-#include <libspe2.h>
-#include <libmisc.h>
-#include "pipe/cell/common.h"
-
-#include "cell_context.h"
-
-
-#define MAX_SPUS 8
-
-/**
- * Global vars, for now anyway.
- */
-struct cell_global_info
-{
- /**
- * SPU/SPE handles, etc
- */
- spe_context_ptr_t spe_contexts[MAX_SPUS];
- pthread_t spe_threads[MAX_SPUS];
-
- /**
- * Data sent to SPUs
- */
- struct cell_init_info inits[MAX_SPUS];
- struct cell_command command[MAX_SPUS];
-};
-
-
-extern struct cell_global_info cell_global;
-
-
-/** This is the handle for the actual SPE code */
-extern spe_program_handle_t g3d_spu;
-
-
-extern void
-send_mbox_message(spe_context_ptr_t ctx, unsigned int msg);
-
-extern uint
-wait_mbox_message(spe_context_ptr_t ctx);
-
-
-extern void
-cell_start_spus(struct cell_context *cell);
-
-
-extern void
-cell_spu_exit(struct cell_context *cell);
-
-
-#endif /* CELL_SPU */
diff --git a/src/mesa/pipe/cell/ppu/cell_state.h b/src/mesa/pipe/cell/ppu/cell_state.h
deleted file mode 100644
index 3a71ba14fa..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state.h
+++ /dev/null
@@ -1,115 +0,0 @@
-
-
-#ifndef CELL_STATE_H
-#define CELL_STATE_H
-
-
-#define CELL_NEW_VIEWPORT 0x1
-#define CELL_NEW_RASTERIZER 0x2
-#define CELL_NEW_FS 0x4
-#define CELL_NEW_BLEND 0x8
-#define CELL_NEW_CLIP 0x10
-#define CELL_NEW_SCISSOR 0x20
-#define CELL_NEW_STIPPLE 0x40
-#define CELL_NEW_FRAMEBUFFER 0x80
-#define CELL_NEW_ALPHA_TEST 0x100
-#define CELL_NEW_DEPTH_STENCIL 0x200
-#define CELL_NEW_SAMPLER 0x400
-#define CELL_NEW_TEXTURE 0x800
-#define CELL_NEW_VERTEX 0x1000
-#define CELL_NEW_VS 0x2000
-#define CELL_NEW_CONSTANTS 0x4000
-#define CELL_NEW_VERTEX_INFO 0x8000
-
-
-
-extern void
-cell_set_framebuffer_state( struct pipe_context *,
- const struct pipe_framebuffer_state * );
-
-
-
-extern void *
-cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *);
-extern void cell_bind_blend_state(struct pipe_context *, void *);
-extern void cell_delete_blend_state(struct pipe_context *, void *);
-
-extern void cell_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color );
-
-
-void *
-cell_create_sampler_state(struct pipe_context *,
- const struct pipe_sampler_state *);
-
-extern void
-cell_bind_sampler_state(struct pipe_context *, unsigned, void *);
-
-extern void
-cell_delete_sampler_state(struct pipe_context *, void *);
-
-
-extern void *
-cell_create_depth_stencil_alpha_state(struct pipe_context *,
- const struct pipe_depth_stencil_alpha_state *);
-
-extern void
-cell_bind_depth_stencil_alpha_state(struct pipe_context *, void *);
-
-extern void
-cell_delete_depth_stencil_alpha_state(struct pipe_context *, void *);
-
-
-void *cell_create_fs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void cell_bind_fs_state(struct pipe_context *, void *);
-void cell_delete_fs_state(struct pipe_context *, void *);
-void *cell_create_vs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void cell_bind_vs_state(struct pipe_context *, void *);
-void cell_delete_vs_state(struct pipe_context *, void *);
-
-
-void *
-cell_create_rasterizer_state(struct pipe_context *,
- const struct pipe_rasterizer_state *);
-void cell_bind_rasterizer_state(struct pipe_context *, void *);
-void cell_delete_rasterizer_state(struct pipe_context *, void *);
-
-
-void cell_set_clip_state( struct pipe_context *,
- const struct pipe_clip_state * );
-
-void cell_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf);
-
-void cell_set_polygon_stipple( struct pipe_context *,
- const struct pipe_poly_stipple * );
-
-void
-cell_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler,
- struct pipe_texture *texture);
-
-void cell_set_scissor_state( struct pipe_context *,
- const struct pipe_scissor_state * );
-
-void cell_set_texture_state( struct pipe_context *,
- unsigned unit, struct pipe_texture * );
-
-void cell_set_vertex_element(struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_element *);
-
-void cell_set_vertex_buffer(struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_buffer *);
-
-void cell_set_viewport_state( struct pipe_context *,
- const struct pipe_viewport_state * );
-
-
-void cell_update_derived( struct cell_context *softpipe );
-
-#endif
diff --git a/src/mesa/pipe/cell/ppu/cell_state_blend.c b/src/mesa/pipe/cell/ppu/cell_state_blend.c
deleted file mode 100644
index 4fc60548c8..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_blend.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-
-void *
-cell_create_blend_state(struct pipe_context *pipe,
- const struct pipe_blend_state *blend)
-{
- return mem_dup(blend, sizeof(*blend));
-}
-
-
-void
-cell_bind_blend_state(struct pipe_context *pipe, void *blend)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->blend = (const struct pipe_blend_state *)blend;
-
- cell->dirty |= CELL_NEW_BLEND;
-}
-
-
-void
-cell_delete_blend_state(struct pipe_context *pipe, void *blend)
-{
- FREE(blend);
-}
-
-
-void
-cell_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->blend_color = *blend_color;
-
- cell->dirty |= CELL_NEW_BLEND;
-}
-
-
-
-
-void *
-cell_create_depth_stencil_alpha_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
-{
- return mem_dup(depth_stencil, sizeof(*depth_stencil));
-}
-
-
-void
-cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->depth_stencil
- = (const struct pipe_depth_stencil_alpha_state *) depth_stencil;
-
- cell->dirty |= CELL_NEW_DEPTH_STENCIL;
-}
-
-
-void
-cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
-{
- FREE(depth);
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_clip.c b/src/mesa/pipe/cell/ppu/cell_state_clip.c
deleted file mode 100644
index 4f43665941..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_clip.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "cell_context.h"
-#include "cell_state.h"
-#include "pipe/draw/draw_context.h"
-
-
-void cell_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct cell_context *cell = cell_context(pipe);
-
- /* pass the clip state to the draw module */
- draw_set_clip_state(cell->draw, clip);
-}
-
-
-
-/* Called when driver state tracker notices changes to the viewport
- * matrix:
- */
-void cell_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell->viewport = *viewport; /* struct copy */
- cell->dirty |= CELL_NEW_VIEWPORT;
-
- /* pass the viewport info to the draw module */
- draw_set_viewport_state(cell->draw, viewport);
-
- /* Using tnl/ and vf/ modules is temporary while getting started.
- * Full pipe will have vertex shader, vertex fetch of its own.
- */
-}
-
-
-void cell_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct cell_context *cell = cell_context(pipe);
-
- memcpy( &cell->scissor, scissor, sizeof(*scissor) );
- cell->dirty |= CELL_NEW_SCISSOR;
-}
-
-
-void cell_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
- struct cell_context *cell = cell_context(pipe);
-
- memcpy( &cell->poly_stipple, stipple, sizeof(*stipple) );
- cell->dirty |= CELL_NEW_STIPPLE;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_derived.c b/src/mesa/pipe/cell/ppu/cell_state_derived.c
deleted file mode 100644
index 56daf5dfde..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_derived.c
+++ /dev/null
@@ -1,192 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_vertex.h"
-#include "cell_context.h"
-#include "cell_batch.h"
-#include "cell_state.h"
-#include "cell_state_emit.h"
-
-
-static int
-find_vs_output(const struct pipe_shader_state *vs,
- uint semantic_name,
- uint semantic_index)
-{
- uint i;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == semantic_name &&
- vs->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
- * coefficients from the post-transform vertex attributes.
- */
-static void
-calculate_vertex_layout( struct cell_context *cell )
-{
- const struct pipe_shader_state *vs = &cell->vs->shader;
- const struct pipe_shader_state *fs = &cell->fs->shader;
- const enum interp_mode colorInterp
- = cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
- struct vertex_info *vinfo = &cell->vertex_info;
- uint i;
- int src;
-
-#if 0
- if (cell->vbuf) {
- /* if using the post-transform vertex buffer, tell draw_vbuf to
- * simply emit the whole post-xform vertex as-is:
- */
- struct vertex_info *vinfo_vbuf = &cell->vertex_info_vbuf;
- vinfo_vbuf->num_attribs = 0;
- draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0);
- vinfo_vbuf->size = 4 * vs->num_outputs + sizeof(struct vertex_header)/4;
- }
-#endif
-
- /* reset vinfo */
- vinfo->num_attribs = 0;
-
- /* we always want to emit vertex pos */
- src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
-
-
- /*
- * Loop over fragment shader inputs, searching for the matching output
- * from the vertex shader.
- */
- for (i = 0; i < fs->num_inputs; i++) {
- switch (fs->input_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- /* already done above */
- break;
-
- case TGSI_SEMANTIC_COLOR:
- src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
- fs->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);
-#if 1
- if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
- src = 0;
-#endif
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_1F, INTERP_PERSPECTIVE, src);
- break;
-
- case TGSI_SEMANTIC_GENERIC:
- /* this includes texcoords and varying vars */
- src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
- fs->input_semantic_index[i]);
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- break;
-
- default:
- assert(0);
- }
- }
-
- draw_compute_vertex_size(vinfo);
-
- /* XXX only signal this if format really changes */
- cell->dirty |= CELL_NEW_VERTEX_INFO;
-}
-
-
-#if 0
-/**
- * Recompute cliprect from scissor bounds, scissor enable and surface size.
- */
-static void
-compute_cliprect(struct cell_context *sp)
-{
- unsigned surfWidth, surfHeight;
-
- if (sp->framebuffer.num_cbufs > 0) {
- surfWidth = sp->framebuffer.cbufs[0]->width;
- surfHeight = sp->framebuffer.cbufs[0]->height;
- }
- else {
- /* no surface? */
- surfWidth = sp->scissor.maxx;
- surfHeight = sp->scissor.maxy;
- }
-
- if (sp->rasterizer->scissor) {
- /* clip to scissor rect */
- sp->cliprect.minx = MAX2(sp->scissor.minx, 0);
- sp->cliprect.miny = MAX2(sp->scissor.miny, 0);
- sp->cliprect.maxx = MIN2(sp->scissor.maxx, surfWidth);
- sp->cliprect.maxy = MIN2(sp->scissor.maxy, surfHeight);
- }
- else {
- /* clip to surface bounds */
- sp->cliprect.minx = 0;
- sp->cliprect.miny = 0;
- sp->cliprect.maxx = surfWidth;
- sp->cliprect.maxy = surfHeight;
- }
-}
-#endif
-
-
-
-void cell_update_derived( struct cell_context *cell )
-{
- if (cell->dirty & (CELL_NEW_RASTERIZER |
- CELL_NEW_FS |
- CELL_NEW_VS))
- calculate_vertex_layout( cell );
-
-#if 0
- if (cell->dirty & (CELL_NEW_SCISSOR |
- CELL_NEW_DEPTH_STENCIL_ALPHA |
- CELL_NEW_FRAMEBUFFER))
- compute_cliprect(cell);
-#endif
-
- cell_emit_state(cell);
-
- cell->dirty = 0;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.c b/src/mesa/pipe/cell/ppu/cell_state_emit.c
deleted file mode 100644
index 5d2a786449..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_emit.c
+++ /dev/null
@@ -1,103 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_util.h"
-#include "cell_context.h"
-#include "cell_state.h"
-#include "cell_state_emit.h"
-#include "cell_batch.h"
-#include "cell_texture.h"
-
-
-static void
-emit_state_cmd(struct cell_context *cell, uint cmd,
- const void *state, uint state_size)
-{
- uint64_t *dst = (uint64_t *)
- cell_batch_alloc(cell, ROUNDUP8(sizeof(uint64_t) + state_size));
- *dst = cmd;
- memcpy(dst + 1, state, state_size);
-}
-
-
-
-void
-cell_emit_state(struct cell_context *cell)
-{
- if (cell->dirty & CELL_NEW_FRAMEBUFFER) {
- struct pipe_surface *cbuf = cell->framebuffer.cbufs[0];
- struct pipe_surface *zbuf = cell->framebuffer.zsbuf;
- struct cell_command_framebuffer *fb
- = cell_batch_alloc(cell, sizeof(*fb));
- fb->opcode = CELL_CMD_STATE_FRAMEBUFFER;
- fb->color_start = cell->cbuf_map[0];
- fb->color_format = cbuf->format;
- fb->depth_start = cell->zsbuf_map;
- fb->depth_format = zbuf ? zbuf->format : PIPE_FORMAT_NONE;
- fb->width = cell->framebuffer.cbufs[0]->width;
- fb->height = cell->framebuffer.cbufs[0]->height;
- }
-
- if (cell->dirty & CELL_NEW_BLEND) {
- emit_state_cmd(cell, CELL_CMD_STATE_BLEND,
- cell->blend,
- sizeof(struct pipe_blend_state));
- }
-
- if (cell->dirty & CELL_NEW_DEPTH_STENCIL) {
- emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL,
- cell->depth_stencil,
- sizeof(struct pipe_depth_stencil_alpha_state));
- }
-
- if (cell->dirty & CELL_NEW_SAMPLER) {
- emit_state_cmd(cell, CELL_CMD_STATE_SAMPLER,
- cell->sampler[0], sizeof(struct pipe_sampler_state));
- }
-
- if (cell->dirty & CELL_NEW_TEXTURE) {
- struct cell_command_texture texture;
- if (cell->texture[0]) {
- texture.start = cell->texture[0]->tiled_data;
- texture.width = cell->texture[0]->base.width[0];
- texture.height = cell->texture[0]->base.height[0];
- }
- else {
- texture.start = NULL;
- texture.width = 0;
- texture.height = 0;
- }
-
- emit_state_cmd(cell, CELL_CMD_STATE_TEXTURE,
- &texture, sizeof(struct cell_command_texture));
- }
-
- if (cell->dirty & CELL_NEW_VERTEX_INFO) {
- emit_state_cmd(cell, CELL_CMD_STATE_VERTEX_INFO,
- &cell->vertex_info, sizeof(struct vertex_info));
- }
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_emit.h b/src/mesa/pipe/cell/ppu/cell_state_emit.h
deleted file mode 100644
index 59f8affe8d..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_emit.h
+++ /dev/null
@@ -1,36 +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 CELL_STATE_EMIT_H
-#define CELL_STATE_EMIT_H
-
-
-extern void
-cell_emit_state(struct cell_context *cell);
-
-
-#endif /* CELL_STATE_EMIT_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_state_fs.c b/src/mesa/pipe/cell/ppu/cell_state_fs.c
deleted file mode 100644
index 3f46a87d18..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_fs.c
+++ /dev/null
@@ -1,171 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/draw/draw_context.h"
-#if 0
-#include "pipe/p_shader_tokens.h"
-#include "pipe/llvm/gallivm.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-#include "pipe/tgsi/exec/tgsi_sse2.h"
-#endif
-
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-void *
-cell_create_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- /*struct cell_context *cell = cell_context(pipe);*/
- struct cell_fragment_shader_state *state;
-
- state = CALLOC_STRUCT(cell_fragment_shader_state);
- if (!state)
- return NULL;
-
- state->shader = *templ;
-
-#if 0
- if (cell->dump_fs) {
- tgsi_dump(state->shader.tokens, 0);
- }
-
-#if defined(__i386__) || defined(__386__)
- if (cell->use_sse) {
- x86_init_func( &state->sse2_program );
- tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program );
- }
-#endif
-
-#ifdef MESA_LLVM
- state->llvm_prog = 0;
- if (!gallivm_global_cpu_engine()) {
- gallivm_cpu_engine_create(state->llvm_prog);
- }
- else
- gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog);
-#endif
-#endif
-
- return state;
-}
-
-
-void
-cell_bind_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell->fs = (struct cell_fragment_shader_state *) fs;
-
- cell->dirty |= CELL_NEW_FS;
-}
-
-
-void
-cell_delete_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct cell_fragment_shader_state *state =
- (struct cell_fragment_shader_state *) fs;
-
- FREE( state );
-}
-
-
-void *
-cell_create_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct cell_context *cell = cell_context(pipe);
- struct cell_vertex_shader_state *state;
-
- state = CALLOC_STRUCT(cell_vertex_shader_state);
- if (!state)
- return NULL;
-
- state->shader = *templ;
-
- state->draw_data = draw_create_vertex_shader(cell->draw, &state->shader);
- if (state->draw_data == NULL) {
- FREE( state );
- return NULL;
- }
-
- return state;
-}
-
-
-void
-cell_bind_vs_state(struct pipe_context *pipe, void *vs)
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell->vs = (const struct cell_vertex_shader_state *) vs;
-
- draw_bind_vertex_shader(cell->draw, cell->vs->draw_data);
-
- cell->dirty |= CELL_NEW_VS;
-}
-
-
-void
-cell_delete_vs_state(struct pipe_context *pipe, void *vs)
-{
- struct cell_context *cell = cell_context(pipe);
-
- struct cell_vertex_shader_state *state =
- (struct cell_vertex_shader_state *) vs;
-
- draw_delete_vertex_shader(cell->draw, state->draw_data);
- FREE( state );
-}
-
-
-void
-cell_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf)
-{
- struct cell_context *cell = cell_context(pipe);
- struct pipe_winsys *ws = pipe->winsys;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- /* note: reference counting */
- pipe_buffer_reference(ws,
- &cell->constants[shader].buffer,
- buf->buffer);
- cell->constants[shader].size = buf->size;
-
- cell->dirty |= CELL_NEW_CONSTANTS;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c
deleted file mode 100644
index d8128ece54..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c
+++ /dev/null
@@ -1,106 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-
-struct spu_rasterizer_state
-{
- unsigned flatshade:1;
-#if 0
- unsigned light_twoside:1;
- unsigned front_winding:2; /**< PIPE_WINDING_x */
- unsigned cull_mode:2; /**< PIPE_WINDING_x */
- unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned offset_cw:1;
- unsigned offset_ccw:1;
-#endif
- unsigned scissor:1;
- unsigned poly_smooth:1;
- unsigned poly_stipple_enable:1;
- unsigned point_smooth:1;
-#if 0
- unsigned point_sprite:1;
- unsigned point_size_per_vertex:1; /**< size computed in vertex shader */
-#endif
- unsigned multisample:1; /* XXX maybe more ms state in future */
- unsigned line_smooth:1;
- unsigned line_stipple_enable:1;
- unsigned line_stipple_factor:8; /**< [1..256] actually */
- unsigned line_stipple_pattern:16;
-#if 0
- unsigned bypass_clipping:1;
-#endif
- unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */
-
- float line_width;
- float point_size; /**< used when no per-vertex size */
-#if 0
- float offset_units;
- float offset_scale;
- ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */
-#endif
-};
-
-
-
-void *
-cell_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup)
-{
- struct pipe_rasterizer_state *state
- = MALLOC(sizeof(struct pipe_rasterizer_state));
- memcpy(state, setup, sizeof(struct pipe_rasterizer_state));
- return state;
-}
-
-
-void
-cell_bind_rasterizer_state(struct pipe_context *pipe, void *setup)
-{
- struct cell_context *cell = cell_context(pipe);
-
- /* pass-through to draw module */
- draw_set_rasterizer_state(cell->draw, setup);
-
- cell->rasterizer = (struct pipe_rasterizer_state *)setup;
-
- cell->dirty |= CELL_NEW_RASTERIZER;
-}
-
-
-void
-cell_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer)
-{
- FREE(rasterizer);
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_sampler.c b/src/mesa/pipe/cell/ppu/cell_state_sampler.c
deleted file mode 100644
index ade6cc8338..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_sampler.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors:
- * Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "pipe/draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-#include "cell_texture.h"
-
-
-void *
-cell_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
-{
- return mem_dup(sampler, sizeof(*sampler));
-}
-
-void
-cell_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- assert(unit < PIPE_MAX_SAMPLERS);
- cell->sampler[unit] = (struct pipe_sampler_state *)sampler;
-
- cell->dirty |= CELL_NEW_SAMPLER;
-}
-
-
-void
-cell_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
-{
- FREE( sampler );
-}
-
-
-
-void
-cell_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler,
- struct pipe_texture *texture)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->texture[sampler] = texture;
-
- cell_update_texture_mapping(cell);
-
- cell->dirty |= CELL_NEW_TEXTURE;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c
deleted file mode 100644
index 287610b76b..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_surface.c
+++ /dev/null
@@ -1,71 +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.
- *
- **************************************************************************/
-
-
-#include "pipe/p_inlines.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-void
-cell_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct cell_context *cell = cell_context(pipe);
-
- if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) {
- struct pipe_surface *csurf = fb->cbufs[0];
- struct pipe_surface *zsurf = fb->zsbuf;
- uint i;
-
- /* unmap old surfaces */
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) {
- pipe_surface_unmap(cell->framebuffer.cbufs[i]);
- cell->cbuf_map[i] = NULL;
- }
- }
-
- if (cell->framebuffer.zsbuf && cell->zsbuf_map) {
- pipe_surface_unmap(cell->framebuffer.zsbuf);
- cell->zsbuf_map = NULL;
- }
-
- /* update my state */
- cell->framebuffer = *fb;
-
- /* map new surfaces */
- if (csurf)
- cell->cbuf_map[0] = pipe_surface_map(csurf);
-
- if (zsurf)
- cell->zsbuf_map = pipe_surface_map(zsurf);
-
- cell->dirty |= CELL_NEW_FRAMEBUFFER;
- }
-}
-
diff --git a/src/mesa/pipe/cell/ppu/cell_state_vertex.c b/src/mesa/pipe/cell/ppu/cell_state_vertex.c
deleted file mode 100644
index 0f01e920f9..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_state_vertex.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "cell_context.h"
-#include "cell_state.h"
-
-#include "pipe/draw/draw_context.h"
-
-
-void
-cell_set_vertex_element(struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_element *attrib)
-{
- struct cell_context *cell = cell_context(pipe);
- assert(index < PIPE_ATTRIB_MAX);
- cell->vertex_element[index] = *attrib; /* struct copy */
- cell->dirty |= CELL_NEW_VERTEX;
-
- draw_set_vertex_element(cell->draw, index, attrib);
-}
-
-
-void
-cell_set_vertex_buffer(struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_buffer *buffer)
-{
- struct cell_context *cell = cell_context(pipe);
- assert(index < PIPE_ATTRIB_MAX);
- cell->vertex_buffer[index] = *buffer; /* struct copy */
- cell->dirty |= CELL_NEW_VERTEX;
-
- draw_set_vertex_buffer(cell->draw, index, buffer);
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c
deleted file mode 100644
index fca93e4742..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_surface.c
+++ /dev/null
@@ -1,179 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/util/p_tile.h"
-#include "cell_context.h"
-#include "cell_surface.h"
-
-
-/* Upload data to a rectangular sub-region. Lots of choices how to do this:
- *
- * - memcpy by span to current destination
- * - upload data as new buffer and blit
- *
- * Currently always memcpy.
- */
-static void
-cell_surface_data(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- const void *src, unsigned src_pitch,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- pipe_copy_rect(pipe_surface_map(dst),
- dst->cpp,
- dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
-
- pipe_surface_unmap(dst);
-}
-
-
-static void
-cell_surface_copy(struct pipe_context *pipe,
- unsigned 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->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- do_flip ? -src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : 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->pitch + x) * dst->cpp;
-}
-
-
-#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->pitch > 0);
- assert(width <= dst->pitch);
-
- switch (dst->cpp) {
- case 1:
- {
- ubyte *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
- case 2:
- {
- ushort *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
- case 4:
- {
- unsigned *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
- 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->pitch * 4;
- }
- }
- 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;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_surface.h b/src/mesa/pipe/cell/ppu/cell_surface.h
deleted file mode 100644
index 9e58f32944..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_surface.h
+++ /dev/null
@@ -1,42 +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.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef CELL_SURFACE_H
-#define CELL_SURFACE_H
-
-
-struct cell_context;
-
-
-extern void
-cell_init_surface_functions(struct cell_context *cell);
-
-
-#endif /* SP_SURFACE_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_texture.c b/src/mesa/pipe/cell/ppu/cell_texture.c
deleted file mode 100644
index df178d9ca2..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_texture.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Michel Dänzer <michel@tungstengraphics.com>
- */
-
-#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 "cell_context.h"
-#include "cell_state.h"
-#include "cell_texture.h"
-
-
-/* Simple, maximally packed layout.
- */
-
-static unsigned minify( unsigned d )
-{
- return MAX2(1, d>>1);
-}
-
-
-static void
-cell_texture_layout(struct cell_texture * spt)
-{
- struct pipe_texture *pt = &spt->base;
- unsigned level;
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned depth = pt->depth[0];
-
- spt->buffer_size = 0;
-
- for ( level = pt->first_level ; level <= pt->last_level ; level++ ) {
- pt->width[level] = width;
- pt->height[level] = height;
- pt->depth[level] = depth;
-
- spt->level_offset[level] = spt->buffer_size;
-
- spt->buffer_size += ((pt->compressed) ? MAX2(1, height/4) : height) *
- ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
- width * pt->cpp;
-
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
- }
-}
-
-
-struct pipe_texture *
-cell_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
-{
- struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
- if (!spt)
- return NULL;
-
- spt->base = *templat;
-
- cell_texture_layout(spt);
-
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
-
- if (!spt->buffer) {
- FREE(spt);
- return NULL;
- }
-
- return &spt->base;
-}
-
-
-void
-cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
-{
- if (!*pt)
- return;
-
- /*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
- */
- if (--(*pt)->refcount <= 0) {
- struct cell_texture *spt = cell_texture(*pt);
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
- */
-
- pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
-
- FREE(spt);
- }
- *pt = NULL;
-}
-
-
-/**
- * Called via pipe->get_tex_surface()
- */
-struct pipe_surface *
-cell_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
-{
- struct cell_texture *spt = cell_texture(pt);
- struct pipe_surface *ps;
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->refcount);
- assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = ps->width;
- ps->offset = spt->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
- ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- (pt->compressed ? ps->height/4 : ps->height) *
- ps->width * ps->cpp;
- } else {
- assert(face == 0);
- assert(zslice == 0);
- }
- }
- return ps;
-}
-
-
-
-static void
-tile_copy_data(uint w, uint h, uint tile_size, uint *dst, const uint *src)
-{
- const uint tile_size2 = tile_size * tile_size;
- const uint h_t = h / tile_size, w_t = w / tile_size;
-
- uint it, jt; /* tile counters */
- uint i, j; /* intra-tile counters */
-
- for (it = 0; it < h_t; it++) {
- for (jt = 0; jt < w_t; jt++) {
- /* fill in tile (i, j) */
- uint *tdst = dst + (it * w_t + jt) * tile_size2;
- for (i = 0; i < tile_size; i++) {
- for (j = 0; j < tile_size; j++) {
- const uint srci = it * tile_size + i;
- const uint srcj = jt * tile_size + j;
- *tdst++ = src[srci * h + srcj];
- }
- }
- }
- }
-}
-
-
-
-/**
- * Convert linear texture image data to tiled format for SPU usage.
- */
-static void
-cell_tile_texture(struct cell_context *cell,
- struct cell_texture *texture)
-{
- uint face = 0, level = 0, zslice = 0;
- struct pipe_surface *surf;
- const uint w = texture->base.width[0], h = texture->base.height[0];
- const uint *src;
-
- /* temporary restrictions: */
- assert(w >= TILE_SIZE);
- assert(h >= TILE_SIZE);
- assert(w % TILE_SIZE == 0);
- assert(h % TILE_SIZE == 0);
-
- surf = cell_get_tex_surface(&cell->pipe, &texture->base, face, level, zslice);
- ASSERT(surf);
-
- src = (const uint *) pipe_surface_map(surf);
-
- if (texture->tiled_data) {
- align_free(texture->tiled_data);
- }
- texture->tiled_data = align_malloc(w * h * 4, 16);
-
- tile_copy_data(w, h, TILE_SIZE, texture->tiled_data, src);
-
- pipe_surface_unmap(surf);
-
- pipe_surface_reference(&surf, NULL);
-}
-
-
-
-void
-cell_update_texture_mapping(struct cell_context *cell)
-{
- uint face = 0, level = 0, zslice = 0;
-
- if (cell->texture[0])
- cell_tile_texture(cell, cell->texture[0]);
-#if 0
- if (cell->tex_surf && cell->tex_map) {
- pipe_surface_unmap(cell->tex_surf);
- cell->tex_map = NULL;
- }
-
- /* XXX free old surface */
-
- cell->tex_surf = cell_get_tex_surface(&cell->pipe,
- &cell->texture[0]->base,
- face, level, zslice);
-
- cell->tex_map = pipe_surface_map(cell->tex_surf);
-#endif
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_texture.h b/src/mesa/pipe/cell/ppu/cell_texture.h
deleted file mode 100644
index 0264fed88e..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_texture.h
+++ /dev/null
@@ -1,80 +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 CELL_TEXTURE_H
-#define CELL_TEXTURE_H
-
-
-struct pipe_context;
-struct pipe_texture;
-
-
-/**
- * Subclass of pipe_texture
- */
-struct cell_texture
-{
- struct pipe_texture base;
-
- unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
-
- /* The data is held here:
- */
- struct pipe_buffer *buffer;
- unsigned long buffer_size;
-
- void *tiled_data; /* XXX this may be temporary */ /*ALIGN16*/
-};
-
-
-/** cast wrapper */
-static INLINE struct cell_texture *
-cell_texture(struct pipe_texture *pt)
-{
- return (struct cell_texture *) pt;
-}
-
-
-
-extern struct pipe_texture *
-cell_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
-extern void
-cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-extern struct pipe_surface *
-cell_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice);
-
-
-extern void
-cell_update_texture_mapping(struct cell_context *cell);
-
-
-#endif /* CELL_TEXTURE */
diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.c b/src/mesa/pipe/cell/ppu/cell_vbuf.c
deleted file mode 100644
index e9fafe492e..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_vbuf.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Authors
- * Brian Paul
- */
-
-
-#include "cell_batch.h"
-#include "cell_context.h"
-#include "cell_flush.h"
-#include "cell_spu.h"
-#include "cell_vbuf.h"
-#include "pipe/draw/draw_vbuf.h"
-
-
-/** Allow vertex data to be inlined after RENDER command */
-#define ALLOW_INLINE_VERTS 1
-
-
-/**
- * Subclass of vbuf_render because we need a cell_context pointer in
- * a few places.
- */
-struct cell_vbuf_render
-{
- struct vbuf_render base;
- struct cell_context *cell;
- uint prim; /**< PIPE_PRIM_x */
- uint vertex_size; /**< in bytes */
- void *vertex_buffer; /**< just for debug, really */
- uint vertex_buf; /**< in [0, CELL_NUM_BUFFERS-1] */
-};
-
-
-/** cast wrapper */
-static struct cell_vbuf_render *
-cell_vbuf_render(struct vbuf_render *vbr)
-{
- return (struct cell_vbuf_render *) vbr;
-}
-
-
-
-static const struct vertex_info *
-cell_vbuf_get_vertex_info(struct vbuf_render *vbr)
-{
- struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
- return &cvbr->cell->vertex_info;
-}
-
-
-static void *
-cell_vbuf_allocate_vertices(struct vbuf_render *vbr,
- ushort vertex_size, ushort nr_vertices)
-{
- struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
- /*printf("Alloc verts %u * %u\n", vertex_size, nr_vertices);*/
-
- assert(cvbr->vertex_buf == ~0);
- cvbr->vertex_buf = cell_get_empty_buffer(cvbr->cell);
- cvbr->vertex_buffer = cvbr->cell->buffer[cvbr->vertex_buf];
- cvbr->vertex_size = vertex_size;
- return cvbr->vertex_buffer;
-}
-
-
-static void
-cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
- unsigned vertex_size, unsigned vertices_used)
-{
- struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
- struct cell_context *cell = cvbr->cell;
-
- /*
- printf("%s vertex_buf = %u count = %u\n",
- __FUNCTION__, cvbr->vertex_buf, vertices_used);
- */
-
- /* Tell SPUs they can release the vert buf */
- if (cvbr->vertex_buf != ~0U) {
- struct cell_command_release_verts *release
- = (struct cell_command_release_verts *)
- cell_batch_alloc(cell, sizeof(struct cell_command_release_verts));
- release->opcode = CELL_CMD_RELEASE_VERTS;
- release->vertex_buf = cvbr->vertex_buf;
- }
-
- cvbr->vertex_buf = ~0;
- cell_flush_int(&cell->pipe, 0x0);
-
- assert(vertices == cvbr->vertex_buffer);
- cvbr->vertex_buffer = NULL;
-}
-
-
-
-static void
-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);*/
-}
-
-
-static void
-cell_vbuf_draw(struct vbuf_render *vbr,
- const ushort *indices,
- uint nr_indices)
-{
- struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
- struct cell_context *cell = cvbr->cell;
- float xmin, ymin, xmax, ymax;
- uint i;
- uint nr_vertices = 0, min_index = ~0;
- const void *vertices = cvbr->vertex_buffer;
- const uint vertex_size = cvbr->vertex_size;
-
- for (i = 0; i < nr_indices; i++) {
- if (indices[i] > nr_vertices)
- nr_vertices = indices[i];
- if (indices[i] < min_index)
- min_index = indices[i];
- }
- nr_vertices++;
-
-#if 0
- /*if (min_index > 0)*/
- printf("%s min_index = %u\n", __FUNCTION__, min_index);
-#endif
-
-#if 0
- printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u\n",
- nr_indices, nr_vertices);
- printf(" ");
- for (i = 0; i < nr_indices; i += 3) {
- printf("%u %u %u, ", indices[i+0], indices[i+1], indices[i+2]);
- }
- printf("\n");
-#elif 0
- printf("cell_vbuf_draw() nr_indices = %u nr_verts = %u indexes = [%u %u %u ...]\n",
- nr_indices, nr_vertices,
- indices[0], indices[1], indices[2]);
- printf("ind space = %u, vert space = %u, space = %u\n",
- nr_indices * 2,
- nr_vertices * 4 * cell->vertex_info.size,
- cell_batch_free_space(cell));
-#endif
-
- /* compute x/y bounding box */
- xmin = ymin = 1e50;
- xmax = ymax = -1e50;
- for (i = min_index; i < nr_vertices; i++) {
- const float *v = (float *) ((ubyte *) vertices + i * vertex_size);
- if (v[0] < xmin)
- xmin = v[0];
- if (v[0] > xmax)
- xmax = v[0];
- if (v[1] < ymin)
- ymin = v[1];
- if (v[1] > ymax)
- ymax = v[1];
- }
-#if 0
- printf("PPU Bounds %g, %g .. %g, %g\n", xmin, ymin, xmax, ymax);
- fflush(stdout);
-#endif
-
- if (cvbr->prim != PIPE_PRIM_TRIANGLES)
- return; /* only render tris for now */
-
- /* build/insert batch RENDER command */
- {
- const uint index_bytes = ROUNDUP8(nr_indices * 2);
- const uint vertex_bytes = nr_vertices * 4 * cell->vertex_info.size;
- const uint batch_size = sizeof(struct cell_command_render) + index_bytes;
-
- struct cell_command_render *render
- = (struct cell_command_render *)
- cell_batch_alloc(cell, batch_size);
-
- render->opcode = CELL_CMD_RENDER;
- render->prim_type = cvbr->prim;
-
- render->num_indexes = nr_indices;
- render->min_index = min_index;
-
- /* append indices after render command */
- memcpy(render + 1, indices, nr_indices * 2);
-
- /* if there's room, append vertices after the indices, else leave
- * vertices in the original/separate buffer.
- */
- render->vertex_size = 4 * cell->vertex_info.size;
- render->num_verts = nr_vertices;
- if (ALLOW_INLINE_VERTS &&
- min_index == 0 &&
- vertex_bytes + 16 <= cell_batch_free_space(cell)) {
- /* vertex data inlined, after indices, at 16-byte boundary */
- void *dst = cell_batch_alloc_aligned(cell, vertex_bytes, 16);
- memcpy(dst, vertices, vertex_bytes);
- render->inline_verts = TRUE;
- render->vertex_buf = ~0;
- }
- else {
- /* vertex data in separate buffer */
- render->inline_verts = FALSE;
- ASSERT(cvbr->vertex_buf >= 0);
- render->vertex_buf = cvbr->vertex_buf;
- }
-
- render->xmin = xmin;
- render->ymin = ymin;
- render->xmax = xmax;
- render->ymax = ymax;
- }
-
-#if 0
- /* helpful for debug */
- cell_flush_int(&cell->pipe, PIPE_FLUSH_WAIT);
-#endif
-}
-
-
-static void
-cell_vbuf_destroy(struct vbuf_render *vbr)
-{
- struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
- cvbr->cell->vbuf_render = NULL;
- FREE(cvbr);
-}
-
-
-/**
- * Initialize the post-transform vertex buffer information for the given
- * context.
- */
-void
-cell_init_vbuf(struct cell_context *cell)
-{
- assert(cell->draw);
-
- cell->vbuf_render = CALLOC_STRUCT(cell_vbuf_render);
-
- /* The max number of indexes is what can fix into a batch buffer,
- * minus the render and release-verts commands.
- */
- cell->vbuf_render->base.max_indices
- = (CELL_BUFFER_SIZE
- - sizeof(struct cell_command_render)
- - sizeof(struct cell_command_release_verts))
- / sizeof(ushort);
- cell->vbuf_render->base.max_vertex_buffer_bytes = CELL_BUFFER_SIZE;
-
- cell->vbuf_render->base.get_vertex_info = cell_vbuf_get_vertex_info;
- cell->vbuf_render->base.allocate_vertices = cell_vbuf_allocate_vertices;
- cell->vbuf_render->base.set_primitive = cell_vbuf_set_primitive;
- cell->vbuf_render->base.draw = cell_vbuf_draw;
- cell->vbuf_render->base.release_vertices = cell_vbuf_release_vertices;
- cell->vbuf_render->base.destroy = cell_vbuf_destroy;
-
- cell->vbuf_render->cell = cell;
-#if 1
- cell->vbuf_render->vertex_buf = ~0;
-#endif
-
- cell->vbuf = draw_vbuf_stage(cell->draw, &cell->vbuf_render->base);
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_vbuf.h b/src/mesa/pipe/cell/ppu/cell_vbuf.h
deleted file mode 100644
index d265cbf770..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_vbuf.h
+++ /dev/null
@@ -1,38 +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 CELL_VBUF_H
-#define CELL_VBUF_H
-
-
-struct cell_context;
-
-extern void
-cell_init_vbuf(struct cell_context *cell);
-
-
-#endif /* CELL_VBUF_H */
diff --git a/src/mesa/pipe/cell/ppu/cell_vertex_shader.c b/src/mesa/pipe/cell/ppu/cell_vertex_shader.c
deleted file mode 100644
index 80dd500b34..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_vertex_shader.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * (C) Copyright IBM Corporation 2008
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \file cell_vertex_shader.c
- * Vertex shader interface routines for Cell.
- *
- * \author Ian Romanick <idr@us.ibm.com>
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-#include "pipe/p_winsys.h"
-
-#include "cell_context.h"
-#include "cell_draw_arrays.h"
-#include "cell_spu.h"
-#include "cell_batch.h"
-
-#include "pipe/cell/common.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.h"
-
-/**
- * Run the vertex shader on all vertices in the vertex queue.
- * Called by the draw module when the vertx cache needs to be flushed.
- */
-void
-cell_vertex_shader_queue_flush(struct draw_context *draw)
-{
- struct cell_context *const cell =
- (struct cell_context *) draw->driver_private;
- struct cell_command_vs *const vs = &cell_global.command[0].vs;
- uint64_t *batch;
- struct cell_array_info *array_info;
- unsigned i, j;
-
- assert(draw->vs.queue_nr != 0);
-
- /* XXX: do this on statechange:
- */
- draw_update_vertex_fetch(draw);
-
- for (i = 0; i < draw->vertex_fetch.nr_attrs; i++) {
- batch = cell_batch_alloc(cell, sizeof(batch[0]) + sizeof(*array_info));
-
- batch[0] = CELL_CMD_STATE_VS_ARRAY_INFO;
-
- array_info = (struct cell_array_info *) &batch[1];
- assert(draw->vertex_fetch.src_ptr[i] != NULL);
- array_info->base = (uintptr_t) draw->vertex_fetch.src_ptr[i];
- array_info->attr = i;
- array_info->pitch = draw->vertex_fetch.pitch[i];
- array_info->format = draw->vertex_element[i].src_format;
- }
-
- batch = cell_batch_alloc(cell, sizeof(batch[0])
- + sizeof(struct pipe_viewport_state));
- batch[0] = CELL_CMD_STATE_VIEWPORT;
- (void) memcpy(&batch[1], &draw->viewport,
- sizeof(struct pipe_viewport_state));
-
- cell_batch_flush(cell);
-
- vs->opcode = CELL_CMD_VS_EXECUTE;
- vs->shader.num_outputs = draw->num_vs_outputs;
- vs->shader.declarations = (uintptr_t) draw->machine.Declarations;
- vs->shader.num_declarations = draw->machine.NumDeclarations;
- vs->shader.instructions = (uintptr_t) draw->machine.Instructions;
- vs->shader.num_instructions = draw->machine.NumInstructions;
- vs->shader.uniforms = (uintptr_t) draw->user.constants;
- vs->shader.immediates = (uintptr_t) draw->machine.Imms;
- vs->shader.num_immediates = draw->machine.ImmLimit / 4;
- vs->nr_attrs = draw->vertex_fetch.nr_attrs;
-
- (void) memcpy(vs->plane, draw->plane, sizeof(draw->plane));
- vs->nr_planes = draw->nr_planes;
-
- for (i = 0; i < draw->vs.queue_nr; i += SPU_VERTS_PER_BATCH) {
- const unsigned n = MIN2(SPU_VERTS_PER_BATCH, draw->vs.queue_nr - i);
-
- for (j = 0; j < n; j++) {
- vs->elts[j] = draw->vs.queue[i + j].elt;
- vs->vOut[j] = (uintptr_t) draw->vs.queue[i + j].dest;
- }
-
- for (/* empty */; j < SPU_VERTS_PER_BATCH; j++) {
- vs->elts[j] = vs->elts[0];
- vs->vOut[j] = vs->vOut[0];
- }
-
- vs->num_elts = n;
- send_mbox_message(cell_global.spe_contexts[0], CELL_CMD_VS_EXECUTE);
-
- cell_flush_int(& cell->pipe, PIPE_FLUSH_WAIT);
- }
-
- draw->vs.queue_nr = 0;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_winsys.c b/src/mesa/pipe/cell/ppu/cell_winsys.c
deleted file mode 100644
index ebabce3c8f..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_winsys.c
+++ /dev/null
@@ -1,40 +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.
- *
- **************************************************************************/
-
-
-#include "pipe/p_util.h"
-#include "cell_winsys.h"
-
-
-struct cell_winsys *
-cell_get_winsys(uint format)
-{
- struct cell_winsys *cws = CALLOC_STRUCT(cell_winsys);
- if (cws)
- cws->preferredFormat = format;
- return cws;
-}
diff --git a/src/mesa/pipe/cell/ppu/cell_winsys.h b/src/mesa/pipe/cell/ppu/cell_winsys.h
deleted file mode 100644
index ae2af5696b..0000000000
--- a/src/mesa/pipe/cell/ppu/cell_winsys.h
+++ /dev/null
@@ -1,50 +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 CELL_WINSYS_H
-#define CELL_WINSYS_H
-
-#include "pipe/p_compiler.h"
-
-
-/**
- * Very simple winsys at this time.
- * Will probably eventually add SPU control info.
- */
-struct cell_winsys
-{
- uint preferredFormat;
-};
-
-
-extern struct cell_winsys *
-cell_get_winsys(uint format);
-
-
-
-#endif
diff --git a/src/mesa/pipe/cell/spu/Makefile b/src/mesa/pipe/cell/spu/Makefile
deleted file mode 100644
index f202971d73..0000000000
--- a/src/mesa/pipe/cell/spu/Makefile
+++ /dev/null
@@ -1,72 +0,0 @@
-# Gallium3D Cell driver: SPU code
-
-# This makefile builds the g3d_spu.a file that's linked into the
-# PPU code/library.
-
-
-TOP = ../../../../..
-include $(TOP)/configs/linux-cell
-
-
-PROG = g3d
-
-PROG_SPU = $(PROG)_spu
-PROG_SPU_A = $(PROG)_spu.a
-PROG_SPU_EMBED_O = $(PROG)_spu-embed.o
-
-
-SOURCES = \
- spu_main.c \
- spu_blend.c \
- spu_render.c \
- spu_texture.c \
- spu_tile.c \
- spu_tri.c \
- spu_exec.c \
- spu_util.c \
- spu_vertex_fetch.c \
- spu_vertex_shader.c
-
-SPU_OBJECTS = $(SOURCES:.c=.o) \
-
-SPU_ASM_OUT = $(SOURCES:.c=.s) \
-
-INCLUDE_DIRS = -I$(TOP)/src/mesa
-
-
-.c.o:
- $(SPU_CC) $(SPU_CFLAGS) -c $<
-
-.c.s:
- $(SPU_CC) $(SPU_CFLAGS) -S $<
-
-
-# The .a file will be linked into the main/PPU executable
-default: $(PROG_SPU_A)
-
-$(PROG_SPU_A): $(PROG_SPU_EMBED_O)
- $(SPU_AR) $(SPU_AR_FLAGS) $(PROG_SPU_A) $(PROG_SPU_EMBED_O)
-
-$(PROG_SPU_EMBED_O): $(PROG_SPU)
- $(SPU_EMBED) $(SPU_EMBED_FLAGS) $(PROG_SPU) $(PROG_SPU) $(PROG_SPU_EMBED_O)
-
-$(PROG_SPU): $(SPU_OBJECTS)
- $(SPU_CC) -o $(PROG_SPU) $(SPU_OBJECTS) $(SPU_LFLAGS)
-
-
-
-asmfiles: $(SPU_ASM_OUT)
-
-
-clean:
- rm -f *~ *.o *.a *.d *.s $(PROG_SPU)
-
-
-
-depend: $(SOURCES)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDE_DIRS) $(SOURCES) 2> /dev/null
-
-include depend
-
diff --git a/src/mesa/pipe/cell/spu/spu_blend.c b/src/mesa/pipe/cell/spu/spu_blend.c
deleted file mode 100644
index 23ec0eeb45..0000000000
--- a/src/mesa/pipe/cell/spu/spu_blend.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "spu_main.h"
-#include "spu_blend.h"
-#include "spu_colorpack.h"
-
-
-void
-blend_quad(uint itx, uint ity, vector float colors[4])
-{
- /* simple SRC_ALPHA, ONE_MINUS_SRC_ALPHA blending */
- vector float fbc00 = spu_unpack_color(spu.ctile.ui[ity][itx]);
- vector float fbc01 = spu_unpack_color(spu.ctile.ui[ity][itx+1]);
- vector float fbc10 = spu_unpack_color(spu.ctile.ui[ity+1][itx]);
- vector float fbc11 = spu_unpack_color(spu.ctile.ui[ity+1][itx+1]);
-
- vector float alpha00 = spu_splats(spu_extract(colors[0], 3));
- vector float alpha01 = spu_splats(spu_extract(colors[1], 3));
- vector float alpha10 = spu_splats(spu_extract(colors[2], 3));
- vector float alpha11 = spu_splats(spu_extract(colors[3], 3));
-
- vector float one_minus_alpha00 = spu_sub(spu_splats(1.0f), alpha00);
- vector float one_minus_alpha01 = spu_sub(spu_splats(1.0f), alpha01);
- vector float one_minus_alpha10 = spu_sub(spu_splats(1.0f), alpha10);
- vector float one_minus_alpha11 = spu_sub(spu_splats(1.0f), alpha11);
-
- colors[0] = spu_add(spu_mul(colors[0], alpha00),
- spu_mul(fbc00, one_minus_alpha00));
- colors[1] = spu_add(spu_mul(colors[1], alpha01),
- spu_mul(fbc01, one_minus_alpha01));
- colors[2] = spu_add(spu_mul(colors[2], alpha10),
- spu_mul(fbc10, one_minus_alpha10));
- colors[3] = spu_add(spu_mul(colors[3], alpha11),
- spu_mul(fbc11, one_minus_alpha11));
-}
-
diff --git a/src/mesa/pipe/cell/spu/spu_blend.h b/src/mesa/pipe/cell/spu/spu_blend.h
deleted file mode 100644
index 2b594b578b..0000000000
--- a/src/mesa/pipe/cell/spu/spu_blend.h
+++ /dev/null
@@ -1,37 +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.
- *
- **************************************************************************/
-
-
-#ifndef SPU_BLEND_H
-#define SPU_BLEND_H
-
-
-extern void
-blend_quad(uint itx, uint ity, vector float colors[4]);
-
-
-#endif /* SPU_BLEND_H */
diff --git a/src/mesa/pipe/cell/spu/spu_colorpack.h b/src/mesa/pipe/cell/spu/spu_colorpack.h
deleted file mode 100644
index e9fee8a3a6..0000000000
--- a/src/mesa/pipe/cell/spu/spu_colorpack.h
+++ /dev/null
@@ -1,110 +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 SPU_COLORPACK_H
-#define SPU_COLORPACK_H
-
-
-#include <spu_intrinsics.h>
-
-
-static INLINE unsigned int
-spu_pack_R8G8B8A8(vector float rgba)
-{
- vector unsigned int out = spu_convtu(rgba, 32);
-
- out = spu_shuffle(out, out, ((vector unsigned char) {
- 0, 4, 8, 12, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0 }) );
-
- return spu_extract(out, 0);
-}
-
-
-static INLINE unsigned int
-spu_pack_A8R8G8B8(vector float rgba)
-{
- vector unsigned int out = spu_convtu(rgba, 32);
- out = spu_shuffle(out, out, ((vector unsigned char) {
- 12, 0, 4, 8, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0}) );
- return spu_extract(out, 0);
-}
-
-
-static INLINE unsigned int
-spu_pack_B8G8R8A8(vector float rgba)
-{
- vector unsigned int out = spu_convtu(rgba, 32);
- out = spu_shuffle(out, out, ((vector unsigned char) {
- 8, 4, 0, 12, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0}) );
- return spu_extract(out, 0);
-}
-
-
-static INLINE unsigned int
-spu_pack_color_shuffle(vector float rgba, vector unsigned char shuffle)
-{
- vector unsigned int out = spu_convtu(rgba, 32);
- out = spu_shuffle(out, out, shuffle);
- return spu_extract(out, 0);
-}
-
-
-static INLINE vector float
-spu_unpack_color(uint color)
-{
- vector unsigned int color_u4 = spu_splats(color);
- color_u4 = spu_shuffle(color_u4, color_u4,
- ((vector unsigned char) {
- 0, 0, 0, 0,
- 5, 5, 5, 5,
- 10, 10, 10, 10,
- 15, 15, 15, 15}) );
- return spu_convtf(color_u4, 32);
-}
-
-
-static INLINE vector float
-spu_unpack_A8R8G8B8(uint color)
-{
- vector unsigned int color_u4 = spu_splats(color);
- color_u4 = spu_shuffle(color_u4, color_u4,
- ((vector unsigned char) {
- 5, 5, 5, 5,
- 10, 10, 10, 10,
- 15, 15, 15, 15,
- 0, 0, 0, 0}) );
-
- return spu_convtf(color_u4, 32);
-}
-
-
-#endif /* SPU_COLORPACK_H */
diff --git a/src/mesa/pipe/cell/spu/spu_exec.c b/src/mesa/pipe/cell/spu/spu_exec.c
deleted file mode 100644
index e51008b9b3..0000000000
--- a/src/mesa/pipe/cell/spu/spu_exec.c
+++ /dev/null
@@ -1,1948 +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.
- *
- **************************************************************************/
-
-/**
- * TGSI interpretor/executor.
- *
- * Flow control information:
- *
- * Since we operate on 'quads' (4 pixels or 4 vertices in parallel)
- * flow control statements (IF/ELSE/ENDIF, LOOP/ENDLOOP) require special
- * care since a condition may be true for some quad components but false
- * for other components.
- *
- * We basically execute all statements (even if they're in the part of
- * an IF/ELSE clause that's "not taken") and use a special mask to
- * control writing to destination registers. This is the ExecMask.
- * See store_dest().
- *
- * The ExecMask is computed from three other masks (CondMask, LoopMask and
- * ContMask) which are controlled by the flow control instructions (namely:
- * (IF/ELSE/ENDIF, LOOP/ENDLOOP and CONT).
- *
- *
- * Authors:
- * Michal Krol
- * Brian Paul
- */
-
-#include <libmisc.h>
-#include <spu_mfcio.h>
-#include <transpose_matrix4x4.h>
-#include <simdmath/ceilf4.h>
-#include <simdmath/cosf4.h>
-#include <simdmath/divf4.h>
-#include <simdmath/floorf4.h>
-#include <simdmath/log2f4.h>
-#include <simdmath/powf4.h>
-#include <simdmath/sinf4.h>
-#include <simdmath/sqrtf4.h>
-#include <simdmath/truncf4.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-#include "pipe/tgsi/util/tgsi_util.h"
-#include "spu_exec.h"
-#include "spu_main.h"
-#include "spu_vertex_shader.h"
-
-#define TILE_TOP_LEFT 0
-#define TILE_TOP_RIGHT 1
-#define TILE_BOTTOM_LEFT 2
-#define TILE_BOTTOM_RIGHT 3
-
-/*
- * Shorthand locations of various utility registers (_I = Index, _C = Channel)
- */
-#define TEMP_0_I TGSI_EXEC_TEMP_00000000_I
-#define TEMP_0_C TGSI_EXEC_TEMP_00000000_C
-#define TEMP_7F_I TGSI_EXEC_TEMP_7FFFFFFF_I
-#define TEMP_7F_C TGSI_EXEC_TEMP_7FFFFFFF_C
-#define TEMP_80_I TGSI_EXEC_TEMP_80000000_I
-#define TEMP_80_C TGSI_EXEC_TEMP_80000000_C
-#define TEMP_FF_I TGSI_EXEC_TEMP_FFFFFFFF_I
-#define TEMP_FF_C TGSI_EXEC_TEMP_FFFFFFFF_C
-#define TEMP_1_I TGSI_EXEC_TEMP_ONE_I
-#define TEMP_1_C TGSI_EXEC_TEMP_ONE_C
-#define TEMP_2_I TGSI_EXEC_TEMP_TWO_I
-#define TEMP_2_C TGSI_EXEC_TEMP_TWO_C
-#define TEMP_128_I TGSI_EXEC_TEMP_128_I
-#define TEMP_128_C TGSI_EXEC_TEMP_128_C
-#define TEMP_M128_I TGSI_EXEC_TEMP_MINUS_128_I
-#define TEMP_M128_C TGSI_EXEC_TEMP_MINUS_128_C
-#define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I
-#define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C
-#define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I
-#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_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)))
-
-#define IS_CHANNEL_ENABLED2(INST, CHAN)\
- ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
-
-#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
- if (IS_CHANNEL_ENABLED( INST, CHAN ))
-
-#define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
- if (IS_CHANNEL_ENABLED2( INST, CHAN ))
-
-
-/** The execution mask depends on the conditional mask and the loop mask */
-#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.
- * After this, we can call spu_exec_machine_run() many times.
- */
-void
-spu_exec_machine_init(struct spu_exec_machine *mach,
- uint numSamplers,
- struct spu_sampler *samplers,
- unsigned processor)
-{
- qword zero;
- qword not_zero;
- uint i;
-
- mach->Samplers = samplers;
- mach->Processor = processor;
- mach->Addrs = &mach->Temps[TGSI_EXEC_NUM_TEMPS];
-
- zero = si_xor(zero, zero);
- not_zero = si_xori(zero, 0xff);
-
- /* Setup constants. */
- mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q = zero;
- mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].q = not_zero;
- mach->Temps[TEMP_7F_I].xyzw[TEMP_7F_C].q = si_shli(not_zero, -1);
- mach->Temps[TEMP_80_I].xyzw[TEMP_80_C].q = si_shli(not_zero, 31);
-
- mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q = (qword) spu_splats(1.0f);
- mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].q = (qword) spu_splats(2.0f);
- mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].q = (qword) spu_splats(128.0f);
- mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].q = (qword) spu_splats(-128.0f);
-}
-
-
-static INLINE qword
-micro_abs(qword src)
-{
- return si_rotmi(si_shli(src, 1), -1);
-}
-
-static INLINE qword
-micro_ceil(qword src)
-{
- return (qword) _ceilf4((vec_float4) src);
-}
-
-static INLINE qword
-micro_cos(qword src)
-{
- return (qword) _cosf4((vec_float4) src);
-}
-
-static const qword br_shuf = {
- TILE_BOTTOM_RIGHT + 0, TILE_BOTTOM_RIGHT + 1,
- TILE_BOTTOM_RIGHT + 2, TILE_BOTTOM_RIGHT + 3,
- TILE_BOTTOM_RIGHT + 0, TILE_BOTTOM_RIGHT + 1,
- TILE_BOTTOM_RIGHT + 2, TILE_BOTTOM_RIGHT + 3,
- TILE_BOTTOM_RIGHT + 0, TILE_BOTTOM_RIGHT + 1,
- TILE_BOTTOM_RIGHT + 2, TILE_BOTTOM_RIGHT + 3,
- TILE_BOTTOM_RIGHT + 0, TILE_BOTTOM_RIGHT + 1,
- TILE_BOTTOM_RIGHT + 2, TILE_BOTTOM_RIGHT + 3,
-};
-
-static const qword bl_shuf = {
- TILE_BOTTOM_LEFT + 0, TILE_BOTTOM_LEFT + 1,
- TILE_BOTTOM_LEFT + 2, TILE_BOTTOM_LEFT + 3,
- TILE_BOTTOM_LEFT + 0, TILE_BOTTOM_LEFT + 1,
- TILE_BOTTOM_LEFT + 2, TILE_BOTTOM_LEFT + 3,
- TILE_BOTTOM_LEFT + 0, TILE_BOTTOM_LEFT + 1,
- TILE_BOTTOM_LEFT + 2, TILE_BOTTOM_LEFT + 3,
- TILE_BOTTOM_LEFT + 0, TILE_BOTTOM_LEFT + 1,
- TILE_BOTTOM_LEFT + 2, TILE_BOTTOM_LEFT + 3,
-};
-
-static const qword tl_shuf = {
- TILE_TOP_LEFT + 0, TILE_TOP_LEFT + 1,
- TILE_TOP_LEFT + 2, TILE_TOP_LEFT + 3,
- TILE_TOP_LEFT + 0, TILE_TOP_LEFT + 1,
- TILE_TOP_LEFT + 2, TILE_TOP_LEFT + 3,
- TILE_TOP_LEFT + 0, TILE_TOP_LEFT + 1,
- TILE_TOP_LEFT + 2, TILE_TOP_LEFT + 3,
- TILE_TOP_LEFT + 0, TILE_TOP_LEFT + 1,
- TILE_TOP_LEFT + 2, TILE_TOP_LEFT + 3,
-};
-
-static qword
-micro_ddx(qword src)
-{
- qword bottom_right = si_shufb(src, src, br_shuf);
- qword bottom_left = si_shufb(src, src, bl_shuf);
-
- return si_fs(bottom_right, bottom_left);
-}
-
-static qword
-micro_ddy(qword src)
-{
- qword top_left = si_shufb(src, src, tl_shuf);
- qword bottom_left = si_shufb(src, src, bl_shuf);
-
- return si_fs(top_left, bottom_left);
-}
-
-static INLINE qword
-micro_div(qword src0, qword src1)
-{
- return (qword) _divf4((vec_float4) src0, (vec_float4) src1);
-}
-
-static qword
-micro_flr(qword src)
-{
- return (qword) _floorf4((vec_float4) src);
-}
-
-static qword
-micro_frc(qword src)
-{
- return si_fs(src, (qword) _floorf4((vec_float4) src));
-}
-
-static INLINE qword
-micro_ge(qword src0, qword src1)
-{
- return si_or(si_fceq(src0, src1), si_fcgt(src0, src1));
-}
-
-static qword
-micro_lg2(qword src)
-{
- return (qword) _log2f4((vec_float4) src);
-}
-
-static INLINE qword
-micro_lt(qword src0, qword src1)
-{
- const qword tmp = si_or(si_fceq(src0, src1), si_fcgt(src0, src1));
-
- return si_xori(tmp, 0xff);
-}
-
-static INLINE qword
-micro_max(qword src0, qword src1)
-{
- return si_selb(src1, src0, si_fcgt(src0, src1));
-}
-
-static INLINE qword
-micro_min(qword src0, qword src1)
-{
- return si_selb(src0, src1, si_fcgt(src0, src1));
-}
-
-static qword
-micro_neg(qword src)
-{
- return si_xor(src, (qword) spu_splats(0x80000000));
-}
-
-static qword
-micro_set_sign(qword src)
-{
- return si_or(src, (qword) spu_splats(0x80000000));
-}
-
-static qword
-micro_pow(qword src0, qword src1)
-{
- return (qword) _powf4((vec_float4) src0, (vec_float4) src1);
-}
-
-static qword
-micro_rnd(qword src)
-{
- const qword half = (qword) spu_splats(0.5f);
-
- /* May be able to use _roundf4. There may be some difference, though.
- */
- return (qword) _floorf4((vec_float4) si_fa(src, half));
-}
-
-static INLINE qword
-micro_ishr(qword src0, qword src1)
-{
- return si_rotma(src0, si_sfi(src1, 0));
-}
-
-static qword
-micro_trunc(qword src)
-{
- return (qword) _truncf4((vec_float4) src);
-}
-
-static qword
-micro_sin(qword src)
-{
- return (qword) _sinf4((vec_float4) src);
-}
-
-static INLINE qword
-micro_sqrt(qword src)
-{
- return (qword) _sqrtf4((vec_float4) src);
-}
-
-static void
-fetch_src_file_channel(
- const struct spu_exec_machine *mach,
- const uint file,
- const uint swizzle,
- const union spu_exec_channel *index,
- union spu_exec_channel *chan )
-{
- switch( swizzle ) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- switch( file ) {
- case TGSI_FILE_CONSTANT: {
- unsigned char buffer[32] ALIGN16_ATTRIB;
- unsigned i;
-
- for (i = 0; i < 4; i++) {
- const float *ptr = mach->Consts[index->i[i]];
- const uint64_t addr = (uint64_t)(uintptr_t) ptr;
- const unsigned size = ((addr & 0x0f) == 0) ? 16 : 32;
-
- mfc_get(buffer, addr & ~0x0f, size, TAG_VERTEX_BUFFER, 0, 0);
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
-
- (void) memcpy(& chan->f[i], &buffer[(addr & 0x0f)
- + (sizeof(float) * swizzle)], sizeof(float));
- }
- break;
- }
-
- case TGSI_FILE_INPUT:
- chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Inputs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- case TGSI_FILE_TEMPORARY:
- chan->u[0] = mach->Temps[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Temps[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Temps[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Temps[index->i[3]].xyzw[swizzle].u[3];
- 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 );
-
- chan->f[0] = mach->Imms[index->i[0]][swizzle];
- chan->f[1] = mach->Imms[index->i[1]][swizzle];
- chan->f[2] = mach->Imms[index->i[2]][swizzle];
- chan->f[3] = mach->Imms[index->i[3]][swizzle];
- break;
-
- case TGSI_FILE_ADDRESS:
- chan->u[0] = mach->Addrs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Addrs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Addrs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- case TGSI_FILE_OUTPUT:
- /* vertex/fragment output vars can be read too */
- chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Outputs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Outputs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Outputs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- default:
- assert( 0 );
- }
- break;
-
- case TGSI_EXTSWIZZLE_ZERO:
- *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C];
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C];
- break;
-
- default:
- assert( 0 );
- }
-}
-
-static void
-fetch_source(
- const struct spu_exec_machine *mach,
- union spu_exec_channel *chan,
- const struct tgsi_full_src_register *reg,
- const uint chan_index )
-{
- union spu_exec_channel index;
- uint swizzle;
-
- index.i[0] =
- index.i[1] =
- index.i[2] =
- index.i[3] = reg->SrcRegister.Index;
-
- if (reg->SrcRegister.Indirect) {
- union spu_exec_channel index2;
- union spu_exec_channel indir_index;
-
- index2.i[0] =
- index2.i[1] =
- index2.i[2] =
- index2.i[3] = reg->SrcRegisterInd.Index;
-
- swizzle = tgsi_util_get_src_register_swizzle(&reg->SrcRegisterInd,
- CHAN_X);
- fetch_src_file_channel(
- mach,
- reg->SrcRegisterInd.File,
- swizzle,
- &index2,
- &indir_index );
-
- index.q = si_a(index.q, indir_index.q);
- }
-
- if( reg->SrcRegister.Dimension ) {
- switch( reg->SrcRegister.File ) {
- case TGSI_FILE_INPUT:
- index.q = si_mpyi(index.q, 17);
- break;
- case TGSI_FILE_CONSTANT:
- index.q = si_shli(index.q, 12);
- break;
- default:
- assert( 0 );
- }
-
- index.i[0] += reg->SrcRegisterDim.Index;
- index.i[1] += reg->SrcRegisterDim.Index;
- index.i[2] += reg->SrcRegisterDim.Index;
- index.i[3] += reg->SrcRegisterDim.Index;
-
- if (reg->SrcRegisterDim.Indirect) {
- union spu_exec_channel index2;
- union spu_exec_channel indir_index;
-
- index2.i[0] =
- index2.i[1] =
- index2.i[2] =
- index2.i[3] = reg->SrcRegisterDimInd.Index;
-
- swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterDimInd, CHAN_X );
- fetch_src_file_channel(
- mach,
- reg->SrcRegisterDimInd.File,
- swizzle,
- &index2,
- &indir_index );
-
- index.q = si_a(index.q, indir_index.q);
- }
- }
-
- swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
- fetch_src_file_channel(
- mach,
- reg->SrcRegister.File,
- swizzle,
- &index,
- chan );
-
- switch (tgsi_util_get_full_src_register_sign_mode( reg, chan_index )) {
- case TGSI_UTIL_SIGN_CLEAR:
- chan->q = micro_abs(chan->q);
- break;
-
- case TGSI_UTIL_SIGN_SET:
- chan->q = micro_set_sign(chan->q);
- break;
-
- case TGSI_UTIL_SIGN_TOGGLE:
- chan->q = micro_neg(chan->q);
- break;
-
- case TGSI_UTIL_SIGN_KEEP:
- break;
- }
-
- if (reg->SrcRegisterExtMod.Complement) {
- chan->q = si_fs(mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q, chan->q);
- }
-}
-
-static void
-store_dest(
- struct spu_exec_machine *mach,
- const union spu_exec_channel *chan,
- const struct tgsi_full_dst_register *reg,
- const struct tgsi_full_instruction *inst,
- uint chan_index )
-{
- union spu_exec_channel *dst;
-
- switch( reg->DstRegister.File ) {
- case TGSI_FILE_NULL:
- return;
-
- case TGSI_FILE_OUTPUT:
- dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
- + reg->DstRegister.Index].xyzw[chan_index];
- break;
-
- case TGSI_FILE_TEMPORARY:
- dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index];
- break;
-
- case TGSI_FILE_ADDRESS:
- dst = &mach->Addrs[reg->DstRegister.Index].xyzw[chan_index];
- 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];
- break;
-
- case TGSI_SAT_ZERO_ONE:
- /* XXX need to obey ExecMask here */
- dst->q = micro_max(chan->q, mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q);
- dst->q = micro_min(dst->q, mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q);
- break;
-
- case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
- break;
-
- default:
- assert( 0 );
- }
-}
-
-#define FETCH(VAL,INDEX,CHAN)\
- fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
-
-#define STORE(VAL,INDEX,CHAN)\
- store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
-
-
-/**
- * Execute ARB-style KIL which is predicated by a src register.
- * Kill fragment if any of the four values is less than zero.
- */
-static void
-exec_kilp(struct spu_exec_machine *mach,
- const struct tgsi_full_instruction *inst)
-{
- uint uniquemask;
- uint chan_index;
- uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
- union spu_exec_channel r[1];
-
- /* This mask stores component bits that were already tested. Note that
- * we test if the value is less than zero, so 1.0 and 0.0 need not to be
- * tested. */
- uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
-
- for (chan_index = 0; chan_index < 4; chan_index++)
- {
- uint swizzle;
- uint i;
-
- /* unswizzle channel */
- swizzle = tgsi_util_get_full_src_register_extswizzle (
- &inst->FullSrcRegisters[0],
- chan_index);
-
- /* check if the component has not been already tested */
- if (uniquemask & (1 << swizzle))
- continue;
- uniquemask |= 1 << swizzle;
-
- FETCH(&r[0], 0, chan_index);
- for (i = 0; i < 4; i++)
- if (r[0].f[i] < 0.0f)
- kilmask |= 1 << i;
- }
-
- mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
-}
-
-
-/*
- * Fetch a texel using STR texture coordinates.
- */
-static void
-fetch_texel( struct spu_sampler *sampler,
- const union spu_exec_channel *s,
- const union spu_exec_channel *t,
- const union spu_exec_channel *p,
- float lodbias, /* XXX should be float[4] */
- union spu_exec_channel *r,
- union spu_exec_channel *g,
- union spu_exec_channel *b,
- union spu_exec_channel *a )
-{
- qword rgba[4];
- qword out[4];
-
- sampler->get_samples(sampler, s->f, t->f, p->f, lodbias, (float *) rgba);
-
- _transpose_matrix4x4(out, rgba);
- r->q = out[0];
- g->q = out[1];
- b->q = out[2];
- a->q = out[3];
-}
-
-
-static void
-exec_tex(struct spu_exec_machine *mach,
- const struct tgsi_full_instruction *inst,
- boolean biasLod)
-{
- const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
- union spu_exec_channel r[8];
- uint chan_index;
- float lodBias;
-
- /* printf("Sampler %u unit %u\n", sampler, unit); */
-
- switch (inst->InstructionExtTexture.Texture) {
- case TGSI_TEXTURE_1D:
-
- FETCH(&r[0], 0, CHAN_X);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[1], 0, CHAN_W);
- r[0].q = micro_div(r[0].q, r[1].q);
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[1], 0, CHAN_W);
- lodBias = r[2].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */
- &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
- break;
-
- case TGSI_TEXTURE_2D:
- case TGSI_TEXTURE_RECT:
-
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[3], 0, CHAN_W);
- r[0].q = micro_div(r[0].q, r[3].q);
- r[1].q = micro_div(r[1].q, r[3].q);
- r[2].q = micro_div(r[2].q, r[3].q);
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias, /* inputs */
- &r[0], &r[1], &r[2], &r[3]); /* outputs */
- break;
-
- case TGSI_TEXTURE_3D:
- case TGSI_TEXTURE_CUBE:
-
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[3], 0, CHAN_W);
- r[0].q = micro_div(r[0].q, r[3].q);
- r[1].q = micro_div(r[1].q, r[3].q);
- r[2].q = micro_div(r[2].q, r[3].q);
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias,
- &r[0], &r[1], &r[2], &r[3]);
- break;
-
- default:
- assert (0);
- }
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[chan_index], 0, chan_index );
- }
-}
-
-
-
-static void
-constant_interpolation(
- struct spu_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- mach->Inputs[attrib].xyzw[chan].f[i] = mach->InterpCoefs[attrib].a0[chan];
- }
-}
-
-static void
-linear_interpolation(
- struct spu_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- const float x = mach->QuadPos.xyzw[0].f[0];
- const float y = mach->QuadPos.xyzw[1].f[0];
- const float dadx = mach->InterpCoefs[attrib].dadx[chan];
- const float dady = mach->InterpCoefs[attrib].dady[chan];
- const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
- mach->Inputs[attrib].xyzw[chan].f[0] = a0;
- mach->Inputs[attrib].xyzw[chan].f[1] = a0 + dadx;
- mach->Inputs[attrib].xyzw[chan].f[2] = a0 + dady;
- mach->Inputs[attrib].xyzw[chan].f[3] = a0 + dadx + dady;
-}
-
-static void
-perspective_interpolation(
- struct spu_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- const float x = mach->QuadPos.xyzw[0].f[0];
- const float y = mach->QuadPos.xyzw[1].f[0];
- const float dadx = mach->InterpCoefs[attrib].dadx[chan];
- const float dady = mach->InterpCoefs[attrib].dady[chan];
- const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
- const float *w = mach->QuadPos.xyzw[3].f;
- /* divide by W here */
- mach->Inputs[attrib].xyzw[chan].f[0] = a0 / w[0];
- mach->Inputs[attrib].xyzw[chan].f[1] = (a0 + dadx) / w[1];
- mach->Inputs[attrib].xyzw[chan].f[2] = (a0 + dady) / w[2];
- mach->Inputs[attrib].xyzw[chan].f[3] = (a0 + dadx + dady) / w[3];
-}
-
-
-typedef void (* interpolation_func)(
- struct spu_exec_machine *mach,
- unsigned attrib,
- unsigned chan );
-
-static void
-exec_declaration(struct spu_exec_machine *mach,
- const struct tgsi_full_declaration *decl)
-{
- if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
- unsigned first, last, mask;
- interpolation_func interp;
-
- assert( decl->Declaration.Declare == TGSI_DECLARE_RANGE );
-
- first = decl->u.DeclarationRange.First;
- last = decl->u.DeclarationRange.Last;
- mask = decl->Declaration.UsageMask;
-
- switch( decl->Interpolation.Interpolate ) {
- case TGSI_INTERPOLATE_CONSTANT:
- interp = constant_interpolation;
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- interp = linear_interpolation;
- break;
-
- case TGSI_INTERPOLATE_PERSPECTIVE:
- interp = perspective_interpolation;
- break;
-
- default:
- assert( 0 );
- }
-
- if( mask == TGSI_WRITEMASK_XYZW ) {
- unsigned i, j;
-
- for( i = first; i <= last; i++ ) {
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- interp( mach, i, j );
- }
- }
- }
- else {
- unsigned i, j;
-
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- if( mask & (1 << j) ) {
- for( i = first; i <= last; i++ ) {
- interp( mach, i, j );
- }
- }
- }
- }
- }
- }
-}
-
-static void
-exec_instruction(
- struct spu_exec_machine *mach,
- const struct tgsi_full_instruction *inst,
- int *pc )
-{
- uint chan_index;
- union spu_exec_channel r[8];
-
- (*pc)++;
-
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ARL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = si_cflts(r[0].q, 0);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MOV:
- /* TGSI_OPCODE_SWZ */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LIT:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_X );
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- r[0].q = micro_max(r[0].q, mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q);
- STORE( &r[0], 0, CHAN_Y );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[1], 0, CHAN_Y );
- r[1].q = micro_max(r[1].q, mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q);
-
- FETCH( &r[2], 0, CHAN_W );
- r[2].q = micro_min(r[2].q, mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].q);
- r[2].q = micro_max(r[2].q, mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].q);
- r[1].q = micro_pow(r[1].q, r[2].q);
-
- /* r0 = (r0 > 0.0) ? r1 : 0.0
- */
- r[0].q = si_fcgt(r[0].q, mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q);
- r[0].q = si_selb(mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q, r[1].q,
- r[0].q);
- STORE( &r[0], 0, CHAN_Z );
- }
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_RCP:
- /* TGSI_OPCODE_RECIP */
- FETCH( &r[0], 0, CHAN_X );
- r[0].q = micro_div(mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q, r[0].q);
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_RSQ:
- /* TGSI_OPCODE_RECIPSQRT */
- FETCH( &r[0], 0, CHAN_X );
- r[0].q = micro_sqrt(r[0].q);
- r[0].q = micro_div(mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q, r[0].q);
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_EXP:
- assert (0);
- break;
-
- case TGSI_OPCODE_LOG:
- assert (0);
- break;
-
- case TGSI_OPCODE_MUL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index )
- {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- r[0].q = si_fm(r[0].q, r[1].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_ADD:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = si_fa(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP3:
- /* TGSI_OPCODE_DOT3 */
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- r[0].q = si_fm(r[0].q, r[1].q);
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
-
- FETCH( &r[1], 0, CHAN_Z );
- FETCH( &r[2], 1, CHAN_Z );
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP4:
- /* TGSI_OPCODE_DOT4 */
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- r[0].q = si_fm(r[0].q, r[1].q);
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FETCH(&r[1], 0, CHAN_W);
- FETCH(&r[2], 1, CHAN_W);
-
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DST:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- FETCH( &r[0], 0, CHAN_Y );
- FETCH( &r[1], 1, CHAN_Y);
- r[0].q = si_fm(r[0].q, r[1].q);
- STORE( &r[0], 0, CHAN_Y );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_Z );
- STORE( &r[0], 0, CHAN_Z );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- FETCH( &r[0], 1, CHAN_W );
- STORE( &r[0], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MIN:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- r[0].q = micro_min(r[0].q, r[1].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_MAX:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- r[0].q = micro_max(r[0].q, r[1].q);
-
- STORE(&r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLT:
- /* TGSI_OPCODE_SETLT */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
-
- r[0].q = micro_ge(r[0].q, r[1].q);
- r[0].q = si_xori(r[0].q, 0xff);
-
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SGE:
- /* TGSI_OPCODE_SETGE */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = micro_ge(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MAD:
- /* TGSI_OPCODE_MADD */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- FETCH( &r[2], 2, chan_index );
- r[0].q = si_fma(r[0].q, r[1].q, r[2].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SUB:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- r[0].q = si_fs(r[0].q, r[1].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_LERP:
- /* TGSI_OPCODE_LRP */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
- FETCH(&r[2], 2, chan_index);
-
- r[1].q = si_fs(r[1].q, r[2].q);
- r[0].q = si_fma(r[0].q, r[1].q, r[2].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_CND:
- assert (0);
- break;
-
- case TGSI_OPCODE_CND0:
- assert (0);
- break;
-
- case TGSI_OPCODE_DOT2ADD:
- /* TGSI_OPCODE_DP2A */
- assert (0);
- break;
-
- case TGSI_OPCODE_INDEX:
- assert (0);
- break;
-
- case TGSI_OPCODE_NEGATE:
- assert (0);
- break;
-
- case TGSI_OPCODE_FRAC:
- /* TGSI_OPCODE_FRC */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_frc(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CLAMP:
- assert (0);
- break;
-
- case TGSI_OPCODE_FLOOR:
- /* TGSI_OPCODE_FLR */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_flr(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_ROUND:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_rnd(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_EXPBASE2:
- /* TGSI_OPCODE_EX2 */
- FETCH(&r[0], 0, CHAN_X);
-
- r[0].q = micro_pow(mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].q, r[0].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LOGBASE2:
- /* TGSI_OPCODE_LG2 */
- FETCH( &r[0], 0, CHAN_X );
- r[0].q = micro_lg2(r[0].q);
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_POWER:
- /* TGSI_OPCODE_POW */
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- r[0].q = micro_pow(r[0].q, r[1].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CROSSPRODUCT:
- /* TGSI_OPCODE_XPD */
- FETCH(&r[0], 0, CHAN_Y);
- FETCH(&r[1], 1, CHAN_Z);
- FETCH(&r[3], 0, CHAN_Z);
- FETCH(&r[4], 1, CHAN_Y);
-
- /* r2 = (r0 * r1) - (r3 * r5)
- */
- r[2].q = si_fm(r[3].q, r[5].q);
- r[2].q = si_fms(r[0].q, r[1].q, r[2].q);
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &r[2], 0, CHAN_X );
- }
-
- FETCH(&r[2], 1, CHAN_X);
- FETCH(&r[5], 0, CHAN_X);
-
- /* r3 = (r3 * r2) - (r1 * r5)
- */
- r[1].q = si_fm(r[1].q, r[5].q);
- r[3].q = si_fms(r[3].q, r[2].q, r[1].q);
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- STORE( &r[3], 0, CHAN_Y );
- }
-
- /* r5 = (r5 * r4) - (r0 * r2)
- */
- r[0].q = si_fm(r[0].q, r[2].q);
- r[5].q = si_fms(r[5].q, r[4].q, r[0].q);
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- STORE( &r[5], 0, CHAN_Z );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MULTIPLYMATRIX:
- assert (0);
- break;
-
- case TGSI_OPCODE_ABS:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
-
- r[0].q = micro_abs(r[0].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_RCC:
- assert (0);
- break;
-
- case TGSI_OPCODE_DPH:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- r[0].q = si_fm(r[0].q, r[1].q);
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FETCH(&r[1], 1, CHAN_W);
-
- r[0].q = si_fa(r[0].q, r[1].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_COS:
- FETCH(&r[0], 0, CHAN_X);
-
- r[0].q = micro_cos(r[0].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DDX:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_ddx(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DDY:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_ddy(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_KILP:
- exec_kilp (mach, inst);
- break;
-
- case TGSI_OPCODE_KIL:
- /* for enabled ExecMask bits, set the killed bit */
- mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= mach->ExecMask;
- break;
-
- case TGSI_OPCODE_PK2H:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK2US:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK4B:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK4UB:
- assert (0);
- break;
-
- case TGSI_OPCODE_RFL:
- assert (0);
- break;
-
- case TGSI_OPCODE_SEQ:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
-
- r[0].q = si_fceq(r[0].q, r[1].q);
-
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SFL:
- assert (0);
- break;
-
- case TGSI_OPCODE_SGT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = si_fcgt(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SIN:
- FETCH( &r[0], 0, CHAN_X );
- r[0].q = micro_sin(r[0].q);
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
-
- r[0].q = si_fcgt(r[0].q, r[1].q);
- r[0].q = si_xori(r[0].q, 0xff);
-
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SNE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
-
- r[0].q = si_fceq(r[0].q, r[1].q);
- r[0].q = si_xori(r[0].q, 0xff);
-
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_STR:
- assert (0);
- break;
-
- case TGSI_OPCODE_TEX:
- /* simple texture lookup */
- /* src[0] = texcoord */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, FALSE);
- break;
-
- case TGSI_OPCODE_TXB:
- /* Texture lookup with lod bias */
- /* src[0] = texcoord (src[0].w = load bias) */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE);
- break;
-
- case TGSI_OPCODE_TXD:
- /* Texture lookup with explict partial derivatives */
- /* src[0] = texcoord */
- /* src[1] = d[strq]/dx */
- /* src[2] = d[strq]/dy */
- /* src[3] = sampler unit */
- assert (0);
- break;
-
- case TGSI_OPCODE_TXL:
- /* Texture lookup with explit LOD */
- /* src[0] = texcoord (src[0].w = load bias) */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE);
- break;
-
- case TGSI_OPCODE_UP2H:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP2US:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP4B:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP4UB:
- assert (0);
- break;
-
- case TGSI_OPCODE_X2D:
- assert (0);
- break;
-
- case TGSI_OPCODE_ARA:
- assert (0);
- break;
-
- case TGSI_OPCODE_ARR:
- assert (0);
- break;
-
- case TGSI_OPCODE_BRA:
- assert (0);
- break;
-
- case TGSI_OPCODE_CAL:
- /* skip the call if no execution channels are enabled */
- if (mach->ExecMask) {
- /* do the call */
-
- /* push the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
- mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
-
- assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
- mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
-
- /* note that PC was already incremented above */
- mach->CallStack[mach->CallStackTop++] = *pc;
- *pc = inst->InstructionExtLabel.Label;
- }
- break;
-
- case TGSI_OPCODE_RET:
- mach->FuncMask &= ~mach->ExecMask;
- UPDATE_EXEC_MASK(mach);
-
- if (mach->ExecMask == 0x0) {
- /* really return now (otherwise, keep executing */
-
- if (mach->CallStackTop == 0) {
- /* returning from main() */
- *pc = -1;
- return;
- }
- *pc = mach->CallStack[--mach->CallStackTop];
-
- /* pop the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop > 0);
- mach->CondMask = mach->CondStack[--mach->CondStackTop];
- assert(mach->LoopStackTop > 0);
- mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[--mach->ContStackTop];
- assert(mach->FuncStackTop > 0);
- mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
-
- UPDATE_EXEC_MASK(mach);
- }
- break;
-
- case TGSI_OPCODE_SSG:
- assert (0);
- break;
-
- case TGSI_OPCODE_CMP:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
- FETCH(&r[2], 2, chan_index);
-
- /* r0 = (r0 < 0.0) ? r1 : r2
- */
- r[3].q = si_xor(r[3].q, r[3].q);
- r[0].q = micro_lt(r[0].q, r[3].q);
- r[0].q = si_selb(r[1].q, r[2].q, r[0].q);
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_SCS:
- if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) || IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- FETCH( &r[0], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
- r[1].q = micro_cos(r[0].q);
- STORE( &r[1], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- r[1].q = micro_sin(r[0].q);
- STORE( &r[1], 0, CHAN_Y );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- STORE( &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, CHAN_Z );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_NRM:
- assert (0);
- break;
-
- case TGSI_OPCODE_DIV:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_DP2:
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- r[0].q = si_fm(r[0].q, r[1].q);
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- r[0].q = si_fma(r[1].q, r[2].q, r[0].q);
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_IF:
- /* push CondMask */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
- mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- FETCH( &r[0], 0, CHAN_X );
- /* update CondMask */
- if( ! r[0].u[0] ) {
- mach->CondMask &= ~0x1;
- }
- if( ! r[0].u[1] ) {
- mach->CondMask &= ~0x2;
- }
- if( ! r[0].u[2] ) {
- mach->CondMask &= ~0x4;
- }
- if( ! r[0].u[3] ) {
- mach->CondMask &= ~0x8;
- }
- UPDATE_EXEC_MASK(mach);
- /* Todo: If CondMask==0, jump to ELSE */
- break;
-
- case TGSI_OPCODE_ELSE:
- /* invert CondMask wrt previous mask */
- {
- uint prevMask;
- assert(mach->CondStackTop > 0);
- prevMask = mach->CondStack[mach->CondStackTop - 1];
- mach->CondMask = ~mach->CondMask & prevMask;
- UPDATE_EXEC_MASK(mach);
- /* Todo: If CondMask==0, jump to ENDIF */
- }
- break;
-
- case TGSI_OPCODE_ENDIF:
- /* pop CondMask */
- assert(mach->CondStackTop > 0);
- mach->CondMask = mach->CondStack[--mach->CondStackTop];
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_END:
- /* halt execution */
- *pc = -1;
- break;
-
- case TGSI_OPCODE_REP:
- assert (0);
- break;
-
- case TGSI_OPCODE_ENDREP:
- assert (0);
- break;
-
- case TGSI_OPCODE_PUSHA:
- assert (0);
- break;
-
- case TGSI_OPCODE_POPA:
- assert (0);
- break;
-
- case TGSI_OPCODE_CEIL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_ceil(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_I2F:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = si_csflt(r[0].q, 0);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_NOT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = si_xorbi(r[0].q, 0xff);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_TRUNC:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- r[0].q = micro_trunc(r[0].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SHL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
-
- r[0].q = si_shl(r[0].q, r[1].q);
-
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SHR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = micro_ishr(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_AND:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = si_and(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_OR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = si_or(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MOD:
- assert (0);
- break;
-
- case TGSI_OPCODE_XOR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- r[0].q = si_xor(r[0].q, r[1].q);
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SAD:
- assert (0);
- break;
-
- case TGSI_OPCODE_TXF:
- assert (0);
- break;
-
- case TGSI_OPCODE_TXQ:
- assert (0);
- break;
-
- case TGSI_OPCODE_EMIT:
- mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += 16;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
- break;
-
- case TGSI_OPCODE_ENDPRIM:
- mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]++;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0;
- break;
-
- case TGSI_OPCODE_LOOP:
- /* fall-through (for now) */
- case TGSI_OPCODE_BGNLOOP2:
- /* push LoopMask and ContMasks */
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
- break;
-
- case TGSI_OPCODE_ENDLOOP:
- /* fall-through (for now at least) */
- case TGSI_OPCODE_ENDLOOP2:
- /* Restore ContMask, but don't pop */
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
- if (mach->LoopMask) {
- /* repeat loop: jump to instruction just past BGNLOOP */
- *pc = inst->InstructionExtLabel.Label + 1;
- }
- else {
- /* exit loop: pop LoopMask */
- assert(mach->LoopStackTop > 0);
- mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- /* pop ContMask */
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[--mach->ContStackTop];
- }
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_BRK:
- /* turn off loop channels for each enabled exec channel */
- mach->LoopMask &= ~mach->ExecMask;
- /* Todo: if mach->LoopMask == 0, jump to end of loop */
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_CONT:
- /* turn off cont channels for each enabled exec channel */
- mach->ContMask &= ~mach->ExecMask;
- /* Todo: if mach->LoopMask == 0, jump to end of loop */
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_BGNSUB:
- /* no-op */
- break;
-
- case TGSI_OPCODE_ENDSUB:
- /* no-op */
- break;
-
- case TGSI_OPCODE_NOISE1:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE2:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE3:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE4:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOP:
- break;
-
- default:
- assert( 0 );
- }
-}
-
-
-/**
- * Run TGSI interpreter.
- * \return bitmask of "alive" quad components
- */
-uint
-spu_exec_machine_run( struct spu_exec_machine *mach )
-{
- uint i;
- int pc = 0;
-
- mach->CondMask = 0xf;
- mach->LoopMask = 0xf;
- mach->ContMask = 0xf;
- 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->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
- mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
-
- if( mach->Processor == TGSI_PROCESSOR_GEOMETRY ) {
- mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0] = 0;
- mach->Primitives[0] = 0;
- }
-
-
- /* execute declarations (interpolants) */
- if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
- for (i = 0; i < mach->NumDeclarations; i++) {
- uint8_t buffer[sizeof(struct tgsi_full_declaration) + 32] ALIGN16_ATTRIB;
- struct tgsi_full_declaration decl;
- unsigned long decl_addr = (unsigned long) (mach->Declarations+i);
- unsigned size = ((sizeof(decl) + (decl_addr & 0x0f) + 0x0f) & ~0x0f);
-
- mfc_get(buffer, decl_addr & ~0x0f, size, TAG_INSTRUCTION_FETCH, 0, 0);
- wait_on_mask(1 << TAG_INSTRUCTION_FETCH);
-
- memcpy(& decl, buffer + (decl_addr & 0x0f), sizeof(decl));
- exec_declaration( mach, &decl );
- }
- }
-
- /* execute instructions, until pc is set to -1 */
- while (pc != -1) {
- uint8_t buffer[sizeof(struct tgsi_full_instruction) + 32] ALIGN16_ATTRIB;
- struct tgsi_full_instruction inst;
- unsigned long inst_addr = (unsigned long) (mach->Instructions + pc);
- unsigned size = ((sizeof(inst) + (inst_addr & 0x0f) + 0x0f) & ~0x0f);
-
- assert(pc < mach->NumInstructions);
- mfc_get(buffer, inst_addr & ~0x0f, size, TAG_INSTRUCTION_FETCH, 0, 0);
- wait_on_mask(1 << TAG_INSTRUCTION_FETCH);
-
- memcpy(& inst, buffer + (inst_addr & 0x0f), sizeof(inst));
- exec_instruction( mach, & inst, &pc );
- }
-
-#if 0
- /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */
- if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
- /*
- * Scale back depth component.
- */
- for (i = 0; i < 4; i++)
- mach->Outputs[0].xyzw[2].f[i] *= ctx->DrawBuffer->_DepthMaxF;
- }
-#endif
-
- return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
-}
-
-
diff --git a/src/mesa/pipe/cell/spu/spu_exec.h b/src/mesa/pipe/cell/spu/spu_exec.h
deleted file mode 100644
index b4c7661ef6..0000000000
--- a/src/mesa/pipe/cell/spu/spu_exec.h
+++ /dev/null
@@ -1,172 +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.
- *
- **************************************************************************/
-
-#if !defined SPU_EXEC_H
-#define SPU_EXEC_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-/**
- * Registers may be treated as float, signed int or unsigned int.
- */
-union spu_exec_channel
-{
- float f[QUAD_SIZE];
- int i[QUAD_SIZE];
- unsigned u[QUAD_SIZE];
- qword q;
-};
-
-/**
- * A vector[RGBA] of channels[4 pixels]
- */
-struct spu_exec_vector
-{
- union spu_exec_channel xyzw[NUM_CHANNELS];
-};
-
-/**
- * For fragment programs, information for computing fragment input
- * values from plane equation of the triangle/line.
- */
-struct spu_interp_coef
-{
- float a0[NUM_CHANNELS]; /* in an xyzw layout */
- float dadx[NUM_CHANNELS];
- float dady[NUM_CHANNELS];
-};
-
-
-struct softpipe_tile_cache; /**< Opaque to TGSI */
-
-/**
- * Information for sampling textures, which must be implemented
- * by code outside the TGSI executor.
- */
-struct spu_sampler
-{
- const struct pipe_sampler_state *state;
- struct pipe_texture *texture;
- /** Get samples for four fragments in a quad */
- void (*get_samples)(struct spu_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE]);
- void *pipe; /*XXX temporary*/
- struct softpipe_tile_cache *cache;
-};
-
-
-/**
- * Run-time virtual machine state for executing TGSI shader.
- */
-struct spu_exec_machine
-{
- /*
- * 32 program temporaries
- * 4 internal temporaries
- * 1 address
- */
- struct spu_exec_vector Temps[TGSI_EXEC_NUM_TEMPS
- + TGSI_EXEC_NUM_ADDRS + 1]
- ALIGN16_ATTRIB;
-
- struct spu_exec_vector *Addrs;
-
- struct spu_sampler *Samplers;
-
- float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
- unsigned ImmLimit;
- float (*Consts)[4];
- struct spu_exec_vector *Inputs;
- struct spu_exec_vector *Outputs;
- unsigned Processor;
-
- /* GEOMETRY processor only. */
- unsigned *Primitives;
-
- /* FRAGMENT processor only. */
- const struct spu_interp_coef *InterpCoefs;
- struct spu_exec_vector QuadPos;
-
- /* Conditional execution masks */
- uint CondMask; /**< For IF/ELSE/ENDIF */
- uint LoopMask; /**< For BGNLOOP/ENDLOOP */
- uint ContMask; /**< For loop CONT statements */
- uint FuncMask; /**< For function calls */
- uint ExecMask; /**< = CondMask & LoopMask */
-
- /** Condition mask stack (for nested conditionals) */
- uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
- int CondStackTop;
-
- /** Loop mask stack (for nested loops) */
- uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
- int LoopStackTop;
-
- /** Loop continue mask stack (see comments in tgsi_exec.c) */
- uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
- int ContStackTop;
-
- /** Function execution mask stack (for executing subroutine code) */
- uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
- int FuncStackTop;
-
- /** Function call stack for saving/restoring the program counter */
- uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
- int CallStackTop;
-
- struct tgsi_full_instruction *Instructions;
- uint NumInstructions;
-
- struct tgsi_full_declaration *Declarations;
- uint NumDeclarations;
-};
-
-
-extern void
-spu_exec_machine_init(struct spu_exec_machine *mach,
- uint numSamplers,
- struct spu_sampler *samplers,
- unsigned processor);
-
-extern uint
-spu_exec_machine_run( struct spu_exec_machine *mach );
-
-
-#if defined __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* SPU_EXEC_H */
diff --git a/src/mesa/pipe/cell/spu/spu_main.c b/src/mesa/pipe/cell/spu/spu_main.c
deleted file mode 100644
index e375197fe6..0000000000
--- a/src/mesa/pipe/cell/spu/spu_main.c
+++ /dev/null
@@ -1,567 +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.
- *
- **************************************************************************/
-
-
-/* main() for Cell SPU code */
-
-
-#include <stdio.h>
-#include <libmisc.h>
-
-#include "spu_main.h"
-#include "spu_render.h"
-#include "spu_texture.h"
-#include "spu_tile.h"
-//#include "spu_test.h"
-#include "spu_vertex_shader.h"
-#include "pipe/cell/common.h"
-#include "pipe/p_defines.h"
-
-
-/*
-helpful headers:
-/usr/lib/gcc/spu/4.1.1/include/spu_mfcio.h
-/opt/ibm/cell-sdk/prototype/sysroot/usr/include/libmisc.h
-*/
-
-boolean Debug = FALSE;
-
-struct spu_global spu;
-
-struct spu_vs_context draw;
-
-/**
- * Tell the PPU that this SPU has finished copying a buffer to
- * local store and that it may be reused by the PPU.
- * This is done by writting a 16-byte batch-buffer-status block back into
- * main memory (in cell_context->buffer_status[]).
- */
-static void
-release_buffer(uint buffer)
-{
- /* Evidently, using less than a 16-byte status doesn't work reliably */
- static const uint status[4] ALIGN16_ATTRIB
- = {CELL_BUFFER_STATUS_FREE, 0, 0, 0};
-
- const uint index = 4 * (spu.init.id * CELL_NUM_BUFFERS + buffer);
- uint *dst = spu.init.buffer_status + index;
-
- ASSERT(buffer < CELL_NUM_BUFFERS);
-
- mfc_put((void *) &status, /* src in local memory */
- (unsigned int) dst, /* dst in main memory */
- sizeof(status), /* size */
- TAG_MISC, /* tag is unimportant */
- 0, /* tid */
- 0 /* rid */);
-}
-
-
-/**
- * For tiles whose status is TILE_STATUS_CLEAR, write solid-filled
- * tiles back to the main framebuffer.
- */
-static void
-really_clear_tiles(uint surfaceIndex)
-{
- const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
- uint i;
-
- if (surfaceIndex == 0) {
- clear_c_tile(&spu.ctile);
-
- 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 (spu.ctile_status[ty][tx] == TILE_STATUS_CLEAR) {
- put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 0);
- }
- }
- }
- else {
- clear_z_tile(&spu.ztile);
-
- 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 (spu.ztile_status[ty][tx] == TILE_STATUS_CLEAR)
- put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 1);
- }
- }
-
-#if 0
- wait_on_mask(1 << TAG_SURFACE_CLEAR);
-#endif
-}
-
-
-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;
- }
- else {
- memset(spu.ztile_status, TILE_STATUS_CLEAR, sizeof(spu.ztile_status));
- spu.fb.depth_clear_value = clear->value;
- }
- return;
-#endif
-
- if (clear->surface == 0) {
- spu.fb.color_clear_value = clear->value;
- clear_c_tile(&spu.ctile);
- }
- else {
- spu.fb.depth_clear_value = clear->value;
- clear_z_tile(&spu.ztile);
- }
-
- /*
- 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 */
- }
-
-#if 0
- wait_on_mask(1 << TAG_SURFACE_CLEAR);
-#endif
-
- if (Debug)
- printf("SPU %u: CLEAR SURF done\n", spu.init.id);
-}
-
-
-static void
-cmd_release_verts(const struct cell_command_release_verts *release)
-{
- if (Debug)
- printf("SPU %u: RELEASE VERTS %u\n",
- spu.init.id, release->vertex_buf);
- ASSERT(release->vertex_buf != ~0U);
- release_buffer(release->vertex_buf);
-}
-
-
-static void
-cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
-{
- if (Debug)
- printf("SPU %u: FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n",
- spu.init.id,
- cmd->width,
- cmd->height,
- cmd->color_start,
- cmd->color_format,
- cmd->depth_format);
-
- ASSERT_ALIGN16(cmd->color_start);
- ASSERT_ALIGN16(cmd->depth_start);
-
- spu.fb.color_start = cmd->color_start;
- spu.fb.depth_start = cmd->depth_start;
- spu.fb.color_format = cmd->color_format;
- spu.fb.depth_format = cmd->depth_format;
- spu.fb.width = cmd->width;
- spu.fb.height = cmd->height;
- spu.fb.width_tiles = (spu.fb.width + TILE_SIZE - 1) / TILE_SIZE;
- spu.fb.height_tiles = (spu.fb.height + TILE_SIZE - 1) / TILE_SIZE;
-
- if (spu.fb.depth_format == PIPE_FORMAT_Z32_UNORM)
- spu.fb.zsize = 4;
- else if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM)
- spu.fb.zsize = 2;
- else
- spu.fb.zsize = 0;
-
- if (spu.fb.color_format == PIPE_FORMAT_A8R8G8B8_UNORM)
- spu.color_shuffle = ((vector unsigned char) {
- 12, 0, 4, 8, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0});
- else if (spu.fb.color_format == PIPE_FORMAT_B8G8R8A8_UNORM)
- spu.color_shuffle = ((vector unsigned char) {
- 8, 4, 0, 12, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0});
- else
- ASSERT(0);
-}
-
-
-static void
-cmd_state_blend(const struct pipe_blend_state *state)
-{
- if (Debug)
- printf("SPU %u: BLEND: enabled %d\n",
- spu.init.id,
- state->blend_enable);
-
- memcpy(&spu.blend, state, sizeof(*state));
-}
-
-
-static void
-cmd_state_depth_stencil(const struct pipe_depth_stencil_alpha_state *state)
-{
- if (Debug)
- printf("SPU %u: DEPTH_STENCIL: ztest %d\n",
- spu.init.id,
- state->depth.enabled);
-
- memcpy(&spu.depth_stencil, state, sizeof(*state));
-}
-
-
-static void
-cmd_state_sampler(const struct pipe_sampler_state *state)
-{
- if (Debug)
- printf("SPU %u: SAMPLER\n",
- spu.init.id);
-
- memcpy(&spu.sampler[0], state, sizeof(*state));
- if (spu.sampler[0].min_img_filter == PIPE_TEX_FILTER_LINEAR)
- spu.sample_texture = sample_texture_bilinear;
- else
- spu.sample_texture = sample_texture_nearest;
-}
-
-
-static void
-cmd_state_texture(const struct cell_command_texture *texture)
-{
- if (Debug)
- printf("SPU %u: TEXTURE at %p size %u x %u\n",
- spu.init.id, texture->start, texture->width, texture->height);
-
- memcpy(&spu.texture, texture, sizeof(*texture));
- spu.tex_size = (vector float)
- { spu.texture.width, spu.texture.height, 0.0, 0.0};
- spu.tex_size_mask = (vector unsigned int)
- { spu.texture.width - 1, spu.texture.height - 1, 0, 0 };
-}
-
-
-static void
-cmd_state_vertex_info(const struct vertex_info *vinfo)
-{
- if (Debug) {
- printf("SPU %u: VERTEX_INFO num_attribs=%u\n", spu.init.id,
- vinfo->num_attribs);
- }
- ASSERT(vinfo->num_attribs >= 1);
- ASSERT(vinfo->num_attribs <= 8);
- memcpy(&spu.vertex_info, vinfo, sizeof(*vinfo));
-}
-
-
-static void
-cmd_state_vs_array_info(const struct cell_array_info *vs_info)
-{
- const unsigned attr = vs_info->attr;
-
- ASSERT(attr < PIPE_ATTRIB_MAX);
- draw.vertex_fetch.src_ptr[attr] = vs_info->base;
- draw.vertex_fetch.pitch[attr] = vs_info->pitch;
- draw.vertex_fetch.format[attr] = vs_info->format;
- draw.vertex_fetch.dirty = 1;
-}
-
-
-static void
-cmd_finish(void)
-{
- if (Debug)
- printf("SPU %u: FINISH\n", spu.init.id);
- really_clear_tiles(0);
- /* wait for all outstanding DMAs to finish */
- mfc_write_tag_mask(~0);
- mfc_read_tag_status_all();
- /* send mbox message to PPU */
- spu_write_out_mbox(CELL_CMD_FINISH);
-}
-
-
-/**
- * Execute a batch of commands
- * The opcode param encodes the location of the buffer and its size.
- */
-static void
-cmd_batch(uint opcode)
-{
- const uint buf = (opcode >> 8) & 0xff;
- uint size = (opcode >> 16);
- uint64_t buffer[CELL_BUFFER_SIZE / 8] ALIGN16_ATTRIB;
- const unsigned usize = size / sizeof(buffer[0]);
- uint pos;
-
- if (Debug)
- printf("SPU %u: BATCH buffer %u, len %u, from %p\n",
- spu.init.id, buf, size, spu.init.buffers[buf]);
-
- ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH);
-
- ASSERT_ALIGN16(spu.init.buffers[buf]);
-
- size = ROUNDUP16(size);
-
- ASSERT_ALIGN16(spu.init.buffers[buf]);
-
- mfc_get(buffer, /* dest */
- (unsigned int) spu.init.buffers[buf], /* src */
- size,
- TAG_BATCH_BUFFER,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask(1 << TAG_BATCH_BUFFER);
-
- /* Tell PPU we're done copying the buffer to local store */
- if (Debug)
- printf("SPU %u: release batch buf %u\n", spu.init.id, buf);
- release_buffer(buf);
-
- for (pos = 0; pos < usize; /* no incr */) {
- switch (buffer[pos]) {
- case CELL_CMD_STATE_FRAMEBUFFER:
- {
- struct cell_command_framebuffer *fb
- = (struct cell_command_framebuffer *) &buffer[pos];
- cmd_state_framebuffer(fb);
- pos += sizeof(*fb) / 8;
- }
- break;
- case CELL_CMD_CLEAR_SURFACE:
- {
- struct cell_command_clear_surface *clr
- = (struct cell_command_clear_surface *) &buffer[pos];
- cmd_clear_surface(clr);
- pos += sizeof(*clr) / 8;
- }
- break;
- case CELL_CMD_RENDER:
- {
- struct cell_command_render *render
- = (struct cell_command_render *) &buffer[pos];
- uint pos_incr;
- cmd_render(render, &pos_incr);
- pos += pos_incr;
- }
- break;
- case CELL_CMD_RELEASE_VERTS:
- {
- struct cell_command_release_verts *release
- = (struct cell_command_release_verts *) &buffer[pos];
- cmd_release_verts(release);
- pos += sizeof(*release) / 8;
- }
- break;
- case CELL_CMD_FINISH:
- cmd_finish();
- pos += 1;
- break;
- case CELL_CMD_STATE_BLEND:
- cmd_state_blend((struct pipe_blend_state *)
- &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct pipe_blend_state)) / 8);
- break;
- case CELL_CMD_STATE_DEPTH_STENCIL:
- cmd_state_depth_stencil((struct pipe_depth_stencil_alpha_state *)
- &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct pipe_depth_stencil_alpha_state)) / 8);
- break;
- case CELL_CMD_STATE_SAMPLER:
- cmd_state_sampler((struct pipe_sampler_state *) &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct pipe_sampler_state)) / 8);
- break;
- case CELL_CMD_STATE_TEXTURE:
- cmd_state_texture((struct cell_command_texture *) &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct cell_command_texture)) / 8);
- break;
- case CELL_CMD_STATE_VERTEX_INFO:
- cmd_state_vertex_info((struct vertex_info *) &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct vertex_info)) / 8);
- break;
- case CELL_CMD_STATE_VIEWPORT:
- (void) memcpy(& draw.viewport, &buffer[pos+1],
- sizeof(struct pipe_viewport_state));
- pos += (1 + ROUNDUP8(sizeof(struct pipe_viewport_state)) / 8);
- break;
- case CELL_CMD_STATE_VS_ARRAY_INFO:
- cmd_state_vs_array_info((struct cell_array_info *) &buffer[pos+1]);
- pos += (1 + ROUNDUP8(sizeof(struct cell_array_info)) / 8);
- break;
- default:
- printf("SPU %u: bad opcode: 0x%llx\n", spu.init.id, buffer[pos]);
- ASSERT(0);
- break;
- }
- }
-
- if (Debug)
- printf("SPU %u: BATCH complete\n", spu.init.id);
-}
-
-
-/**
- * Temporary/simple main loop for SPEs: Get a command, execute it, repeat.
- */
-static void
-main_loop(void)
-{
- struct cell_command cmd;
- int exitFlag = 0;
-
- if (Debug)
- printf("SPU %u: Enter main loop\n", spu.init.id);
-
- ASSERT((sizeof(struct cell_command) & 0xf) == 0);
- ASSERT_ALIGN16(&cmd);
-
- while (!exitFlag) {
- unsigned opcode;
- int tag = 0;
-
- if (Debug)
- printf("SPU %u: Wait for cmd...\n", spu.init.id);
-
- /* read/wait from mailbox */
- opcode = (unsigned int) spu_read_in_mbox();
-
- if (Debug)
- printf("SPU %u: got cmd 0x%x\n", spu.init.id, opcode);
-
- /* command payload */
- mfc_get(&cmd, /* dest */
- (unsigned int) spu.init.cmd, /* src */
- sizeof(struct cell_command), /* bytes */
- tag,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask( 1 << tag );
-
- /*
- * NOTE: most commands should be contained in a batch buffer
- */
-
- switch (opcode & CELL_CMD_OPCODE_MASK) {
- case CELL_CMD_EXIT:
- if (Debug)
- printf("SPU %u: EXIT\n", spu.init.id);
- exitFlag = 1;
- break;
- case CELL_CMD_VS_EXECUTE:
- spu_execute_vertex_shader(&draw, &cmd.vs);
- break;
- case CELL_CMD_BATCH:
- cmd_batch(opcode);
- break;
- default:
- printf("Bad opcode!\n");
- }
-
- }
-
- if (Debug)
- printf("SPU %u: Exit main loop\n", spu.init.id);
-}
-
-
-
-static void
-one_time_init(void)
-{
- memset(spu.ctile_status, TILE_STATUS_DEFINED, sizeof(spu.ctile_status));
- memset(spu.ztile_status, TILE_STATUS_DEFINED, sizeof(spu.ztile_status));
- invalidate_tex_cache();
-}
-
-
-
-/* In some versions of the SDK the SPE main takes 'unsigned long' as a
- * parameter. In others it takes 'unsigned long long'. Use a define to
- * select between the two.
- */
-#ifdef SPU_MAIN_PARAM_LONG_LONG
-typedef unsigned long long main_param_t;
-#else
-typedef unsigned long main_param_t;
-#endif
-
-/**
- * SPE entrypoint.
- */
-int
-main(main_param_t speid, main_param_t argp)
-{
- int tag = 0;
-
- (void) speid;
-
- ASSERT(sizeof(tile_t) == TILE_SIZE * TILE_SIZE * 4);
- ASSERT(sizeof(struct cell_command_render) % 8 == 0);
-
- one_time_init();
-
- if (Debug)
- printf("SPU: main() speid=%lu\n", speid);
-
- mfc_get(&spu.init, /* dest */
- (unsigned int) argp, /* src */
- sizeof(struct cell_init_info), /* bytes */
- tag,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask( 1 << tag );
-
-#if 0
- if (spu.init.id==0)
- spu_test_misc();
-#endif
-
- main_loop();
-
- return 0;
-}
diff --git a/src/mesa/pipe/cell/spu/spu_main.h b/src/mesa/pipe/cell/spu/spu_main.h
deleted file mode 100644
index 1710a17512..0000000000
--- a/src/mesa/pipe/cell/spu/spu_main.h
+++ /dev/null
@@ -1,177 +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 SPU_MAIN_H
-#define SPU_MAIN_H
-
-
-#include <spu_mfcio.h>
-
-#include "pipe/cell/common.h"
-#include "pipe/draw/draw_vertex.h"
-#include "pipe/p_state.h"
-
-
-
-#define MAX_WIDTH 1024
-#define MAX_HEIGHT 1024
-
-
-typedef union {
- ushort us[TILE_SIZE][TILE_SIZE];
- uint ui[TILE_SIZE][TILE_SIZE];
- vector unsigned short us8[TILE_SIZE/2][TILE_SIZE/4];
- vector unsigned int ui4[TILE_SIZE/2][TILE_SIZE/2];
-} tile_t;
-
-
-#define TILE_STATUS_CLEAR 1
-#define TILE_STATUS_DEFINED 2 /**< defined in FB, but not in local store */
-#define TILE_STATUS_CLEAN 3 /**< in local store, but not changed */
-#define TILE_STATUS_DIRTY 4 /**< modified locally, but not put back yet */
-#define TILE_STATUS_GETTING 5 /**< mfc_get() called but not yet arrived */
-
-
-struct spu_framebuffer {
- void *color_start; /**< addr of color surface in main memory */
- void *depth_start; /**< addr of depth surface in main memory */
- enum pipe_format color_format;
- enum pipe_format depth_format;
- uint width, height; /**< size in pixels */
- uint width_tiles, height_tiles; /**< width and height in tiles */
-
- uint color_clear_value;
- uint depth_clear_value;
-
- uint zsize; /**< 0, 2 or 4 bytes per Z */
-} ALIGN16_ATTRIB;
-
-
-/**
- * All SPU global/context state will be in singleton object of this type:
- */
-struct spu_global
-{
- struct cell_init_info init;
-
- struct spu_framebuffer fb;
- struct pipe_blend_state blend_stencil;
- struct pipe_depth_stencil_alpha_state depth_stencil;
- struct pipe_blend_state blend;
- struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
- struct cell_command_texture texture;
-
- struct vertex_info vertex_info;
-
- /* XXX more state to come */
-
-
- /** current color and Z tiles */
- tile_t ctile ALIGN16_ATTRIB;
- tile_t ztile ALIGN16_ATTRIB;
-
- /** Current tiles' status */
- ubyte cur_ctile_status, cur_ztile_status;
-
- /** Status of all tiles in framebuffer */
- ubyte ctile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
- ubyte ztile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
-
-
- /** for converting RGBA to PIPE_FORMAT_x colors */
- vector unsigned char color_shuffle;
-
- vector float tex_size;
- vector unsigned int tex_size_mask; /**< == int(size - 1) */
-
- vector float (*sample_texture)(vector float texcoord);
-
-} ALIGN16_ATTRIB;
-
-
-extern struct spu_global spu;
-extern boolean Debug;
-
-
-
-
-/* DMA TAGS */
-
-#define TAG_SURFACE_CLEAR 10
-#define TAG_VERTEX_BUFFER 11
-#define TAG_READ_TILE_COLOR 12
-#define TAG_READ_TILE_Z 13
-#define TAG_WRITE_TILE_COLOR 14
-#define TAG_WRITE_TILE_Z 15
-#define TAG_INDEX_BUFFER 16
-#define TAG_BATCH_BUFFER 17
-#define TAG_MISC 18
-#define TAG_TEXTURE_TILE 19
-#define TAG_INSTRUCTION_FETCH 20
-
-
-
-static INLINE void
-wait_on_mask(unsigned tagMask)
-{
- mfc_write_tag_mask( tagMask );
- /* wait for completion of _any_ DMAs specified by tagMask */
- mfc_read_tag_status_any();
-}
-
-
-static INLINE void
-wait_on_mask_all(unsigned tagMask)
-{
- mfc_write_tag_mask( tagMask );
- /* wait for completion of _any_ DMAs specified by tagMask */
- mfc_read_tag_status_all();
-}
-
-
-
-
-
-static INLINE void
-memset16(ushort *d, ushort value, uint count)
-{
- uint i;
- for (i = 0; i < count; i++)
- d[i] = value;
-}
-
-
-static INLINE void
-memset32(uint *d, uint value, uint count)
-{
- uint i;
- for (i = 0; i < count; i++)
- d[i] = value;
-}
-
-
-#endif /* SPU_MAIN_H */
diff --git a/src/mesa/pipe/cell/spu/spu_render.c b/src/mesa/pipe/cell/spu/spu_render.c
deleted file mode 100644
index 932fb500b3..0000000000
--- a/src/mesa/pipe/cell/spu/spu_render.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-#include <libmisc.h>
-#include <spu_mfcio.h>
-
-#include "spu_main.h"
-#include "spu_render.h"
-#include "spu_tri.h"
-#include "spu_tile.h"
-#include "pipe/cell/common.h"
-
-
-
-/**
- * Given a rendering command's bounding box (in pixels) compute the
- * location of the corresponding screen tile bounding box.
- */
-static INLINE void
-tile_bounding_box(const struct cell_command_render *render,
- uint *txmin, uint *tymin,
- uint *box_num_tiles, uint *box_width_tiles)
-{
-#if 0
- /* Debug: full-window bounding box */
- uint txmax = spu.fb.width_tiles - 1;
- uint tymax = spu.fb.height_tiles - 1;
- *txmin = 0;
- *tymin = 0;
- *box_num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
- *box_width_tiles = spu.fb.width_tiles;
- (void) render;
- (void) txmax;
- (void) tymax;
-#else
- uint txmax, tymax, box_height_tiles;
-
- *txmin = (uint) render->xmin / TILE_SIZE;
- *tymin = (uint) render->ymin / TILE_SIZE;
- txmax = (uint) render->xmax / TILE_SIZE;
- tymax = (uint) render->ymax / TILE_SIZE;
- if (txmax >= spu.fb.width_tiles)
- txmax = spu.fb.width_tiles-1;
- if (tymax >= spu.fb.height_tiles)
- tymax = spu.fb.height_tiles-1;
- *box_width_tiles = txmax - *txmin + 1;
- box_height_tiles = tymax - *tymin + 1;
- *box_num_tiles = *box_width_tiles * box_height_tiles;
-#endif
-#if 0
- printf("SPU %u: bounds: %g, %g ... %g, %g\n", spu.init.id,
- render->xmin, render->ymin, render->xmax, render->ymax);
- printf("SPU %u: tiles: %u, %u .. %u, %u\n",
- spu.init.id, *txmin, *tymin, txmax, tymax);
- ASSERT(render->xmin <= render->xmax);
- ASSERT(render->ymin <= render->ymax);
-#endif
-}
-
-
-/** Check if the tile at (tx,ty) belongs to this SPU */
-static INLINE boolean
-my_tile(uint tx, uint ty)
-{
- return (spu.fb.width_tiles * ty + tx) % spu.init.num_spus == spu.init.id;
-}
-
-
-/**
- * Start fetching non-clear color/Z tiles from main memory
- */
-static INLINE void
-get_cz_tiles(uint tx, uint ty)
-{
- if (spu.depth_stencil.depth.enabled) {
- if (spu.cur_ztile_status != TILE_STATUS_CLEAR) {
- //printf("SPU %u: getting Z tile %u, %u\n", spu.init.id, tx, ty);
- get_tile(tx, ty, &spu.ztile, TAG_READ_TILE_Z, 1);
- spu.cur_ztile_status = TILE_STATUS_GETTING;
- }
- }
-
- if (spu.cur_ctile_status != TILE_STATUS_CLEAR) {
- //printf("SPU %u: getting C tile %u, %u\n", spu.init.id, tx, ty);
- get_tile(tx, ty, &spu.ctile, TAG_READ_TILE_COLOR, 0);
- spu.cur_ctile_status = TILE_STATUS_GETTING;
- }
-}
-
-
-/**
- * Start putting dirty color/Z tiles back to main memory
- */
-static INLINE void
-put_cz_tiles(uint tx, uint ty)
-{
- if (spu.cur_ztile_status == TILE_STATUS_DIRTY) {
- /* tile was modified and needs to be written back */
- //printf("SPU %u: put dirty Z tile %u, %u\n", spu.init.id, tx, ty);
- put_tile(tx, ty, &spu.ztile, TAG_WRITE_TILE_Z, 1);
- spu.cur_ztile_status = TILE_STATUS_DEFINED;
- }
- else if (spu.cur_ztile_status == TILE_STATUS_GETTING) {
- /* tile was never used */
- spu.cur_ztile_status = TILE_STATUS_DEFINED;
- //printf("SPU %u: put getting Z tile %u, %u\n", spu.init.id, tx, ty);
- }
-
- if (spu.cur_ctile_status == TILE_STATUS_DIRTY) {
- /* tile was modified and needs to be written back */
- //printf("SPU %u: put dirty C tile %u, %u\n", spu.init.id, tx, ty);
- put_tile(tx, ty, &spu.ctile, TAG_WRITE_TILE_COLOR, 0);
- spu.cur_ctile_status = TILE_STATUS_DEFINED;
- }
- else if (spu.cur_ctile_status == TILE_STATUS_GETTING) {
- /* tile was never used */
- spu.cur_ctile_status = TILE_STATUS_DEFINED;
- //printf("SPU %u: put getting C tile %u, %u\n", spu.init.id, tx, ty);
- }
-}
-
-
-/**
- * Wait for 'put' of color/z tiles to complete.
- */
-static INLINE void
-wait_put_cz_tiles(void)
-{
- wait_on_mask(1 << TAG_WRITE_TILE_COLOR);
- if (spu.depth_stencil.depth.enabled) {
- wait_on_mask(1 << TAG_WRITE_TILE_Z);
- }
-}
-
-
-/**
- * Render primitives
- * \param pos_incr returns value indicating how may words to skip after
- * this command in the batch buffer
- */
-void
-cmd_render(const struct cell_command_render *render, uint *pos_incr)
-{
- /* we'll DMA into these buffers */
- ubyte vertex_data[CELL_BUFFER_SIZE] ALIGN16_ATTRIB;
- const uint vertex_size = render->vertex_size; /* in bytes */
- /*const*/ uint total_vertex_bytes = render->num_verts * vertex_size;
- uint index_bytes;
- const ubyte *vertices;
- const ushort *indexes;
- uint i, j;
-
-
- if (Debug) {
- printf("SPU %u: RENDER prim %u, num_vert=%u num_ind=%u "
- "inline_vert=%u\n",
- spu.init.id,
- render->prim_type,
- render->num_verts,
- render->num_indexes,
- render->inline_verts);
-
- /*
- printf(" bound: %g, %g .. %g, %g\n",
- render->xmin, render->ymin, render->xmax, render->ymax);
- */
- }
-
- ASSERT(sizeof(*render) % 4 == 0);
- ASSERT(total_vertex_bytes % 16 == 0);
- ASSERT(render->prim_type == PIPE_PRIM_TRIANGLES);
- ASSERT(render->num_indexes % 3 == 0);
-
-
- /* indexes are right after the render command in the batch buffer */
- indexes = (const ushort *) (render + 1);
- index_bytes = ROUNDUP8(render->num_indexes * 2);
- *pos_incr = index_bytes / 8 + sizeof(*render) / 8;
-
-
- if (render->inline_verts) {
- /* Vertices are after indexes in batch buffer at next 16-byte addr */
- vertices = (const ubyte *) render + (*pos_incr * 8);
- vertices = (const ubyte *) align_pointer((void *) vertices, 16);
- ASSERT_ALIGN16(vertices);
- *pos_incr = ((vertices + total_vertex_bytes) - (ubyte *) render) / 8;
- }
- else {
- /* Begin DMA fetch of vertex buffer */
- ubyte *src = spu.init.buffers[render->vertex_buf];
- ubyte *dest = vertex_data;
-
- /* skip vertex data we won't use */
-#if 01
- src += render->min_index * vertex_size;
- dest += render->min_index * vertex_size;
- total_vertex_bytes -= render->min_index * vertex_size;
-#endif
- ASSERT(total_vertex_bytes % 16 == 0);
- ASSERT_ALIGN16(dest);
- ASSERT_ALIGN16(src);
-
- mfc_get(dest, /* in vertex_data[] array */
- (unsigned int) src, /* src in main memory */
- total_vertex_bytes, /* size */
- TAG_VERTEX_BUFFER,
- 0, /* tid */
- 0 /* rid */);
-
- vertices = vertex_data;
-
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
- }
-
-
- /**
- ** find tiles which intersect the prim bounding box
- **/
- uint txmin, tymin, box_width_tiles, box_num_tiles;
- tile_bounding_box(render, &txmin, &tymin,
- &box_num_tiles, &box_width_tiles);
-
-
- /* make sure any pending clears have completed */
- wait_on_mask(1 << TAG_SURFACE_CLEAR); /* XXX temporary */
-
-
- /**
- ** loop over tiles, rendering tris
- **/
- for (i = 0; i < box_num_tiles; i++) {
- const uint tx = txmin + i % box_width_tiles;
- const uint ty = tymin + i / box_width_tiles;
-
- ASSERT(tx < spu.fb.width_tiles);
- ASSERT(ty < spu.fb.height_tiles);
-
- if (!my_tile(tx, ty))
- continue;
-
- spu.cur_ctile_status = spu.ctile_status[ty][tx];
- spu.cur_ztile_status = spu.ztile_status[ty][tx];
-
- get_cz_tiles(tx, ty);
-
- uint drawn = 0;
-
- /* loop over tris */
- for (j = 0; j < render->num_indexes; j += 3) {
- const float *v0, *v1, *v2;
-
- v0 = (const float *) (vertices + indexes[j+0] * vertex_size);
- v1 = (const float *) (vertices + indexes[j+1] * vertex_size);
- v2 = (const float *) (vertices + indexes[j+2] * vertex_size);
-
- drawn += tri_draw(v0, v1, v2, tx, ty);
- }
-
- //printf("SPU %u: drew %u of %u\n", spu.init.id, drawn, render->num_indexes/3);
-
- /* write color/z tiles back to main framebuffer, if dirtied */
- put_cz_tiles(tx, ty);
-
- wait_put_cz_tiles(); /* XXX seems unnecessary... */
-
- spu.ctile_status[ty][tx] = spu.cur_ctile_status;
- spu.ztile_status[ty][tx] = spu.cur_ztile_status;
- }
-
- if (Debug)
- printf("SPU %u: RENDER done\n",
- spu.init.id);
-}
-
-
diff --git a/src/mesa/pipe/cell/spu/spu_render.h b/src/mesa/pipe/cell/spu/spu_render.h
deleted file mode 100644
index fbcdc5ec31..0000000000
--- a/src/mesa/pipe/cell/spu/spu_render.h
+++ /dev/null
@@ -1,38 +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.
- *
- **************************************************************************/
-
-
-#ifndef SPU_RENDER_H
-#define SPU_RENDER_H
-
-#include "pipe/cell/common.h"
-
-extern void
-cmd_render(const struct cell_command_render *render, uint *pos_incr);
-
-#endif /* SPU_RENDER_H */
-
diff --git a/src/mesa/pipe/cell/spu/spu_texture.c b/src/mesa/pipe/cell/spu/spu_texture.c
deleted file mode 100644
index 3962aaa4a9..0000000000
--- a/src/mesa/pipe/cell/spu/spu_texture.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_compiler.h"
-#include "spu_main.h"
-#include "spu_texture.h"
-#include "spu_tile.h"
-#include "spu_colorpack.h"
-
-
-/**
- * Number of texture tiles to cache.
- * Note that this will probably be the largest consumer of SPU local store/
- * memory for this driver!
- */
-#define CACHE_SIZE 16
-
-static tile_t tex_tiles[CACHE_SIZE] ALIGN16_ATTRIB;
-
-static vector unsigned int tex_tile_xy[CACHE_SIZE];
-
-
-
-/**
- * Mark all tex cache entries as invalid.
- */
-void
-invalidate_tex_cache(void)
-{
- /* XXX memset? */
- uint i;
- for (i = 0; i < CACHE_SIZE; i++) {
- tex_tile_xy[i] = ((vector unsigned int) { ~0U, ~0U, ~0U, ~0U });
- }
-}
-
-
-/**
- * Return the cache pos/index which corresponds to tile (tx,ty)
- */
-static INLINE uint
-cache_pos(vector unsigned int txty)
-{
- uint pos = (spu_extract(txty,0) + spu_extract(txty,1) * 4) % CACHE_SIZE;
- return pos;
-}
-
-
-/**
- * Make sure the tile for texel (i,j) is present, return its position/index
- * in the cache.
- */
-static uint
-get_tex_tile(vector unsigned int ij)
-{
- /* tile address: tx,ty */
- const vector unsigned int txty = spu_rlmask(ij, -5); /* divide by 32 */
- const uint pos = cache_pos(txty);
-
- if ((spu_extract(tex_tile_xy[pos], 0) != spu_extract(txty, 0)) ||
- (spu_extract(tex_tile_xy[pos], 1) != spu_extract(txty, 1))) {
-
- /* texture cache miss, fetch tile from main memory */
- const uint tiles_per_row = spu.texture.width / TILE_SIZE;
- const uint bytes_per_tile = sizeof(tile_t);
- const void *src = (const ubyte *) spu.texture.start
- + (spu_extract(txty,1) * tiles_per_row + spu_extract(txty,0)) * bytes_per_tile;
-
- printf("SPU %u: tex cache miss at %d, %d pos=%u old=%d,%d\n",
- spu.init.id,
- spu_extract(txty,0),
- spu_extract(txty,1),
- pos,
- spu_extract(tex_tile_xy[pos],0),
- spu_extract(tex_tile_xy[pos],1));
-
- ASSERT_ALIGN16(tex_tiles[pos].ui);
- ASSERT_ALIGN16(src);
-
- mfc_get(tex_tiles[pos].ui, /* dest */
- (unsigned int) src,
- bytes_per_tile, /* size */
- TAG_TEXTURE_TILE,
- 0, /* tid */
- 0 /* rid */);
-
- wait_on_mask(1 << TAG_TEXTURE_TILE);
-
- tex_tile_xy[pos] = txty;
- }
- else {
-#if 0
- printf("SPU %u: tex cache HIT at %d, %d\n",
- spu.init.id, tx, ty);
-#endif
- }
-
- return pos;
-}
-
-
-/**
- * Get texture sample at texcoord.
- * XXX this is extremely primitive for now.
- */
-vector float
-sample_texture_nearest(vector float texcoord)
-{
- vector float tc = spu_mul(texcoord, spu.tex_size);
- vector unsigned int itc = spu_convtu(tc, 0); /* convert to int */
- itc = spu_and(itc, spu.tex_size_mask); /* mask (GL_REPEAT) */
- vector unsigned int ij = spu_and(itc, TILE_SIZE-1); /* intra tile addr */
- uint pos = get_tex_tile(itc);
- uint texel = tex_tiles[pos].ui[spu_extract(ij, 1)][spu_extract(ij, 0)];
- return spu_unpack_A8R8G8B8(texel);
-}
-
-
-vector float
-sample_texture_bilinear(vector float texcoord)
-{
- static const vector unsigned int offset10 = {1, 0, 0, 0};
- static const vector unsigned int offset01 = {0, 1, 0, 0};
-
- vector float tc = spu_mul(texcoord, spu.tex_size);
- tc = spu_add(tc, spu_splats(-0.5f)); /* half texel bias */
-
- /* integer texcoords S,T: */
- vector unsigned int itc00 = spu_convtu(tc, 0); /* convert to int */
- vector unsigned int itc01 = spu_add(itc00, offset01);
- vector unsigned int itc10 = spu_add(itc00, offset10);
- vector unsigned int itc11 = spu_add(itc10, offset01);
-
- /* mask (GL_REPEAT) */
- itc00 = spu_and(itc00, spu.tex_size_mask);
- itc01 = spu_and(itc01, spu.tex_size_mask);
- itc10 = spu_and(itc10, spu.tex_size_mask);
- itc11 = spu_and(itc11, spu.tex_size_mask);
-
- /* intra tile addr */
- vector unsigned int ij00 = spu_and(itc00, TILE_SIZE-1);
- vector unsigned int ij01 = spu_and(itc01, TILE_SIZE-1);
- vector unsigned int ij10 = spu_and(itc10, TILE_SIZE-1);
- vector unsigned int ij11 = spu_and(itc11, TILE_SIZE-1);
-
- /* get tile cache positions */
- uint pos00 = get_tex_tile(itc00);
- uint pos01, pos10, pos11;
- if ((spu_extract(ij00, 0) < TILE_SIZE-1) &&
- (spu_extract(ij00, 1) < TILE_SIZE-1)) {
- /* all texels are in the same tile */
- pos01 = pos10 = pos11 = pos00;
- }
- else {
- pos01 = get_tex_tile(itc01);
- pos10 = get_tex_tile(itc10);
- pos11 = get_tex_tile(itc11);
- }
-
- /* get texels from tiles and convert to float[4] */
- vector float texel00 = spu_unpack_A8R8G8B8(tex_tiles[pos00].ui[spu_extract(ij00, 1)][spu_extract(ij00, 0)]);
- vector float texel01 = spu_unpack_A8R8G8B8(tex_tiles[pos01].ui[spu_extract(ij01, 1)][spu_extract(ij01, 0)]);
- vector float texel10 = spu_unpack_A8R8G8B8(tex_tiles[pos10].ui[spu_extract(ij10, 1)][spu_extract(ij10, 0)]);
- vector float texel11 = spu_unpack_A8R8G8B8(tex_tiles[pos11].ui[spu_extract(ij11, 1)][spu_extract(ij11, 0)]);
-
- /* Compute weighting factors in [0,1]
- * Multiply texcoord by 1024, AND with 1023, convert back to float.
- */
- vector float tc1024 = spu_mul(tc, spu_splats(1024.0f));
- vector signed int itc1024 = spu_convts(tc1024, 0);
- itc1024 = spu_and(itc1024, spu_splats((1 << 10) - 1));
- vector float weight = spu_convtf(itc1024, 10);
-
- /* smeared frac and 1-frac */
- vector float sfrac = spu_splats(spu_extract(weight, 0));
- vector float tfrac = spu_splats(spu_extract(weight, 1));
- vector float sfrac1 = spu_sub(spu_splats(1.0f), sfrac);
- vector float tfrac1 = spu_sub(spu_splats(1.0f), tfrac);
-
- /* multiply the samples (colors) by the S/T weights */
- texel00 = spu_mul(spu_mul(texel00, sfrac1), tfrac1);
- texel10 = spu_mul(spu_mul(texel10, sfrac ), tfrac1);
- texel01 = spu_mul(spu_mul(texel01, sfrac1), tfrac );
- texel11 = spu_mul(spu_mul(texel11, sfrac ), tfrac );
-
- /* compute sum of weighted samples */
- vector float texel_sum = spu_add(texel00, texel01);
- texel_sum = spu_add(texel_sum, texel10);
- texel_sum = spu_add(texel_sum, texel11);
-
- return texel_sum;
-}
diff --git a/src/mesa/pipe/cell/spu/spu_texture.h b/src/mesa/pipe/cell/spu/spu_texture.h
deleted file mode 100644
index 95eb87080f..0000000000
--- a/src/mesa/pipe/cell/spu/spu_texture.h
+++ /dev/null
@@ -1,47 +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.
- *
- **************************************************************************/
-
-#ifndef SPU_TEXTURE_H
-#define SPU_TEXTURE_H
-
-
-#include "pipe/p_compiler.h"
-
-
-extern void
-invalidate_tex_cache(void);
-
-
-extern vector float
-sample_texture_nearest(vector float texcoord);
-
-
-extern vector float
-sample_texture_bilinear(vector float texcoord);
-
-
-#endif /* SPU_TEXTURE_H */
diff --git a/src/mesa/pipe/cell/spu/spu_tile.c b/src/mesa/pipe/cell/spu/spu_tile.c
deleted file mode 100644
index 12dc246328..0000000000
--- a/src/mesa/pipe/cell/spu/spu_tile.c
+++ /dev/null
@@ -1,83 +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.
- *
- **************************************************************************/
-
-
-
-#include "spu_tile.h"
-#include "spu_main.h"
-
-
-void
-get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf)
-{
- const uint offset = ty * spu.fb.width_tiles + tx;
- const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? spu.fb.zsize : 4);
- const ubyte *src = zBuf ? spu.fb.depth_start : spu.fb.color_start;
-
- src += offset * bytesPerTile;
-
- ASSERT(tx < spu.fb.width_tiles);
- ASSERT(ty < spu.fb.height_tiles);
- ASSERT_ALIGN16(tile);
- /*
- printf("get_tile: dest: %p src: 0x%x size: %d\n",
- tile, (unsigned int) src, bytesPerTile);
- */
- mfc_get(tile->ui, /* dest in local memory */
- (unsigned int) src, /* src in main memory */
- bytesPerTile,
- tag,
- 0, /* tid */
- 0 /* rid */);
-}
-
-
-void
-put_tile(uint tx, uint ty, const tile_t *tile, int tag, int zBuf)
-{
- const uint offset = ty * spu.fb.width_tiles + tx;
- const uint bytesPerTile = TILE_SIZE * TILE_SIZE * (zBuf ? spu.fb.zsize : 4);
- ubyte *dst = zBuf ? spu.fb.depth_start : spu.fb.color_start;
-
- dst += offset * bytesPerTile;
-
- ASSERT(tx < spu.fb.width_tiles);
- ASSERT(ty < spu.fb.height_tiles);
- ASSERT_ALIGN16(tile);
- /*
- printf("SPU %u: put_tile: src: %p dst: 0x%x size: %d\n",
- spu.init.id,
- tile, (unsigned int) dst, bytesPerTile);
- */
- mfc_put((void *) tile->ui, /* src in local memory */
- (unsigned int) dst, /* dst in main memory */
- bytesPerTile,
- tag,
- 0, /* tid */
- 0 /* rid */);
-}
-
diff --git a/src/mesa/pipe/cell/spu/spu_tile.h b/src/mesa/pipe/cell/spu/spu_tile.h
deleted file mode 100644
index e53340a55a..0000000000
--- a/src/mesa/pipe/cell/spu/spu_tile.h
+++ /dev/null
@@ -1,73 +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 SPU_TILE_H
-#define SPU_TILE_H
-
-
-#include <libmisc.h>
-#include <spu_mfcio.h>
-#include "spu_main.h"
-#include "pipe/cell/common.h"
-
-
-
-void
-get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf);
-
-void
-put_tile(uint tx, uint ty, const tile_t *tile, int tag, int zBuf);
-
-
-
-static INLINE void
-clear_c_tile(tile_t *ctile)
-{
- memset32((uint*) ctile->ui,
- spu.fb.color_clear_value,
- TILE_SIZE * TILE_SIZE);
-}
-
-
-static INLINE void
-clear_z_tile(tile_t *ztile)
-{
- if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
- memset16((ushort*) ztile->us,
- spu.fb.depth_clear_value,
- TILE_SIZE * TILE_SIZE);
- }
- else {
- ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z32_UNORM);
- memset32((uint*) ztile->ui,
- spu.fb.depth_clear_value,
- TILE_SIZE * TILE_SIZE);
- }
-}
-
-
-#endif /* SPU_TILE_H */
diff --git a/src/mesa/pipe/cell/spu/spu_tri.c b/src/mesa/pipe/cell/spu/spu_tri.c
deleted file mode 100644
index be9624cf7d..0000000000
--- a/src/mesa/pipe/cell/spu/spu_tri.c
+++ /dev/null
@@ -1,926 +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.
- *
- **************************************************************************/
-
-/**
- * Triangle rendering within a tile.
- */
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_format.h"
-#include "pipe/p_util.h"
-#include "spu_blend.h"
-#include "spu_colorpack.h"
-#include "spu_main.h"
-#include "spu_texture.h"
-#include "spu_tile.h"
-#include "spu_tri.h"
-
-#include "spu_ztest.h"
-
-
-/** Masks are uint[4] vectors with each element being 0 or 0xffffffff */
-typedef vector unsigned int mask_t;
-
-typedef union
-{
- vector float v;
- float f[4];
-} float4;
-
-
-/**
- * Simplified types taken from other parts of Gallium
- */
-struct vertex_header {
- vector float data[1];
-};
-
-
-
-/* XXX fix this */
-#undef CEILF
-#define CEILF(X) ((float) (int) ((X) + 0.99999))
-
-
-#define QUAD_TOP_LEFT 0
-#define QUAD_TOP_RIGHT 1
-#define QUAD_BOTTOM_LEFT 2
-#define QUAD_BOTTOM_RIGHT 3
-#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT)
-#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT)
-#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT)
-#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT)
-#define MASK_ALL 0xf
-
-
-#define DEBUG_VERTS 0
-
-/**
- * Triangle edge info
- */
-struct edge {
- float dx; /**< X(v1) - X(v0), used only during setup */
- float dy; /**< Y(v1) - Y(v0), used only during setup */
- float dxdy; /**< dx/dy */
- float sx, sy; /**< first sample point coord */
- int lines; /**< number of lines on this edge */
-};
-
-
-struct interp_coef
-{
- float4 a0;
- float4 dadx;
- float4 dady;
-};
-
-
-/**
- * Triangle setup info (derived from draw_stage).
- * Also used for line drawing (taking some liberties).
- */
-struct setup_stage {
-
- /* Vertices are just an array of floats making up each attribute in
- * turn. Currently fixed at 4 floats, but should change in time.
- * Codegen will help cope with this.
- */
- const struct vertex_header *vmax;
- const struct vertex_header *vmid;
- const struct vertex_header *vmin;
- const struct vertex_header *vprovoke;
-
- struct edge ebot;
- struct edge etop;
- struct edge emaj;
-
- float oneoverarea;
-
- uint tx, ty;
-
- int cliprect_minx, cliprect_maxx, cliprect_miny, cliprect_maxy;
-
-#if 0
- struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS];
-#else
- struct interp_coef coef[PIPE_MAX_SHADER_INPUTS];
-#endif
-
-#if 0
- struct quad_header quad;
-#endif
-
- struct {
- int left[2]; /**< [0] = row0, [1] = row1 */
- int right[2];
- int y;
- unsigned y_flags;
- unsigned mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */
- } span;
-};
-
-
-
-static struct setup_stage setup;
-
-
-
-
-#if 0
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct setup_stage *setup_stage( struct draw_stage *stage )
-{
- return (struct setup_stage *)stage;
-}
-#endif
-
-#if 0
-/**
- * Clip setup.quad against the scissor/surface bounds.
- */
-static INLINE void
-quad_clip(struct setup_stage *setup)
-{
- const struct pipe_scissor_state *cliprect = &setup.softpipe->cliprect;
- const int minx = (int) cliprect->minx;
- const int maxx = (int) cliprect->maxx;
- 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) {
- /* totally clipped */
- setup.quad.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);
-}
-#endif
-
-#if 0
-/**
- * Emit a quad (pass to next stage) with clipping.
- */
-static INLINE void
-clip_emit_quad(struct setup_stage *setup)
-{
- quad_clip(setup);
- if (setup.quad.mask) {
- struct softpipe_context *sp = setup.softpipe;
- sp->quad.first->run(sp->quad.first, &setup.quad);
- }
-}
-#endif
-
-/**
- * Evaluate attribute coefficients (plane equations) to compute
- * attribute values for the four fragments in a quad.
- * Eg: four colors will be compute.
- */
-static INLINE void
-eval_coeff(uint slot, float x, float y, vector float result[4])
-{
- switch (spu.vertex_info.interp_mode[slot]) {
- case INTERP_CONSTANT:
- result[QUAD_TOP_LEFT] =
- result[QUAD_TOP_RIGHT] =
- result[QUAD_BOTTOM_LEFT] =
- result[QUAD_BOTTOM_RIGHT] = setup.coef[slot].a0.v;
- break;
-
- case INTERP_LINEAR:
- /* fall-through, for now */
- default:
- {
- register vector float dadx = setup.coef[slot].dadx.v;
- register vector float dady = setup.coef[slot].dady.v;
- register vector float topLeft
- = spu_add(setup.coef[slot].a0.v,
- spu_add(spu_mul(spu_splats(x), dadx),
- spu_mul(spu_splats(y), dady)));
-
- result[QUAD_TOP_LEFT] = topLeft;
- result[QUAD_TOP_RIGHT] = spu_add(topLeft, dadx);
- result[QUAD_BOTTOM_LEFT] = spu_add(topLeft, dady);
- result[QUAD_BOTTOM_RIGHT] = spu_add(spu_add(topLeft, dadx), dady);
- }
- }
-}
-
-
-static INLINE vector float
-eval_z(float x, float y)
-{
- const uint slot = 0;
- const float dzdx = setup.coef[slot].dadx.f[2];
- const float dzdy = setup.coef[slot].dady.f[2];
- const float topLeft = setup.coef[slot].a0.f[2] + x * dzdx + y * dzdy;
- const vector float topLeftv = spu_splats(topLeft);
- const vector float derivs = (vector float) { 0.0, dzdx, dzdy, dzdx + dzdy };
- return spu_add(topLeftv, derivs);
-}
-
-
-static INLINE mask_t
-do_depth_test(int x, int y, mask_t quadmask)
-{
- float4 zvals;
- mask_t mask;
-
- zvals.v = eval_z((float) x, (float) y);
-
- if (spu.fb.depth_format == PIPE_FORMAT_Z16_UNORM) {
- int ix = (x - setup.cliprect_minx) / 4;
- int iy = (y - setup.cliprect_miny) / 2;
- mask = spu_z16_test_less(zvals.v, &spu.ztile.us8[iy][ix], x>>1, quadmask);
- }
- else {
- int ix = (x - setup.cliprect_minx) / 2;
- int iy = (y - setup.cliprect_miny) / 2;
- mask = spu_z32_test_less(zvals.v, &spu.ztile.ui4[iy][ix], quadmask);
- }
-
- if (spu_extract(spu_orx(mask), 0))
- spu.cur_ztile_status = TILE_STATUS_DIRTY;
-
- return mask;
-}
-
-
-/**
- * Emit a quad (pass to next stage). No clipping is done.
- * Note: about 1/5 to 1/7 of the time, mask is zero and this function
- * should be skipped. But adding the test for that slows things down
- * overall.
- */
-static INLINE void
-emit_quad( int x, int y, mask_t mask )
-{
-#if 0
- struct softpipe_context *sp = setup.softpipe;
- setup.quad.x0 = x;
- setup.quad.y0 = y;
- setup.quad.mask = mask;
- sp->quad.first->run(sp->quad.first, &setup.quad);
-#else
-
- if (spu.depth_stencil.depth.enabled) {
- mask = do_depth_test(x, y, mask);
- }
-
- /* If any bits in mask are set... */
- if (spu_extract(spu_orx(mask), 0)) {
- const int ix = x - setup.cliprect_minx;
- const int iy = y - setup.cliprect_miny;
- const vector unsigned char shuffle = spu.color_shuffle;
- vector float colors[4];
-
- spu.cur_ctile_status = TILE_STATUS_DIRTY;
-
- if (spu.texture.start) {
- /* texture mapping */
- vector float texcoords[4];
- eval_coeff(2, (float) x, (float) y, texcoords);
-
- if (spu_extract(mask, 0))
- colors[0] = spu.sample_texture(texcoords[0]);
- if (spu_extract(mask, 1))
- colors[1] = spu.sample_texture(texcoords[1]);
- if (spu_extract(mask, 2))
- colors[2] = spu.sample_texture(texcoords[2]);
- if (spu_extract(mask, 3))
- colors[3] = spu.sample_texture(texcoords[3]);
- }
- else {
- /* simple shading */
- eval_coeff(1, (float) x, (float) y, colors);
- }
-
-#if 1
- if (spu.blend.blend_enable)
- blend_quad(ix % TILE_SIZE, iy % TILE_SIZE, colors);
-#endif
-
- if (spu_extract(mask, 0))
- spu.ctile.ui[iy][ix] = spu_pack_color_shuffle(colors[0], shuffle);
- if (spu_extract(mask, 1))
- spu.ctile.ui[iy][ix+1] = spu_pack_color_shuffle(colors[1], shuffle);
- if (spu_extract(mask, 2))
- spu.ctile.ui[iy+1][ix] = spu_pack_color_shuffle(colors[2], shuffle);
- if (spu_extract(mask, 3))
- spu.ctile.ui[iy+1][ix+1] = spu_pack_color_shuffle(colors[3], shuffle);
-
-#if 0
- /* SIMD_Z with swizzled color buffer (someday) */
- vector unsigned int uicolors = *((vector unsigned int *) &colors);
- spu.ctile.ui4[iy/2][ix/2] = spu_sel(spu.ctile.ui4[iy/2][ix/2], uicolors, mask);
-#endif
- }
-
-#endif
-}
-
-
-/**
- * Given an X or Y coordinate, return the block/quad coordinate that it
- * belongs to.
- */
-static INLINE int block( int x )
-{
- return x & ~1;
-}
-
-
-/**
- * Compute mask which indicates which pixels in the 2x2 quad are actually inside
- * the triangle's bounds.
- * The mask is a uint4 vector and each element will be 0 or 0xffffffff.
- */
-static INLINE mask_t calculate_mask( int x )
-{
- /* This is a little tricky.
- * Use & instead of && to avoid branches.
- * Use negation to convert true/false to ~0/0 values.
- */
- mask_t mask;
- mask = spu_insert(-((x >= setup.span.left[0]) & (x < setup.span.right[0])), mask, 0);
- mask = spu_insert(-((x+1 >= setup.span.left[0]) & (x+1 < setup.span.right[0])), mask, 1);
- mask = spu_insert(-((x >= setup.span.left[1]) & (x < setup.span.right[1])), mask, 2);
- mask = spu_insert(-((x+1 >= setup.span.left[1]) & (x+1 < setup.span.right[1])), mask, 3);
- return mask;
-}
-
-
-/**
- * Render a horizontal span of quads
- */
-static void flush_spans( void )
-{
- int minleft, maxright;
- int x;
-
- switch (setup.span.y_flags) {
- case 0x3:
- /* both odd and even lines written (both quad rows) */
- minleft = MIN2(setup.span.left[0], setup.span.left[1]);
- maxright = MAX2(setup.span.right[0], setup.span.right[1]);
- break;
-
- case 0x1:
- /* only even line written (quad top row) */
- minleft = setup.span.left[0];
- maxright = setup.span.right[0];
- break;
-
- case 0x2:
- /* only odd line written (quad bottom row) */
- minleft = setup.span.left[1];
- maxright = setup.span.right[1];
- break;
-
- default:
- return;
- }
-
-
- /* OK, we're very likely to need the tile data now.
- * clear or finish waiting if needed.
- */
- if (spu.cur_ctile_status == TILE_STATUS_GETTING) {
- /* wait for mfc_get() to complete */
- //printf("SPU: %u: waiting for ctile\n", spu.init.id);
- wait_on_mask(1 << TAG_READ_TILE_COLOR);
- spu.cur_ctile_status = TILE_STATUS_CLEAN;
- }
- else if (spu.cur_ctile_status == TILE_STATUS_CLEAR) {
- //printf("SPU %u: clearing C tile %u, %u\n", spu.init.id, setup.tx, setup.ty);
- clear_c_tile(&spu.ctile);
- spu.cur_ctile_status = TILE_STATUS_DIRTY;
- }
- ASSERT(spu.cur_ctile_status != TILE_STATUS_DEFINED);
-
- if (spu.depth_stencil.depth.enabled) {
- if (spu.cur_ztile_status == TILE_STATUS_GETTING) {
- /* wait for mfc_get() to complete */
- //printf("SPU: %u: waiting for ztile\n", spu.init.id);
- wait_on_mask(1 << TAG_READ_TILE_Z);
- spu.cur_ztile_status = TILE_STATUS_CLEAN;
- }
- else if (spu.cur_ztile_status == TILE_STATUS_CLEAR) {
- //printf("SPU %u: clearing Z tile %u, %u\n", spu.init.id, setup.tx, setup.ty);
- clear_z_tile(&spu.ztile);
- spu.cur_ztile_status = TILE_STATUS_DIRTY;
- }
- ASSERT(spu.cur_ztile_status != TILE_STATUS_DEFINED);
- }
-
- /* XXX this loop could be moved into the above switch cases and
- * calculate_mask() could be simplified a bit...
- */
- for (x = block(minleft); x <= block(maxright); x += 2) {
-#if 1
- emit_quad( x, setup.span.y, calculate_mask( x ) );
-#endif
- }
-
- setup.span.y = 0;
- setup.span.y_flags = 0;
- setup.span.right[0] = 0;
- setup.span.right[1] = 0;
-}
-
-#if DEBUG_VERTS
-static void print_vertex(const struct vertex_header *v)
-{
- int i;
- fprintf(stderr, "Vertex: (%p)\n", v);
- for (i = 0; i < setup.quad.nr_attrs; i++) {
- fprintf(stderr, " %d: %f %f %f %f\n", i,
- v->data[i][0], v->data[i][1], v->data[i][2], v->data[i][3]);
- }
-}
-#endif
-
-
-static boolean setup_sort_vertices(const struct vertex_header *v0,
- const struct vertex_header *v1,
- const struct vertex_header *v2)
-{
-
-#if DEBUG_VERTS
- fprintf(stderr, "Triangle:\n");
- print_vertex(v0);
- print_vertex(v1);
- print_vertex(v2);
-#endif
-
- setup.vprovoke = v2;
-
- /* determine bottom to top order of vertices */
- {
- float y0 = spu_extract(v0->data[0], 1);
- float y1 = spu_extract(v1->data[0], 1);
- float y2 = spu_extract(v2->data[0], 1);
- if (y0 <= y1) {
- if (y1 <= y2) {
- /* y0<=y1<=y2 */
- setup.vmin = v0;
- setup.vmid = v1;
- setup.vmax = v2;
- }
- else if (y2 <= y0) {
- /* y2<=y0<=y1 */
- setup.vmin = v2;
- setup.vmid = v0;
- setup.vmax = v1;
- }
- else {
- /* y0<=y2<=y1 */
- setup.vmin = v0;
- setup.vmid = v2;
- setup.vmax = v1;
- }
- }
- else {
- if (y0 <= y2) {
- /* y1<=y0<=y2 */
- setup.vmin = v1;
- setup.vmid = v0;
- setup.vmax = v2;
- }
- else if (y2 <= y1) {
- /* y2<=y1<=y0 */
- setup.vmin = v2;
- setup.vmid = v1;
- setup.vmax = v0;
- }
- else {
- /* y1<=y2<=y0 */
- setup.vmin = v1;
- setup.vmid = v2;
- setup.vmax = v0;
- }
- }
- }
-
- /* Check if triangle is completely outside the tile bounds */
- if (spu_extract(setup.vmin->data[0], 1) > setup.cliprect_maxy)
- return FALSE;
- if (spu_extract(setup.vmax->data[0], 1) < setup.cliprect_miny)
- return FALSE;
- if (spu_extract(setup.vmin->data[0], 0) < setup.cliprect_minx &&
- spu_extract(setup.vmid->data[0], 0) < setup.cliprect_minx &&
- spu_extract(setup.vmax->data[0], 0) < setup.cliprect_minx)
- return FALSE;
- if (spu_extract(setup.vmin->data[0], 0) > setup.cliprect_maxx &&
- spu_extract(setup.vmid->data[0], 0) > setup.cliprect_maxx &&
- spu_extract(setup.vmax->data[0], 0) > setup.cliprect_maxx)
- return FALSE;
-
- setup.ebot.dx = spu_extract(setup.vmid->data[0], 0) - spu_extract(setup.vmin->data[0], 0);
- setup.ebot.dy = spu_extract(setup.vmid->data[0], 1) - spu_extract(setup.vmin->data[0], 1);
- setup.emaj.dx = spu_extract(setup.vmax->data[0], 0) - spu_extract(setup.vmin->data[0], 0);
- setup.emaj.dy = spu_extract(setup.vmax->data[0], 1) - spu_extract(setup.vmin->data[0], 1);
- setup.etop.dx = spu_extract(setup.vmax->data[0], 0) - spu_extract(setup.vmid->data[0], 0);
- setup.etop.dy = spu_extract(setup.vmax->data[0], 1) - spu_extract(setup.vmid->data[0], 1);
-
- /*
- * Compute triangle's area. Use 1/area to compute partial
- * derivatives of attributes later.
- *
- * The area will be the same as prim->det, but the sign may be
- * different depending on how the vertices get sorted above.
- *
- * To determine whether the primitive is front or back facing we
- * use the prim->det value because its sign is correct.
- */
- {
- const float area = (setup.emaj.dx * setup.ebot.dy -
- setup.ebot.dx * setup.emaj.dy);
-
- setup.oneoverarea = 1.0f / area;
- /*
- _mesa_printf("%s one-over-area %f area %f det %f\n",
- __FUNCTION__, setup.oneoverarea, area, prim->det );
- */
- }
-
-#if 0
- /* 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 = (prim->det > 0.0) ^ (setup.softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
-#endif
-
- return TRUE;
-}
-
-
-/**
- * Compute a0 for a constant-valued coefficient (GL_FLAT shading).
- * The value value comes from vertex->data[slot].
- * The result will be put into setup.coef[slot].a0.
- * \param slot which attribute slot
- */
-static INLINE void
-const_coeff(uint slot)
-{
- setup.coef[slot].dadx.v = (vector float) {0.0, 0.0, 0.0, 0.0};
- setup.coef[slot].dady.v = (vector float) {0.0, 0.0, 0.0, 0.0};
- setup.coef[slot].a0.v = setup.vprovoke->data[slot];
-}
-
-
-/**
- * Compute a0, dadx and dady for a linearly interpolated coefficient,
- * for a triangle.
- */
-static INLINE void
-tri_linear_coeff(uint slot, uint firstComp, uint lastComp)
-{
- uint i;
- const float *vmin_d = (float *) &setup.vmin->data[slot];
- const float *vmid_d = (float *) &setup.vmid->data[slot];
- const float *vmax_d = (float *) &setup.vmax->data[slot];
- const float x = spu_extract(setup.vmin->data[0], 0) - 0.5f;
- const float y = spu_extract(setup.vmin->data[0], 1) - 0.5f;
-
- for (i = firstComp; i < lastComp; i++) {
- float botda = vmid_d[i] - vmin_d[i];
- float majda = vmax_d[i] - vmin_d[i];
- float a = setup.ebot.dy * majda - botda * setup.emaj.dy;
- float b = setup.emaj.dx * botda - majda * setup.ebot.dx;
-
- ASSERT(slot < PIPE_MAX_SHADER_INPUTS);
-
- setup.coef[slot].dadx.f[i] = a * setup.oneoverarea;
- setup.coef[slot].dady.f[i] = b * setup.oneoverarea;
-
- /* calculate a0 as the value which would be sampled for the
- * fragment at (0,0), taking into account that we want to sample at
- * pixel centers, in other words (0.5, 0.5).
- *
- * this is neat but unfortunately not a good way to do things for
- * triangles with very large values of dadx or dady as it will
- * result in the subtraction and re-addition from a0 of a very
- * large number, which means we'll end up loosing a lot of the
- * fractional bits and precision from a0. the way to fix this is
- * to define a0 as the sample at a pixel center somewhere near vmin
- * instead - i'll switch to this later.
- */
- setup.coef[slot].a0.f[i] = (vmin_d[i] -
- (setup.coef[slot].dadx.f[i] * x +
- setup.coef[slot].dady.f[i] * y));
- }
-
- /*
- _mesa_printf("attr[%d].%c: %f dx:%f dy:%f\n",
- slot, "xyzw"[i],
- setup.coef[slot].a0[i],
- setup.coef[slot].dadx.f[i],
- setup.coef[slot].dady.f[i]);
- */
-}
-
-
-/**
- * As above, but interp setup all four vector components.
- */
-static INLINE void
-tri_linear_coeff4(uint slot)
-{
- const vector float vmin_d = setup.vmin->data[slot];
- const vector float vmid_d = setup.vmid->data[slot];
- const vector float vmax_d = setup.vmax->data[slot];
- const vector float xxxx = spu_splats(spu_extract(setup.vmin->data[0], 0) - 0.5f);
- const vector float yyyy = spu_splats(spu_extract(setup.vmin->data[0], 1) - 0.5f);
-
- vector float botda = vmid_d - vmin_d;
- vector float majda = vmax_d - vmin_d;
-
- vector float a = spu_sub(spu_mul(spu_splats(setup.ebot.dy), majda),
- spu_mul(botda, spu_splats(setup.emaj.dy)));
- vector float b = spu_sub(spu_mul(spu_splats(setup.emaj.dx), botda),
- spu_mul(majda, spu_splats(setup.ebot.dx)));
-
- setup.coef[slot].dadx.v = spu_mul(a, spu_splats(setup.oneoverarea));
- setup.coef[slot].dady.v = spu_mul(b, spu_splats(setup.oneoverarea));
-
- vector float tempx = spu_mul(setup.coef[slot].dadx.v, xxxx);
- vector float tempy = spu_mul(setup.coef[slot].dady.v, yyyy);
-
- setup.coef[slot].a0.v = spu_sub(vmin_d, spu_add(tempx, tempy));
-}
-
-
-
-#if 0
-/**
- * Compute a0, dadx and dady for a perspective-corrected interpolant,
- * for a triangle.
- * We basically multiply the vertex value by 1/w before computing
- * the plane coefficients (a0, dadx, dady).
- * Later, when we compute the value at a particular fragment position we'll
- * divide the interpolated value by the interpolated W at that fragment.
- */
-static void tri_persp_coeff( unsigned slot,
- unsigned i )
-{
- /* premultiply by 1/w:
- */
- float mina = setup.vmin->data[slot][i] * setup.vmin->data[0][3];
- float mida = setup.vmid->data[slot][i] * setup.vmid->data[0][3];
- float maxa = setup.vmax->data[slot][i] * setup.vmax->data[0][3];
-
- float botda = mida - mina;
- float majda = maxa - mina;
- float a = setup.ebot.dy * majda - botda * setup.emaj.dy;
- float b = setup.emaj.dx * botda - majda * setup.ebot.dx;
-
- /*
- printf("tri persp %d,%d: %f %f %f\n", slot, i,
- setup.vmin->data[slot][i],
- setup.vmid->data[slot][i],
- setup.vmax->data[slot][i]
- );
- */
-
- assert(slot < PIPE_MAX_SHADER_INPUTS);
- assert(i <= 3);
-
- setup.coef[slot].dadx.f[i] = a * setup.oneoverarea;
- setup.coef[slot].dady.f[i] = b * setup.oneoverarea;
- setup.coef[slot].a0.f[i] = (mina -
- (setup.coef[slot].dadx.f[i] * (setup.vmin->data[0][0] - 0.5f) +
- setup.coef[slot].dady.f[i] * (setup.vmin->data[0][1] - 0.5f)));
-}
-#endif
-
-
-/**
- * Compute the setup.coef[] array dadx, dady, a0 values.
- * Must be called after setup.vmin,vmid,vmax,vprovoke are initialized.
- */
-static void setup_tri_coefficients(void)
-{
-#if 1
- uint i;
-
- for (i = 0; i < spu.vertex_info.num_attribs; i++) {
- switch (spu.vertex_info.interp_mode[i]) {
- case INTERP_NONE:
- break;
- case INTERP_POS:
- /*tri_linear_coeff(i, 2, 3);*/
- /* XXX interp W if PERSPECTIVE... */
- tri_linear_coeff4(i);
- break;
- case INTERP_CONSTANT:
- const_coeff(i);
- break;
- case INTERP_LINEAR:
- tri_linear_coeff4(i);
- break;
- case INTERP_PERSPECTIVE:
- tri_linear_coeff4(i); /* temporary */
- break;
- default:
- ASSERT(0);
- }
- }
-#else
- ASSERT(spu.vertex_info.interp_mode[0] == INTERP_POS);
- ASSERT(spu.vertex_info.interp_mode[1] == INTERP_LINEAR ||
- spu.vertex_info.interp_mode[1] == INTERP_CONSTANT);
- tri_linear_coeff(0, 2, 3); /* slot 0, z */
- tri_linear_coeff(1, 0, 4); /* slot 1, color */
-#endif
-}
-
-
-static void setup_tri_edges(void)
-{
- float vmin_x = spu_extract(setup.vmin->data[0], 0) + 0.5f;
- float vmid_x = spu_extract(setup.vmid->data[0], 0) + 0.5f;
-
- float vmin_y = spu_extract(setup.vmin->data[0], 1) - 0.5f;
- float vmid_y = spu_extract(setup.vmid->data[0], 1) - 0.5f;
- float vmax_y = spu_extract(setup.vmax->data[0], 1) - 0.5f;
-
- 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.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.dxdy = setup.ebot.dx / setup.ebot.dy;
- setup.ebot.sx = vmin_x + (setup.ebot.sy - vmin_y) * setup.ebot.dxdy;
-}
-
-
-/**
- * Render the upper or lower half of a triangle.
- * Scissoring/cliprect is applied here too.
- */
-static void subtriangle( struct edge *eleft,
- struct edge *eright,
- unsigned lines )
-{
- const int minx = setup.cliprect_minx;
- const int maxx = setup.cliprect_maxx;
- const int miny = setup.cliprect_miny;
- const int maxy = setup.cliprect_maxy;
- int y, start_y, finish_y;
- int sy = (int)eleft->sy;
-
- ASSERT((int)eleft->sy == (int) eright->sy);
-
- /* clip top/bottom */
- start_y = sy;
- finish_y = sy + lines;
-
- if (start_y < miny)
- start_y = miny;
-
- if (finish_y > maxy)
- finish_y = maxy;
-
- start_y -= sy;
- finish_y -= sy;
-
- /*
- _mesa_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y);
- */
-
- for (y = start_y; y < finish_y; y++) {
-
- /* avoid accumulating adds as floats don't have the precision to
- * accurately iterate large triangle edges that way. luckily we
- * can just multiply these days.
- *
- * this is all drowned out by the attribute interpolation anyway.
- */
- int left = (int)(eleft->sx + y * eleft->dxdy);
- int right = (int)(eright->sx + y * eright->dxdy);
-
- /* clip left/right */
- if (left < minx)
- left = minx;
- if (right > maxx)
- right = maxx;
-
- if (left < right) {
- int _y = sy + y;
- if (block(_y) != setup.span.y) {
- flush_spans();
- setup.span.y = block(_y);
- }
-
- setup.span.left[_y&1] = left;
- setup.span.right[_y&1] = right;
- setup.span.y_flags |= 1<<(_y&1);
- }
- }
-
-
- /* save the values so that emaj can be restarted:
- */
- eleft->sx += lines * eleft->dxdy;
- eright->sx += lines * eright->dxdy;
- eleft->sy += lines;
- eright->sy += lines;
-}
-
-
-/**
- * Draw triangle into tile at (tx, ty) (tile coords)
- * The tile data should have already been fetched.
- */
-boolean
-tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty)
-{
- setup.tx = tx;
- setup.ty = ty;
-
- /* set clipping bounds to tile bounds */
- setup.cliprect_minx = tx * TILE_SIZE;
- setup.cliprect_miny = ty * TILE_SIZE;
- setup.cliprect_maxx = (tx + 1) * TILE_SIZE;
- setup.cliprect_maxy = (ty + 1) * TILE_SIZE;
-
- if (!setup_sort_vertices((struct vertex_header *) v0,
- (struct vertex_header *) v1,
- (struct vertex_header *) v2)) {
- return FALSE; /* totally clipped */
- }
-
- setup_tri_coefficients();
- setup_tri_edges();
-
- setup.span.y = 0;
- setup.span.y_flags = 0;
- setup.span.right[0] = 0;
- setup.span.right[1] = 0;
- /* setup.span.z_mode = tri_z_mode( setup.ctx ); */
-
- /* init_constant_attribs( setup ); */
-
- if (setup.oneoverarea < 0.0) {
- /* emaj on left:
- */
- subtriangle( &setup.emaj, &setup.ebot, setup.ebot.lines );
- subtriangle( &setup.emaj, &setup.etop, setup.etop.lines );
- }
- else {
- /* emaj on right:
- */
- subtriangle( &setup.ebot, &setup.emaj, setup.ebot.lines );
- subtriangle( &setup.etop, &setup.emaj, setup.etop.lines );
- }
-
- flush_spans();
-
- return TRUE;
-}
diff --git a/src/mesa/pipe/cell/spu/spu_tri.h b/src/mesa/pipe/cell/spu/spu_tri.h
deleted file mode 100644
index aa694dd7c9..0000000000
--- a/src/mesa/pipe/cell/spu/spu_tri.h
+++ /dev/null
@@ -1,37 +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 SPU_TRI_H
-#define SPU_TRI_H
-
-
-extern boolean
-tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty);
-
-
-#endif /* SPU_TRI_H */
diff --git a/src/mesa/pipe/cell/spu/spu_util.c b/src/mesa/pipe/cell/spu/spu_util.c
deleted file mode 100644
index ac373240c1..0000000000
--- a/src/mesa/pipe/cell/spu/spu_util.c
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-//#include "tgsi_build.h"
-#include "pipe/tgsi/util/tgsi_util.h"
-
-unsigned
-tgsi_util_get_src_register_swizzle(
- const struct tgsi_src_register *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->SwizzleX;
- case 1:
- return reg->SwizzleY;
- case 2:
- return reg->SwizzleZ;
- case 3:
- return reg->SwizzleW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-unsigned
-tgsi_util_get_src_register_extswizzle(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->ExtSwizzleX;
- case 1:
- return reg->ExtSwizzleY;
- case 2:
- return reg->ExtSwizzleZ;
- case 3:
- return reg->ExtSwizzleW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-unsigned
-tgsi_util_get_full_src_register_extswizzle(
- const struct tgsi_full_src_register *reg,
- unsigned component )
-{
- unsigned swizzle;
-
- /*
- * First, calculate the extended swizzle for a given channel. This will give
- * us either a channel index into the simple swizzle or a constant 1 or 0.
- */
- swizzle = tgsi_util_get_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);
-
- /*
- * Second, calculate the simple swizzle for the unswizzled channel index.
- * Leave the constants intact, they are not affected by the simple swizzle.
- */
- if( swizzle <= TGSI_SWIZZLE_W ) {
- swizzle = tgsi_util_get_src_register_swizzle(
- &reg->SrcRegister,
- component );
- }
-
- return swizzle;
-}
-
-unsigned
-tgsi_util_get_src_register_extnegate(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->NegateX;
- case 1:
- return reg->NegateY;
- case 2:
- return reg->NegateZ;
- case 3:
- return reg->NegateW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-void
-tgsi_util_set_src_register_extnegate(
- struct tgsi_src_register_ext_swz *reg,
- unsigned negate,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->NegateX = negate;
- break;
- case 1:
- reg->NegateY = negate;
- break;
- case 2:
- reg->NegateZ = negate;
- break;
- case 3:
- reg->NegateW = negate;
- break;
- default:
- assert( 0 );
- }
-}
-
-unsigned
-tgsi_util_get_full_src_register_sign_mode(
- const struct tgsi_full_src_register *reg,
- unsigned component )
-{
- unsigned sign_mode;
-
- if( reg->SrcRegisterExtMod.Absolute ) {
- /* Consider only the post-abs negation. */
-
- if( reg->SrcRegisterExtMod.Negate ) {
- sign_mode = TGSI_UTIL_SIGN_SET;
- }
- else {
- sign_mode = TGSI_UTIL_SIGN_CLEAR;
- }
- }
- else {
- /* Accumulate the three negations. */
-
- unsigned negate;
-
- negate = reg->SrcRegister.Negate;
- if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
- negate = !negate;
- }
- if( reg->SrcRegisterExtMod.Negate ) {
- negate = !negate;
- }
-
- if( negate ) {
- sign_mode = TGSI_UTIL_SIGN_TOGGLE;
- }
- else {
- sign_mode = TGSI_UTIL_SIGN_KEEP;
- }
- }
-
- return sign_mode;
-}
diff --git a/src/mesa/pipe/cell/spu/spu_vertex_fetch.c b/src/mesa/pipe/cell/spu/spu_vertex_fetch.c
deleted file mode 100644
index 6e86a919ce..0000000000
--- a/src/mesa/pipe/cell/spu/spu_vertex_fetch.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include <spu_mfcio.h>
-#include <transpose_matrix4x4.h>
-
-#include "pipe/p_util.h"
-#include "pipe/p_state.h"
-#include "pipe/p_shader_tokens.h"
-#include "spu_exec.h"
-#include "spu_vertex_shader.h"
-#include "spu_main.h"
-
-
-#define DRAW_DBG 0
-
-
-static const vec_float4 defaults = { 0.0, 0.0, 0.0, 1.0 };
-
-/**
- * Fetch a float[4] vertex attribute from memory, doing format/type
- * conversion as needed.
- *
- * This is probably needed/dupliocated elsewhere, eg format
- * conversion, texture sampling etc.
- */
-#define FETCH_ATTRIB( NAME, SZ, CVT ) \
-static qword \
-fetch_##NAME(const void *ptr) \
-{ \
- vec_float4 attrib = defaults; \
- int i; \
- \
- for (i = 0; i < SZ; i++) { \
- attrib = spu_insert(CVT, attrib, i); \
- } \
- return (qword) attrib; \
-}
-
-#define CVT_64_FLOAT (float) ((double *) ptr)[i]
-#define CVT_32_FLOAT ((float *) ptr)[i]
-
-#define CVT_8_USCALED (float) ((unsigned char *) ptr)[i]
-#define CVT_16_USCALED (float) ((unsigned short *) ptr)[i]
-#define CVT_32_USCALED (float) ((unsigned int *) ptr)[i]
-
-#define CVT_8_SSCALED (float) ((char *) ptr)[i]
-#define CVT_16_SSCALED (float) ((short *) ptr)[i]
-#define CVT_32_SSCALED (float) ((int *) ptr)[i]
-
-#define CVT_8_UNORM (float) ((unsigned char *) ptr)[i] / 255.0f
-#define CVT_16_UNORM (float) ((unsigned short *) ptr)[i] / 65535.0f
-#define CVT_32_UNORM (float) ((unsigned int *) ptr)[i] / 4294967295.0f
-
-#define CVT_8_SNORM (float) ((char *) ptr)[i] / 127.0f
-#define CVT_16_SNORM (float) ((short *) ptr)[i] / 32767.0f
-#define CVT_32_SNORM (float) ((int *) ptr)[i] / 2147483647.0f
-
-FETCH_ATTRIB( R64G64B64A64_FLOAT, 4, CVT_64_FLOAT )
-FETCH_ATTRIB( R64G64B64_FLOAT, 3, CVT_64_FLOAT )
-FETCH_ATTRIB( R64G64_FLOAT, 2, CVT_64_FLOAT )
-FETCH_ATTRIB( R64_FLOAT, 1, CVT_64_FLOAT )
-
-FETCH_ATTRIB( R32G32B32A32_FLOAT, 4, CVT_32_FLOAT )
-FETCH_ATTRIB( R32G32B32_FLOAT, 3, CVT_32_FLOAT )
-FETCH_ATTRIB( R32G32_FLOAT, 2, CVT_32_FLOAT )
-FETCH_ATTRIB( R32_FLOAT, 1, CVT_32_FLOAT )
-
-FETCH_ATTRIB( R32G32B32A32_USCALED, 4, CVT_32_USCALED )
-FETCH_ATTRIB( R32G32B32_USCALED, 3, CVT_32_USCALED )
-FETCH_ATTRIB( R32G32_USCALED, 2, CVT_32_USCALED )
-FETCH_ATTRIB( R32_USCALED, 1, CVT_32_USCALED )
-
-FETCH_ATTRIB( R32G32B32A32_SSCALED, 4, CVT_32_SSCALED )
-FETCH_ATTRIB( R32G32B32_SSCALED, 3, CVT_32_SSCALED )
-FETCH_ATTRIB( R32G32_SSCALED, 2, CVT_32_SSCALED )
-FETCH_ATTRIB( R32_SSCALED, 1, CVT_32_SSCALED )
-
-FETCH_ATTRIB( R32G32B32A32_UNORM, 4, CVT_32_UNORM )
-FETCH_ATTRIB( R32G32B32_UNORM, 3, CVT_32_UNORM )
-FETCH_ATTRIB( R32G32_UNORM, 2, CVT_32_UNORM )
-FETCH_ATTRIB( R32_UNORM, 1, CVT_32_UNORM )
-
-FETCH_ATTRIB( R32G32B32A32_SNORM, 4, CVT_32_SNORM )
-FETCH_ATTRIB( R32G32B32_SNORM, 3, CVT_32_SNORM )
-FETCH_ATTRIB( R32G32_SNORM, 2, CVT_32_SNORM )
-FETCH_ATTRIB( R32_SNORM, 1, CVT_32_SNORM )
-
-FETCH_ATTRIB( R16G16B16A16_USCALED, 4, CVT_16_USCALED )
-FETCH_ATTRIB( R16G16B16_USCALED, 3, CVT_16_USCALED )
-FETCH_ATTRIB( R16G16_USCALED, 2, CVT_16_USCALED )
-FETCH_ATTRIB( R16_USCALED, 1, CVT_16_USCALED )
-
-FETCH_ATTRIB( R16G16B16A16_SSCALED, 4, CVT_16_SSCALED )
-FETCH_ATTRIB( R16G16B16_SSCALED, 3, CVT_16_SSCALED )
-FETCH_ATTRIB( R16G16_SSCALED, 2, CVT_16_SSCALED )
-FETCH_ATTRIB( R16_SSCALED, 1, CVT_16_SSCALED )
-
-FETCH_ATTRIB( R16G16B16A16_UNORM, 4, CVT_16_UNORM )
-FETCH_ATTRIB( R16G16B16_UNORM, 3, CVT_16_UNORM )
-FETCH_ATTRIB( R16G16_UNORM, 2, CVT_16_UNORM )
-FETCH_ATTRIB( R16_UNORM, 1, CVT_16_UNORM )
-
-FETCH_ATTRIB( R16G16B16A16_SNORM, 4, CVT_16_SNORM )
-FETCH_ATTRIB( R16G16B16_SNORM, 3, CVT_16_SNORM )
-FETCH_ATTRIB( R16G16_SNORM, 2, CVT_16_SNORM )
-FETCH_ATTRIB( R16_SNORM, 1, CVT_16_SNORM )
-
-FETCH_ATTRIB( R8G8B8A8_USCALED, 4, CVT_8_USCALED )
-FETCH_ATTRIB( R8G8B8_USCALED, 3, CVT_8_USCALED )
-FETCH_ATTRIB( R8G8_USCALED, 2, CVT_8_USCALED )
-FETCH_ATTRIB( R8_USCALED, 1, CVT_8_USCALED )
-
-FETCH_ATTRIB( R8G8B8A8_SSCALED, 4, CVT_8_SSCALED )
-FETCH_ATTRIB( R8G8B8_SSCALED, 3, CVT_8_SSCALED )
-FETCH_ATTRIB( R8G8_SSCALED, 2, CVT_8_SSCALED )
-FETCH_ATTRIB( R8_SSCALED, 1, CVT_8_SSCALED )
-
-FETCH_ATTRIB( R8G8B8A8_UNORM, 4, CVT_8_UNORM )
-FETCH_ATTRIB( R8G8B8_UNORM, 3, CVT_8_UNORM )
-FETCH_ATTRIB( R8G8_UNORM, 2, CVT_8_UNORM )
-FETCH_ATTRIB( R8_UNORM, 1, CVT_8_UNORM )
-
-FETCH_ATTRIB( R8G8B8A8_SNORM, 4, CVT_8_SNORM )
-FETCH_ATTRIB( R8G8B8_SNORM, 3, CVT_8_SNORM )
-FETCH_ATTRIB( R8G8_SNORM, 2, CVT_8_SNORM )
-FETCH_ATTRIB( R8_SNORM, 1, CVT_8_SNORM )
-
-FETCH_ATTRIB( A8R8G8B8_UNORM, 4, CVT_8_UNORM )
-//FETCH_ATTRIB( R8G8B8A8_UNORM, 4, CVT_8_UNORM )
-
-
-
-static spu_fetch_func get_fetch_func( enum pipe_format format )
-{
-#if 0
- {
- char tmp[80];
- pf_sprint_name(tmp, format);
- _mesa_printf("%s: %s\n", __FUNCTION__, tmp);
- }
-#endif
-
- switch (format) {
- case PIPE_FORMAT_R64_FLOAT:
- return fetch_R64_FLOAT;
- case PIPE_FORMAT_R64G64_FLOAT:
- return fetch_R64G64_FLOAT;
- case PIPE_FORMAT_R64G64B64_FLOAT:
- return fetch_R64G64B64_FLOAT;
- case PIPE_FORMAT_R64G64B64A64_FLOAT:
- return fetch_R64G64B64A64_FLOAT;
-
- case PIPE_FORMAT_R32_FLOAT:
- return fetch_R32_FLOAT;
- case PIPE_FORMAT_R32G32_FLOAT:
- return fetch_R32G32_FLOAT;
- case PIPE_FORMAT_R32G32B32_FLOAT:
- return fetch_R32G32B32_FLOAT;
- case PIPE_FORMAT_R32G32B32A32_FLOAT:
- return fetch_R32G32B32A32_FLOAT;
-
- case PIPE_FORMAT_R32_UNORM:
- return fetch_R32_UNORM;
- case PIPE_FORMAT_R32G32_UNORM:
- return fetch_R32G32_UNORM;
- case PIPE_FORMAT_R32G32B32_UNORM:
- return fetch_R32G32B32_UNORM;
- case PIPE_FORMAT_R32G32B32A32_UNORM:
- return fetch_R32G32B32A32_UNORM;
-
- case PIPE_FORMAT_R32_USCALED:
- return fetch_R32_USCALED;
- case PIPE_FORMAT_R32G32_USCALED:
- return fetch_R32G32_USCALED;
- case PIPE_FORMAT_R32G32B32_USCALED:
- return fetch_R32G32B32_USCALED;
- case PIPE_FORMAT_R32G32B32A32_USCALED:
- return fetch_R32G32B32A32_USCALED;
-
- case PIPE_FORMAT_R32_SNORM:
- return fetch_R32_SNORM;
- case PIPE_FORMAT_R32G32_SNORM:
- return fetch_R32G32_SNORM;
- case PIPE_FORMAT_R32G32B32_SNORM:
- return fetch_R32G32B32_SNORM;
- case PIPE_FORMAT_R32G32B32A32_SNORM:
- return fetch_R32G32B32A32_SNORM;
-
- case PIPE_FORMAT_R32_SSCALED:
- return fetch_R32_SSCALED;
- case PIPE_FORMAT_R32G32_SSCALED:
- return fetch_R32G32_SSCALED;
- case PIPE_FORMAT_R32G32B32_SSCALED:
- return fetch_R32G32B32_SSCALED;
- case PIPE_FORMAT_R32G32B32A32_SSCALED:
- return fetch_R32G32B32A32_SSCALED;
-
- case PIPE_FORMAT_R16_UNORM:
- return fetch_R16_UNORM;
- case PIPE_FORMAT_R16G16_UNORM:
- return fetch_R16G16_UNORM;
- case PIPE_FORMAT_R16G16B16_UNORM:
- return fetch_R16G16B16_UNORM;
- case PIPE_FORMAT_R16G16B16A16_UNORM:
- return fetch_R16G16B16A16_UNORM;
-
- case PIPE_FORMAT_R16_USCALED:
- return fetch_R16_USCALED;
- case PIPE_FORMAT_R16G16_USCALED:
- return fetch_R16G16_USCALED;
- case PIPE_FORMAT_R16G16B16_USCALED:
- return fetch_R16G16B16_USCALED;
- case PIPE_FORMAT_R16G16B16A16_USCALED:
- return fetch_R16G16B16A16_USCALED;
-
- case PIPE_FORMAT_R16_SNORM:
- return fetch_R16_SNORM;
- case PIPE_FORMAT_R16G16_SNORM:
- return fetch_R16G16_SNORM;
- case PIPE_FORMAT_R16G16B16_SNORM:
- return fetch_R16G16B16_SNORM;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- return fetch_R16G16B16A16_SNORM;
-
- case PIPE_FORMAT_R16_SSCALED:
- return fetch_R16_SSCALED;
- case PIPE_FORMAT_R16G16_SSCALED:
- return fetch_R16G16_SSCALED;
- case PIPE_FORMAT_R16G16B16_SSCALED:
- return fetch_R16G16B16_SSCALED;
- case PIPE_FORMAT_R16G16B16A16_SSCALED:
- return fetch_R16G16B16A16_SSCALED;
-
- case PIPE_FORMAT_R8_UNORM:
- return fetch_R8_UNORM;
- case PIPE_FORMAT_R8G8_UNORM:
- return fetch_R8G8_UNORM;
- case PIPE_FORMAT_R8G8B8_UNORM:
- return fetch_R8G8B8_UNORM;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return fetch_R8G8B8A8_UNORM;
-
- case PIPE_FORMAT_R8_USCALED:
- return fetch_R8_USCALED;
- case PIPE_FORMAT_R8G8_USCALED:
- return fetch_R8G8_USCALED;
- case PIPE_FORMAT_R8G8B8_USCALED:
- return fetch_R8G8B8_USCALED;
- case PIPE_FORMAT_R8G8B8A8_USCALED:
- return fetch_R8G8B8A8_USCALED;
-
- case PIPE_FORMAT_R8_SNORM:
- return fetch_R8_SNORM;
- case PIPE_FORMAT_R8G8_SNORM:
- return fetch_R8G8_SNORM;
- case PIPE_FORMAT_R8G8B8_SNORM:
- return fetch_R8G8B8_SNORM;
- case PIPE_FORMAT_R8G8B8A8_SNORM:
- return fetch_R8G8B8A8_SNORM;
-
- case PIPE_FORMAT_R8_SSCALED:
- return fetch_R8_SSCALED;
- case PIPE_FORMAT_R8G8_SSCALED:
- return fetch_R8G8_SSCALED;
- case PIPE_FORMAT_R8G8B8_SSCALED:
- return fetch_R8G8B8_SSCALED;
- case PIPE_FORMAT_R8G8B8A8_SSCALED:
- return fetch_R8G8B8A8_SSCALED;
-
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return fetch_A8R8G8B8_UNORM;
-
- case 0:
- return NULL; /* not sure why this is needed */
-
- default:
- assert(0);
- return NULL;
- }
-}
-
-
-/**
- * Fetch vertex attributes for 'count' vertices.
- */
-static void generic_vertex_fetch(struct spu_vs_context *draw,
- struct spu_exec_machine *machine,
- const unsigned *elts,
- unsigned count)
-{
- unsigned nr_attrs = draw->vertex_fetch.nr_attrs;
- unsigned attr;
-
- assert(count <= 4);
-
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
-
-#if DRAW_DBG
- printf("SPU: %s count = %u, nr_attrs = %u\n",
- __FUNCTION__, count, nr_attrs);
-#endif
-
- /* loop over vertex attributes (vertex shader inputs)
- */
- for (attr = 0; attr < nr_attrs; attr++) {
- const unsigned pitch = draw->vertex_fetch.pitch[attr];
- const uint64_t src = draw->vertex_fetch.src_ptr[attr];
- const spu_fetch_func fetch = draw->vertex_fetch.fetch[attr];
- unsigned i;
- qword p[4];
-
-
- /* Fetch four attributes for four vertices.
- *
- * Could fetch directly into AOS format, but this is meant to be
- * a prototype for an sse implementation, which would have
- * difficulties doing that.
- */
- for (i = 0; i < count; i++) {
- uint8_t buffer[32] ALIGN16_ATTRIB;
- const uint64_t addr = src + (elts[i] * pitch);
- const unsigned size = ((addr & 0x0f) == 0) ? 16 : 32;
-
-#if DRAW_DBG
- printf("SPU: fetching = 0x%llx\n", addr);
-#endif
- mfc_get(buffer, addr & ~0x0f, size, TAG_VERTEX_BUFFER, 0, 0);
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
-
- p[i] = (*fetch)(buffer + (addr & 0x0f));
- }
-
- /* Be nice and zero out any missing vertices:
- */
- for (/* empty */; i < 4; i++)
- p[i] = si_xor(p[i], p[i]);
-
- /* Transpose/swizzle into vector-friendly format. Currently
- * assuming that all vertex shader inputs are float[4], but this
- * isn't true -- if the vertex shader only wants tex0.xy, we
- * could optimize for that.
- *
- * To do so fully without codegen would probably require an
- * excessive number of fetch functions, but we could at least
- * minimize the transpose step:
- */
- _transpose_matrix4x4(&machine->Inputs[attr].xyzw[0].q, p);
- }
-}
-
-
-void spu_update_vertex_fetch( struct spu_vs_context *draw )
-{
- unsigned i;
-
-
- for (i = 0; i < draw->vertex_fetch.nr_attrs; i++) {
- draw->vertex_fetch.fetch[i] =
- get_fetch_func(draw->vertex_fetch.format[i]);
- }
-
- draw->vertex_fetch.fetch_func = generic_vertex_fetch;
-}
diff --git a/src/mesa/pipe/cell/spu/spu_vertex_shader.c b/src/mesa/pipe/cell/spu/spu_vertex_shader.c
deleted file mode 100644
index c1cbbb6d1e..0000000000
--- a/src/mesa/pipe/cell/spu/spu_vertex_shader.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- * Ian Romanick <idr@us.ibm.com>
- */
-
-#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 "pipe/draw/draw_private.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/cell/common.h"
-#include "spu_main.h"
-
-static INLINE unsigned
-compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
-{
- unsigned mask = 0;
- unsigned i;
-
- /* Do the hardwired planes first:
- */
- if (-clip[0] + clip[3] < 0) mask |= CLIP_RIGHT_BIT;
- if ( clip[0] + clip[3] < 0) mask |= CLIP_LEFT_BIT;
- if (-clip[1] + clip[3] < 0) mask |= CLIP_TOP_BIT;
- if ( clip[1] + clip[3] < 0) mask |= CLIP_BOTTOM_BIT;
- if (-clip[2] + clip[3] < 0) mask |= CLIP_FAR_BIT;
- if ( clip[2] + clip[3] < 0) mask |= CLIP_NEAR_BIT;
-
- /* Followed by any remaining ones:
- */
- for (i = 6; i < nr; i++) {
- if (dot4(clip, plane[i]) < 0)
- mask |= (1<<i);
- }
-
- return mask;
-}
-
-
-/**
- * Transform vertices with the current vertex program/shader
- * Up to four vertices can be shaded at a time.
- * \param vbuffer the input vertex data
- * \param elts indexes of four input vertices
- * \param count number of vertices to shade [1..4]
- * \param vOut array of pointers to four output vertices
- */
-static void
-run_vertex_program(struct spu_vs_context *draw,
- unsigned elts[4], unsigned count,
- const uint64_t *vOut)
-{
- struct spu_exec_machine *machine = &draw->machine;
- unsigned int j;
-
- ALIGN16_DECL(struct spu_exec_vector, inputs, PIPE_ATTRIB_MAX);
- ALIGN16_DECL(struct spu_exec_vector, outputs, PIPE_ATTRIB_MAX);
- const float *scale = draw->viewport.scale;
- const float *trans = draw->viewport.translate;
-
- assert(count <= 4);
-
- machine->Processor = TGSI_PROCESSOR_VERTEX;
-
- ASSERT_ALIGN16(draw->constants);
- machine->Consts = (float (*)[4]) draw->constants;
-
- machine->Inputs = ALIGN16_ASSIGN(inputs);
- machine->Outputs = ALIGN16_ASSIGN(outputs);
-
- spu_vertex_fetch( draw, machine, elts, count );
-
- /* run shader */
- spu_exec_machine_run( machine );
-
-
- /* store machine results */
- for (j = 0; j < count; j++) {
- unsigned slot;
- float x, y, z, w;
- unsigned char buffer[sizeof(struct vertex_header)
- + MAX_VERTEX_SIZE] ALIGN16_ATTRIB;
- struct vertex_header *const tmpOut =
- (struct vertex_header *) buffer;
- const unsigned vert_size = ROUNDUP16(sizeof(struct vertex_header)
- + (sizeof(float) * 4
- * draw->num_vs_outputs));
-
- mfc_get(tmpOut, vOut[j], vert_size, TAG_VERTEX_BUFFER, 0, 0);
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
-
-
- /* Handle attr[0] (position) specially:
- *
- * XXX: Computing the clipmask should be done in the vertex
- * program as a set of DP4 instructions appended to the
- * user-provided code.
- */
- x = tmpOut->clip[0] = machine->Outputs[0].xyzw[0].f[j];
- y = tmpOut->clip[1] = machine->Outputs[0].xyzw[1].f[j];
- z = tmpOut->clip[2] = machine->Outputs[0].xyzw[2].f[j];
- w = tmpOut->clip[3] = machine->Outputs[0].xyzw[3].f[j];
-
- tmpOut->clipmask = compute_clipmask(tmpOut->clip, draw->plane,
- draw->nr_planes);
- tmpOut->edgeflag = 1;
-
- /* divide by w */
- w = 1.0f / w;
- x *= w;
- y *= w;
- z *= w;
-
- /* Viewport mapping */
- tmpOut->data[0][0] = x * scale[0] + trans[0];
- tmpOut->data[0][1] = y * scale[1] + trans[1];
- tmpOut->data[0][2] = z * scale[2] + trans[2];
- tmpOut->data[0][3] = w;
-
- /* Remaining attributes are packed into sequential post-transform
- * vertex attrib slots.
- */
- for (slot = 1; slot < draw->num_vs_outputs; slot++) {
- tmpOut->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
- tmpOut->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
- tmpOut->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
- tmpOut->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
- }
-
- mfc_put(tmpOut, vOut[j], vert_size, TAG_VERTEX_BUFFER, 0, 0);
- } /* loop over vertices */
-}
-
-
-static void
-spu_bind_vertex_shader(struct spu_vs_context *draw,
- void *uniforms,
- void *planes,
- unsigned nr_planes,
- unsigned num_outputs
- )
-{
- draw->constants = (float (*)[4]) uniforms;
-
- (void) memcpy(draw->plane, planes, sizeof(float) * 4 * nr_planes);
- draw->nr_planes = nr_planes;
- draw->num_vs_outputs = num_outputs;
-
- /* specify the shader to interpret/execute */
- spu_exec_machine_init(&draw->machine,
- PIPE_MAX_SAMPLERS,
- NULL /*samplers*/,
- PIPE_SHADER_VERTEX);
-}
-
-
-unsigned char immediates[(sizeof(float) * 4 * TGSI_EXEC_NUM_IMMEDIATES) + 32]
- ALIGN16_ATTRIB;
-
-void
-spu_execute_vertex_shader(struct spu_vs_context *draw,
- const struct cell_command_vs *vs)
-{
- unsigned i;
-
- const uint64_t immediate_addr = vs->shader.immediates;
- const unsigned immediate_size =
- ROUNDUP16((sizeof(float) * 4 * vs->shader.num_immediates)
- + (immediate_addr & 0x0f));
-
- mfc_get(immediates, immediate_addr & ~0x0f, immediate_size,
- TAG_VERTEX_BUFFER, 0, 0);
-
- draw->machine.Instructions = (struct tgsi_full_instruction *)
- vs->shader.instructions;
- draw->machine.NumInstructions = vs->shader.num_instructions;
-
- draw->machine.Declarations = (struct tgsi_full_declaration *)
- vs->shader.declarations;
- draw->machine.NumDeclarations = vs->shader.num_declarations;
-
- draw->vertex_fetch.nr_attrs = vs->nr_attrs;
-
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
-
- (void) memcpy(& draw->machine.Imms, &immediates[immediate_addr & 0x0f],
- sizeof(float) * 4 * vs->shader.num_immediates);
-
- spu_bind_vertex_shader(draw, vs->shader.uniforms,
- vs->plane, vs->nr_planes,
- vs->shader.num_outputs);
-
- for (i = 0; i < vs->num_elts; i += 4) {
- const unsigned batch_size = MIN2(vs->num_elts - i, 4);
-
- run_vertex_program(draw, & vs->elts[i], batch_size, &vs->vOut[i]);
- }
-}
diff --git a/src/mesa/pipe/cell/spu/spu_vertex_shader.h b/src/mesa/pipe/cell/spu/spu_vertex_shader.h
deleted file mode 100644
index c96b93ff0a..0000000000
--- a/src/mesa/pipe/cell/spu/spu_vertex_shader.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef SPU_VERTEX_SHADER_H
-#define SPU_VERTEX_SHADER_H
-
-#include "pipe/p_format.h"
-#include "spu_exec.h"
-
-struct spu_vs_context;
-
-typedef qword (*spu_fetch_func)(const void *ptr);
-typedef void (*spu_full_fetch_func)( struct spu_vs_context *draw,
- struct spu_exec_machine *machine,
- const unsigned *elts,
- unsigned count );
-
-struct spu_vs_context {
- struct pipe_viewport_state viewport;
-
- struct {
- uint64_t src_ptr[PIPE_ATTRIB_MAX];
- unsigned pitch[PIPE_ATTRIB_MAX];
- enum pipe_format format[PIPE_ATTRIB_MAX];
- unsigned nr_attrs;
- boolean dirty;
-
- spu_fetch_func fetch[PIPE_ATTRIB_MAX];
- spu_full_fetch_func fetch_func;
- } vertex_fetch;
-
- /* Clip derived state:
- */
- float plane[12][4];
- unsigned nr_planes;
-
- struct spu_exec_machine machine;
- const float (*constants)[4];
-
- unsigned num_vs_outputs;
-};
-
-extern void spu_update_vertex_fetch(struct spu_vs_context *draw);
-
-static INLINE void spu_vertex_fetch(struct spu_vs_context *draw,
- struct spu_exec_machine *machine,
- const unsigned *elts,
- unsigned count)
-{
- if (draw->vertex_fetch.dirty) {
- spu_update_vertex_fetch(draw);
- draw->vertex_fetch.dirty = 0;
- }
-
- (*draw->vertex_fetch.fetch_func)(draw, machine, elts, count);
-}
-
-struct cell_command_vs;
-
-extern void
-spu_execute_vertex_shader(struct spu_vs_context *draw,
- const struct cell_command_vs *vs);
-
-#endif /* SPU_VERTEX_SHADER_H */
diff --git a/src/mesa/pipe/cell/spu/spu_ztest.h b/src/mesa/pipe/cell/spu/spu_ztest.h
deleted file mode 100644
index ce8ad00339..0000000000
--- a/src/mesa/pipe/cell/spu/spu_ztest.h
+++ /dev/null
@@ -1,135 +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.
- *
- **************************************************************************/
-
-
-/**
- * Zbuffer/depth test code.
- */
-
-
-#ifndef SPU_ZTEST_H
-#define SPU_ZTEST_H
-
-
-#ifdef __SPU__
-#include <spu_intrinsics.h>
-#endif
-
-
-
-/**
- * Perform Z testing for a 16-bit/value Z buffer.
- *
- * \param zvals vector of four fragment zvalues as floats
- * \param zbuf ptr to vector of ushort[8] zbuffer values. Note that this
- * contains the Z values for 2 quads, 8 pixels.
- * \param x x coordinate of quad (only lsbit is significant)
- * \param inMask indicates which fragments in the quad are alive
- * \return new mask indicating which fragments are alive after ztest
- */
-static INLINE vector unsigned int
-spu_z16_test_less(vector float zvals, vector unsigned short *zbuf,
- uint x, vector unsigned int inMask)
-{
-#define ZERO 0x80
- vector unsigned int zvals_ui4, zbuf_ui4, mask;
-
- /* convert floats to uints in [0, 65535] */
- zvals_ui4 = spu_convtu(zvals, 32); /* convert to [0, 2^32] */
- zvals_ui4 = spu_rlmask(zvals_ui4, -16); /* right shift 16 */
-
- /* XXX this conditional could be removed with a bit of work */
- if (x & 1) {
- /* convert zbuffer values from ushorts to uints */
- /* gather lower four ushorts */
- zbuf_ui4 = spu_shuffle((vector unsigned int) *zbuf,
- (vector unsigned int) *zbuf,
- ((vector unsigned char) {
- ZERO, ZERO, 8, 9, ZERO, ZERO, 10, 11,
- ZERO, ZERO, 12, 13, ZERO, ZERO, 14, 15}));
- /* mask = (zbuf_ui4 < zvals_ui4) ? ~0 : 0 */
- mask = spu_cmpgt(zbuf_ui4, zvals_ui4);
- /* mask &= inMask */
- mask = spu_and(mask, inMask);
- /* zbuf = mask ? zval : zbuf */
- zbuf_ui4 = spu_sel(zbuf_ui4, zvals_ui4, mask);
- /* convert zbuffer values from uints back to ushorts, preserve lower 4 */
- *zbuf = (vector unsigned short)
- spu_shuffle(zbuf_ui4, (vector unsigned int) *zbuf,
- ((vector unsigned char) {
- 16, 17, 18, 19, 20, 21, 22, 23,
- 2, 3, 6, 7, 10, 11, 14, 15}));
- }
- else {
- /* convert zbuffer values from ushorts to uints */
- /* gather upper four ushorts */
- zbuf_ui4 = spu_shuffle((vector unsigned int) *zbuf,
- (vector unsigned int) *zbuf,
- ((vector unsigned char) {
- ZERO, ZERO, 0, 1, ZERO, ZERO, 2, 3,
- ZERO, ZERO, 4, 5, ZERO, ZERO, 6, 7}));
- /* mask = (zbuf_ui4 < zvals_ui4) ? ~0 : 0 */
- mask = spu_cmpgt(zbuf_ui4, zvals_ui4);
- /* mask &= inMask */
- mask = spu_and(mask, inMask);
- /* zbuf = mask ? zval : zbuf */
- zbuf_ui4 = spu_sel(zbuf_ui4, zvals_ui4, mask);
- /* convert zbuffer values from uints back to ushorts, preserve upper 4 */
- *zbuf = (vector unsigned short)
- spu_shuffle(zbuf_ui4, (vector unsigned int) *zbuf,
- ((vector unsigned char) {
- 2, 3, 6, 7, 10, 11, 14, 15,
- 24, 25, 26, 27, 28, 29, 30, 31}));
- }
- return mask;
-#undef ZERO
-}
-
-
-/**
- * As above, but Zbuffer values as 32-bit uints
- */
-static INLINE vector unsigned int
-spu_z32_test_less(vector float zvals, vector unsigned int *zbuf_ptr,
- vector unsigned int inMask)
-{
- vector unsigned int zvals_ui4, mask, zbuf = *zbuf_ptr;
-
- /* convert floats to uints in [0, 0xffffffff] */
- zvals_ui4 = spu_convtu(zvals, 32);
- /* mask = (zbuf < zvals_ui4) ? ~0 : 0 */
- mask = spu_cmpgt(zbuf, zvals_ui4);
- /* mask &= inMask */
- mask = spu_and(mask, inMask);
- /* zbuf = mask ? zval : zbuf */
- *zbuf_ptr = spu_sel(zbuf, zvals_ui4, mask);
-
- return mask;
-}
-
-
-#endif /* SPU_ZTEST_H */
diff --git a/src/mesa/pipe/cso_cache/cso_cache.c b/src/mesa/pipe/cso_cache/cso_cache.c
deleted file mode 100644
index 9e77e0774d..0000000000
--- a/src/mesa/pipe/cso_cache/cso_cache.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Zack Rusin <zack@tungstengraphics.com>
- */
-
-#include "cso_cache.h"
-#include "cso_hash.h"
-
-#if 1
-static unsigned hash_key(const void *key, unsigned key_size)
-{
- unsigned *ikey = (unsigned *)key;
- unsigned hash = 0, i;
-
- assert(key_size % 4 == 0);
-
- /* I'm sure this can be improved on:
- */
- for (i = 0; i < key_size/4; i++)
- hash ^= ikey[i];
-
- return hash;
-}
-#else
-static unsigned hash_key(const unsigned char *p, int n)
-{
- unsigned h = 0;
- unsigned g;
-
- while (n--) {
- h = (h << 4) + *p++;
- if ((g = (h & 0xf0000000)) != 0)
- h ^= g >> 23;
- h &= ~g;
- }
- return h;
-}
-#endif
-
-unsigned cso_construct_key(void *item, int item_size)
-{
- return hash_key((item), item_size);
-}
-
-static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_type type)
-{
- struct cso_hash *hash = 0;
-
- switch(type) {
- case CSO_BLEND:
- hash = sc->blend_hash;
- break;
- case CSO_SAMPLER:
- hash = sc->sampler_hash;
- break;
- case CSO_DEPTH_STENCIL_ALPHA:
- hash = sc->depth_stencil_hash;
- break;
- case CSO_RASTERIZER:
- hash = sc->rasterizer_hash;
- break;
- case CSO_FRAGMENT_SHADER:
- hash = sc->fs_hash;
- break;
- case CSO_VERTEX_SHADER:
- hash = sc->vs_hash;
- break;
- }
-
- return hash;
-}
-
-static int _cso_size_for_type(enum cso_cache_type type)
-{
- switch(type) {
- case CSO_BLEND:
- return sizeof(struct pipe_blend_state);
- case CSO_SAMPLER:
- return sizeof(struct pipe_sampler_state);
- case CSO_DEPTH_STENCIL_ALPHA:
- return sizeof(struct pipe_depth_stencil_alpha_state);
- case CSO_RASTERIZER:
- return sizeof(struct pipe_rasterizer_state);
- case CSO_FRAGMENT_SHADER:
- return sizeof(struct pipe_shader_state);
- case CSO_VERTEX_SHADER:
- return sizeof(struct pipe_shader_state);
- }
- return 0;
-}
-
-struct cso_hash_iter
-cso_insert_state(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type,
- void *state)
-{
- struct cso_hash *hash = _cso_hash_for_type(sc, type);
- return cso_hash_insert(hash, hash_key, state);
-}
-
-struct cso_hash_iter
-cso_find_state(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type)
-{
- struct cso_hash *hash = _cso_hash_for_type(sc, type);
-
- return cso_hash_find(hash, hash_key);
-}
-
-struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type,
- void *templ)
-{
- struct cso_hash_iter iter = cso_find_state(sc, hash_key, type);
- int size = _cso_size_for_type(type);
- while (!cso_hash_iter_is_null(iter)) {
- void *iter_data = cso_hash_iter_data(iter);
- if (!memcmp(iter_data, templ, size))
- return iter;
- iter = cso_hash_iter_next(iter);
- }
- return iter;
-}
-
-void * cso_take_state(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type)
-{
- struct cso_hash *hash = _cso_hash_for_type(sc, type);
- return cso_hash_take(hash, hash_key);
-}
-
-struct cso_cache *cso_cache_create(void)
-{
- struct cso_cache *sc = malloc(sizeof(struct cso_cache));
-
- sc->blend_hash = cso_hash_create();
- sc->sampler_hash = cso_hash_create();
- sc->depth_stencil_hash = cso_hash_create();
- sc->rasterizer_hash = cso_hash_create();
- sc->fs_hash = cso_hash_create();
- sc->vs_hash = cso_hash_create();
-
- return sc;
-}
-
-void cso_cache_delete(struct cso_cache *sc)
-{
- assert(sc);
- cso_hash_delete(sc->blend_hash);
- cso_hash_delete(sc->sampler_hash);
- cso_hash_delete(sc->depth_stencil_hash);
- cso_hash_delete(sc->rasterizer_hash);
- cso_hash_delete(sc->fs_hash);
- cso_hash_delete(sc->vs_hash);
- free(sc);
-}
diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h
deleted file mode 100644
index 116e2eaa2c..0000000000
--- a/src/mesa/pipe/cso_cache/cso_cache.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin <zack@tungstengraphics.com>
- */
-
-#ifndef CSO_CACHE_H
-#define CSO_CACHE_H
-
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-
-
-struct cso_hash;
-
-struct cso_cache {
- struct cso_hash *blend_hash;
- struct cso_hash *depth_stencil_hash;
- struct cso_hash *fs_hash;
- struct cso_hash *vs_hash;
- struct cso_hash *rasterizer_hash;
- struct cso_hash *sampler_hash;
-};
-
-struct cso_blend {
- struct pipe_blend_state state;
- void *data;
-};
-
-struct cso_depth_stencil_alpha {
- struct pipe_depth_stencil_alpha_state state;
- void *data;
-};
-
-struct cso_rasterizer {
- struct pipe_rasterizer_state state;
- void *data;
-};
-
-struct cso_fragment_shader {
- struct pipe_shader_state state;
- void *data;
-};
-
-struct cso_vertex_shader {
- struct pipe_shader_state state;
- void *data;
-};
-
-struct cso_sampler {
- struct pipe_sampler_state state;
- void *data;
-};
-
-
-enum cso_cache_type {
- CSO_BLEND,
- CSO_SAMPLER,
- CSO_DEPTH_STENCIL_ALPHA,
- CSO_RASTERIZER,
- CSO_FRAGMENT_SHADER,
- CSO_VERTEX_SHADER
-};
-
-unsigned cso_construct_key(void *item, int item_size);
-
-struct cso_cache *cso_cache_create(void);
-void cso_cache_delete(struct cso_cache *sc);
-
-struct cso_hash_iter cso_insert_state(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type,
- void *state);
-struct cso_hash_iter cso_find_state(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type);
-struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
- unsigned hash_key, enum cso_cache_type type,
- void *templ);
-void * cso_take_state(struct cso_cache *sc, unsigned hash_key,
- enum cso_cache_type type);
-
-#endif
diff --git a/src/mesa/pipe/cso_cache/cso_hash.c b/src/mesa/pipe/cso_cache/cso_hash.c
deleted file mode 100644
index 0338cb3b47..0000000000
--- a/src/mesa/pipe/cso_cache/cso_hash.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin <zack@tungstengraphics.com>
- */
-
-#include "cso_hash.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#define MAX(a, b) ((a > b) ? (a) : (b))
-
-static const int MinNumBits = 4;
-
-static const unsigned char prime_deltas[] = {
- 0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
- 1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
-};
-
-static int primeForNumBits(int numBits)
-{
- return (1 << numBits) + prime_deltas[numBits];
-}
-
-/*
- Returns the smallest integer n such that
- primeForNumBits(n) >= hint.
-*/
-static int countBits(int hint)
-{
- int numBits = 0;
- int bits = hint;
-
- while (bits > 1) {
- bits >>= 1;
- numBits++;
- }
-
- if (numBits >= (int)sizeof(prime_deltas)) {
- numBits = sizeof(prime_deltas) - 1;
- } else if (primeForNumBits(numBits) < hint) {
- ++numBits;
- }
- return numBits;
-}
-
-struct cso_node {
- struct cso_node *next;
- unsigned key;
- void *value;
-};
-
-struct cso_hash_data {
- struct cso_node *fakeNext;
- struct cso_node **buckets;
- int size;
- int nodeSize;
- short userNumBits;
- short numBits;
- int numBuckets;
-};
-
-struct cso_hash {
- union {
- struct cso_hash_data *d;
- struct cso_node *e;
- } data;
-};
-
-static void *cso_data_allocate_node(struct cso_hash_data *hash)
-{
- return malloc(hash->nodeSize);
-}
-
-static void cso_data_free_node(struct cso_node *node)
-{
- /* XXX still a leak here.
- * Need to cast value ptr to original cso type, then free the
- * driver-specific data hanging off of it. For example:
- struct cso_sampler *csamp = (struct cso_sampler *) node->value;
- free(csamp->data);
- */
- free(node->value);
- free(node);
-}
-
-static struct cso_node *
-cso_hash_create_node(struct cso_hash *hash,
- unsigned akey, void *avalue,
- struct cso_node **anextNode)
-{
- struct cso_node *node = cso_data_allocate_node(hash->data.d);
- node->key = akey;
- node->value = avalue;
-
- node->next = (struct cso_node*)(*anextNode);
- *anextNode = node;
- ++hash->data.d->size;
- return node;
-}
-
-static void cso_data_rehash(struct cso_hash_data *hash, int hint)
-{
- if (hint < 0) {
- hint = countBits(-hint);
- if (hint < MinNumBits)
- hint = MinNumBits;
- hash->userNumBits = hint;
- while (primeForNumBits(hint) < (hash->size >> 1))
- ++hint;
- } else if (hint < MinNumBits) {
- hint = MinNumBits;
- }
-
- if (hash->numBits != hint) {
- struct cso_node *e = (struct cso_node *)(hash);
- struct cso_node **oldBuckets = hash->buckets;
- int oldNumBuckets = hash->numBuckets;
- int i = 0;
-
- hash->numBits = hint;
- hash->numBuckets = primeForNumBits(hint);
- hash->buckets = malloc(sizeof(struct cso_node*) * hash->numBuckets);
- for (i = 0; i < hash->numBuckets; ++i)
- hash->buckets[i] = e;
-
- for (i = 0; i < oldNumBuckets; ++i) {
- struct cso_node *firstNode = oldBuckets[i];
- while (firstNode != e) {
- unsigned h = firstNode->key;
- struct cso_node *lastNode = firstNode;
- while (lastNode->next != e && lastNode->next->key == h)
- lastNode = lastNode->next;
-
- struct cso_node *afterLastNode = lastNode->next;
- struct cso_node **beforeFirstNode = &hash->buckets[h % hash->numBuckets];
- while (*beforeFirstNode != e)
- beforeFirstNode = &(*beforeFirstNode)->next;
- lastNode->next = *beforeFirstNode;
- *beforeFirstNode = firstNode;
- firstNode = afterLastNode;
- }
- }
- free(oldBuckets);
- }
-}
-
-static void cso_data_might_grow(struct cso_hash_data *hash)
-{
- if (hash->size >= hash->numBuckets)
- cso_data_rehash(hash, hash->numBits + 1);
-}
-
-static void cso_data_has_shrunk(struct cso_hash_data *hash)
-{
- if (hash->size <= (hash->numBuckets >> 3) &&
- hash->numBits > hash->userNumBits) {
- int max = MAX(hash->numBits-2, hash->userNumBits);
- cso_data_rehash(hash, max);
- }
-}
-
-static struct cso_node *cso_data_first_node(struct cso_hash_data *hash)
-{
- struct cso_node *e = (struct cso_node *)(hash);
- struct cso_node **bucket = hash->buckets;
- int n = hash->numBuckets;
- while (n--) {
- if (*bucket != e)
- return *bucket;
- ++bucket;
- }
- return e;
-}
-
-static struct cso_node **cso_hash_find_node(struct cso_hash *hash, unsigned akey)
-{
- struct cso_node **node;
-
- if (hash->data.d->numBuckets) {
- node = (struct cso_node **)(&hash->data.d->buckets[akey % hash->data.d->numBuckets]);
- assert(*node == hash->data.e || (*node)->next);
- while (*node != hash->data.e && (*node)->key != akey)
- node = &(*node)->next;
- } else {
- node = (struct cso_node **)((const struct cso_node * const *)(&hash->data.e));
- }
- return node;
-}
-
-struct cso_hash_iter cso_hash_insert(struct cso_hash *hash,
- unsigned key, void *data)
-{
- cso_data_might_grow(hash->data.d);
-
- struct cso_node **nextNode = cso_hash_find_node(hash, key);
- struct cso_node *node = cso_hash_create_node(hash, key, data, nextNode);
- struct cso_hash_iter iter = {hash, node};
- return iter;
-}
-
-struct cso_hash * cso_hash_create(void)
-{
- struct cso_hash *hash = malloc(sizeof(struct cso_hash));
- hash->data.d = malloc(sizeof(struct cso_hash_data));
- hash->data.d->fakeNext = 0;
- hash->data.d->buckets = 0;
- hash->data.d->size = 0;
- hash->data.d->nodeSize = sizeof(struct cso_node);
- hash->data.d->userNumBits = MinNumBits;
- hash->data.d->numBits = 0;
- hash->data.d->numBuckets = 0;
-
- return hash;
-}
-
-void cso_hash_delete(struct cso_hash *hash)
-{
- struct cso_node *e_for_x = (struct cso_node *)(hash->data.d);
- struct cso_node **bucket = (struct cso_node **)(hash->data.d->buckets);
- int n = hash->data.d->numBuckets;
- while (n--) {
- struct cso_node *cur = *bucket++;
- while (cur != e_for_x) {
- struct cso_node *next = cur->next;
- cso_data_free_node(cur);
- cur = next;
- }
- }
- free(hash->data.d->buckets);
- free(hash->data.d);
- free(hash);
-}
-
-struct cso_hash_iter cso_hash_find(struct cso_hash *hash,
- unsigned key)
-{
- struct cso_node **nextNode = cso_hash_find_node(hash, key);
- struct cso_hash_iter iter = {hash, *nextNode};
- return iter;
-}
-
-unsigned cso_hash_iter_key(struct cso_hash_iter iter)
-{
- if (!iter.node || iter.hash->data.e == iter.node)
- return 0;
- return iter.node->key;
-}
-
-void * cso_hash_iter_data(struct cso_hash_iter iter)
-{
- if (!iter.node || iter.hash->data.e == iter.node)
- return 0;
- return iter.node->value;
-}
-
-static struct cso_node *cso_hash_data_next(struct cso_node *node)
-{
- union {
- struct cso_node *next;
- struct cso_node *e;
- struct cso_hash_data *d;
- } a;
- a.next = node->next;
- if (!a.next) {
- fprintf(stderr, "iterating beyond the last element\n");
- return 0;
- }
- if (a.next->next)
- return a.next;
-
- int start = (node->key % a.d->numBuckets) + 1;
- struct cso_node **bucket = a.d->buckets + start;
- int n = a.d->numBuckets - start;
- while (n--) {
- if (*bucket != a.e)
- return *bucket;
- ++bucket;
- }
- return a.e;
-}
-
-
-static struct cso_node *cso_hash_data_prev(struct cso_node *node)
-{
- union {
- struct cso_node *e;
- struct cso_hash_data *d;
- } a;
-
- a.e = node;
- while (a.e->next)
- a.e = a.e->next;
-
- int start;
- if (node == a.e)
- start = a.d->numBuckets - 1;
- else
- start = node->key % a.d->numBuckets;
-
- struct cso_node *sentinel = node;
- struct cso_node **bucket = a.d->buckets + start;
- while (start >= 0) {
- if (*bucket != sentinel) {
- struct cso_node *prev = *bucket;
- while (prev->next != sentinel)
- prev = prev->next;
- return prev;
- }
-
- sentinel = a.e;
- --bucket;
- --start;
- }
- fprintf(stderr, "iterating backward beyond first element\n");
- return a.e;
-}
-
-struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter)
-{
- struct cso_hash_iter next = {iter.hash, cso_hash_data_next(iter.node)};
- return next;
-}
-
-int cso_hash_iter_is_null(struct cso_hash_iter iter)
-{
- if (!iter.node || iter.node == iter.hash->data.e)
- return 1;
- return 0;
-}
-
-void * cso_hash_take(struct cso_hash *hash,
- unsigned akey)
-{
- struct cso_node **node = cso_hash_find_node(hash, akey);
- if (*node != hash->data.e) {
- void *t = (*node)->value;
- struct cso_node *next = (*node)->next;
- cso_data_free_node(*node);
- *node = next;
- --hash->data.d->size;
- cso_data_has_shrunk(hash->data.d);
- return t;
- }
- return 0;
-}
-
-struct cso_hash_iter cso_hash_iter_prev(struct cso_hash_iter iter)
-{
- struct cso_hash_iter prev = {iter.hash,
- cso_hash_data_prev(iter.node)};
- return prev;
-}
-
-struct cso_hash_iter cso_hash_first_node(struct cso_hash *hash)
-{
- struct cso_hash_iter iter = {hash, cso_data_first_node(hash->data.d)};
- return iter;
-}
diff --git a/src/mesa/pipe/cso_cache/cso_hash.h b/src/mesa/pipe/cso_cache/cso_hash.h
deleted file mode 100644
index b4aa111860..0000000000
--- a/src/mesa/pipe/cso_cache/cso_hash.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin <zack@tungstengraphics.com>
- */
-
-#ifndef CSO_HASH_H
-#define CSO_HASH_H
-
-struct cso_hash;
-struct cso_node;
-
-struct cso_hash_iter {
- struct cso_hash *hash;
- struct cso_node *node;
-};
-
-struct cso_hash *cso_hash_create(void);
-void cso_hash_delete(struct cso_hash *hash);
-
-struct cso_hash_iter cso_hash_insert(struct cso_hash *hash, unsigned key,
- void *data);
-void *cso_hash_take(struct cso_hash *hash, unsigned key);
-
-struct cso_hash_iter cso_hash_first_node(struct cso_hash *hash);
-struct cso_hash_iter cso_hash_find(struct cso_hash *hash, unsigned key);
-
-
-int cso_hash_iter_is_null(struct cso_hash_iter iter);
-unsigned cso_hash_iter_key(struct cso_hash_iter iter);
-void *cso_hash_iter_data(struct cso_hash_iter iter);
-
-struct cso_hash_iter cso_hash_iter_next(struct cso_hash_iter iter);
-struct cso_hash_iter cso_hash_iter_prev(struct cso_hash_iter iter);
-
-#endif
diff --git a/src/mesa/pipe/draw/Makefile b/src/mesa/pipe/draw/Makefile
deleted file mode 100644
index 451911a354..0000000000
--- a/src/mesa/pipe/draw/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-default:
- cd .. ; make
diff --git a/src/mesa/pipe/draw/draw_clip.c b/src/mesa/pipe/draw/draw_clip.c
deleted file mode 100644
index 61130c5600..0000000000
--- a/src/mesa/pipe/draw/draw_clip.c
+++ /dev/null
@@ -1,488 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Clipping stage
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-
-#include "draw_context.h"
-#include "draw_private.h"
-
-
-#ifndef IS_NEGATIVE
-#define IS_NEGATIVE(X) ((X) < 0.0)
-#endif
-
-#ifndef DIFFERENT_SIGNS
-#define DIFFERENT_SIGNS(x, y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
-#endif
-
-#ifndef MAX_CLIPPED_VERTICES
-#define MAX_CLIPPED_VERTICES ((2 * (6 + PIPE_MAX_CLIP_PLANES))+1)
-#endif
-
-
-
-struct clipper {
- struct draw_stage stage; /**< base class */
-
- /* Basically duplicate some of the flatshading logic here:
- */
- boolean flat;
- uint num_color_attribs;
- uint color_attribs[4]; /* front/back primary/secondary colors */
-
- float (*plane)[4];
-};
-
-
-/* This is a bit confusing:
- */
-static INLINE struct clipper *clipper_stage( struct draw_stage *stage )
-{
- return (struct clipper *)stage;
-}
-
-
-#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT)))
-
-
-/* All attributes are float[4], so this is easy:
- */
-static void interp_attr( float *fdst,
- float t,
- const float *fin,
- const float *fout )
-{
- fdst[0] = LINTERP( t, fout[0], fin[0] );
- fdst[1] = LINTERP( t, fout[1], fin[1] );
- fdst[2] = LINTERP( t, fout[2], fin[2] );
- fdst[3] = LINTERP( t, fout[3], fin[3] );
-}
-
-static void copy_colors( struct draw_stage *stage,
- struct vertex_header *dst,
- const struct vertex_header *src )
-{
- const struct clipper *clipper = clipper_stage(stage);
- uint i;
- for (i = 0; i < clipper->num_color_attribs; i++) {
- const uint attr = clipper->color_attribs[i];
- COPY_4FV(dst->data[attr], src->data[attr]);
- }
-}
-
-
-
-/* Interpolate between two vertices to produce a third.
- */
-static void interp( const struct clipper *clip,
- struct vertex_header *dst,
- float t,
- const struct vertex_header *out,
- const struct vertex_header *in )
-{
- const unsigned nr_attrs = clip->stage.draw->num_vs_outputs;
- unsigned j;
-
- /* Vertex header.
- */
- {
- dst->clipmask = 0;
- dst->edgeflag = 0;
- dst->pad = 0;
- dst->vertex_id = UNDEFINED_VERTEX_ID;
- }
-
- /* Clip coordinates: interpolate normally
- */
- {
- interp_attr(dst->clip, t, in->clip, out->clip);
- }
-
- /* Do the projective divide and insert window coordinates:
- */
- {
- const float *pos = dst->clip;
- const float *scale = clip->stage.draw->viewport.scale;
- const float *trans = clip->stage.draw->viewport.translate;
- const float oow = 1.0f / pos[3];
-
- dst->data[0][0] = pos[0] * oow * scale[0] + trans[0];
- dst->data[0][1] = pos[1] * oow * scale[1] + trans[1];
- dst->data[0][2] = pos[2] * oow * scale[2] + trans[2];
- dst->data[0][3] = oow;
- }
-
- /* Other attributes
- * Note: start at 1 to skip winpos (data[0]) since we just computed
- * it above.
- */
- for (j = 1; j < nr_attrs; j++) {
- interp_attr(dst->data[j], t, in->data[j], out->data[j]);
- }
-}
-
-
-static void emit_poly( struct draw_stage *stage,
- struct vertex_header **inlist,
- unsigned n,
- const struct prim_header *origPrim)
-{
- struct prim_header header;
- unsigned i;
-
- /* later stages may need the determinant, but only the sign matters */
- header.det = origPrim->det;
-
- for (i = 2; i < n; i++) {
- header.v[0] = inlist[i-1];
- header.v[1] = inlist[i];
- header.v[2] = inlist[0]; /* keep in v[2] for flatshading */
-
- {
- unsigned tmp1 = header.v[1]->edgeflag;
- unsigned tmp2 = header.v[2]->edgeflag;
-
- if (i != n-1) header.v[1]->edgeflag = 0;
- if (i != 2) header.v[2]->edgeflag = 0;
-
- header.edgeflags = ((header.v[0]->edgeflag << 0) |
- (header.v[1]->edgeflag << 1) |
- (header.v[2]->edgeflag << 2));
-
- stage->next->tri( stage->next, &header );
-
- header.v[1]->edgeflag = tmp1;
- header.v[2]->edgeflag = tmp2;
- }
- }
-}
-
-
-
-
-/* Clip a triangle against the viewport and user clip planes.
- */
-static void
-do_clip_tri( struct draw_stage *stage,
- struct prim_header *header,
- unsigned clipmask )
-{
- struct clipper *clipper = clipper_stage( stage );
- struct vertex_header *a[MAX_CLIPPED_VERTICES];
- struct vertex_header *b[MAX_CLIPPED_VERTICES];
- struct vertex_header **inlist = a;
- struct vertex_header **outlist = b;
- unsigned tmpnr = 0;
- unsigned n = 3;
- unsigned i;
-
- inlist[0] = header->v[0];
- inlist[1] = header->v[1];
- inlist[2] = header->v[2];
-
- while (clipmask && n >= 3) {
- const unsigned plane_idx = ffs(clipmask)-1;
- const float *plane = clipper->plane[plane_idx];
- struct vertex_header *vert_prev = inlist[0];
- float dp_prev = dot4( vert_prev->clip, plane );
- unsigned outcount = 0;
-
- clipmask &= ~(1<<plane_idx);
-
- inlist[n] = inlist[0]; /* prevent rotation of vertices */
-
- for (i = 1; i <= n; i++) {
- struct vertex_header *vert = inlist[i];
-
- float dp = dot4( vert->clip, plane );
-
- if (!IS_NEGATIVE(dp_prev)) {
- outlist[outcount++] = vert_prev;
- }
-
- if (DIFFERENT_SIGNS(dp, dp_prev)) {
- struct vertex_header *new_vert = clipper->stage.tmp[tmpnr++];
- outlist[outcount++] = new_vert;
-
- if (IS_NEGATIVE(dp)) {
- /* Going out of bounds. Avoid division by zero as we
- * know dp != dp_prev from DIFFERENT_SIGNS, above.
- */
- float t = dp / (dp - dp_prev);
- interp( clipper, new_vert, t, vert, vert_prev );
-
- /* Force edgeflag true in this case:
- */
- new_vert->edgeflag = 1;
- } else {
- /* Coming back in.
- */
- float t = dp_prev / (dp_prev - dp);
- interp( clipper, new_vert, t, vert_prev, vert );
-
- /* Copy starting vert's edgeflag:
- */
- new_vert->edgeflag = vert_prev->edgeflag;
- }
- }
-
- vert_prev = vert;
- dp_prev = dp;
- }
-
- {
- struct vertex_header **tmp = inlist;
- inlist = outlist;
- outlist = tmp;
- n = outcount;
- }
- }
-
- /* If flat-shading, copy color to new provoking vertex.
- */
- if (clipper->flat && inlist[0] != header->v[2]) {
- if (1) {
- inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
- }
-
- copy_colors(stage, inlist[0], header->v[2]);
- }
-
-
-
- /* Emit the polygon as triangles to the setup stage:
- */
- if (n >= 3)
- emit_poly( stage, inlist, n, header );
-}
-
-
-/* Clip a line against the viewport and user clip planes.
- */
-static void
-do_clip_line( struct draw_stage *stage,
- struct prim_header *header,
- unsigned clipmask )
-{
- const struct clipper *clipper = clipper_stage( stage );
- struct vertex_header *v0 = header->v[0];
- struct vertex_header *v1 = header->v[1];
- const float *pos0 = v0->clip;
- const float *pos1 = v1->clip;
- float t0 = 0.0F;
- float t1 = 0.0F;
- struct prim_header newprim;
-
- while (clipmask) {
- const unsigned plane_idx = ffs(clipmask)-1;
- const float *plane = clipper->plane[plane_idx];
- const float dp0 = dot4( pos0, plane );
- const float dp1 = dot4( pos1, plane );
-
- if (dp1 < 0.0F) {
- float t = dp1 / (dp1 - dp0);
- t1 = MAX2(t1, t);
- }
-
- if (dp0 < 0.0F) {
- float t = dp0 / (dp0 - dp1);
- t0 = MAX2(t0, t);
- }
-
- if (t0 + t1 >= 1.0F)
- return; /* discard */
-
- clipmask &= ~(1 << plane_idx); /* turn off this plane's bit */
- }
-
- if (v0->clipmask) {
- interp( clipper, stage->tmp[0], t0, v0, v1 );
-
- if (clipper->flat)
- copy_colors(stage, stage->tmp[0], v0);
-
- newprim.v[0] = stage->tmp[0];
- }
- else {
- newprim.v[0] = v0;
- }
-
- if (v1->clipmask) {
- interp( clipper, stage->tmp[1], t1, v1, v0 );
- newprim.v[1] = stage->tmp[1];
- }
- else {
- newprim.v[1] = v1;
- }
-
- stage->next->line( stage->next, &newprim );
-}
-
-
-static void
-clip_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- if (header->v[0]->clipmask == 0)
- stage->next->point( stage->next, header );
-}
-
-
-static void
-clip_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- unsigned clipmask = (header->v[0]->clipmask |
- header->v[1]->clipmask);
-
- if (clipmask == 0) {
- /* no clipping needed */
- stage->next->line( stage->next, header );
- }
- else if ((header->v[0]->clipmask &
- header->v[1]->clipmask) == 0) {
- do_clip_line(stage, header, clipmask);
- }
- /* else, totally clipped */
-}
-
-
-static void
-clip_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- unsigned clipmask = (header->v[0]->clipmask |
- header->v[1]->clipmask |
- header->v[2]->clipmask);
-
- if (clipmask == 0) {
- /* no clipping needed */
- stage->next->tri( stage->next, header );
- }
- else if ((header->v[0]->clipmask &
- header->v[1]->clipmask &
- header->v[2]->clipmask) == 0) {
- do_clip_tri(stage, header, clipmask);
- }
-}
-
-/* Update state. Could further delay this until we hit the first
- * primitive that really requires clipping.
- */
-static void
-clip_init_state( struct draw_stage *stage )
-{
- struct clipper *clipper = clipper_stage( stage );
-
- clipper->flat = stage->draw->rasterizer->flatshade ? TRUE : FALSE;
-
- if (clipper->flat) {
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
- uint i;
-
- clipper->num_color_attribs = 0;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- clipper->color_attribs[clipper->num_color_attribs++] = i;
- }
- }
- }
-
- stage->tri = clip_tri;
- stage->line = clip_line;
-}
-
-
-
-static void clip_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- clip_init_state( stage );
- stage->tri( stage, header );
-}
-
-static void clip_first_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- clip_init_state( stage );
- stage->line( stage, header );
-}
-
-
-static void clip_flush( struct draw_stage *stage,
- unsigned flags )
-{
- stage->tri = clip_first_tri;
- stage->line = clip_first_line;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void clip_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void clip_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Allocate a new clipper stage.
- * \return pointer to new stage object
- */
-struct draw_stage *draw_clip_stage( struct draw_context *draw )
-{
- struct clipper *clipper = CALLOC_STRUCT(clipper);
-
- draw_alloc_tmps( &clipper->stage, MAX_CLIPPED_VERTICES+1 );
-
- clipper->stage.draw = draw;
- clipper->stage.point = clip_point;
- clipper->stage.line = clip_first_line;
- clipper->stage.tri = clip_first_tri;
- clipper->stage.flush = clip_flush;
- clipper->stage.reset_stipple_counter = clip_reset_stipple_counter;
- clipper->stage.destroy = clip_destroy;
-
- clipper->plane = draw->plane;
-
- return &clipper->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_context.c b/src/mesa/pipe/draw/draw_context.c
deleted file mode 100644
index b15f57c824..0000000000
--- a/src/mesa/pipe/draw/draw_context.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_util.h"
-#include "draw_context.h"
-#include "draw_private.h"
-
-
-
-struct draw_context *draw_create( void )
-{
- struct draw_context *draw = CALLOC_STRUCT( draw_context );
-
-#if defined(__i386__) || defined(__386__)
- draw->use_sse = GETENV( "GALLIUM_NOSSE" ) == NULL;
-#else
- draw->use_sse = FALSE;
-#endif
-
- /* create pipeline stages */
- draw->pipeline.wide = draw_wide_stage( draw );
- draw->pipeline.stipple = draw_stipple_stage( draw );
- draw->pipeline.unfilled = draw_unfilled_stage( draw );
- draw->pipeline.twoside = draw_twoside_stage( draw );
- draw->pipeline.offset = draw_offset_stage( draw );
- draw->pipeline.clip = draw_clip_stage( draw );
- draw->pipeline.flatshade = draw_flatshade_stage( draw );
- draw->pipeline.cull = draw_cull_stage( draw );
- draw->pipeline.validate = draw_validate_stage( draw );
- draw->pipeline.first = draw->pipeline.validate;
-
- ASSIGN_4V( draw->plane[0], -1, 0, 0, 1 );
- ASSIGN_4V( draw->plane[1], 1, 0, 0, 1 );
- ASSIGN_4V( draw->plane[2], 0, -1, 0, 1 );
- ASSIGN_4V( draw->plane[3], 0, 1, 0, 1 );
- ASSIGN_4V( draw->plane[4], 0, 0, 1, 1 ); /* yes these are correct */
- ASSIGN_4V( draw->plane[5], 0, 0, -1, 1 ); /* mesa's a bit wonky */
- draw->nr_planes = 6;
-
- /* Statically allocate maximum sized vertices for the cache - could be cleverer...
- */
- {
- uint i;
- const unsigned size = (MAX_VERTEX_SIZE + 0x0f) & ~0x0f;
- char *tmp = align_malloc(Elements(draw->vcache.vertex) * size, 16);
-
- for (i = 0; i < Elements(draw->vcache.vertex); i++)
- draw->vcache.vertex[i] = (struct vertex_header *)(tmp + i * size);
- }
-
- draw->shader_queue_flush = draw_vertex_shader_queue_flush;
-
- draw->convert_wide_points = TRUE;
- draw->convert_wide_lines = TRUE;
-
- draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
-
- draw_vertex_cache_invalidate( draw );
- draw_set_mapped_element_buffer( draw, 0, NULL );
-
- return draw;
-}
-
-
-void draw_destroy( struct draw_context *draw )
-{
- draw->pipeline.wide->destroy( draw->pipeline.wide );
- draw->pipeline.stipple->destroy( draw->pipeline.stipple );
- draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
- draw->pipeline.twoside->destroy( draw->pipeline.twoside );
- draw->pipeline.offset->destroy( draw->pipeline.offset );
- draw->pipeline.clip->destroy( draw->pipeline.clip );
- draw->pipeline.flatshade->destroy( draw->pipeline.flatshade );
- draw->pipeline.cull->destroy( draw->pipeline.cull );
- draw->pipeline.validate->destroy( draw->pipeline.validate );
- if (draw->pipeline.rasterize)
- draw->pipeline.rasterize->destroy( draw->pipeline.rasterize );
- tgsi_exec_machine_free_data(&draw->machine);
- align_free( draw->vcache.vertex[0] ); /* Frees all the vertices. */
- FREE( draw );
-}
-
-
-
-void draw_flush( struct draw_context *draw )
-{
- draw_do_flush( draw, DRAW_FLUSH_BACKEND );
-}
-
-
-
-/**
- * Register new primitive rasterization/rendering state.
- * This causes the drawing pipeline to be rebuilt.
- */
-void draw_set_rasterizer_state( struct draw_context *draw,
- const struct pipe_rasterizer_state *raster )
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-
- draw->rasterizer = raster;
-}
-
-
-/**
- * Plug in the primitive rendering/rasterization stage (which is the last
- * stage in the drawing pipeline).
- * This is provided by the device driver.
- */
-void draw_set_rasterize_stage( struct draw_context *draw,
- struct draw_stage *stage )
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-
- draw->pipeline.rasterize = stage;
-}
-
-
-/**
- * Set the draw module's clipping state.
- */
-void draw_set_clip_state( struct draw_context *draw,
- const struct pipe_clip_state *clip )
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-
- assert(clip->nr <= PIPE_MAX_CLIP_PLANES);
- memcpy(&draw->plane[6], clip->ucp, clip->nr * sizeof(clip->ucp[0]));
- draw->nr_planes = 6 + clip->nr;
-}
-
-
-/**
- * Set the draw module's viewport state.
- */
-void draw_set_viewport_state( struct draw_context *draw,
- const struct pipe_viewport_state *viewport )
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->viewport = *viewport; /* struct copy */
-}
-
-
-
-void
-draw_set_vertex_buffer(struct draw_context *draw,
- unsigned attr,
- const struct pipe_vertex_buffer *buffer)
-{
- draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ );
- assert(attr < PIPE_ATTRIB_MAX);
- draw->vertex_buffer[attr] = *buffer;
-}
-
-
-void
-draw_set_vertex_element(struct draw_context *draw,
- unsigned attr,
- const struct pipe_vertex_element *element)
-{
- draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ );
- assert(attr < PIPE_ATTRIB_MAX);
- draw->vertex_element[attr] = *element;
-}
-
-
-/**
- * Tell drawing context where to find mapped vertex buffers.
- */
-void
-draw_set_mapped_vertex_buffer(struct draw_context *draw,
- unsigned attr, const void *buffer)
-{
- draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ );
- draw->user.vbuffer[attr] = buffer;
-}
-
-
-void
-draw_set_mapped_constant_buffer(struct draw_context *draw,
- const void *buffer)
-{
- draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE/*STATE_CHANGE*/ );
- draw->user.constants = buffer;
-}
-
-
-/**
- * Tells the draw module whether to convert wide points (size != 1)
- * into triangles.
- */
-void
-draw_convert_wide_points(struct draw_context *draw, boolean enable)
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->convert_wide_points = enable;
-}
-
-
-/**
- * Tells the draw module whether to convert wide lines (width != 1)
- * into triangles.
- */
-void
-draw_convert_wide_lines(struct draw_context *draw, boolean enable)
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->convert_wide_lines = enable;
-}
-
-
-/**
- * Allocate space for temporary post-transform vertices, such as for clipping.
- */
-void draw_alloc_tmps( struct draw_stage *stage, unsigned nr )
-{
- assert(!stage->tmp);
-
- stage->nr_tmps = nr;
-
- if (nr) {
- ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
- unsigned i;
-
- stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
-
- for (i = 0; i < nr; i++)
- stage->tmp[i] = (struct vertex_header *)(store + i * MAX_VERTEX_SIZE);
- }
-}
-
-
-void draw_free_tmps( struct draw_stage *stage )
-{
- if (stage->tmp) {
- FREE( stage->tmp[0] );
- FREE( stage->tmp );
- stage->tmp = NULL;
- }
-}
-
-
-boolean draw_use_sse(struct draw_context *draw)
-{
- return (boolean) draw->use_sse;
-}
-
-
-void draw_reset_vertex_ids(struct draw_context *draw)
-{
- struct draw_stage *stage = draw->pipeline.first;
-
- while (stage) {
- unsigned i;
-
- for (i = 0; i < stage->nr_tmps; i++)
- stage->tmp[i]->vertex_id = UNDEFINED_VERTEX_ID;
-
- stage = stage->next;
- }
-
- draw_vertex_cache_reset_vertex_ids(draw);
-}
diff --git a/src/mesa/pipe/draw/draw_context.h b/src/mesa/pipe/draw/draw_context.h
deleted file mode 100644
index ddeb184497..0000000000
--- a/src/mesa/pipe/draw/draw_context.h
+++ /dev/null
@@ -1,142 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Public interface into the drawing module.
- */
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef DRAW_CONTEXT_H
-#define DRAW_CONTEXT_H
-
-
-#include "pipe/p_state.h"
-
-
-struct vertex_buffer;
-struct vertex_info;
-struct draw_context;
-struct draw_stage;
-struct draw_vertex_shader;
-
-
-/**
- * Clipmask flags
- */
-/*@{*/
-#define CLIP_RIGHT_BIT 0x01
-#define CLIP_LEFT_BIT 0x02
-#define CLIP_TOP_BIT 0x04
-#define CLIP_BOTTOM_BIT 0x08
-#define CLIP_NEAR_BIT 0x10
-#define CLIP_FAR_BIT 0x20
-/*@}*/
-
-/**
- * Bitshift for each clip flag
- */
-/*@{*/
-#define CLIP_RIGHT_SHIFT 0
-#define CLIP_LEFT_SHIFT 1
-#define CLIP_TOP_SHIFT 2
-#define CLIP_BOTTOM_SHIFT 3
-#define CLIP_NEAR_SHIFT 4
-#define CLIP_FAR_SHIFT 5
-/*@}*/
-
-
-struct draw_context *draw_create( void );
-
-void draw_destroy( struct draw_context *draw );
-
-void draw_set_viewport_state( struct draw_context *draw,
- const struct pipe_viewport_state *viewport );
-
-void draw_set_clip_state( struct draw_context *pipe,
- const struct pipe_clip_state *clip );
-
-void draw_set_rasterizer_state( struct draw_context *draw,
- const struct pipe_rasterizer_state *raster );
-
-void draw_set_rasterize_stage( struct draw_context *draw,
- struct draw_stage *stage );
-
-void draw_convert_wide_points(struct draw_context *draw, boolean enable);
-
-void draw_convert_wide_lines(struct draw_context *draw, boolean enable);
-
-
-struct draw_vertex_shader *
-draw_create_vertex_shader(struct draw_context *draw,
- const struct pipe_shader_state *shader);
-void draw_bind_vertex_shader(struct draw_context *draw,
- struct draw_vertex_shader *dvs);
-void draw_delete_vertex_shader(struct draw_context *draw,
- struct draw_vertex_shader *dvs);
-
-boolean draw_use_sse(struct draw_context *draw);
-
-void draw_set_vertex_buffer(struct draw_context *draw,
- unsigned attr,
- const struct pipe_vertex_buffer *buffer);
-
-void draw_set_vertex_element(struct draw_context *draw,
- unsigned attr,
- const struct pipe_vertex_element *element);
-
-void draw_set_mapped_element_buffer( struct draw_context *draw,
- unsigned eltSize, void *elements );
-
-void draw_set_mapped_vertex_buffer(struct draw_context *draw,
- unsigned attr, const void *buffer);
-
-void draw_set_mapped_constant_buffer(struct draw_context *draw,
- const void *buffer);
-
-
-/***********************************************************************
- * draw_prim.c
- */
-
-void draw_arrays(struct draw_context *draw, unsigned prim,
- unsigned start, unsigned count);
-
-void draw_flush(struct draw_context *draw);
-
-/***********************************************************************
- * draw_debug.c
- */
-boolean draw_validate_prim( unsigned prim, unsigned length );
-unsigned draw_trim_prim( unsigned mode, unsigned count );
-
-
-
-#endif /* DRAW_CONTEXT_H */
diff --git a/src/mesa/pipe/draw/draw_cull.c b/src/mesa/pipe/draw/draw_cull.c
deleted file mode 100644
index 05c274e4dc..0000000000
--- a/src/mesa/pipe/draw/draw_cull.c
+++ /dev/null
@@ -1,150 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Drawing stage for polygon culling
- */
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "draw_private.h"
-
-
-struct cull_stage {
- struct draw_stage stage;
- unsigned winding; /**< which winding(s) to cull (one of PIPE_WINDING_x) */
-};
-
-
-static INLINE struct cull_stage *cull_stage( struct draw_stage *stage )
-{
- return (struct cull_stage *)stage;
-}
-
-
-
-
-static void cull_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- /* Window coords: */
- const float *v0 = header->v[0]->data[0];
- const float *v1 = header->v[1]->data[0];
- const float *v2 = header->v[2]->data[0];
-
- /* edge vectors e = v0 - v2, f = v1 - v2 */
- const float ex = v0[0] - v2[0];
- const float ey = v0[1] - v2[1];
- const float fx = v1[0] - v2[0];
- const float fy = v1[1] - v2[1];
-
- /* det = cross(e,f).z */
- header->det = ex * fy - ey * fx;
-
- if (header->det != 0) {
- /* if (det < 0 then Z points toward camera and triangle is
- * counter-clockwise winding.
- */
- unsigned winding = (header->det < 0) ? PIPE_WINDING_CCW : PIPE_WINDING_CW;
-
- if ((winding & cull_stage(stage)->winding) == 0) {
- /* triangle is not culled, pass to next stage */
- stage->next->tri( stage->next, header );
- }
- }
-}
-
-static void cull_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct cull_stage *cull = cull_stage(stage);
-
- cull->winding = stage->draw->rasterizer->cull_mode;
-
- stage->tri = cull_tri;
- stage->tri( stage, header );
-}
-
-
-
-static void cull_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void cull_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void cull_flush( struct draw_stage *stage, unsigned flags )
-{
- stage->tri = cull_first_tri;
- stage->next->flush( stage->next, flags );
-}
-
-static void cull_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void cull_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Create a new polygon culling stage.
- */
-struct draw_stage *draw_cull_stage( struct draw_context *draw )
-{
- struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
-
- draw_alloc_tmps( &cull->stage, 0 );
-
- cull->stage.draw = draw;
- cull->stage.next = NULL;
- cull->stage.point = cull_point;
- cull->stage.line = cull_line;
- cull->stage.tri = cull_first_tri;
- cull->stage.flush = cull_flush;
- cull->stage.reset_stipple_counter = cull_reset_stipple_counter;
- cull->stage.destroy = cull_destroy;
-
- return &cull->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_debug.c b/src/mesa/pipe/draw/draw_debug.c
deleted file mode 100644
index d6220b5f62..0000000000
--- a/src/mesa/pipe/draw/draw_debug.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "draw_private.h"
-#include "draw_context.h"
-
-
-
-static void
-draw_prim_info(unsigned prim, unsigned *first, unsigned *incr)
-{
- assert(prim >= PIPE_PRIM_POINTS);
- assert(prim <= PIPE_PRIM_POLYGON);
-
- switch (prim) {
- case PIPE_PRIM_POINTS:
- *first = 1;
- *incr = 1;
- break;
- case PIPE_PRIM_LINES:
- *first = 2;
- *incr = 2;
- break;
- case PIPE_PRIM_LINE_STRIP:
- *first = 2;
- *incr = 1;
- break;
- case PIPE_PRIM_LINE_LOOP:
- *first = 2;
- *incr = 1;
- break;
- case PIPE_PRIM_TRIANGLES:
- *first = 3;
- *incr = 3;
- break;
- case PIPE_PRIM_TRIANGLE_STRIP:
- *first = 3;
- *incr = 1;
- break;
- case PIPE_PRIM_TRIANGLE_FAN:
- case PIPE_PRIM_POLYGON:
- *first = 3;
- *incr = 1;
- break;
- case PIPE_PRIM_QUADS:
- *first = 4;
- *incr = 4;
- break;
- case PIPE_PRIM_QUAD_STRIP:
- *first = 4;
- *incr = 2;
- break;
- default:
- assert(0);
- *first = 1;
- *incr = 1;
- break;
- }
-}
-
-
-unsigned
-draw_trim_prim( unsigned mode, unsigned count )
-{
- unsigned length, first, incr;
-
- draw_prim_info( mode, &first, &incr );
-
- if (count < first)
- length = 0;
- else
- length = count - (count - first) % incr;
-
- return length;
-}
-
-
-boolean
-draw_validate_prim( unsigned mode, unsigned count )
-{
- return (count > 0 &&
- count == draw_trim_prim( mode, count ));
-}
-
diff --git a/src/mesa/pipe/draw/draw_flatshade.c b/src/mesa/pipe/draw/draw_flatshade.c
deleted file mode 100644
index 1419f287d2..0000000000
--- a/src/mesa/pipe/draw/draw_flatshade.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-
-
-/** subclass of draw_stage */
-struct flat_stage
-{
- struct draw_stage stage;
-
- uint num_color_attribs;
- uint color_attribs[4]; /* front/back primary/secondary colors */
-};
-
-
-static INLINE struct flat_stage *
-flat_stage(struct draw_stage *stage)
-{
- return (struct flat_stage *) stage;
-}
-
-
-/** Copy all the color attributes from 'src' vertex to 'dst' vertex */
-static INLINE void copy_colors( struct draw_stage *stage,
- struct vertex_header *dst,
- const struct vertex_header *src )
-{
- const struct flat_stage *flat = flat_stage(stage);
- uint i;
- for (i = 0; i < flat->num_color_attribs; i++) {
- const uint attr = flat->color_attribs[i];
- COPY_4FV(dst->data[attr], src->data[attr]);
- }
-}
-
-
-/** Copy all the color attributes from src vertex to dst0 & dst1 vertices */
-static INLINE void copy_colors2( struct draw_stage *stage,
- struct vertex_header *dst0,
- struct vertex_header *dst1,
- const struct vertex_header *src )
-{
- const struct flat_stage *flat = flat_stage(stage);
- uint i;
- for (i = 0; i < flat->num_color_attribs; i++) {
- const uint attr = flat->color_attribs[i];
- COPY_4FV(dst0->data[attr], src->data[attr]);
- COPY_4FV(dst1->data[attr], src->data[attr]);
- }
-}
-
-
-/**
- * Flatshade tri. Required for clipping and when unfilled tris are
- * active, otherwise handled by hardware.
- */
-static void flatshade_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct prim_header tmp;
-
- tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
- tmp.v[0] = dup_vert(stage, header->v[0], 0);
- tmp.v[1] = dup_vert(stage, header->v[1], 1);
- tmp.v[2] = header->v[2];
-
- copy_colors2(stage, tmp.v[0], tmp.v[1], tmp.v[2]);
-
- stage->next->tri( stage->next, &tmp );
-}
-
-
-/**
- * Flatshade line. Required for clipping.
- */
-static void flatshade_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct prim_header tmp;
-
- tmp.v[0] = dup_vert(stage, header->v[0], 0);
- tmp.v[1] = header->v[1];
-
- copy_colors(stage, tmp.v[0], tmp.v[1]);
-
- stage->next->line( stage->next, &tmp );
-}
-
-
-static void flatshade_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void flatshade_init_state( struct draw_stage *stage )
-{
- struct flat_stage *flat = flat_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
- uint i;
-
- /* Find which vertex shader outputs are colors, make a list */
- flat->num_color_attribs = 0;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- flat->color_attribs[flat->num_color_attribs++] = i;
- }
- }
-
- stage->line = flatshade_line;
- stage->tri = flatshade_tri;
-}
-
-static void flatshade_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- flatshade_init_state( stage );
- stage->tri( stage, header );
-}
-
-static void flatshade_first_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- flatshade_init_state( stage );
- stage->line( stage, header );
-}
-
-
-static void flatshade_flush( struct draw_stage *stage,
- unsigned flags )
-{
- stage->tri = flatshade_first_tri;
- stage->line = flatshade_first_line;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void flatshade_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void flatshade_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Create flatshading drawing stage.
- */
-struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
-{
- struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage);
-
- draw_alloc_tmps( &flatshade->stage, 2 );
-
- flatshade->stage.draw = draw;
- flatshade->stage.next = NULL;
- flatshade->stage.point = flatshade_point;
- flatshade->stage.line = flatshade_first_line;
- flatshade->stage.tri = flatshade_first_tri;
- flatshade->stage.flush = flatshade_flush;
- flatshade->stage.reset_stipple_counter = flatshade_reset_stipple_counter;
- flatshade->stage.destroy = flatshade_destroy;
-
- return &flatshade->stage;
-}
-
-
diff --git a/src/mesa/pipe/draw/draw_offset.c b/src/mesa/pipe/draw/draw_offset.c
deleted file mode 100644
index a2990ee8a8..0000000000
--- a/src/mesa/pipe/draw/draw_offset.c
+++ /dev/null
@@ -1,186 +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.
- *
- **************************************************************************/
-
-/**
- * \brief polygon offset state
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- * \author Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "draw_private.h"
-
-
-
-struct offset_stage {
- struct draw_stage stage;
-
- float scale;
- float units;
-};
-
-
-
-static INLINE struct offset_stage *offset_stage( struct draw_stage *stage )
-{
- return (struct offset_stage *) stage;
-}
-
-
-
-
-
-/**
- * Offset tri Z. Some hardware can handle this, but not usually when
- * doing unfilled rendering.
- */
-static void do_offset_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct offset_stage *offset = offset_stage(stage);
- float inv_det = 1.0f / header->det;
-
- /* Window coords:
- */
- float *v0 = header->v[0]->data[0];
- float *v1 = header->v[1]->data[0];
- float *v2 = header->v[2]->data[0];
-
- /* edge vectors e = v0 - v2, f = v1 - v2 */
- float ex = v0[0] - v2[0];
- float ey = v0[1] - v2[1];
- float ez = v0[2] - v2[2];
- float fx = v1[0] - v2[0];
- float fy = v1[1] - v2[1];
- float fz = v1[2] - v2[2];
-
- /* (a,b) = cross(e,f).xy */
- 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 zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale;
-
- /*
- * Note: we're applying the offset and clamping per-vertex.
- * Ideally, the offset is applied per-fragment prior to fragment shading.
- */
- v0[2] = CLAMP(v0[2] + zoffset, 0.0f, 1.0f);
- v1[2] = CLAMP(v1[2] + zoffset, 0.0f, 1.0f);
- v2[2] = CLAMP(v2[2] + zoffset, 0.0f, 1.0f);
-
- stage->next->tri( stage->next, header );
-}
-
-
-static void offset_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct prim_header tmp;
-
- tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
- tmp.v[0] = dup_vert(stage, header->v[0], 0);
- tmp.v[1] = dup_vert(stage, header->v[1], 1);
- tmp.v[2] = dup_vert(stage, header->v[2], 2);
-
- do_offset_tri( stage, &tmp );
-}
-
-
-static void offset_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct offset_stage *offset = offset_stage(stage);
- float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */
-
- offset->units = stage->draw->rasterizer->offset_units * mrd;
- offset->scale = stage->draw->rasterizer->offset_scale;
-
- stage->tri = offset_tri;
- stage->tri( stage, header );
-}
-
-
-static void offset_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void offset_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void offset_flush( struct draw_stage *stage,
- unsigned flags )
-{
- stage->tri = offset_first_tri;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void offset_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void offset_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Create polygon offset drawing stage.
- */
-struct draw_stage *draw_offset_stage( struct draw_context *draw )
-{
- struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
-
- draw_alloc_tmps( &offset->stage, 3 );
-
- offset->stage.draw = draw;
- offset->stage.next = NULL;
- offset->stage.point = offset_point;
- offset->stage.line = offset_line;
- offset->stage.tri = offset_first_tri;
- offset->stage.flush = offset_flush;
- offset->stage.reset_stipple_counter = offset_reset_stipple_counter;
- offset->stage.destroy = offset_destroy;
-
- return &offset->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c
deleted file mode 100644
index 51e2242719..0000000000
--- a/src/mesa/pipe/draw/draw_prim.c
+++ /dev/null
@@ -1,482 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_debug.h"
-
-#include "draw_private.h"
-#include "draw_context.h"
-
-
-
-#define RP_NONE 0
-#define RP_POINT 1
-#define RP_LINE 2
-#define RP_TRI 3
-
-
-static unsigned reduced_prim[PIPE_PRIM_POLYGON + 1] = {
- RP_POINT,
- RP_LINE,
- RP_LINE,
- RP_LINE,
- RP_TRI,
- RP_TRI,
- RP_TRI,
- RP_TRI,
- RP_TRI,
- RP_TRI
-};
-
-
-static void draw_prim_queue_flush( struct draw_context *draw )
-{
- unsigned i;
-
- if (0)
- debug_printf("Flushing with %d prims, %d verts\n",
- draw->pq.queue_nr, draw->vs.queue_nr);
-
- assert (draw->pq.queue_nr != 0);
-
- /* NOTE: we cannot save draw->pipeline->first in a local var because
- * draw->pipeline->first is often changed by the first call to tri(),
- * line(), etc.
- */
- if (draw->rasterizer->line_stipple_enable) {
- switch (draw->reduced_prim) {
- case RP_TRI:
- for (i = 0; i < draw->pq.queue_nr; i++) {
- if (draw->pq.queue[i].reset_line_stipple)
- draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
-
- draw->pipeline.first->tri( draw->pipeline.first, &draw->pq.queue[i] );
- }
- break;
- case RP_LINE:
- for (i = 0; i < draw->pq.queue_nr; i++) {
- if (draw->pq.queue[i].reset_line_stipple)
- draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
-
- draw->pipeline.first->line( draw->pipeline.first, &draw->pq.queue[i] );
- }
- break;
- case RP_POINT:
- draw->pipeline.first->reset_stipple_counter( draw->pipeline.first );
- for (i = 0; i < draw->pq.queue_nr; i++)
- draw->pipeline.first->point( draw->pipeline.first, &draw->pq.queue[i] );
- break;
- }
- }
- else {
- switch (draw->reduced_prim) {
- case RP_TRI:
- for (i = 0; i < draw->pq.queue_nr; i++)
- draw->pipeline.first->tri( draw->pipeline.first, &draw->pq.queue[i] );
- break;
- case RP_LINE:
- for (i = 0; i < draw->pq.queue_nr; i++)
- draw->pipeline.first->line( draw->pipeline.first, &draw->pq.queue[i] );
- break;
- case RP_POINT:
- for (i = 0; i < draw->pq.queue_nr; i++)
- draw->pipeline.first->point( draw->pipeline.first, &draw->pq.queue[i] );
- break;
- }
- }
-
- draw->pq.queue_nr = 0;
- draw_vertex_cache_unreference( draw );
-}
-
-
-
-void draw_do_flush( struct draw_context *draw, unsigned flags )
-{
- if (0)
- debug_printf("Flushing with %d verts, %d prims\n",
- draw->vs.queue_nr,
- draw->pq.queue_nr );
-
-
- if (flags >= DRAW_FLUSH_SHADER_QUEUE) {
- if (draw->vs.queue_nr)
- (*draw->shader_queue_flush)(draw);
-
- if (flags >= DRAW_FLUSH_PRIM_QUEUE) {
- if (draw->pq.queue_nr)
- draw_prim_queue_flush(draw);
-
- if (flags >= DRAW_FLUSH_VERTEX_CACHE) {
- draw_vertex_cache_invalidate(draw);
-
- if (flags >= DRAW_FLUSH_STATE_CHANGE) {
- draw->pipeline.first->flush( draw->pipeline.first, flags );
- draw->pipeline.first = draw->pipeline.validate;
- draw->reduced_prim = ~0;
- }
- }
- }
- }
-}
-
-
-
-/* Return a pointer to a freshly queued primitive header. Ensure that
- * there is room in the vertex cache for a maximum of "nr_verts" new
- * vertices. Flush primitive and/or vertex queues if necessary to
- * make space.
- */
-static struct prim_header *get_queued_prim( struct draw_context *draw,
- unsigned nr_verts )
-{
- if (!draw_vertex_cache_check_space( draw, nr_verts )) {
-// debug_printf("v");
- draw_do_flush( draw, DRAW_FLUSH_VERTEX_CACHE );
- }
- else if (draw->pq.queue_nr == PRIM_QUEUE_LENGTH) {
-// debug_printf("p");
- draw_do_flush( draw, DRAW_FLUSH_PRIM_QUEUE );
- }
-
- assert(draw->pq.queue_nr < PRIM_QUEUE_LENGTH);
-
- return &draw->pq.queue[draw->pq.queue_nr++];
-}
-
-
-
-/**
- * Add a point to the primitive queue.
- * \param i0 index into user's vertex arrays
- */
-static void do_point( struct draw_context *draw,
- unsigned i0 )
-{
- struct prim_header *prim = get_queued_prim( draw, 1 );
-
- prim->reset_line_stipple = 0;
- prim->edgeflags = 1;
- prim->pad = 0;
- prim->v[0] = draw->vcache.get_vertex( draw, i0 );
-}
-
-
-/**
- * Add a line to the primitive queue.
- * \param i0 index into user's vertex arrays
- * \param i1 index into user's vertex arrays
- */
-static void do_line( struct draw_context *draw,
- boolean reset_stipple,
- unsigned i0,
- unsigned i1 )
-{
- struct prim_header *prim = get_queued_prim( draw, 2 );
-
- prim->reset_line_stipple = reset_stipple;
- prim->edgeflags = 1;
- prim->pad = 0;
- prim->v[0] = draw->vcache.get_vertex( draw, i0 );
- prim->v[1] = draw->vcache.get_vertex( draw, i1 );
-}
-
-/**
- * Add a triangle to the primitive queue.
- */
-static void do_triangle( struct draw_context *draw,
- unsigned i0,
- unsigned i1,
- unsigned i2 )
-{
- struct prim_header *prim = get_queued_prim( draw, 3 );
-
- prim->reset_line_stipple = 1;
- prim->edgeflags = ~0;
- prim->pad = 0;
- prim->v[0] = draw->vcache.get_vertex( draw, i0 );
- prim->v[1] = draw->vcache.get_vertex( draw, i1 );
- prim->v[2] = draw->vcache.get_vertex( draw, i2 );
-}
-
-static void do_ef_triangle( struct draw_context *draw,
- boolean reset_stipple,
- unsigned ef_mask,
- unsigned i0,
- unsigned i1,
- unsigned i2 )
-{
- struct prim_header *prim = get_queued_prim( draw, 3 );
- struct vertex_header *v0 = draw->vcache.get_vertex( draw, i0 );
- struct vertex_header *v1 = draw->vcache.get_vertex( draw, i1 );
- struct vertex_header *v2 = draw->vcache.get_vertex( draw, i2 );
-
- prim->reset_line_stipple = reset_stipple;
-
- prim->edgeflags = ef_mask & ((v0->edgeflag << 0) |
- (v1->edgeflag << 1) |
- (v2->edgeflag << 2));
- prim->pad = 0;
- prim->v[0] = v0;
- prim->v[1] = v1;
- prim->v[2] = v2;
-}
-
-
-static void do_ef_quad( struct draw_context *draw,
- unsigned v0,
- unsigned v1,
- unsigned v2,
- unsigned v3 )
-{
- const unsigned omitEdge2 = ~(1 << 1);
- const unsigned omitEdge3 = ~(1 << 2);
- do_ef_triangle( draw, 1, omitEdge2, v0, v1, v3 );
- do_ef_triangle( draw, 0, omitEdge3, v1, v2, v3 );
-}
-
-static void do_quad( struct draw_context *draw,
- unsigned v0,
- unsigned v1,
- unsigned v2,
- unsigned v3 )
-{
- do_triangle( draw, v0, v1, v3 );
- do_triangle( draw, v1, v2, v3 );
-}
-
-
-/**
- * Main entrypoint to draw some number of points/lines/triangles
- */
-static void
-draw_prim( struct draw_context *draw,
- unsigned prim, unsigned start, unsigned count )
-{
- unsigned i;
- boolean unfilled = (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL);
-
-// debug_printf("%s (%d) %d/%d\n", __FUNCTION__, draw->prim, start, count );
-
- switch (prim) {
- case PIPE_PRIM_POINTS:
- for (i = 0; i < count; i ++) {
- do_point( draw,
- start + i );
- }
- break;
-
- case PIPE_PRIM_LINES:
- for (i = 0; i+1 < count; i += 2) {
- do_line( draw,
- TRUE,
- start + i + 0,
- start + i + 1);
- }
- break;
-
- case PIPE_PRIM_LINE_LOOP:
- if (count >= 2) {
- for (i = 1; i < count; i++) {
- do_line( draw,
- i == 1, /* XXX: only if vb not split */
- start + i - 1,
- start + i );
- }
-
- do_line( draw,
- 0,
- start + count - 1,
- start + 0 );
- }
- break;
-
- case PIPE_PRIM_LINE_STRIP:
- for (i = 1; i < count; i++) {
- do_line( draw,
- i == 1,
- start + i - 1,
- start + i );
- }
- break;
-
- case PIPE_PRIM_TRIANGLES:
- if (unfilled) {
- for (i = 0; i+2 < count; i += 3) {
- do_ef_triangle( draw,
- 1,
- ~0,
- start + i + 0,
- start + i + 1,
- start + i + 2 );
- }
- }
- else {
- for (i = 0; i+2 < count; i += 3) {
- do_triangle( draw,
- start + i + 0,
- start + i + 1,
- start + i + 2 );
- }
- }
- break;
-
- case PIPE_PRIM_TRIANGLE_STRIP:
- for (i = 0; i+2 < count; i++) {
- if (i & 1) {
- do_triangle( draw,
- start + i + 1,
- start + i + 0,
- start + i + 2 );
- }
- else {
- do_triangle( draw,
- start + i + 0,
- start + i + 1,
- start + i + 2 );
- }
- }
- break;
-
- case PIPE_PRIM_TRIANGLE_FAN:
- if (count >= 3) {
- for (i = 0; i+2 < count; i++) {
- do_triangle( draw,
- start + 0,
- start + i + 1,
- start + i + 2 );
- }
- }
- break;
-
-
- case PIPE_PRIM_QUADS:
- if (unfilled) {
- for (i = 0; i+3 < count; i += 4) {
- do_ef_quad( draw,
- start + i + 0,
- start + i + 1,
- start + i + 2,
- start + i + 3);
- }
- }
- else {
- for (i = 0; i+3 < count; i += 4) {
- do_quad( draw,
- start + i + 0,
- start + i + 1,
- start + i + 2,
- start + i + 3);
- }
- }
- break;
-
- case PIPE_PRIM_QUAD_STRIP:
- if (unfilled) {
- for (i = 0; i+3 < count; i += 2) {
- do_ef_quad( draw,
- start + i + 2,
- start + i + 0,
- start + i + 1,
- start + i + 3);
- }
- }
- else {
- for (i = 0; i+3 < count; i += 2) {
- do_quad( draw,
- start + i + 2,
- start + i + 0,
- start + i + 1,
- start + i + 3);
- }
- }
- break;
-
- case PIPE_PRIM_POLYGON:
- if (unfilled) {
- unsigned ef_mask = (1<<2) | (1<<0);
-
- for (i = 0; i+2 < count; i++) {
-
- if (i + 3 >= count)
- ef_mask |= (1<<1);
-
- do_ef_triangle( draw,
- i == 0,
- ef_mask,
- start + i + 1,
- start + i + 2,
- start + 0);
-
- ef_mask &= ~(1<<2);
- }
- }
- else {
- for (i = 0; i+2 < count; i++) {
- do_triangle( draw,
- start + i + 1,
- start + i + 2,
- start + 0);
- }
- }
- break;
-
- default:
- assert(0);
- break;
- }
-}
-
-
-
-
-/**
- * Draw vertex arrays
- * This is the main entrypoint into the drawing module.
- * \param prim one of PIPE_PRIM_x
- * \param start index of first vertex to draw
- * \param count number of vertices to draw
- */
-void
-draw_arrays(struct draw_context *draw, unsigned prim,
- unsigned start, unsigned count)
-{
- if (reduced_prim[prim] != draw->reduced_prim) {
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->reduced_prim = reduced_prim[prim];
- }
-
- /* drawing done here: */
- draw_prim(draw, prim, start, count);
-}
-
-
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
deleted file mode 100644
index 7782db0477..0000000000
--- a/src/mesa/pipe/draw/draw_private.h
+++ /dev/null
@@ -1,346 +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.
- *
- **************************************************************************/
-
-/**
- * Private data structures, etc for the draw module.
- */
-
-
-/**
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-
-#ifndef DRAW_PRIVATE_H
-#define DRAW_PRIVATE_H
-
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-
-#include "x86/rtasm/x86sse.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-
-
-struct gallivm_prog;
-struct gallivm_cpu_engine;
-
-/**
- * Basic vertex info.
- * Carry some useful information around with the vertices in the prim pipe.
- */
-struct vertex_header {
- unsigned clipmask:12;
- unsigned edgeflag:1;
- unsigned pad:3;
- unsigned vertex_id:16;
-
- float clip[4];
-
- float data[][4]; /* Note variable size */
-};
-
-/* NOTE: It should match vertex_id size above */
-#define UNDEFINED_VERTEX_ID 0xffff
-
-/* XXX This is too large */
-#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
-
-
-
-/**
- * Basic info for a point/line/triangle primitive.
- */
-struct prim_header {
- float det; /**< front/back face determinant */
- unsigned reset_line_stipple:1;
- unsigned edgeflags:3;
- unsigned pad:28;
- struct vertex_header *v[3]; /**< 1 to 3 vertex pointers */
-};
-
-
-
-struct draw_context;
-
-/**
- * Base class for all primitive drawing stages.
- */
-struct draw_stage
-{
- struct draw_context *draw; /**< parent context */
-
- struct draw_stage *next; /**< next stage in pipeline */
-
- struct vertex_header **tmp; /**< temp vert storage, such as for clipping */
- unsigned nr_tmps;
-
- void (*point)( struct draw_stage *,
- struct prim_header * );
-
- void (*line)( struct draw_stage *,
- struct prim_header * );
-
- void (*tri)( struct draw_stage *,
- struct prim_header * );
-
- void (*flush)( struct draw_stage *,
- unsigned flags );
-
- void (*reset_stipple_counter)( struct draw_stage * );
-
- void (*destroy)( struct draw_stage * );
-};
-
-
-#define PRIM_QUEUE_LENGTH 16
-#define VCACHE_SIZE 32
-#define VCACHE_OVERFLOW 4
-#define VS_QUEUE_LENGTH (VCACHE_SIZE + VCACHE_OVERFLOW + 1) /* can never fill up */
-
-/**
- * Private version of the compiled vertex_shader
- */
-struct draw_vertex_shader {
- const struct pipe_shader_state *state;
-#if defined(__i386__) || defined(__386__)
- struct x86_function sse2_program;
-#endif
-#ifdef MESA_LLVM
- struct gallivm_prog *llvm_prog;
-#endif
-};
-
-
-/* Internal function for vertex fetch.
- */
-typedef void (*fetch_func)(const void *ptr, float *attrib);
-typedef void (*full_fetch_func)( struct draw_context *draw,
- struct tgsi_exec_machine *machine,
- const unsigned *elts,
- unsigned count );
-
-
-
-/**
- * Private context for the drawing module.
- */
-struct draw_context
-{
- /** Drawing/primitive pipeline stages */
- struct {
- struct draw_stage *first; /**< one of the following */
-
- struct draw_stage *validate;
-
- /* stages (in logical order) */
- struct draw_stage *flatshade;
- struct draw_stage *clip;
- struct draw_stage *cull;
- struct draw_stage *twoside;
- struct draw_stage *offset;
- struct draw_stage *unfilled;
- struct draw_stage *stipple;
- struct draw_stage *wide;
- struct draw_stage *rasterize;
- } pipeline;
-
- /* pipe state that we need: */
- const struct pipe_rasterizer_state *rasterizer;
- struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
- struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
- const struct draw_vertex_shader *vertex_shader;
-
- uint num_vs_outputs; /**< convenience, from vertex_shader */
-
- /* user-space vertex data, buffers */
- struct {
- /** vertex element/index buffer (ex: glDrawElements) */
- const void *elts;
- /** bytes per index (0, 1, 2 or 4) */
- unsigned eltSize;
-
- /** vertex arrays */
- const void *vbuffer[PIPE_ATTRIB_MAX];
-
- /** constant buffer (for vertex shader) */
- const void *constants;
- } user;
-
- /* Clip derived state:
- */
- float plane[12][4];
- unsigned nr_planes;
-
- boolean convert_wide_points; /**< convert wide points to tris? */
- boolean convert_wide_lines; /**< convert side lines to tris? */
-
- unsigned reduced_prim;
-
- /** TGSI program interpreter runtime state */
- struct tgsi_exec_machine machine;
-
- /* Vertex fetch internal state
- */
- struct {
- const ubyte *src_ptr[PIPE_ATTRIB_MAX];
- unsigned pitch[PIPE_ATTRIB_MAX];
- fetch_func fetch[PIPE_ATTRIB_MAX];
- unsigned nr_attrs;
- full_fetch_func fetch_func;
- } vertex_fetch;
-
- /* Post-tnl vertex cache:
- */
- struct {
- unsigned referenced; /**< bitfield */
- unsigned idx[VCACHE_SIZE + VCACHE_OVERFLOW];
- struct vertex_header *vertex[VCACHE_SIZE + VCACHE_OVERFLOW];
- unsigned overflow;
-
- /** To find space in the vertex cache: */
- struct vertex_header *(*get_vertex)( struct draw_context *draw,
- unsigned i );
- } vcache;
-
- /* Vertex shader queue:
- */
- struct {
- struct {
- unsigned elt; /**< index into the user's vertex arrays */
- struct vertex_header *dest; /**< points into vcache.vertex[] array */
- } queue[VS_QUEUE_LENGTH];
- unsigned queue_nr;
- } vs;
-
- /**
- * Run the vertex shader on all vertices in the vertex queue.
- */
- void (*shader_queue_flush)(struct draw_context *draw);
-
- /* Prim pipeline queue:
- */
- struct {
- /* Need to queue up primitives until their vertices have been
- * transformed by a vs queue flush.
- */
- struct prim_header queue[PRIM_QUEUE_LENGTH];
- unsigned queue_nr;
- } pq;
-
- int use_sse : 1;
-#ifdef MESA_LLVM
- struct gallivm_cpu_engine *engine;
-#endif
-
- void *driver_private;
-};
-
-
-
-extern struct draw_stage *draw_unfilled_stage( struct draw_context *context );
-extern struct draw_stage *draw_twoside_stage( struct draw_context *context );
-extern struct draw_stage *draw_offset_stage( struct draw_context *context );
-extern struct draw_stage *draw_clip_stage( struct draw_context *context );
-extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
-extern struct draw_stage *draw_cull_stage( struct draw_context *context );
-extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
-extern struct draw_stage *draw_wide_stage( struct draw_context *context );
-extern struct draw_stage *draw_validate_stage( struct draw_context *context );
-
-
-extern void draw_free_tmps( struct draw_stage *stage );
-extern void draw_reset_tmps( struct draw_stage *stage );
-extern void draw_alloc_tmps( struct draw_stage *stage, unsigned nr );
-
-extern void draw_reset_vertex_ids( struct draw_context *draw );
-
-
-extern int draw_vertex_cache_check_space( struct draw_context *draw,
- unsigned nr_verts );
-
-extern void draw_vertex_cache_invalidate( struct draw_context *draw );
-extern void draw_vertex_cache_unreference( struct draw_context *draw );
-extern void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw );
-
-
-extern void draw_vertex_shader_queue_flush( struct draw_context *draw );
-#ifdef MESA_LLVM
-extern void draw_vertex_shader_queue_flush_llvm( struct draw_context *draw );
-#endif
-
-struct tgsi_exec_machine;
-
-extern void draw_update_vertex_fetch( struct draw_context *draw );
-
-
-#define DRAW_FLUSH_SHADER_QUEUE 0x1 /* sized not to overflow, never raised */
-#define DRAW_FLUSH_PRIM_QUEUE 0x2
-#define DRAW_FLUSH_VERTEX_CACHE 0x4
-#define DRAW_FLUSH_STATE_CHANGE 0x8
-#define DRAW_FLUSH_BACKEND 0x10
-
-
-void draw_do_flush( struct draw_context *draw, unsigned flags );
-
-
-
-/**
- * Get a writeable copy of a vertex.
- * \param stage drawing stage info
- * \param vert the vertex to copy (source)
- * \param idx index into stage's tmp[] array to put the copy (dest)
- * \return pointer to the copied vertex
- */
-static INLINE struct vertex_header *
-dup_vert( struct draw_stage *stage,
- const struct vertex_header *vert,
- unsigned idx )
-{
- struct vertex_header *tmp = stage->tmp[idx];
- const uint vsize = sizeof(struct vertex_header)
- + stage->draw->num_vs_outputs * 4 * sizeof(float);
- memcpy(tmp, vert, vsize);
- tmp->vertex_id = UNDEFINED_VERTEX_ID;
- return tmp;
-}
-
-static INLINE float
-dot4(const float *a, const float *b)
-{
- float result = (a[0]*b[0] +
- a[1]*b[1] +
- a[2]*b[2] +
- a[3]*b[3]);
-
- return result;
-}
-
-#endif /* DRAW_PRIVATE_H */
diff --git a/src/mesa/pipe/draw/draw_stipple.c b/src/mesa/pipe/draw/draw_stipple.c
deleted file mode 100644
index 9029101916..0000000000
--- a/src/mesa/pipe/draw/draw_stipple.c
+++ /dev/null
@@ -1,238 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-/* Implement line stipple by cutting lines up into smaller lines.
- * There are hundreds of ways to implement line stipple, this is one
- * choice that should work in all situations, requires no state
- * manipulations, but with a penalty in terms of large amounts of
- * generated geometry.
- */
-
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-
-
-/** Subclass of draw_stage */
-struct stipple_stage {
- struct draw_stage stage;
- float counter;
- uint pattern;
- uint factor;
-};
-
-
-static INLINE struct stipple_stage *
-stipple_stage(struct draw_stage *stage)
-{
- return (struct stipple_stage *) stage;
-}
-
-
-/**
- * Compute interpolated vertex attributes for 'dst' at position 't'
- * between 'v0' and 'v1'.
- * XXX using linear interpolation for all attribs at this time.
- */
-static void
-screen_interp( struct draw_context *draw,
- struct vertex_header *dst,
- float t,
- const struct vertex_header *v0,
- const struct vertex_header *v1 )
-{
- uint attr;
- for (attr = 0; attr < draw->num_vs_outputs; attr++) {
- const float *val0 = v0->data[attr];
- const float *val1 = v1->data[attr];
- float *newv = dst->data[attr];
- uint i;
- for (i = 0; i < 4; i++) {
- newv[i] = val0[i] + t * (val1[i] - val0[i]);
- }
- }
-}
-
-
-static void
-emit_segment(struct draw_stage *stage, struct prim_header *header,
- float t0, float t1)
-{
- struct vertex_header *v0new = dup_vert(stage, header->v[0], 0);
- struct vertex_header *v1new = dup_vert(stage, header->v[1], 1);
- struct prim_header newprim = *header;
-
- if (t0 > 0.0) {
- screen_interp( stage->draw, v0new, t0, header->v[0], header->v[1] );
- newprim.v[0] = v0new;
- }
-
- if (t1 < 1.0) {
- screen_interp( stage->draw, v1new, t1, header->v[0], header->v[1] );
- newprim.v[1] = v1new;
- }
-
- stage->next->line( stage->next, &newprim );
-}
-
-
-static INLINE unsigned
-stipple_test(int counter, ushort pattern, int factor)
-{
- int b = (counter / factor) & 0xf;
- return (1 << b) & pattern;
-}
-
-
-static void
-stipple_line(struct draw_stage *stage, struct prim_header *header)
-{
- struct stipple_stage *stipple = stipple_stage(stage);
- struct vertex_header *v0 = header->v[0];
- struct vertex_header *v1 = header->v[1];
- const float *pos0 = v0->data[0];
- const float *pos1 = v1->data[0];
- float start = 0;
- int state = 0;
-
- float x0 = pos0[0];
- float x1 = pos1[0];
- float y0 = pos0[1];
- float y1 = pos1[1];
-
- float dx = x0 > x1 ? x0 - x1 : x1 - x0;
- float dy = y0 > y1 ? y0 - y1 : y1 - y0;
-
- float length = MAX2(dx, dy);
- int i;
-
- /* XXX ToDo: intead of iterating pixel-by-pixel, use a look-up table.
- */
- for (i = 0; i < length; i++) {
- int result = stipple_test( (int) stipple->counter+i,
- (ushort) stipple->pattern, stipple->factor );
- if (result != state) {
- /* changing from "off" to "on" or vice versa */
- if (state) {
- if (start != i) {
- /* finishing an "on" segment */
- emit_segment( stage, header, start / length, i / length );
- }
- }
- else {
- /* starting an "on" segment */
- start = (float) i;
- }
- state = result;
- }
- }
-
- if (state && start < length)
- emit_segment( stage, header, start / length, 1.0 );
-
- stipple->counter += length;
-}
-
-
-static void
-reset_stipple_counter(struct draw_stage *stage)
-{
- struct stipple_stage *stipple = stipple_stage(stage);
- stipple->counter = 0;
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void
-stipple_first_line(struct draw_stage *stage,
- struct prim_header *header)
-{
- struct stipple_stage *stipple = stipple_stage(stage);
- struct draw_context *draw = stage->draw;
-
- stipple->pattern = draw->rasterizer->line_stipple_pattern;
- stipple->factor = draw->rasterizer->line_stipple_factor + 1;
-
- stage->line = stipple_line;
- stage->line( stage, header );
-}
-
-
-static void
-stipple_flush(struct draw_stage *stage, unsigned flags)
-{
- stage->line = stipple_first_line;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void
-passthrough_point(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void
-passthrough_tri(struct draw_stage *stage, struct prim_header *header)
-{
- stage->next->tri(stage->next, header);
-}
-
-
-static void
-stipple_destroy( struct draw_stage *stage )
-{
- FREE( stage );
-}
-
-
-/**
- * Create line stippler stage
- */
-struct draw_stage *draw_stipple_stage( struct draw_context *draw )
-{
- struct stipple_stage *stipple = CALLOC_STRUCT(stipple_stage);
-
- draw_alloc_tmps( &stipple->stage, 2 );
-
- stipple->stage.draw = draw;
- stipple->stage.next = NULL;
- stipple->stage.point = passthrough_point;
- stipple->stage.line = stipple_first_line;
- stipple->stage.tri = passthrough_tri;
- stipple->stage.reset_stipple_counter = reset_stipple_counter;
- stipple->stage.flush = stipple_flush;
- stipple->stage.destroy = stipple_destroy;
-
- return &stipple->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_twoside.c b/src/mesa/pipe/draw/draw_twoside.c
deleted file mode 100644
index ad2aaf10bb..0000000000
--- a/src/mesa/pipe/draw/draw_twoside.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-
-
-struct twoside_stage {
- struct draw_stage stage;
- float sign; /**< +1 or -1 */
- uint attrib_front0, attrib_back0;
- uint attrib_front1, attrib_back1;
-};
-
-
-static INLINE struct twoside_stage *twoside_stage( struct draw_stage *stage )
-{
- return (struct twoside_stage *)stage;
-}
-
-
-
-
-/**
- * Copy back color(s) to front color(s).
- */
-static INLINE struct vertex_header *
-copy_bfc( struct twoside_stage *twoside,
- const struct vertex_header *v,
- unsigned idx )
-{
- struct vertex_header *tmp = dup_vert( &twoside->stage, v, idx );
-
- if (twoside->attrib_back0) {
- COPY_4FV(tmp->data[twoside->attrib_front0],
- tmp->data[twoside->attrib_back0]);
- }
- if (twoside->attrib_back1) {
- COPY_4FV(tmp->data[twoside->attrib_front1],
- tmp->data[twoside->attrib_back1]);
- }
-
- return tmp;
-}
-
-
-/* Twoside tri:
- */
-static void twoside_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct twoside_stage *twoside = twoside_stage(stage);
-
- if (header->det * twoside->sign < 0.0) {
- /* this is a back-facing triangle */
- struct prim_header tmp;
-
- tmp.det = header->det;
- tmp.edgeflags = header->edgeflags;
- /* copy back attribs to front attribs */
- tmp.v[0] = copy_bfc(twoside, header->v[0], 0);
- tmp.v[1] = copy_bfc(twoside, header->v[1], 1);
- tmp.v[2] = copy_bfc(twoside, header->v[2], 2);
-
- stage->next->tri( stage->next, &tmp );
- }
- else {
- stage->next->tri( stage->next, header );
- }
-}
-
-
-static void twoside_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- /* pass-through */
- stage->next->line( stage->next, header );
-}
-
-
-static void twoside_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- /* pass-through */
- stage->next->point( stage->next, header );
-}
-
-
-static void twoside_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct twoside_stage *twoside = twoside_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
- uint i;
-
- twoside->attrib_front0 = 0;
- twoside->attrib_front1 = 0;
- twoside->attrib_back0 = 0;
- twoside->attrib_back1 = 0;
-
- /* Find which vertex shader outputs are front/back colors */
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
- if (vs->output_semantic_index[i] == 0)
- twoside->attrib_front0 = i;
- else
- twoside->attrib_front1 = i;
- }
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- if (vs->output_semantic_index[i] == 0)
- twoside->attrib_back0 = i;
- else
- twoside->attrib_back1 = i;
- }
- }
-
- if (!twoside->attrib_back0)
- twoside->attrib_front0 = 0;
-
- if (!twoside->attrib_back1)
- twoside->attrib_front1 = 0;
-
- /*
- * We'll multiply the primitive's determinant by this sign to determine
- * if the triangle is back-facing (negative).
- * sign = -1 for CCW, +1 for CW
- */
- twoside->sign = (stage->draw->rasterizer->front_winding == PIPE_WINDING_CCW) ? -1.0f : 1.0f;
-
- stage->tri = twoside_tri;
- stage->tri( stage, header );
-}
-
-
-static void twoside_flush( struct draw_stage *stage, unsigned flags )
-{
- stage->tri = twoside_first_tri;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void twoside_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void twoside_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Create twoside pipeline stage.
- */
-struct draw_stage *draw_twoside_stage( struct draw_context *draw )
-{
- struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
-
- draw_alloc_tmps( &twoside->stage, 3 );
-
- twoside->stage.draw = draw;
- twoside->stage.next = NULL;
- twoside->stage.point = twoside_point;
- twoside->stage.line = twoside_line;
- twoside->stage.tri = twoside_first_tri;
- twoside->stage.flush = twoside_flush;
- twoside->stage.reset_stipple_counter = twoside_reset_stipple_counter;
- twoside->stage.destroy = twoside_destroy;
-
- return &twoside->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_unfilled.c b/src/mesa/pipe/draw/draw_unfilled.c
deleted file mode 100644
index 364bda8b79..0000000000
--- a/src/mesa/pipe/draw/draw_unfilled.c
+++ /dev/null
@@ -1,204 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Drawing stage for handling glPolygonMode(line/point).
- * Convert triangles to points or lines as needed.
- */
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "draw_private.h"
-
-
-struct unfilled_stage {
- struct draw_stage stage;
-
- /** [0] = front face, [1] = back face.
- * legal values: PIPE_POLYGON_MODE_FILL, PIPE_POLYGON_MODE_LINE,
- * and PIPE_POLYGON_MODE_POINT,
- */
- unsigned mode[2];
-};
-
-
-static INLINE struct unfilled_stage *unfilled_stage( struct draw_stage *stage )
-{
- return (struct unfilled_stage *)stage;
-}
-
-
-
-static void point( struct draw_stage *stage,
- struct vertex_header *v0 )
-{
- struct prim_header tmp;
- tmp.v[0] = v0;
- stage->next->point( stage->next, &tmp );
-}
-
-static void line( struct draw_stage *stage,
- struct vertex_header *v0,
- struct vertex_header *v1 )
-{
- struct prim_header tmp;
- tmp.v[0] = v0;
- tmp.v[1] = v1;
- stage->next->line( stage->next, &tmp );
-}
-
-
-static void points( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct vertex_header *v0 = header->v[0];
- struct vertex_header *v1 = header->v[1];
- struct vertex_header *v2 = header->v[2];
-
- if (header->edgeflags & 0x1) point( stage, v0 );
- if (header->edgeflags & 0x2) point( stage, v1 );
- if (header->edgeflags & 0x4) point( stage, v2 );
-}
-
-
-static void lines( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct vertex_header *v0 = header->v[0];
- struct vertex_header *v1 = header->v[1];
- struct vertex_header *v2 = header->v[2];
-
-#if 0
- assert(((header->edgeflags & 0x1) >> 0) == header->v[0]->edgeflag);
- assert(((header->edgeflags & 0x2) >> 1) == header->v[1]->edgeflag);
- assert(((header->edgeflags & 0x4) >> 2) == header->v[2]->edgeflag);
-#endif
-
- if (header->edgeflags & 0x1) line( stage, v0, v1 );
- if (header->edgeflags & 0x2) line( stage, v1, v2 );
- if (header->edgeflags & 0x4) line( stage, v2, v0 );
-}
-
-
-/* Unfilled tri:
- *
- * Note edgeflags in the vertex struct is not sufficient as we will
- * need to manipulate them when decomposing primitives???
- */
-static void unfilled_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct unfilled_stage *unfilled = unfilled_stage(stage);
- unsigned mode = unfilled->mode[header->det >= 0.0];
-
- switch (mode) {
- case PIPE_POLYGON_MODE_FILL:
- stage->next->tri( stage->next, header );
- break;
- case PIPE_POLYGON_MODE_LINE:
- lines( stage, header );
- break;
- case PIPE_POLYGON_MODE_POINT:
- points( stage, header );
- break;
- default:
- abort();
- }
-}
-
-
-static void unfilled_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct unfilled_stage *unfilled = unfilled_stage(stage);
-
- unfilled->mode[0] = stage->draw->rasterizer->fill_ccw; /* front */
- unfilled->mode[1] = stage->draw->rasterizer->fill_cw; /* back */
-
- stage->tri = unfilled_tri;
- stage->tri( stage, header );
-}
-
-
-static void unfilled_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line( stage->next, header );
-}
-
-
-static void unfilled_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-
-static void unfilled_flush( struct draw_stage *stage,
- unsigned flags )
-{
- stage->next->flush( stage->next, flags );
-}
-
-
-static void unfilled_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void unfilled_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-/**
- * Create unfilled triangle stage.
- */
-struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
-{
- struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
-
- draw_alloc_tmps( &unfilled->stage, 0 );
-
- unfilled->stage.draw = draw;
- unfilled->stage.next = NULL;
- unfilled->stage.tmp = NULL;
- unfilled->stage.point = unfilled_point;
- unfilled->stage.line = unfilled_line;
- unfilled->stage.tri = unfilled_first_tri;
- unfilled->stage.flush = unfilled_flush;
- unfilled->stage.reset_stipple_counter = unfilled_reset_stipple_counter;
- unfilled->stage.destroy = unfilled_destroy;
-
- return &unfilled->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_validate.c b/src/mesa/pipe/draw/draw_validate.c
deleted file mode 100644
index 4375ebabbc..0000000000
--- a/src/mesa/pipe/draw/draw_validate.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "draw_private.h"
-
-
-
-
-
-/**
- * Rebuild the rendering pipeline.
- */
-static struct draw_stage *validate_pipeline( struct draw_stage *stage )
-{
- struct draw_context *draw = stage->draw;
- struct draw_stage *next = draw->pipeline.rasterize;
- int need_det = 0;
- int precalc_flat = 0;
-
- /* Set the validate's next stage to the rasterize stage, so that it
- * can be found later if needed for flushing.
- */
- stage->next = next;
-
- /*
- * NOTE: we build up the pipeline in end-to-start order.
- *
- * TODO: make the current primitive part of the state and build
- * shorter pipelines for lines & points.
- */
-
- if ((draw->rasterizer->line_width != 1.0 && draw->convert_wide_lines) ||
- (draw->rasterizer->point_size != 1.0 && draw->convert_wide_points) ||
- draw->rasterizer->point_sprite) {
- draw->pipeline.wide->next = next;
- next = draw->pipeline.wide;
- }
-
- if (draw->rasterizer->line_stipple_enable) {
- draw->pipeline.stipple->next = next;
- next = draw->pipeline.stipple;
- precalc_flat = 1; /* only needed for lines really */
- }
-
- if (draw->rasterizer->fill_cw != PIPE_POLYGON_MODE_FILL ||
- draw->rasterizer->fill_ccw != PIPE_POLYGON_MODE_FILL) {
- draw->pipeline.unfilled->next = next;
- next = draw->pipeline.unfilled;
- precalc_flat = 1; /* only needed for triangles really */
- need_det = 1;
- }
-
- if (draw->rasterizer->flatshade && precalc_flat) {
- draw->pipeline.flatshade->next = next;
- next = draw->pipeline.flatshade;
- }
-
- if (draw->rasterizer->offset_cw ||
- draw->rasterizer->offset_ccw) {
- draw->pipeline.offset->next = next;
- next = draw->pipeline.offset;
- need_det = 1;
- }
-
- if (draw->rasterizer->light_twoside) {
- draw->pipeline.twoside->next = next;
- next = draw->pipeline.twoside;
- need_det = 1;
- }
-
- /* Always run the cull stage as we calculate determinant there
- * also.
- *
- * This can actually be a win as culling out the triangles can lead
- * to less work emitting vertices, smaller vertex buffers, etc.
- * It's difficult to say whether this will be true in general.
- */
- if (need_det || draw->rasterizer->cull_mode) {
- draw->pipeline.cull->next = next;
- next = draw->pipeline.cull;
- }
-
- /* Clip stage
- */
- if (!draw->rasterizer->bypass_clipping)
- {
- draw->pipeline.clip->next = next;
- next = draw->pipeline.clip;
- }
-
-
- draw->pipeline.first = next;
- return next;
-}
-
-static void validate_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct draw_stage *pipeline = validate_pipeline( stage );
- pipeline->tri( pipeline, header );
-}
-
-static void validate_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct draw_stage *pipeline = validate_pipeline( stage );
- pipeline->line( pipeline, header );
-}
-
-static void validate_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct draw_stage *pipeline = validate_pipeline( stage );
- pipeline->point( pipeline, header );
-}
-
-static void validate_reset_stipple_counter( struct draw_stage *stage )
-{
- struct draw_stage *pipeline = validate_pipeline( stage );
- pipeline->reset_stipple_counter( pipeline );
-}
-
-static void validate_flush( struct draw_stage *stage,
- unsigned flags )
-{
- /* May need to pass a backend flush on to the rasterize stage.
- */
- if (stage->next)
- stage->next->flush( stage->next, flags );
-}
-
-
-static void validate_destroy( struct draw_stage *stage )
-{
- FREE( stage );
-}
-
-
-/**
- * Create validate pipeline stage.
- */
-struct draw_stage *draw_validate_stage( struct draw_context *draw )
-{
- struct draw_stage *stage = CALLOC_STRUCT(draw_stage);
-
- stage->draw = draw;
- stage->next = NULL;
- stage->point = validate_point;
- stage->line = validate_line;
- stage->tri = validate_tri;
- stage->flush = validate_flush;
- stage->reset_stipple_counter = validate_reset_stipple_counter;
- stage->destroy = validate_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/draw/draw_vbuf.c b/src/mesa/pipe/draw/draw_vbuf.c
deleted file mode 100644
index be96c8fdeb..0000000000
--- a/src/mesa/pipe/draw/draw_vbuf.c
+++ /dev/null
@@ -1,567 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Vertex buffer drawing stage.
- *
- * \author José Fonseca <jrfonsec@tungstengraphics.com>
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-
-#include "draw_vbuf.h"
-#include "draw_private.h"
-#include "draw_vertex.h"
-#include "draw_vf.h"
-
-
-/**
- * Vertex buffer emit stage.
- */
-struct vbuf_stage {
- struct draw_stage stage; /**< This must be first (base class) */
-
- struct vbuf_render *render;
-
- const struct vertex_info *vinfo;
-
- /** Vertex size in bytes */
- unsigned vertex_size;
-
- struct draw_vertex_fetch *vf;
-
- /* FIXME: we have no guarantee that 'unsigned' is 32bit */
-
- /** Vertices in hardware format */
- unsigned *vertices;
- unsigned *vertex_ptr;
- unsigned max_vertices;
- unsigned nr_vertices;
-
- /** Indices */
- ushort *indices;
- unsigned max_indices;
- unsigned nr_indices;
-
- /** Pipe primitive */
- unsigned prim;
-};
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct vbuf_stage *
-vbuf_stage( struct draw_stage *stage )
-{
- assert(stage);
- return (struct vbuf_stage *)stage;
-}
-
-
-static void vbuf_flush_indices( struct vbuf_stage *vbuf );
-static void vbuf_flush_vertices( struct vbuf_stage *vbuf );
-static void vbuf_alloc_vertices( struct vbuf_stage *vbuf );
-
-
-static INLINE boolean
-overflow( void *map, void *ptr, unsigned bytes, unsigned bufsz )
-{
- unsigned long used = (unsigned long) ((char *)ptr - (char *)map);
- return (used + bytes) > bufsz;
-}
-
-
-static INLINE void
-check_space( struct vbuf_stage *vbuf, unsigned nr )
-{
- if (vbuf->nr_vertices + nr > vbuf->max_vertices ) {
- vbuf_flush_vertices(vbuf);
- vbuf_alloc_vertices(vbuf);
- }
-
- if (vbuf->nr_indices + nr > vbuf->max_indices )
- vbuf_flush_indices(vbuf);
-}
-
-
-#if 0
-static INLINE void
-dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
-{
- assert(vinfo == vbuf->render->get_vertex_info(vbuf->render));
- unsigned i, j, k;
-
- for (i = 0; i < vinfo->num_attribs; i++) {
- j = vinfo->src_index[i];
- switch (vinfo->emit[i]) {
- case EMIT_OMIT:
- debug_printf("EMIT_OMIT:");
- break;
- case EMIT_ALL:
- assert(i == 0);
- assert(j == 0);
- debug_printf("EMIT_ALL:\t");
- for(k = 0; k < vinfo->size*4; ++k)
- debug_printf("%02x ", *data++);
- break;
- case EMIT_1F:
- debug_printf("EMIT_1F:\t");
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- break;
- case EMIT_1F_PSIZE:
- debug_printf("EMIT_1F_PSIZE:\t");
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- break;
- case EMIT_2F:
- debug_printf("EMIT_2F:\t");
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- break;
- case EMIT_3F:
- debug_printf("EMIT_3F:\t");
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- data += sizeof(float);
- break;
- case EMIT_4F:
- debug_printf("EMIT_4F:\t");
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- debug_printf("%f ", *(float *)data); data += sizeof(float);
- break;
- case EMIT_4UB:
- debug_printf("EMIT_4UB:\t");
- debug_printf("%u ", *data++);
- debug_printf("%u ", *data++);
- debug_printf("%u ", *data++);
- debug_printf("%u ", *data++);
- break;
- default:
- assert(0);
- }
- debug_printf("\n");
- }
- debug_printf("\n");
-}
-#endif
-
-
-/**
- * Extract the needed fields from post-transformed vertex and emit
- * a hardware(driver) vertex.
- * Recall that the vertices are constructed by the 'draw' module and
- * have a couple of slots at the beginning (1-dword header, 4-dword
- * clip pos) that we ignore here. We only use the vertex->data[] fields.
- */
-static INLINE void
-emit_vertex( struct vbuf_stage *vbuf,
- struct vertex_header *vertex )
-{
-#if 0
- debug_printf("emit vertex %d to %p\n",
- vbuf->nr_vertices, vbuf->vertex_ptr);
-#endif
-
- if(vertex->vertex_id != UNDEFINED_VERTEX_ID) {
- if(vertex->vertex_id < vbuf->nr_vertices)
- return;
- else
- debug_printf("Bad vertex id 0x%04x (>= 0x%04x)\n",
- vertex->vertex_id, vbuf->nr_vertices);
- return;
- }
-
- vertex->vertex_id = vbuf->nr_vertices++;
-
- if(!vbuf->vf) {
- const struct vertex_info *vinfo = vbuf->vinfo;
- uint i;
- uint count = 0; /* for debug/sanity */
-
- assert(vinfo == vbuf->render->get_vertex_info(vbuf->render));
-
- for (i = 0; i < vinfo->num_attribs; i++) {
- uint j = vinfo->src_index[i];
- switch (vinfo->emit[i]) {
- case EMIT_OMIT:
- /* no-op */
- break;
- case EMIT_ALL:
- /* just copy the whole vertex as-is to the vbuf */
- assert(i == 0);
- assert(j == 0);
- memcpy(vbuf->vertex_ptr, vertex, vinfo->size * 4);
- vbuf->vertex_ptr += vinfo->size;
- count += vinfo->size;
- break;
- case EMIT_1F:
- *vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
- count++;
- break;
- case EMIT_1F_PSIZE:
- *vbuf->vertex_ptr++ = fui(vbuf->stage.draw->rasterizer->point_size);
- count++;
- break;
- case EMIT_2F:
- *vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
- count += 2;
- break;
- case EMIT_3F:
- *vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][2]);
- count += 3;
- break;
- case EMIT_4F:
- *vbuf->vertex_ptr++ = fui(vertex->data[j][0]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][1]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][2]);
- *vbuf->vertex_ptr++ = fui(vertex->data[j][3]);
- count += 4;
- break;
- case EMIT_4UB:
- *vbuf->vertex_ptr++ = pack_ub4(float_to_ubyte( vertex->data[j][2] ),
- float_to_ubyte( vertex->data[j][1] ),
- float_to_ubyte( vertex->data[j][0] ),
- float_to_ubyte( vertex->data[j][3] ));
- count += 1;
- break;
- default:
- assert(0);
- }
- }
- assert(count == vinfo->size);
-#if 0
- {
- static float data[256];
- draw_vf_emit_vertex(vbuf->vf, vertex, data);
- if(memcmp((uint8_t *)vbuf->vertex_ptr - vbuf->vertex_size, data, vbuf->vertex_size)) {
- debug_printf("With VF:\n");
- dump_emitted_vertex(vbuf->vinfo, (uint8_t *)data);
- debug_printf("Without VF:\n");
- dump_emitted_vertex(vbuf->vinfo, (uint8_t *)vbuf->vertex_ptr - vbuf->vertex_size);
- assert(0);
- }
- }
-#endif
- }
- else {
- draw_vf_emit_vertex(vbuf->vf, vertex, vbuf->vertex_ptr);
-
- vbuf->vertex_ptr += vbuf->vertex_size/4;
- }
-}
-
-
-static void
-vbuf_tri( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
- unsigned i;
-
- check_space( vbuf, 3 );
-
- for (i = 0; i < 3; i++) {
- emit_vertex( vbuf, prim->v[i] );
-
- vbuf->indices[vbuf->nr_indices++] = (ushort) prim->v[i]->vertex_id;
- }
-}
-
-
-static void
-vbuf_line( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
- unsigned i;
-
- check_space( vbuf, 2 );
-
- for (i = 0; i < 2; i++) {
- emit_vertex( vbuf, prim->v[i] );
-
- vbuf->indices[vbuf->nr_indices++] = (ushort) prim->v[i]->vertex_id;
- }
-}
-
-
-static void
-vbuf_point( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- check_space( vbuf, 1 );
-
- emit_vertex( vbuf, prim->v[0] );
-
- vbuf->indices[vbuf->nr_indices++] = (ushort) prim->v[0]->vertex_id;
-}
-
-
-/**
- * Set the prim type for subsequent vertices.
- * This may result in a new vertex size. The existing vbuffer (if any)
- * will be flushed if needed and a new one allocated.
- */
-static void
-vbuf_set_prim( struct vbuf_stage *vbuf, uint newprim )
-{
- const struct vertex_info *vinfo;
- unsigned vertex_size;
-
- assert(newprim == PIPE_PRIM_POINTS ||
- newprim == PIPE_PRIM_LINES ||
- newprim == PIPE_PRIM_TRIANGLES);
-
- vbuf->prim = newprim;
- vbuf->render->set_primitive(vbuf->render, newprim);
-
- vinfo = vbuf->render->get_vertex_info(vbuf->render);
- vertex_size = vinfo->size * sizeof(float);
-
- if (vertex_size != vbuf->vertex_size)
- vbuf_flush_vertices(vbuf);
-
- vbuf->vinfo = vinfo;
- vbuf->vertex_size = vertex_size;
- if(vbuf->vf)
- draw_vf_set_vertex_info(vbuf->vf,
- vbuf->vinfo,
- vbuf->stage.draw->rasterizer->point_size);
-
- if (!vbuf->vertices)
- vbuf_alloc_vertices(vbuf);
-}
-
-
-static void
-vbuf_first_tri( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- vbuf_flush_indices( vbuf );
- stage->tri = vbuf_tri;
- vbuf_set_prim(vbuf, PIPE_PRIM_TRIANGLES);
- stage->tri( stage, prim );
-}
-
-
-static void
-vbuf_first_line( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- vbuf_flush_indices( vbuf );
- stage->line = vbuf_line;
- vbuf_set_prim(vbuf, PIPE_PRIM_LINES);
- stage->line( stage, prim );
-}
-
-
-static void
-vbuf_first_point( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- vbuf_flush_indices( vbuf );
- stage->point = vbuf_point;
- vbuf_set_prim(vbuf, PIPE_PRIM_POINTS);
- stage->point( stage, prim );
-}
-
-
-static void
-vbuf_flush_indices( struct vbuf_stage *vbuf )
-{
- if(!vbuf->nr_indices)
- return;
-
- assert((uint) (vbuf->vertex_ptr - vbuf->vertices) ==
- vbuf->nr_vertices * vbuf->vertex_size / sizeof(unsigned));
-
- switch(vbuf->prim) {
- case PIPE_PRIM_POINTS:
- break;
- case PIPE_PRIM_LINES:
- assert(vbuf->nr_indices % 2 == 0);
- break;
- case PIPE_PRIM_TRIANGLES:
- assert(vbuf->nr_indices % 3 == 0);
- break;
- default:
- assert(0);
- }
-
- vbuf->render->draw(vbuf->render, vbuf->indices, vbuf->nr_indices);
-
- vbuf->nr_indices = 0;
-
- /* don't need to reset point/line/tri functions */
-#if 0
- stage->point = vbuf_first_point;
- stage->line = vbuf_first_line;
- stage->tri = vbuf_first_tri;
-#endif
-}
-
-
-/**
- * Flush existing vertex buffer and allocate a new one.
- *
- * XXX: We separate flush-on-index-full and flush-on-vb-full, but may
- * raise issues uploading vertices if the hardware wants to flush when
- * we flush.
- */
-static void
-vbuf_flush_vertices( struct vbuf_stage *vbuf )
-{
- if(vbuf->vertices) {
- vbuf_flush_indices(vbuf);
-
- /* Reset temporary vertices ids */
- if(vbuf->nr_vertices)
- draw_reset_vertex_ids( vbuf->stage.draw );
-
- /* Free the vertex buffer */
- vbuf->render->release_vertices(vbuf->render,
- vbuf->vertices,
- vbuf->vertex_size,
- vbuf->nr_vertices);
- vbuf->max_vertices = vbuf->nr_vertices = 0;
- vbuf->vertex_ptr = vbuf->vertices = NULL;
-
- }
-}
-
-
-static void
-vbuf_alloc_vertices( struct vbuf_stage *vbuf )
-{
- assert(!vbuf->nr_indices);
- assert(!vbuf->vertices);
-
- /* Allocate a new vertex buffer */
- vbuf->max_vertices = vbuf->render->max_vertex_buffer_bytes / vbuf->vertex_size;
- vbuf->vertices = (uint *) vbuf->render->allocate_vertices(vbuf->render,
- (ushort) vbuf->vertex_size,
- (ushort) vbuf->max_vertices);
- vbuf->vertex_ptr = vbuf->vertices;
-}
-
-
-
-static void
-vbuf_flush( struct draw_stage *stage, unsigned flags )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- vbuf_flush_indices( vbuf );
-
- stage->point = vbuf_first_point;
- stage->line = vbuf_first_line;
- stage->tri = vbuf_first_tri;
-
- if (flags & DRAW_FLUSH_BACKEND)
- vbuf_flush_vertices( vbuf );
-}
-
-
-static void
-vbuf_reset_stipple_counter( struct draw_stage *stage )
-{
- /* XXX: Need to do something here for hardware with linestipple.
- */
- (void) stage;
-}
-
-
-static void vbuf_destroy( struct draw_stage *stage )
-{
- struct vbuf_stage *vbuf = vbuf_stage( stage );
-
- if(vbuf->indices)
- align_free( vbuf->indices );
-
- if(vbuf->vf)
- draw_vf_destroy( vbuf->vf );
-
- FREE( stage );
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
- struct vbuf_render *render )
-{
- struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
-
- if(!vbuf)
- return NULL;
-
- vbuf->stage.draw = draw;
- vbuf->stage.point = vbuf_first_point;
- vbuf->stage.line = vbuf_first_line;
- vbuf->stage.tri = vbuf_first_tri;
- vbuf->stage.flush = vbuf_flush;
- vbuf->stage.reset_stipple_counter = vbuf_reset_stipple_counter;
- vbuf->stage.destroy = vbuf_destroy;
-
- vbuf->render = render;
-
- assert(render->max_indices < UNDEFINED_VERTEX_ID);
- vbuf->max_indices = render->max_indices;
- vbuf->indices = (ushort *)
- align_malloc( vbuf->max_indices * sizeof(vbuf->indices[0]), 16 );
- if(!vbuf->indices)
- vbuf_destroy(&vbuf->stage);
-
- vbuf->vertices = NULL;
- vbuf->vertex_ptr = vbuf->vertices;
-
- vbuf->prim = ~0;
-
- if(!GETENV("GALLIUM_NOVF"))
- vbuf->vf = draw_vf_create();
-
- return &vbuf->stage;
-}
diff --git a/src/mesa/pipe/draw/draw_vbuf.h b/src/mesa/pipe/draw/draw_vbuf.h
deleted file mode 100644
index cfd2b9820c..0000000000
--- a/src/mesa/pipe/draw/draw_vbuf.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Vertex buffer drawing stage.
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- * \author José Fonseca <jrfonsec@tungstengraphics.com>
- */
-
-#ifndef DRAW_VBUF_H_
-#define DRAW_VBUF_H_
-
-
-#include "pipe/p_util.h"
-
-
-struct draw_context;
-struct vertex_info;
-
-
-/**
- * Interface for hardware vertex buffer rendering.
- */
-struct vbuf_render {
-
- /**
- * Driver limits. May be tuned lower to improve cache hits on
- * index list.
- */
- unsigned max_indices;
- unsigned max_vertex_buffer_bytes;
-
- /**
- * Get the hardware vertex format.
- *
- * XXX: have this in draw_context instead?
- */
- const struct vertex_info *(*get_vertex_info)( struct vbuf_render * );
-
- /**
- * Request a destination for vertices.
- * Hardware renderers will use ttm memory, others will just malloc
- * something.
- */
- void *(*allocate_vertices)( struct vbuf_render *,
- ushort vertex_size,
- ushort nr_vertices );
-
- /**
- * Notify the renderer of the current primitive when it changes.
- * Prim is restricted to TRIANGLES, LINES and POINTS.
- */
- void (*set_primitive)( struct vbuf_render *, unsigned prim );
-
- /**
- * DrawElements, note indices are ushort:
- */
- void (*draw)( struct vbuf_render *,
- const ushort *indices,
- uint nr_indices );
-
- /**
- * Called when vbuf is done with this set of vertices:
- */
- void (*release_vertices)( struct vbuf_render *,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used );
-
- void (*destroy)( struct vbuf_render * );
-};
-
-
-
-struct draw_stage *
-draw_vbuf_stage( struct draw_context *draw,
- struct vbuf_render *render );
-
-
-#endif /*DRAW_VBUF_H_*/
diff --git a/src/mesa/pipe/draw/draw_vertex.c b/src/mesa/pipe/draw/draw_vertex.c
deleted file mode 100644
index 2d6592150f..0000000000
--- a/src/mesa/pipe/draw/draw_vertex.c
+++ /dev/null
@@ -1,79 +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.
- *
- **************************************************************************/
-
-/*
- * Functions for specifying the post-transformation vertex layout.
- *
- * Author:
- * Brian Paul
- * Keith Whitwell
- */
-
-
-#include "pipe/draw/draw_private.h"
-#include "pipe/draw/draw_vertex.h"
-
-
-/**
- * Compute the size of a vertex, in dwords/floats, to update the
- * vinfo->size field.
- */
-void
-draw_compute_vertex_size(struct vertex_info *vinfo)
-{
- uint i;
-
- vinfo->size = 0;
- for (i = 0; i < vinfo->num_attribs; i++) {
- switch (vinfo->emit[i]) {
- case EMIT_OMIT:
- break;
- case EMIT_4UB:
- /* fall-through */
- case EMIT_1F_PSIZE:
- /* fall-through */
- case EMIT_1F:
- vinfo->size += 1;
- break;
- case EMIT_2F:
- vinfo->size += 2;
- break;
- case EMIT_3F:
- vinfo->size += 3;
- break;
- case EMIT_4F:
- vinfo->size += 4;
- break;
- case EMIT_ALL:
- /* fall-through */
- default:
- assert(0);
- }
- }
-
- assert(vinfo->size * 4 <= MAX_VERTEX_SIZE);
-}
diff --git a/src/mesa/pipe/draw/draw_vertex.h b/src/mesa/pipe/draw/draw_vertex.h
deleted file mode 100644
index dfc637b19b..0000000000
--- a/src/mesa/pipe/draw/draw_vertex.h
+++ /dev/null
@@ -1,106 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- */
-
-
-#ifndef DRAW_VERTEX_H
-#define DRAW_VERTEX_H
-
-
-#include "pipe/p_state.h"
-
-
-/**
- * Vertex attribute emit modes
- */
-enum attrib_emit {
- EMIT_OMIT, /**< don't emit the attribute */
- EMIT_ALL, /**< emit whole post-xform vertex, w/ header */
- EMIT_1F,
- EMIT_1F_PSIZE, /**< insert constant point size */
- EMIT_2F,
- EMIT_3F,
- EMIT_4F,
- EMIT_4UB /**< XXX may need variations for RGBA vs BGRA, etc */
-};
-
-
-/**
- * Attribute interpolation mode
- */
-enum interp_mode {
- INTERP_NONE, /**< never interpolate vertex header info */
- INTERP_POS, /**< special case for frag position */
- INTERP_CONSTANT,
- INTERP_LINEAR,
- INTERP_PERSPECTIVE
-};
-
-
-/**
- * Information about hardware/rasterization vertex layout.
- */
-struct vertex_info
-{
- uint num_attribs;
- uint hwfmt[4]; /**< hardware format info for this format */
- enum interp_mode interp_mode[PIPE_MAX_SHADER_INPUTS];
- enum attrib_emit emit[PIPE_MAX_SHADER_INPUTS]; /**< EMIT_x */
- uint src_index[PIPE_MAX_SHADER_INPUTS]; /**< map to post-xform attribs */
- uint size; /**< total vertex size in dwords */
-};
-
-
-
-/**
- * Add another attribute to the given vertex_info object.
- * \param src_index indicates which post-transformed vertex attrib slot
- * corresponds to this attribute.
- * \return slot in which the attribute was added
- */
-static INLINE uint
-draw_emit_vertex_attr(struct vertex_info *vinfo,
- enum attrib_emit emit, enum interp_mode interp,
- uint src_index)
-{
- const uint n = vinfo->num_attribs;
- assert(n < PIPE_MAX_SHADER_INPUTS);
- vinfo->emit[n] = emit;
- vinfo->interp_mode[n] = interp;
- vinfo->src_index[n] = src_index;
- vinfo->num_attribs++;
- return n;
-}
-
-
-extern void draw_compute_vertex_size(struct vertex_info *vinfo);
-
-
-#endif /* DRAW_VERTEX_H */
diff --git a/src/mesa/pipe/draw/draw_vertex_cache.c b/src/mesa/pipe/draw/draw_vertex_cache.c
deleted file mode 100644
index 44427999cc..0000000000
--- a/src/mesa/pipe/draw/draw_vertex_cache.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "draw_private.h"
-#include "draw_context.h"
-
-
-void draw_vertex_cache_invalidate( struct draw_context *draw )
-{
- assert(draw->pq.queue_nr == 0);
- assert(draw->vs.queue_nr == 0);
- assert(draw->vcache.referenced == 0);
-
- memset(draw->vcache.idx, ~0, sizeof(draw->vcache.idx));
-}
-
-
-/**
- * Check if vertex is in cache, otherwise add it. It won't go through
- * VS yet, not until there is a flush operation or the VS queue fills up.
- *
- * Note that cache entries are basically just two pointers: the first
- * an index into the user's vertex arrays, the second a location in
- * the vertex shader cache for the post-transformed vertex.
- *
- * \return pointer to location of (post-transformed) vertex header in the cache
- */
-static struct vertex_header *get_vertex( struct draw_context *draw,
- unsigned i )
-{
- unsigned slot = (i + (i>>5)) % VCACHE_SIZE;
-
- assert(slot < 32); /* so we don't exceed the bitfield size below */
-
- /* Cache miss?
- */
- if (draw->vcache.idx[slot] != i) {
-
- /* If slot is in use, use the overflow area:
- */
- if (draw->vcache.referenced & (1 << slot)) {
- slot = VCACHE_SIZE + draw->vcache.overflow++;
- }
-
- assert(slot < Elements(draw->vcache.idx));
-
- draw->vcache.idx[slot] = i;
-
- /* Add to vertex shader queue:
- */
- assert(draw->vs.queue_nr < VS_QUEUE_LENGTH);
- draw->vs.queue[draw->vs.queue_nr].dest = draw->vcache.vertex[slot];
- draw->vs.queue[draw->vs.queue_nr].elt = i;
- draw->vs.queue_nr++;
-
- /* Need to set the vertex's edge flag here. If we're being called
- * by do_ef_triangle(), that function needs edge flag info!
- */
- draw->vcache.vertex[slot]->clipmask = 0;
- draw->vcache.vertex[slot]->edgeflag = 1; /*XXX use user's edge flag! */
- draw->vcache.vertex[slot]->pad = 0;
- draw->vcache.vertex[slot]->vertex_id = UNDEFINED_VERTEX_ID;
- }
-
-
- /* primitive flushing may have cleared the bitfield but did not
- * clear the idx[] array values. Set the bit now. This fixes a
- * bug found when drawing long triangle fans.
- */
- draw->vcache.referenced |= (1 << slot);
- return draw->vcache.vertex[slot];
-}
-
-
-static struct vertex_header *get_uint_elt_vertex( struct draw_context *draw,
- unsigned i )
-{
- const unsigned *elts = (const unsigned *) draw->user.elts;
- return get_vertex( draw, elts[i] );
-}
-
-
-static struct vertex_header *get_ushort_elt_vertex( struct draw_context *draw,
- unsigned i )
-{
- const ushort *elts = (const ushort *) draw->user.elts;
- return get_vertex( draw, elts[i] );
-}
-
-
-static struct vertex_header *get_ubyte_elt_vertex( struct draw_context *draw,
- unsigned i )
-{
- const ubyte *elts = (const ubyte *) draw->user.elts;
- return get_vertex( draw, elts[i] );
-}
-
-
-void draw_vertex_cache_reset_vertex_ids( struct draw_context *draw )
-{
- unsigned i;
-
- for (i = 0; i < Elements(draw->vcache.vertex); i++)
- draw->vcache.vertex[i]->vertex_id = UNDEFINED_VERTEX_ID;
-}
-
-
-void draw_vertex_cache_unreference( struct draw_context *draw )
-{
- draw->vcache.referenced = 0;
- draw->vcache.overflow = 0;
-}
-
-
-int draw_vertex_cache_check_space( struct draw_context *draw,
- unsigned nr_verts )
-{
- if (draw->vcache.overflow + nr_verts < VCACHE_OVERFLOW) {
- /* The vs queue is sized so that this can never happen:
- */
- assert(draw->vs.queue_nr + nr_verts < VS_QUEUE_LENGTH);
- return TRUE;
- }
- else
- return FALSE;
-}
-
-
-
-/**
- * Tell the drawing context about the index/element buffer to use
- * (ala glDrawElements)
- * If no element buffer is to be used (i.e. glDrawArrays) then this
- * should be called with eltSize=0 and elements=NULL.
- *
- * \param draw the drawing context
- * \param eltSize size of each element (1, 2 or 4 bytes)
- * \param elements the element buffer ptr
- */
-void
-draw_set_mapped_element_buffer( struct draw_context *draw,
- unsigned eltSize, void *elements )
-{
-// draw_statechange( draw );
-
- /* choose the get_vertex() function to use */
- switch (eltSize) {
- case 0:
- draw->vcache.get_vertex = get_vertex;
- break;
- case 1:
- draw->vcache.get_vertex = get_ubyte_elt_vertex;
- break;
- case 2:
- draw->vcache.get_vertex = get_ushort_elt_vertex;
- break;
- case 4:
- draw->vcache.get_vertex = get_uint_elt_vertex;
- break;
- default:
- assert(0);
- }
- draw->user.elts = elements;
- draw->user.eltSize = eltSize;
-}
-
diff --git a/src/mesa/pipe/draw/draw_vertex_fetch.c b/src/mesa/pipe/draw/draw_vertex_fetch.c
deleted file mode 100644
index e13df04605..0000000000
--- a/src/mesa/pipe/draw/draw_vertex_fetch.c
+++ /dev/null
@@ -1,510 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-#include "draw_context.h"
-
-
-#define DRAW_DBG 0
-
-
-/**
- * Fetch a float[4] vertex attribute from memory, doing format/type
- * conversion as needed.
- *
- * This is probably needed/dupliocated elsewhere, eg format
- * conversion, texture sampling etc.
- */
-#define FETCH_ATTRIB( NAME, SZ, CVT ) \
-static void \
-fetch_##NAME(const void *ptr, float *attrib) \
-{ \
- static const float defaults[4] = { 0,0,0,1 }; \
- int i; \
- \
- for (i = 0; i < SZ; i++) { \
- attrib[i] = CVT; \
- } \
- \
- for (; i < 4; i++) { \
- attrib[i] = defaults[i]; \
- } \
-}
-
-#define CVT_64_FLOAT (float) ((double *) ptr)[i]
-#define CVT_32_FLOAT ((float *) ptr)[i]
-
-#define CVT_8_USCALED (float) ((unsigned char *) ptr)[i]
-#define CVT_16_USCALED (float) ((unsigned short *) ptr)[i]
-#define CVT_32_USCALED (float) ((unsigned int *) ptr)[i]
-
-#define CVT_8_SSCALED (float) ((char *) ptr)[i]
-#define CVT_16_SSCALED (float) ((short *) ptr)[i]
-#define CVT_32_SSCALED (float) ((int *) ptr)[i]
-
-#define CVT_8_UNORM (float) ((unsigned char *) ptr)[i] / 255.0f
-#define CVT_16_UNORM (float) ((unsigned short *) ptr)[i] / 65535.0f
-#define CVT_32_UNORM (float) ((unsigned int *) ptr)[i] / 4294967295.0f
-
-#define CVT_8_SNORM (float) ((char *) ptr)[i] / 127.0f
-#define CVT_16_SNORM (float) ((short *) ptr)[i] / 32767.0f
-#define CVT_32_SNORM (float) ((int *) ptr)[i] / 2147483647.0f
-
-FETCH_ATTRIB( R64G64B64A64_FLOAT, 4, CVT_64_FLOAT )
-FETCH_ATTRIB( R64G64B64_FLOAT, 3, CVT_64_FLOAT )
-FETCH_ATTRIB( R64G64_FLOAT, 2, CVT_64_FLOAT )
-FETCH_ATTRIB( R64_FLOAT, 1, CVT_64_FLOAT )
-
-FETCH_ATTRIB( R32G32B32A32_FLOAT, 4, CVT_32_FLOAT )
-FETCH_ATTRIB( R32G32B32_FLOAT, 3, CVT_32_FLOAT )
-FETCH_ATTRIB( R32G32_FLOAT, 2, CVT_32_FLOAT )
-FETCH_ATTRIB( R32_FLOAT, 1, CVT_32_FLOAT )
-
-FETCH_ATTRIB( R32G32B32A32_USCALED, 4, CVT_32_USCALED )
-FETCH_ATTRIB( R32G32B32_USCALED, 3, CVT_32_USCALED )
-FETCH_ATTRIB( R32G32_USCALED, 2, CVT_32_USCALED )
-FETCH_ATTRIB( R32_USCALED, 1, CVT_32_USCALED )
-
-FETCH_ATTRIB( R32G32B32A32_SSCALED, 4, CVT_32_SSCALED )
-FETCH_ATTRIB( R32G32B32_SSCALED, 3, CVT_32_SSCALED )
-FETCH_ATTRIB( R32G32_SSCALED, 2, CVT_32_SSCALED )
-FETCH_ATTRIB( R32_SSCALED, 1, CVT_32_SSCALED )
-
-FETCH_ATTRIB( R32G32B32A32_UNORM, 4, CVT_32_UNORM )
-FETCH_ATTRIB( R32G32B32_UNORM, 3, CVT_32_UNORM )
-FETCH_ATTRIB( R32G32_UNORM, 2, CVT_32_UNORM )
-FETCH_ATTRIB( R32_UNORM, 1, CVT_32_UNORM )
-
-FETCH_ATTRIB( R32G32B32A32_SNORM, 4, CVT_32_SNORM )
-FETCH_ATTRIB( R32G32B32_SNORM, 3, CVT_32_SNORM )
-FETCH_ATTRIB( R32G32_SNORM, 2, CVT_32_SNORM )
-FETCH_ATTRIB( R32_SNORM, 1, CVT_32_SNORM )
-
-FETCH_ATTRIB( R16G16B16A16_USCALED, 4, CVT_16_USCALED )
-FETCH_ATTRIB( R16G16B16_USCALED, 3, CVT_16_USCALED )
-FETCH_ATTRIB( R16G16_USCALED, 2, CVT_16_USCALED )
-FETCH_ATTRIB( R16_USCALED, 1, CVT_16_USCALED )
-
-FETCH_ATTRIB( R16G16B16A16_SSCALED, 4, CVT_16_SSCALED )
-FETCH_ATTRIB( R16G16B16_SSCALED, 3, CVT_16_SSCALED )
-FETCH_ATTRIB( R16G16_SSCALED, 2, CVT_16_SSCALED )
-FETCH_ATTRIB( R16_SSCALED, 1, CVT_16_SSCALED )
-
-FETCH_ATTRIB( R16G16B16A16_UNORM, 4, CVT_16_UNORM )
-FETCH_ATTRIB( R16G16B16_UNORM, 3, CVT_16_UNORM )
-FETCH_ATTRIB( R16G16_UNORM, 2, CVT_16_UNORM )
-FETCH_ATTRIB( R16_UNORM, 1, CVT_16_UNORM )
-
-FETCH_ATTRIB( R16G16B16A16_SNORM, 4, CVT_16_SNORM )
-FETCH_ATTRIB( R16G16B16_SNORM, 3, CVT_16_SNORM )
-FETCH_ATTRIB( R16G16_SNORM, 2, CVT_16_SNORM )
-FETCH_ATTRIB( R16_SNORM, 1, CVT_16_SNORM )
-
-FETCH_ATTRIB( R8G8B8A8_USCALED, 4, CVT_8_USCALED )
-FETCH_ATTRIB( R8G8B8_USCALED, 3, CVT_8_USCALED )
-FETCH_ATTRIB( R8G8_USCALED, 2, CVT_8_USCALED )
-FETCH_ATTRIB( R8_USCALED, 1, CVT_8_USCALED )
-
-FETCH_ATTRIB( R8G8B8A8_SSCALED, 4, CVT_8_SSCALED )
-FETCH_ATTRIB( R8G8B8_SSCALED, 3, CVT_8_SSCALED )
-FETCH_ATTRIB( R8G8_SSCALED, 2, CVT_8_SSCALED )
-FETCH_ATTRIB( R8_SSCALED, 1, CVT_8_SSCALED )
-
-FETCH_ATTRIB( R8G8B8A8_UNORM, 4, CVT_8_UNORM )
-FETCH_ATTRIB( R8G8B8_UNORM, 3, CVT_8_UNORM )
-FETCH_ATTRIB( R8G8_UNORM, 2, CVT_8_UNORM )
-FETCH_ATTRIB( R8_UNORM, 1, CVT_8_UNORM )
-
-FETCH_ATTRIB( R8G8B8A8_SNORM, 4, CVT_8_SNORM )
-FETCH_ATTRIB( R8G8B8_SNORM, 3, CVT_8_SNORM )
-FETCH_ATTRIB( R8G8_SNORM, 2, CVT_8_SNORM )
-FETCH_ATTRIB( R8_SNORM, 1, CVT_8_SNORM )
-
-FETCH_ATTRIB( A8R8G8B8_UNORM, 4, CVT_8_UNORM )
-//FETCH_ATTRIB( R8G8B8A8_UNORM, 4, CVT_8_UNORM )
-
-
-
-static fetch_func get_fetch_func( enum pipe_format format )
-{
-#if 0
- {
- char tmp[80];
- pf_sprint_name(tmp, format);
- debug_printf("%s: %s\n", __FUNCTION__, tmp);
- }
-#endif
-
- switch (format) {
- case PIPE_FORMAT_R64_FLOAT:
- return fetch_R64_FLOAT;
- case PIPE_FORMAT_R64G64_FLOAT:
- return fetch_R64G64_FLOAT;
- case PIPE_FORMAT_R64G64B64_FLOAT:
- return fetch_R64G64B64_FLOAT;
- case PIPE_FORMAT_R64G64B64A64_FLOAT:
- return fetch_R64G64B64A64_FLOAT;
-
- case PIPE_FORMAT_R32_FLOAT:
- return fetch_R32_FLOAT;
- case PIPE_FORMAT_R32G32_FLOAT:
- return fetch_R32G32_FLOAT;
- case PIPE_FORMAT_R32G32B32_FLOAT:
- return fetch_R32G32B32_FLOAT;
- case PIPE_FORMAT_R32G32B32A32_FLOAT:
- return fetch_R32G32B32A32_FLOAT;
-
- case PIPE_FORMAT_R32_UNORM:
- return fetch_R32_UNORM;
- case PIPE_FORMAT_R32G32_UNORM:
- return fetch_R32G32_UNORM;
- case PIPE_FORMAT_R32G32B32_UNORM:
- return fetch_R32G32B32_UNORM;
- case PIPE_FORMAT_R32G32B32A32_UNORM:
- return fetch_R32G32B32A32_UNORM;
-
- case PIPE_FORMAT_R32_USCALED:
- return fetch_R32_USCALED;
- case PIPE_FORMAT_R32G32_USCALED:
- return fetch_R32G32_USCALED;
- case PIPE_FORMAT_R32G32B32_USCALED:
- return fetch_R32G32B32_USCALED;
- case PIPE_FORMAT_R32G32B32A32_USCALED:
- return fetch_R32G32B32A32_USCALED;
-
- case PIPE_FORMAT_R32_SNORM:
- return fetch_R32_SNORM;
- case PIPE_FORMAT_R32G32_SNORM:
- return fetch_R32G32_SNORM;
- case PIPE_FORMAT_R32G32B32_SNORM:
- return fetch_R32G32B32_SNORM;
- case PIPE_FORMAT_R32G32B32A32_SNORM:
- return fetch_R32G32B32A32_SNORM;
-
- case PIPE_FORMAT_R32_SSCALED:
- return fetch_R32_SSCALED;
- case PIPE_FORMAT_R32G32_SSCALED:
- return fetch_R32G32_SSCALED;
- case PIPE_FORMAT_R32G32B32_SSCALED:
- return fetch_R32G32B32_SSCALED;
- case PIPE_FORMAT_R32G32B32A32_SSCALED:
- return fetch_R32G32B32A32_SSCALED;
-
- case PIPE_FORMAT_R16_UNORM:
- return fetch_R16_UNORM;
- case PIPE_FORMAT_R16G16_UNORM:
- return fetch_R16G16_UNORM;
- case PIPE_FORMAT_R16G16B16_UNORM:
- return fetch_R16G16B16_UNORM;
- case PIPE_FORMAT_R16G16B16A16_UNORM:
- return fetch_R16G16B16A16_UNORM;
-
- case PIPE_FORMAT_R16_USCALED:
- return fetch_R16_USCALED;
- case PIPE_FORMAT_R16G16_USCALED:
- return fetch_R16G16_USCALED;
- case PIPE_FORMAT_R16G16B16_USCALED:
- return fetch_R16G16B16_USCALED;
- case PIPE_FORMAT_R16G16B16A16_USCALED:
- return fetch_R16G16B16A16_USCALED;
-
- case PIPE_FORMAT_R16_SNORM:
- return fetch_R16_SNORM;
- case PIPE_FORMAT_R16G16_SNORM:
- return fetch_R16G16_SNORM;
- case PIPE_FORMAT_R16G16B16_SNORM:
- return fetch_R16G16B16_SNORM;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- return fetch_R16G16B16A16_SNORM;
-
- case PIPE_FORMAT_R16_SSCALED:
- return fetch_R16_SSCALED;
- case PIPE_FORMAT_R16G16_SSCALED:
- return fetch_R16G16_SSCALED;
- case PIPE_FORMAT_R16G16B16_SSCALED:
- return fetch_R16G16B16_SSCALED;
- case PIPE_FORMAT_R16G16B16A16_SSCALED:
- return fetch_R16G16B16A16_SSCALED;
-
- case PIPE_FORMAT_R8_UNORM:
- return fetch_R8_UNORM;
- case PIPE_FORMAT_R8G8_UNORM:
- return fetch_R8G8_UNORM;
- case PIPE_FORMAT_R8G8B8_UNORM:
- return fetch_R8G8B8_UNORM;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return fetch_R8G8B8A8_UNORM;
-
- case PIPE_FORMAT_R8_USCALED:
- return fetch_R8_USCALED;
- case PIPE_FORMAT_R8G8_USCALED:
- return fetch_R8G8_USCALED;
- case PIPE_FORMAT_R8G8B8_USCALED:
- return fetch_R8G8B8_USCALED;
- case PIPE_FORMAT_R8G8B8A8_USCALED:
- return fetch_R8G8B8A8_USCALED;
-
- case PIPE_FORMAT_R8_SNORM:
- return fetch_R8_SNORM;
- case PIPE_FORMAT_R8G8_SNORM:
- return fetch_R8G8_SNORM;
- case PIPE_FORMAT_R8G8B8_SNORM:
- return fetch_R8G8B8_SNORM;
- case PIPE_FORMAT_R8G8B8A8_SNORM:
- return fetch_R8G8B8A8_SNORM;
-
- case PIPE_FORMAT_R8_SSCALED:
- return fetch_R8_SSCALED;
- case PIPE_FORMAT_R8G8_SSCALED:
- return fetch_R8G8_SSCALED;
- case PIPE_FORMAT_R8G8B8_SSCALED:
- return fetch_R8G8B8_SSCALED;
- case PIPE_FORMAT_R8G8B8A8_SSCALED:
- return fetch_R8G8B8A8_SSCALED;
-
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return fetch_A8R8G8B8_UNORM;
-
- case 0:
- return NULL; /* not sure why this is needed */
-
- default:
- assert(0);
- return NULL;
- }
-}
-
-
-static void
-transpose_4x4( float *out, const float *in )
-{
- /* This can be achieved in 12 sse instructions, plus the final
- * stores I guess. This is probably a bit more than that - maybe
- * 32 or so?
- */
- out[0] = in[0]; out[1] = in[4]; out[2] = in[8]; out[3] = in[12];
- out[4] = in[1]; out[5] = in[5]; out[6] = in[9]; out[7] = in[13];
- out[8] = in[2]; out[9] = in[6]; out[10] = in[10]; out[11] = in[14];
- out[12] = in[3]; out[13] = in[7]; out[14] = in[11]; out[15] = in[15];
-}
-
-
-
-static void fetch_xyz_rgb( struct draw_context *draw,
- struct tgsi_exec_machine *machine,
- const unsigned *elts,
- unsigned count )
-{
- const unsigned *pitch = draw->vertex_fetch.pitch;
- const ubyte **src = draw->vertex_fetch.src_ptr;
- int i;
-
- assert(count <= 4);
-
-// debug_printf("%s\n", __FUNCTION__);
-
- /* loop over vertex attributes (vertex shader inputs)
- */
-
- for (i = 0; i < 4; i++) {
- {
- const float *in = (const float *)(src[0] + elts[i] * pitch[0]);
- float *out = &machine->Inputs[0].xyzw[0].f[i];
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[12] = 1.0f;
- }
-
- {
- const float *in = (const float *)(src[1] + elts[i] * pitch[1]);
- float *out = &machine->Inputs[1].xyzw[0].f[i];
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[12] = 1.0f;
- }
- }
-}
-
-
-
-
-static void fetch_xyz_rgb_st( struct draw_context *draw,
- struct tgsi_exec_machine *machine,
- const unsigned *elts,
- unsigned count )
-{
- const unsigned *pitch = draw->vertex_fetch.pitch;
- const ubyte **src = draw->vertex_fetch.src_ptr;
- int i;
-
- assert(count <= 4);
-
- /* loop over vertex attributes (vertex shader inputs)
- */
-
- for (i = 0; i < 4; i++) {
- {
- const float *in = (const float *)(src[0] + elts[i] * pitch[0]);
- float *out = &machine->Inputs[0].xyzw[0].f[i];
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[12] = 1.0f;
- }
-
- {
- const float *in = (const float *)(src[1] + elts[i] * pitch[1]);
- float *out = &machine->Inputs[1].xyzw[0].f[i];
- out[0] = in[0];
- out[4] = in[1];
- out[8] = in[2];
- out[12] = 1.0f;
- }
-
- {
- const float *in = (const float *)(src[2] + elts[i] * pitch[2]);
- float *out = &machine->Inputs[2].xyzw[0].f[i];
- out[0] = in[0];
- out[4] = in[1];
- out[8] = 0.0f;
- out[12] = 1.0f;
- }
- }
-}
-
-
-
-
-/**
- * Fetch vertex attributes for 'count' vertices.
- */
-static void generic_vertex_fetch( struct draw_context *draw,
- struct tgsi_exec_machine *machine,
- const unsigned *elts,
- unsigned count )
-{
- unsigned nr_attrs = draw->vertex_fetch.nr_attrs;
- unsigned attr;
-
- assert(count <= 4);
-
-// debug_printf("%s %d\n", __FUNCTION__, count);
-
- /* loop over vertex attributes (vertex shader inputs)
- */
- for (attr = 0; attr < nr_attrs; attr++) {
-
- const unsigned pitch = draw->vertex_fetch.pitch[attr];
- const ubyte *src = draw->vertex_fetch.src_ptr[attr];
- const fetch_func fetch = draw->vertex_fetch.fetch[attr];
- unsigned i;
- float p[4][4];
-
-
- /* Fetch four attributes for four vertices.
- *
- * Could fetch directly into AOS format, but this is meant to be
- * a prototype for an sse implementation, which would have
- * difficulties doing that.
- */
- for (i = 0; i < count; i++)
- fetch( src + elts[i] * pitch, p[i] );
-
- /* Be nice and zero out any missing vertices:
- */
- for ( ; i < 4; i++)
- p[i][0] = p[i][1] = p[i][2] = p[i][3] = 0;
-
- /* Transpose/swizzle into sse-friendly format. Currently
- * assuming that all vertex shader inputs are float[4], but this
- * isn't true -- if the vertex shader only wants tex0.xy, we
- * could optimize for that.
- *
- * To do so fully without codegen would probably require an
- * excessive number of fetch functions, but we could at least
- * minimize the transpose step:
- */
- transpose_4x4( (float *)&machine->Inputs[attr].xyzw[0].f[0], (float *)p );
- }
-}
-
-
-
-void draw_update_vertex_fetch( struct draw_context *draw )
-{
- unsigned nr_attrs, i;
-
-// debug_printf("%s\n", __FUNCTION__);
-
- /* this may happend during context init */
- if (!draw->vertex_shader)
- return;
-
- nr_attrs = draw->vertex_shader->state->num_inputs;
-
- for (i = 0; i < nr_attrs; i++) {
- unsigned buf = draw->vertex_element[i].vertex_buffer_index;
- enum pipe_format format = draw->vertex_element[i].src_format;
-
- draw->vertex_fetch.src_ptr[i] = (const ubyte *) draw->user.vbuffer[buf] +
- draw->vertex_buffer[buf].buffer_offset +
- draw->vertex_element[i].src_offset;
-
- draw->vertex_fetch.pitch[i] = draw->vertex_buffer[buf].pitch;
- draw->vertex_fetch.fetch[i] = get_fetch_func( format );
- }
-
- draw->vertex_fetch.nr_attrs = nr_attrs;
-
- draw->vertex_fetch.fetch_func = generic_vertex_fetch;
-
- switch (nr_attrs) {
- case 2:
- if (draw->vertex_element[0].src_format == PIPE_FORMAT_R32G32B32_FLOAT &&
- draw->vertex_element[1].src_format == PIPE_FORMAT_R32G32B32_FLOAT)
- draw->vertex_fetch.fetch_func = fetch_xyz_rgb;
- break;
- case 3:
- if (draw->vertex_element[0].src_format == PIPE_FORMAT_R32G32B32_FLOAT &&
- draw->vertex_element[1].src_format == PIPE_FORMAT_R32G32B32_FLOAT &&
- draw->vertex_element[2].src_format == PIPE_FORMAT_R32G32_FLOAT)
- draw->vertex_fetch.fetch_func = fetch_xyz_rgb_st;
- break;
- default:
- break;
- }
-
-}
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
deleted file mode 100644
index bf340ef9b0..0000000000
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#if defined(__i386__) || defined(__386__)
-#include "pipe/tgsi/exec/tgsi_sse2.h"
-#endif
-#include "draw_private.h"
-#include "draw_context.h"
-
-#include "x86/rtasm/x86sse.h"
-#include "pipe/llvm/gallivm.h"
-
-
-#define DBG_VS 0
-
-
-static INLINE unsigned
-compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
-{
- unsigned mask = 0;
- unsigned i;
-
- /* Do the hardwired planes first:
- */
- if (-clip[0] + clip[3] < 0) mask |= CLIP_RIGHT_BIT;
- if ( clip[0] + clip[3] < 0) mask |= CLIP_LEFT_BIT;
- if (-clip[1] + clip[3] < 0) mask |= CLIP_TOP_BIT;
- if ( clip[1] + clip[3] < 0) mask |= CLIP_BOTTOM_BIT;
- if (-clip[2] + clip[3] < 0) mask |= CLIP_FAR_BIT;
- if ( clip[2] + clip[3] < 0) mask |= CLIP_NEAR_BIT;
-
- /* Followed by any remaining ones:
- */
- for (i = 6; i < nr; i++) {
- if (dot4(clip, plane[i]) < 0)
- mask |= (1<<i);
- }
-
- return mask;
-}
-
-
-typedef void (XSTDCALL *codegen_function) (
- const struct tgsi_exec_vector *input,
- struct tgsi_exec_vector *output,
- float (*constant)[4],
- struct tgsi_exec_vector *temporary );
-
-
-/**
- * Transform vertices with the current vertex program/shader
- * Up to four vertices can be shaded at a time.
- * \param vbuffer the input vertex data
- * \param elts indexes of four input vertices
- * \param count number of vertices to shade [1..4]
- * \param vOut array of pointers to four output vertices
- */
-static void
-run_vertex_program(struct draw_context *draw,
- unsigned elts[4], unsigned count,
- struct vertex_header *vOut[])
-{
- struct tgsi_exec_machine *machine = &draw->machine;
- unsigned int j;
-
- ALIGN16_DECL(struct tgsi_exec_vector, inputs, PIPE_ATTRIB_MAX);
- ALIGN16_DECL(struct tgsi_exec_vector, outputs, PIPE_ATTRIB_MAX);
- const float *scale = draw->viewport.scale;
- const float *trans = draw->viewport.translate;
-
- assert(count <= 4);
- assert(draw->vertex_shader->state->output_semantic_name[0]
- == TGSI_SEMANTIC_POSITION);
-
- /* Consts does not require 16 byte alignment. */
- machine->Consts = (float (*)[4]) draw->user.constants;
-
- machine->Inputs = ALIGN16_ASSIGN(inputs);
- machine->Outputs = ALIGN16_ASSIGN(outputs);
-
- draw->vertex_fetch.fetch_func( draw, machine, elts, count );
-
- /* run shader */
-#ifdef MESA_LLVM
- if (1) {
- struct gallivm_prog *prog = draw->vertex_shader->llvm_prog;
- gallivm_cpu_vs_exec(prog,
- machine->Inputs,
- machine->Outputs,
- machine->Consts,
- machine->Temps);
- } else
-#elif defined(__i386__) || defined(__386__)
- if (draw->use_sse) {
- /* SSE */
- /* cast away const */
- struct draw_vertex_shader *shader
- = (struct draw_vertex_shader *)draw->vertex_shader;
- codegen_function func
- = (codegen_function) x86_get_func( &shader->sse2_program );
-
- if (func)
- func(
- machine->Inputs,
- machine->Outputs,
- machine->Consts,
- machine->Temps );
- else
- /* interpreter */
- tgsi_exec_machine_run( machine );
- }
- else
-#endif
- {
- /* interpreter */
- tgsi_exec_machine_run( machine );
- }
-
- /* store machine results */
- for (j = 0; j < count; j++) {
- unsigned slot;
- float x, y, z, w;
-
- /* Handle attr[0] (position) specially:
- *
- * XXX: Computing the clipmask should be done in the vertex
- * program as a set of DP4 instructions appended to the
- * user-provided code.
- */
- x = vOut[j]->clip[0] = machine->Outputs[0].xyzw[0].f[j];
- y = vOut[j]->clip[1] = machine->Outputs[0].xyzw[1].f[j];
- z = vOut[j]->clip[2] = machine->Outputs[0].xyzw[2].f[j];
- w = vOut[j]->clip[3] = machine->Outputs[0].xyzw[3].f[j];
-
- vOut[j]->clipmask = compute_clipmask(vOut[j]->clip, draw->plane, draw->nr_planes);
- vOut[j]->edgeflag = 1;
-
- /* divide by w */
- w = 1.0f / w;
- x *= w;
- y *= w;
- z *= w;
-
- /* Viewport mapping */
- vOut[j]->data[0][0] = x * scale[0] + trans[0];
- vOut[j]->data[0][1] = y * scale[1] + trans[1];
- vOut[j]->data[0][2] = z * scale[2] + trans[2];
- vOut[j]->data[0][3] = w;
-
-#if DBG_VS
- debug_printf("output[%d]win: %f %f %f %f\n", j,
- vOut[j]->data[0][0],
- vOut[j]->data[0][1],
- vOut[j]->data[0][2],
- vOut[j]->data[0][3]);
-#endif
- /* Remaining attributes are packed into sequential post-transform
- * vertex attrib slots.
- */
- for (slot = 1; slot < draw->num_vs_outputs; slot++) {
- vOut[j]->data[slot][0] = machine->Outputs[slot].xyzw[0].f[j];
- vOut[j]->data[slot][1] = machine->Outputs[slot].xyzw[1].f[j];
- vOut[j]->data[slot][2] = machine->Outputs[slot].xyzw[2].f[j];
- vOut[j]->data[slot][3] = machine->Outputs[slot].xyzw[3].f[j];
-#if DBG_VS
- debug_printf("output[%d][%d]: %f %f %f %f\n", j, slot,
- vOut[j]->data[slot][0],
- vOut[j]->data[slot][1],
- vOut[j]->data[slot][2],
- vOut[j]->data[slot][3]);
-#endif
- }
- } /* loop over vertices */
-}
-
-
-/**
- * Run the vertex shader on all vertices in the vertex queue.
- * Called by the draw module when the vertx cache needs to be flushed.
- */
-void
-draw_vertex_shader_queue_flush(struct draw_context *draw)
-{
- unsigned i;
-
- assert(draw->vs.queue_nr != 0);
-
- /* XXX: do this on statechange:
- */
- draw_update_vertex_fetch( draw );
-
-// fprintf(stderr, " q(%d) ", draw->vs.queue_nr );
-
- /* run vertex shader on vertex cache entries, four per invokation */
- for (i = 0; i < draw->vs.queue_nr; i += 4) {
- struct vertex_header *dests[4];
- unsigned elts[4];
- int j, n = MIN2(4, draw->vs.queue_nr - i);
-
- for (j = 0; j < n; j++) {
- elts[j] = draw->vs.queue[i + j].elt;
- dests[j] = draw->vs.queue[i + j].dest;
- }
-
- for ( ; j < 4; j++) {
- elts[j] = elts[0];
- dests[j] = dests[0];
- }
-
- assert(n > 0);
- assert(n <= 4);
-
- run_vertex_program(draw, elts, n, dests);
- }
-
- draw->vs.queue_nr = 0;
-}
-
-
-struct draw_vertex_shader *
-draw_create_vertex_shader(struct draw_context *draw,
- const struct pipe_shader_state *shader)
-{
- struct draw_vertex_shader *vs;
-
- vs = CALLOC_STRUCT( draw_vertex_shader );
- if (vs == NULL) {
- return NULL;
- }
-
- vs->state = shader;
-
-#ifdef MESA_LLVM
- struct gallivm_ir *ir = gallivm_ir_new(GALLIVM_VS);
- gallivm_ir_set_layout(ir, GALLIVM_SOA);
- gallivm_ir_set_components(ir, 4);
- gallivm_ir_fill_from_tgsi(ir, shader->tokens);
- vs->llvm_prog = gallivm_ir_compile(ir);
- gallivm_ir_delete(ir);
-
- draw->engine = gallivm_global_cpu_engine();
- if (!draw->engine) {
- draw->engine = gallivm_cpu_engine_create(vs->llvm_prog);
- }
- else {
- gallivm_cpu_jit_compile(draw->engine, vs->llvm_prog);
- }
-#elif defined(__i386__) || defined(__386__)
- if (draw->use_sse) {
- /* cast-away const */
- struct pipe_shader_state *sh = (struct pipe_shader_state *) shader;
-
- x86_init_func( &vs->sse2_program );
- if (!tgsi_emit_sse2( (struct tgsi_token *) sh->tokens,
- &vs->sse2_program )) {
- x86_release_func( (struct x86_function *) &vs->sse2_program );
- fprintf(stdout /*err*/,
- "tgsi_emit_sse2() failed, falling back to interpreter\n");
- }
- }
-#endif
-
- return vs;
-}
-
-
-void
-draw_bind_vertex_shader(struct draw_context *draw,
- struct draw_vertex_shader *dvs)
-{
- draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
-
- draw->vertex_shader = dvs;
- draw->num_vs_outputs = dvs->state->num_outputs;
-
- tgsi_exec_machine_init(&draw->machine);
-
- /* specify the vertex program to interpret/execute */
- tgsi_exec_machine_bind_shader(&draw->machine,
- draw->vertex_shader->state->tokens,
- PIPE_MAX_SAMPLERS,
- NULL /*samplers*/ );
-}
-
-
-void
-draw_delete_vertex_shader(struct draw_context *draw,
- struct draw_vertex_shader *dvs)
-{
-#if defined(__i386__) || defined(__386__)
- x86_release_func( (struct x86_function *) &dvs->sse2_program );
-#endif
-
- FREE( dvs );
-}
diff --git a/src/mesa/pipe/draw/draw_vf.c b/src/mesa/pipe/draw/draw_vf.c
deleted file mode 100644
index f23d7fcec5..0000000000
--- a/src/mesa/pipe/draw/draw_vf.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@tungstengraphics.com>
- */
-
-
-#include <stddef.h>
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
-
-#include "draw_vf.h"
-
-
-#define DRAW_VF_DBG 0
-
-
-/* TODO: remove this */
-extern void
-_mesa_exec_free( void *addr );
-
-
-static boolean match_fastpath( struct draw_vertex_fetch *vf,
- const struct draw_vf_fastpath *fp)
-{
- unsigned j;
-
- if (vf->attr_count != fp->attr_count)
- return FALSE;
-
- for (j = 0; j < vf->attr_count; j++)
- if (vf->attr[j].format != fp->attr[j].format ||
- vf->attr[j].inputsize != fp->attr[j].size ||
- vf->attr[j].vertoffset != fp->attr[j].offset)
- return FALSE;
-
- if (fp->match_strides) {
- if (vf->vertex_stride != fp->vertex_stride)
- return FALSE;
-
- for (j = 0; j < vf->attr_count; j++)
- if (vf->attr[j].inputstride != fp->attr[j].stride)
- return FALSE;
- }
-
- return TRUE;
-}
-
-static boolean search_fastpath_emit( struct draw_vertex_fetch *vf )
-{
- struct draw_vf_fastpath *fp = vf->fastpath;
-
- for ( ; fp ; fp = fp->next) {
- if (match_fastpath(vf, fp)) {
- vf->emit = fp->func;
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-void draw_vf_register_fastpath( struct draw_vertex_fetch *vf,
- boolean match_strides )
-{
- struct draw_vf_fastpath *fastpath = CALLOC_STRUCT(draw_vf_fastpath);
- unsigned i;
-
- fastpath->vertex_stride = vf->vertex_stride;
- fastpath->attr_count = vf->attr_count;
- fastpath->match_strides = match_strides;
- fastpath->func = vf->emit;
- fastpath->attr = (struct draw_vf_attr_type *)
- MALLOC(vf->attr_count * sizeof(fastpath->attr[0]));
-
- for (i = 0; i < vf->attr_count; i++) {
- fastpath->attr[i].format = vf->attr[i].format;
- fastpath->attr[i].stride = vf->attr[i].inputstride;
- fastpath->attr[i].size = vf->attr[i].inputsize;
- fastpath->attr[i].offset = vf->attr[i].vertoffset;
- }
-
- fastpath->next = vf->fastpath;
- vf->fastpath = fastpath;
-}
-
-
-
-
-/***********************************************************************
- * Build codegen functions or return generic ones:
- */
-static void choose_emit_func( struct draw_vertex_fetch *vf,
- unsigned count,
- uint8_t *dest)
-{
- vf->emit = NULL;
-
- /* Does this match an existing (hardwired, codegen or known-bad)
- * fastpath?
- */
- if (search_fastpath_emit(vf)) {
- /* Use this result. If it is null, then it is already known
- * that the current state will fail for codegen and there is no
- * point trying again.
- */
- }
- else if (vf->codegen_emit) {
- vf->codegen_emit( vf );
- }
-
- if (!vf->emit) {
- draw_vf_generate_hardwired_emit(vf);
- }
-
- /* Otherwise use the generic version:
- */
- if (!vf->emit)
- vf->emit = draw_vf_generic_emit;
-
- vf->emit( vf, count, dest );
-}
-
-
-
-
-
-/***********************************************************************
- * Public entrypoints, mostly dispatch to the above:
- */
-
-
-
-static unsigned
-draw_vf_set_vertex_attributes( struct draw_vertex_fetch *vf,
- const struct draw_vf_attr_map *map,
- unsigned nr,
- unsigned vertex_stride )
-{
- unsigned offset = 0;
- unsigned i, j;
-
- assert(nr < PIPE_ATTRIB_MAX);
-
- for (j = 0, i = 0; i < nr; i++) {
- const unsigned format = map[i].format;
- if (format == DRAW_EMIT_PAD) {
-#if (DRAW_VF_DBG)
- debug_printf("%d: pad %d, offset %d\n", i,
- map[i].offset, offset);
-#endif
-
- offset += map[i].offset;
-
- }
- else {
- vf->attr[j].attrib = map[i].attrib;
- vf->attr[j].format = format;
- vf->attr[j].insert = draw_vf_format_info[format].insert;
- vf->attr[j].vertattrsize = draw_vf_format_info[format].attrsize;
- vf->attr[j].vertoffset = offset;
- vf->attr[j].isconst = draw_vf_format_info[format].isconst;
- if(vf->attr[j].isconst)
- memcpy(vf->attr[j].data, &map[i].data, vf->attr[j].vertattrsize);
-
-#if (DRAW_VF_DBG)
- debug_printf("%d: %s, offset %d\n", i,
- draw_vf_format_info[format].name,
- vf->attr[j].vertoffset);
-#endif
-
- offset += draw_vf_format_info[format].attrsize;
- j++;
- }
- }
-
- vf->attr_count = j;
- vf->vertex_stride = vertex_stride ? vertex_stride : offset;
- vf->emit = choose_emit_func;
-
- assert(vf->vertex_stride >= offset);
- return vf->vertex_stride;
-}
-
-
-void draw_vf_set_vertex_info( struct draw_vertex_fetch *vf,
- const struct vertex_info *vinfo,
- float point_size )
-{
- unsigned i, j, k;
- struct draw_vf_attr *a = vf->attr;
- struct draw_vf_attr_map attrs[PIPE_MAX_SHADER_INPUTS];
- unsigned count = 0; /* for debug/sanity */
- unsigned nr_attrs = 0;
-
- for (i = 0; i < vinfo->num_attribs; i++) {
- j = vinfo->src_index[i];
- switch (vinfo->emit[i]) {
- case EMIT_OMIT:
- /* no-op */
- break;
- case EMIT_ALL: {
- /* just copy the whole vertex as-is to the vbuf */
- unsigned s = vinfo->size;
- assert(i == 0);
- assert(j == 0);
- /* copy the vertex header */
- /* XXX: we actually don't copy the header, just pad it */
- attrs[nr_attrs].attrib = 0;
- attrs[nr_attrs].format = DRAW_EMIT_PAD;
- attrs[nr_attrs].offset = offsetof(struct vertex_header, data);
- s -= offsetof(struct vertex_header, data)/4;
- count += offsetof(struct vertex_header, data)/4;
- nr_attrs++;
- /* copy the vertex data */
- for(k = 0; k < (s & ~0x3); k += 4) {
- attrs[nr_attrs].attrib = k/4;
- attrs[nr_attrs].format = DRAW_EMIT_4F;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count += 4;
- }
- /* tail */
- /* XXX: actually, this shouldn't be needed */
- attrs[nr_attrs].attrib = k/4;
- attrs[nr_attrs].offset = 0;
- switch(s & 0x3) {
- case 0:
- break;
- case 1:
- attrs[nr_attrs].format = DRAW_EMIT_1F;
- nr_attrs++;
- count += 1;
- break;
- case 2:
- attrs[nr_attrs].format = DRAW_EMIT_2F;
- nr_attrs++;
- count += 2;
- break;
- case 3:
- attrs[nr_attrs].format = DRAW_EMIT_3F;
- nr_attrs++;
- count += 3;
- break;
- }
- break;
- }
- case EMIT_1F:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_1F;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count++;
- break;
- case EMIT_1F_PSIZE:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_1F_CONST;
- attrs[nr_attrs].offset = 0;
- attrs[nr_attrs].data.f[0] = point_size;
- nr_attrs++;
- count++;
- break;
- case EMIT_2F:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_2F;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count += 2;
- break;
- case EMIT_3F:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_3F;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count += 3;
- break;
- case EMIT_4F:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_4F;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count += 4;
- break;
- case EMIT_4UB:
- attrs[nr_attrs].attrib = j;
- attrs[nr_attrs].format = DRAW_EMIT_4UB_4F_BGRA;
- attrs[nr_attrs].offset = 0;
- nr_attrs++;
- count += 1;
- break;
- default:
- assert(0);
- }
- }
-
- assert(count == vinfo->size);
-
- draw_vf_set_vertex_attributes(vf,
- attrs,
- nr_attrs,
- vinfo->size * sizeof(float) );
-
- for (j = 0; j < vf->attr_count; j++) {
- a[j].inputsize = 4;
- a[j].do_insert = a[j].insert[4 - 1];
- if(a[j].isconst) {
- a[j].inputptr = a[j].data;
- a[j].inputstride = 0;
- }
- }
-}
-
-
-#if 0
-/* Set attribute pointers, adjusted for start position:
- */
-void draw_vf_set_sources( struct draw_vertex_fetch *vf,
- GLvector4f * const sources[],
- unsigned start )
-{
- struct draw_vf_attr *a = vf->attr;
- unsigned j;
-
- for (j = 0; j < vf->attr_count; j++) {
- const GLvector4f *vptr = sources[a[j].attrib];
-
- if ((a[j].inputstride != vptr->stride) ||
- (a[j].inputsize != vptr->size))
- vf->emit = choose_emit_func;
-
- a[j].inputstride = vptr->stride;
- a[j].inputsize = vptr->size;
- a[j].do_insert = a[j].insert[vptr->size - 1];
- a[j].inputptr = ((uint8_t *)vptr->data) + start * vptr->stride;
- }
-}
-#endif
-
-
-/**
- * Emit a vertex to dest.
- */
-void draw_vf_emit_vertex( struct draw_vertex_fetch *vf,
- struct vertex_header *vertex,
- void *dest )
-{
- struct draw_vf_attr *a = vf->attr;
- unsigned j;
-
- for (j = 0; j < vf->attr_count; j++) {
- if(!a[j].isconst) {
- a[j].inputptr = (uint8_t *)&vertex->data[a[j].attrib][0];
- a[j].inputstride = 0; /* XXX: one-vertex-max ATM */
- }
- }
-
- vf->emit( vf, 1, (uint8_t*) dest );
-}
-
-
-
-struct draw_vertex_fetch *draw_vf_create( void )
-{
- struct draw_vertex_fetch *vf = CALLOC_STRUCT(draw_vertex_fetch);
- unsigned i;
-
- for (i = 0; i < PIPE_ATTRIB_MAX; i++)
- vf->attr[i].vf = vf;
-
- vf->identity[0] = 0.0;
- vf->identity[1] = 0.0;
- vf->identity[2] = 0.0;
- vf->identity[3] = 1.0;
-
- vf->codegen_emit = NULL;
-
-#ifdef USE_SSE_ASM
- if (!GETENV("GALLIUM_NO_CODEGEN"))
- vf->codegen_emit = draw_vf_generate_sse_emit;
-#endif
-
- return vf;
-}
-
-
-void draw_vf_destroy( struct draw_vertex_fetch *vf )
-{
- struct draw_vf_fastpath *fp, *tmp;
-
- for (fp = vf->fastpath ; fp ; fp = tmp) {
- tmp = fp->next;
- FREE(fp->attr);
-
- /* KW: At the moment, fp->func is constrained to be allocated by
- * _mesa_exec_alloc(), as the hardwired fastpaths in
- * t_vertex_generic.c are handled specially. It would be nice
- * to unify them, but this probably won't change until this
- * module gets another overhaul.
- */
- //_mesa_exec_free((void *) fp->func);
- FREE(fp);
- }
-
- vf->fastpath = NULL;
- FREE(vf);
-}
diff --git a/src/mesa/pipe/draw/draw_vf.h b/src/mesa/pipe/draw/draw_vf.h
deleted file mode 100644
index e694b98675..0000000000
--- a/src/mesa/pipe/draw/draw_vf.h
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@tungstengraphics.com>
- */
-
-#ifndef DRAW_VF_H
-#define DRAW_VF_H
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-#include "draw_vertex.h"
-#include "draw_private.h" // for vertex_header
-
-
-enum draw_vf_attr_format {
- DRAW_EMIT_1F,
- DRAW_EMIT_2F,
- DRAW_EMIT_3F,
- DRAW_EMIT_4F,
- DRAW_EMIT_3F_XYW, /**< for projective texture */
- DRAW_EMIT_1UB_1F, /**< for fog coordinate */
- DRAW_EMIT_3UB_3F_RGB, /**< for specular color */
- DRAW_EMIT_3UB_3F_BGR, /**< for specular color */
- DRAW_EMIT_4UB_4F_RGBA, /**< for color */
- DRAW_EMIT_4UB_4F_BGRA, /**< for color */
- DRAW_EMIT_4UB_4F_ARGB, /**< for color */
- DRAW_EMIT_4UB_4F_ABGR, /**< for color */
- DRAW_EMIT_1F_CONST,
- DRAW_EMIT_2F_CONST,
- DRAW_EMIT_3F_CONST,
- DRAW_EMIT_4F_CONST,
- DRAW_EMIT_PAD, /**< leave a hole of 'offset' bytes */
- DRAW_EMIT_MAX
-};
-
-struct draw_vf_attr_map
-{
- /** Input attribute number */
- unsigned attrib;
-
- enum draw_vf_attr_format format;
-
- unsigned offset;
-
- /**
- * Constant data for DRAW_EMIT_*_CONST
- */
- union {
- uint8_t ub[4];
- float f[4];
- } data;
-};
-
-struct draw_vertex_fetch;
-
-
-
-#if 0
-unsigned
-draw_vf_set_vertex_attributes( struct draw_vertex_fetch *vf,
- const struct draw_vf_attr_map *map,
- unsigned nr,
- unsigned vertex_stride );
-#endif
-
-void draw_vf_set_vertex_info( struct draw_vertex_fetch *vf,
- const struct vertex_info *vinfo,
- float point_size );
-
-#if 0
-void
-draw_vf_set_sources( struct draw_vertex_fetch *vf,
- GLvector4f * const attrib[],
- unsigned start );
-#endif
-
-void
-draw_vf_emit_vertex( struct draw_vertex_fetch *vf,
- struct vertex_header *vertex,
- void *dest );
-
-struct draw_vertex_fetch *
-draw_vf_create( void );
-
-void
-draw_vf_destroy( struct draw_vertex_fetch *vf );
-
-
-
-/***********************************************************************
- * Internal functions and structs:
- */
-
-struct draw_vf_attr;
-
-typedef void (*draw_vf_extract_func)( const struct draw_vf_attr *a,
- float *out,
- const uint8_t *v );
-
-typedef void (*draw_vf_insert_func)( const struct draw_vf_attr *a,
- uint8_t *v,
- const float *in );
-
-typedef void (*draw_vf_emit_func)( struct draw_vertex_fetch *vf,
- unsigned count,
- uint8_t *dest );
-
-
-
-/**
- * Describes how to convert/move a vertex attribute from a vertex
- * array to a vertex structure.
- */
-struct draw_vf_attr
-{
- struct draw_vertex_fetch *vf;
-
- unsigned format;
- unsigned inputsize;
- unsigned inputstride;
- unsigned vertoffset; /**< position of the attrib in the vertex struct */
-
- boolean isconst; /**< read from const data below */
- uint8_t data[16];
-
- unsigned attrib; /**< which vertex attrib (0=position, etc) */
- unsigned vertattrsize; /**< size of the attribute in bytes */
-
- uint8_t *inputptr;
- const draw_vf_insert_func *insert;
- draw_vf_insert_func do_insert;
- draw_vf_extract_func extract;
-};
-
-struct draw_vertex_fetch
-{
- struct draw_vf_attr attr[PIPE_ATTRIB_MAX];
- unsigned attr_count;
- unsigned vertex_stride;
-
- draw_vf_emit_func emit;
-
- /* Parameters and constants for codegen:
- */
- float identity[4];
-
- struct draw_vf_fastpath *fastpath;
-
- void (*codegen_emit)( struct draw_vertex_fetch *vf );
-};
-
-
-struct draw_vf_attr_type {
- unsigned format;
- unsigned size;
- unsigned stride;
- unsigned offset;
-};
-
-struct draw_vf_fastpath {
- unsigned vertex_stride;
- unsigned attr_count;
- boolean match_strides;
-
- struct draw_vf_attr_type *attr;
-
- draw_vf_emit_func func;
- struct draw_vf_fastpath *next;
-};
-
-
-void
-draw_vf_register_fastpath( struct draw_vertex_fetch *vtx,
- boolean match_strides );
-
-void
-draw_vf_generic_emit( struct draw_vertex_fetch *vf,
- unsigned count,
- uint8_t *v );
-
-void
-draw_vf_generate_hardwired_emit( struct draw_vertex_fetch *vf );
-
-void
-draw_vf_generate_sse_emit( struct draw_vertex_fetch *vf );
-
-
-struct draw_vf_format_info {
- const char *name;
- draw_vf_insert_func insert[4];
- const unsigned attrsize;
- const boolean isconst;
-};
-
-extern const struct draw_vf_format_info
-draw_vf_format_info[DRAW_EMIT_MAX];
-
-
-#endif
diff --git a/src/mesa/pipe/draw/draw_vf_generic.c b/src/mesa/pipe/draw/draw_vf_generic.c
deleted file mode 100644
index 7a60a9db9c..0000000000
--- a/src/mesa/pipe/draw/draw_vf_generic.c
+++ /dev/null
@@ -1,585 +0,0 @@
-
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@tungstengraphics.com>
- */
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-
-#include "draw_vf.h"
-
-
-
-static INLINE void insert_4f_4( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
-}
-
-static INLINE void insert_4f_3( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = 1;
-}
-
-static INLINE void insert_4f_2( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
- out[3] = 1;
-}
-
-static INLINE void insert_4f_1( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
-}
-
-static INLINE void insert_3f_xyw_4( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[3];
-}
-
-static INLINE void insert_3f_xyw_err( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- (void) a; (void) v; (void) in;
- assert(0);
-}
-
-static INLINE void insert_3f_3( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
-}
-
-static INLINE void insert_3f_2( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
-}
-
-static INLINE void insert_3f_1( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
- out[2] = 0;
-}
-
-
-static INLINE void insert_2f_2( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
-}
-
-static INLINE void insert_2f_1( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
-}
-
-static INLINE void insert_1f_1( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- float *out = (float *)(v);
- (void) a;
-
- out[0] = in[0];
-}
-
-static INLINE void insert_null( const struct draw_vf_attr *a, uint8_t *v, const float *in )
-{
- (void) a; (void) v; (void) in;
-}
-
-static INLINE void insert_4ub_4f_rgba_4( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
-}
-
-static INLINE void insert_4ub_4f_rgba_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_rgba_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[2] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_rgba_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- v[1] = 0;
- v[2] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_4( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
-}
-
-static INLINE void insert_4ub_4f_bgra_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[0] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- v[1] = 0;
- v[0] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_4( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
-}
-
-static INLINE void insert_4ub_4f_argb_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- v[3] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- v[2] = 0x00;
- v[3] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_4( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
-}
-
-static INLINE void insert_4ub_4f_abgr_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- v[1] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- v[2] = 0x00;
- v[1] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_3ub_3f_rgb_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
-}
-
-static INLINE void insert_3ub_3f_rgb_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[2] = 0;
-}
-
-static INLINE void insert_3ub_3f_rgb_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- v[1] = 0;
- v[2] = 0;
-}
-
-static INLINE void insert_3ub_3f_bgr_3( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
-}
-
-static INLINE void insert_3ub_3f_bgr_2( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[0] = 0;
-}
-
-static INLINE void insert_3ub_3f_bgr_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- v[1] = 0;
- v[0] = 0;
-}
-
-
-static INLINE void insert_1ub_1f_1( const struct draw_vf_attr *a, uint8_t *v,
- const float *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
-}
-
-
-const struct draw_vf_format_info draw_vf_format_info[DRAW_EMIT_MAX] =
-{
- { "1f",
- { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
- sizeof(float), FALSE },
-
- { "2f",
- { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
- 2 * sizeof(float), FALSE },
-
- { "3f",
- { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
- 3 * sizeof(float), FALSE },
-
- { "4f",
- { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
- 4 * sizeof(float), FALSE },
-
- { "3f_xyw",
- { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err,
- insert_3f_xyw_4 },
- 3 * sizeof(float), FALSE },
-
- { "1ub_1f",
- { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
- sizeof(uint8_t), FALSE },
-
- { "3ub_3f_rgb",
- { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
- insert_3ub_3f_rgb_3 },
- 3 * sizeof(uint8_t), FALSE },
-
- { "3ub_3f_bgr",
- { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
- insert_3ub_3f_bgr_3 },
- 3 * sizeof(uint8_t), FALSE },
-
- { "4ub_4f_rgba",
- { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3,
- insert_4ub_4f_rgba_4 },
- 4 * sizeof(uint8_t), FALSE },
-
- { "4ub_4f_bgra",
- { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
- insert_4ub_4f_bgra_4 },
- 4 * sizeof(uint8_t), FALSE },
-
- { "4ub_4f_argb",
- { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
- insert_4ub_4f_argb_4 },
- 4 * sizeof(uint8_t), FALSE },
-
- { "4ub_4f_abgr",
- { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
- insert_4ub_4f_abgr_4 },
- 4 * sizeof(uint8_t), FALSE },
-
- { "1f_const",
- { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
- sizeof(float), TRUE },
-
- { "2f_const",
- { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
- 2 * sizeof(float), TRUE },
-
- { "3f_const",
- { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
- 3 * sizeof(float), TRUE },
-
- { "4f_const",
- { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
- 4 * sizeof(float), TRUE },
-
- { "pad",
- { NULL, NULL, NULL, NULL },
- 0, FALSE },
-
-};
-
-
-
-
-/***********************************************************************
- * Hardwired fastpaths for emitting whole vertices or groups of
- * vertices
- */
-#define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \
-static void NAME( struct draw_vertex_fetch *vf, \
- unsigned count, \
- uint8_t *v ) \
-{ \
- struct draw_vf_attr *a = vf->attr; \
- unsigned i; \
- \
- for (i = 0 ; i < count ; i++, v += vf->vertex_stride) { \
- if (NR > 0) { \
- F0( &a[0], v + a[0].vertoffset, (float *)a[0].inputptr ); \
- a[0].inputptr += a[0].inputstride; \
- } \
- \
- if (NR > 1) { \
- F1( &a[1], v + a[1].vertoffset, (float *)a[1].inputptr ); \
- a[1].inputptr += a[1].inputstride; \
- } \
- \
- if (NR > 2) { \
- F2( &a[2], v + a[2].vertoffset, (float *)a[2].inputptr ); \
- a[2].inputptr += a[2].inputstride; \
- } \
- \
- if (NR > 3) { \
- F3( &a[3], v + a[3].vertoffset, (float *)a[3].inputptr ); \
- a[3].inputptr += a[3].inputstride; \
- } \
- \
- if (NR > 4) { \
- F4( &a[4], v + a[4].vertoffset, (float *)a[4].inputptr ); \
- a[4].inputptr += a[4].inputstride; \
- } \
- } \
-}
-
-
-#define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
- insert_null, insert_null, NAME)
-
-#define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
- insert_null, NAME)
-
-#define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
- insert_null, NAME)
-
-
-EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4)
-
-EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2)
-
-EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2)
-
-
-/* Use the codegen paths to select one of a number of hardwired
- * fastpaths.
- */
-void draw_vf_generate_hardwired_emit( struct draw_vertex_fetch *vf )
-{
- draw_vf_emit_func func = NULL;
-
- /* Does it fit a hardwired fastpath? Help! this is growing out of
- * control!
- */
- switch (vf->attr_count) {
- case 2:
- if (vf->attr[0].do_insert == insert_3f_3 &&
- vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
- func = emit_xyz3_rgba4;
- }
- break;
- case 3:
- if (vf->attr[2].do_insert == insert_2f_2) {
- if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
- if (vf->attr[0].do_insert == insert_4f_4)
- func = emit_xyzw4_rgba4_st2;
- }
- }
- break;
- case 4:
- if (vf->attr[2].do_insert == insert_2f_2 &&
- vf->attr[3].do_insert == insert_2f_2) {
- if (vf->attr[1].do_insert == insert_4ub_4f_rgba_4) {
- if (vf->attr[0].do_insert == insert_4f_4)
- func = emit_xyzw4_rgba4_st2_st2;
- }
- }
- break;
- }
-
- vf->emit = func;
-}
-
-/***********************************************************************
- * Generic (non-codegen) functions for whole vertices or groups of
- * vertices
- */
-
-void draw_vf_generic_emit( struct draw_vertex_fetch *vf,
- unsigned count,
- uint8_t *v )
-{
- struct draw_vf_attr *a = vf->attr;
- const unsigned attr_count = vf->attr_count;
- const unsigned stride = vf->vertex_stride;
- unsigned i, j;
-
- for (i = 0 ; i < count ; i++, v += stride) {
- for (j = 0; j < attr_count; j++) {
- float *in = (float *)a[j].inputptr;
- a[j].inputptr += a[j].inputstride;
- a[j].do_insert( &a[j], v + a[j].vertoffset, in );
- }
- }
-}
-
-
diff --git a/src/mesa/pipe/draw/draw_vf_sse.c b/src/mesa/pipe/draw/draw_vf_sse.c
deleted file mode 100644
index 1ad2ae756d..0000000000
--- a/src/mesa/pipe/draw/draw_vf_sse.c
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@tungstengraphics.com>
- */
-
-
-#include "simple_list.h"
-
-#include "pipe/p_compiler.h"
-
-#include "draw_vf.h"
-
-
-#if defined(USE_SSE_ASM)
-
-#include "x86/rtasm/x86sse.h"
-#include "x86/common_x86_asm.h"
-
-
-#define X 0
-#define Y 1
-#define Z 2
-#define W 3
-
-
-struct x86_program {
- struct x86_function func;
-
- struct draw_vertex_fetch *vf;
- boolean inputs_safe;
- boolean outputs_safe;
- boolean have_sse2;
-
- struct x86_reg identity;
- struct x86_reg chan0;
-};
-
-
-static struct x86_reg get_identity( struct x86_program *p )
-{
- return p->identity;
-}
-
-static void emit_load4f_4( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movups(&p->func, dest, arg0);
-}
-
-static void emit_load4f_3( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Have to jump through some hoops:
- *
- * c 0 0 0
- * c 0 0 1
- * 0 0 c 1
- * a b c 1
- */
- sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
- sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
- sse_shufps(&p->func, dest, dest, SHUF(Y,Z,X,W) );
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load4f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Initialize from identity, then pull in low two words:
- */
- sse_movups(&p->func, dest, get_identity(p));
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load4f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Pull in low word, then swizzle in identity */
- sse_movss(&p->func, dest, arg0);
- sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
-}
-
-
-
-static void emit_load3f_3( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Over-reads by 1 dword - potential SEGV if input is a vertex
- * array.
- */
- if (p->inputs_safe) {
- sse_movups(&p->func, dest, arg0);
- }
- else {
- /* c 0 0 0
- * c c c c
- * a b c c
- */
- sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
- sse_shufps(&p->func, dest, dest, SHUF(X,X,X,X));
- sse_movlps(&p->func, dest, arg0);
- }
-}
-
-static void emit_load3f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_2(p, dest, arg0);
-}
-
-static void emit_load3f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_1(p, dest, arg0);
-}
-
-static void emit_load2f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load2f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_1(p, dest, arg0);
-}
-
-static void emit_load1f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movss(&p->func, dest, arg0);
-}
-
-static void (*load[4][4])( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 ) = {
- { emit_load1f_1,
- emit_load1f_1,
- emit_load1f_1,
- emit_load1f_1 },
-
- { emit_load2f_1,
- emit_load2f_2,
- emit_load2f_2,
- emit_load2f_2 },
-
- { emit_load3f_1,
- emit_load3f_2,
- emit_load3f_3,
- emit_load3f_3 },
-
- { emit_load4f_1,
- emit_load4f_2,
- emit_load4f_3,
- emit_load4f_4 }
-};
-
-static void emit_load( struct x86_program *p,
- struct x86_reg dest,
- unsigned sz,
- struct x86_reg src,
- unsigned src_sz)
-{
- load[sz-1][src_sz-1](p, dest, src);
-}
-
-static void emit_store4f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movups(&p->func, dest, arg0);
-}
-
-static void emit_store3f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- if (p->outputs_safe) {
- /* Emit the extra dword anyway. This may hurt writecombining,
- * may cause other problems.
- */
- sse_movups(&p->func, dest, arg0);
- }
- else {
- /* Alternate strategy - emit two, shuffle, emit one.
- */
- sse_movlps(&p->func, dest, arg0);
- sse_shufps(&p->func, arg0, arg0, SHUF(Z,Z,Z,Z) ); /* NOTE! destructive */
- sse_movss(&p->func, x86_make_disp(dest,8), arg0);
- }
-}
-
-static void emit_store2f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_store1f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movss(&p->func, dest, arg0);
-}
-
-
-static void (*store[4])( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 ) =
-{
- emit_store1f,
- emit_store2f,
- emit_store3f,
- emit_store4f
-};
-
-static void emit_store( struct x86_program *p,
- struct x86_reg dest,
- unsigned sz,
- struct x86_reg temp )
-
-{
- store[sz-1](p, dest, temp);
-}
-
-static void emit_pack_store_4ub( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg temp )
-{
- /* Scale by 255.0
- */
- sse_mulps(&p->func, temp, p->chan0);
-
- if (p->have_sse2) {
- sse2_cvtps2dq(&p->func, temp, temp);
- sse2_packssdw(&p->func, temp, temp);
- sse2_packuswb(&p->func, temp, temp);
- sse_movss(&p->func, dest, temp);
- }
- else {
- struct x86_reg mmx0 = x86_make_reg(file_MMX, 0);
- struct x86_reg mmx1 = x86_make_reg(file_MMX, 1);
- sse_cvtps2pi(&p->func, mmx0, temp);
- sse_movhlps(&p->func, temp, temp);
- sse_cvtps2pi(&p->func, mmx1, temp);
- mmx_packssdw(&p->func, mmx0, mmx1);
- mmx_packuswb(&p->func, mmx0, mmx0);
- mmx_movd(&p->func, dest, mmx0);
- }
-}
-
-static int get_offset( const void *a, const void *b )
-{
- return (const char *)b - (const char *)a;
-}
-
-/* Not much happens here. Eventually use this function to try and
- * avoid saving/reloading the source pointers each vertex (if some of
- * them can fit in registers).
- */
-static void get_src_ptr( struct x86_program *p,
- struct x86_reg srcREG,
- struct x86_reg vfREG,
- struct draw_vf_attr *a )
-{
- struct draw_vertex_fetch *vf = p->vf;
- struct x86_reg ptr_to_src = x86_make_disp(vfREG, get_offset(vf, &a->inputptr));
-
- /* Load current a[j].inputptr
- */
- x86_mov(&p->func, srcREG, ptr_to_src);
-}
-
-static void update_src_ptr( struct x86_program *p,
- struct x86_reg srcREG,
- struct x86_reg vfREG,
- struct draw_vf_attr *a )
-{
- if (a->inputstride) {
- struct draw_vertex_fetch *vf = p->vf;
- struct x86_reg ptr_to_src = x86_make_disp(vfREG, get_offset(vf, &a->inputptr));
-
- /* add a[j].inputstride (hardcoded value - could just as easily
- * pull the stride value from memory each time).
- */
- x86_lea(&p->func, srcREG, x86_make_disp(srcREG, a->inputstride));
-
- /* save new value of a[j].inputptr
- */
- x86_mov(&p->func, ptr_to_src, srcREG);
- }
-}
-
-
-/* Lots of hardcoding
- *
- * EAX -- pointer to current output vertex
- * ECX -- pointer to current attribute
- *
- */
-static boolean build_vertex_emit( struct x86_program *p )
-{
- struct draw_vertex_fetch *vf = p->vf;
- unsigned j = 0;
-
- struct x86_reg vertexEAX = x86_make_reg(file_REG32, reg_AX);
- struct x86_reg srcECX = x86_make_reg(file_REG32, reg_CX);
- struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP);
- struct x86_reg vfESI = x86_make_reg(file_REG32, reg_SI);
- struct x86_reg temp = x86_make_reg(file_XMM, 0);
- uint8_t *fixup, *label;
-
- /* Push a few regs?
- */
- x86_push(&p->func, countEBP);
- x86_push(&p->func, vfESI);
-
-
- /* Get vertex count, compare to zero
- */
- x86_xor(&p->func, srcECX, srcECX);
- x86_mov(&p->func, countEBP, x86_fn_arg(&p->func, 2));
- x86_cmp(&p->func, countEBP, srcECX);
- fixup = x86_jcc_forward(&p->func, cc_E);
-
- /* Initialize destination register.
- */
- x86_mov(&p->func, vertexEAX, x86_fn_arg(&p->func, 3));
-
- /* Move argument 1 (vf) into a reg:
- */
- x86_mov(&p->func, vfESI, x86_fn_arg(&p->func, 1));
-
-
- /* always load, needed or not:
- */
- sse_movups(&p->func, p->identity, x86_make_disp(vfESI, get_offset(vf, &vf->identity[0])));
-
- /* Note address for loop jump */
- label = x86_get_label(&p->func);
-
- /* Emit code for each of the attributes. Currently routes
- * everything through SSE registers, even when it might be more
- * efficient to stick with regular old x86. No optimization or
- * other tricks - enough new ground to cover here just getting
- * things working.
- */
- while (j < vf->attr_count) {
- struct draw_vf_attr *a = &vf->attr[j];
- struct x86_reg dest = x86_make_disp(vertexEAX, a->vertoffset);
-
- /* Now, load an XMM reg from src, perhaps transform, then save.
- * Could be shortcircuited in specific cases:
- */
- switch (a->format) {
- case DRAW_EMIT_1F:
- case DRAW_EMIT_1F_CONST:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 1, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_2F:
- case DRAW_EMIT_2F_CONST:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 2, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_3F:
- case DRAW_EMIT_3F_CONST:
- /* Potentially the worst case - hardcode 2+1 copying:
- */
- if (0) {
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 3, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- }
- else {
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 2, temp);
- if (a->inputsize > 2) {
- emit_load(p, temp, 1, x86_make_disp(srcECX, 8), 1);
- emit_store(p, x86_make_disp(dest,8), 1, temp);
- }
- else {
- sse_movss(&p->func, x86_make_disp(dest,8), get_identity(p));
- }
- update_src_ptr(p, srcECX, vfESI, a);
- }
- break;
- case DRAW_EMIT_4F:
- case DRAW_EMIT_4F_CONST:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 4, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_3F_XYW:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(X,Y,W,Z));
- emit_store(p, dest, 3, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
-
- case DRAW_EMIT_1UB_1F:
- /* Test for PAD3 + 1UB:
- */
- if (j > 0 &&
- a[-1].vertoffset + a[-1].vertattrsize <= a->vertoffset - 3)
- {
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(X,X,X,X));
- emit_pack_store_4ub(p, x86_make_disp(dest, -3), temp); /* overkill! */
- update_src_ptr(p, srcECX, vfESI, a);
- }
- else {
- debug_printf("Can't emit 1ub %x %x %d\n",
- a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize );
- return FALSE;
- }
- break;
- case DRAW_EMIT_3UB_3F_RGB:
- case DRAW_EMIT_3UB_3F_BGR:
- /* Test for 3UB + PAD1:
- */
- if (j == vf->attr_count - 1 ||
- a[1].vertoffset >= a->vertoffset + 4) {
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- if (a->format == DRAW_EMIT_3UB_3F_BGR)
- sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- }
- /* Test for 3UB + 1UB:
- */
- else if (j < vf->attr_count - 1 &&
- a[1].format == DRAW_EMIT_1UB_1F &&
- a[1].vertoffset == a->vertoffset + 3) {
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- update_src_ptr(p, srcECX, vfESI, a);
-
- /* Make room for incoming value:
- */
- sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
-
- get_src_ptr(p, srcECX, vfESI, &a[1]);
- emit_load(p, temp, 1, x86_deref(srcECX), a[1].inputsize);
- update_src_ptr(p, srcECX, vfESI, &a[1]);
-
- /* Rearrange and possibly do BGR conversion:
- */
- if (a->format == DRAW_EMIT_3UB_3F_BGR)
- sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
- else
- sse_shufps(&p->func, temp, temp, SHUF(Y,Z,W,X));
-
- emit_pack_store_4ub(p, dest, temp);
- j++; /* NOTE: two attrs consumed */
- }
- else {
- debug_printf("Can't emit 3ub\n");
- }
- return FALSE; /* add this later */
- break;
-
- case DRAW_EMIT_4UB_4F_RGBA:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_4UB_4F_BGRA:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_4UB_4F_ARGB:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- case DRAW_EMIT_4UB_4F_ABGR:
- get_src_ptr(p, srcECX, vfESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vfESI, a);
- break;
- default:
- debug_printf("unknown a[%d].format %d\n", j, a->format);
- return FALSE; /* catch any new opcodes */
- }
-
- /* Increment j by at least 1 - may have been incremented above also:
- */
- j++;
- }
-
- /* Next vertex:
- */
- x86_lea(&p->func, vertexEAX, x86_make_disp(vertexEAX, vf->vertex_stride));
-
- /* decr count, loop if not zero
- */
- x86_dec(&p->func, countEBP);
- x86_test(&p->func, countEBP, countEBP);
- x86_jcc(&p->func, cc_NZ, label);
-
- /* Exit mmx state?
- */
- if (p->func.need_emms)
- mmx_emms(&p->func);
-
- /* Land forward jump here:
- */
- x86_fixup_fwd_jump(&p->func, fixup);
-
- /* Pop regs and return
- */
- x86_pop(&p->func, x86_get_base_reg(vfESI));
- x86_pop(&p->func, countEBP);
- x86_ret(&p->func);
-
- vf->emit = (draw_vf_emit_func)x86_get_func(&p->func);
- return TRUE;
-}
-
-
-
-void draw_vf_generate_sse_emit( struct draw_vertex_fetch *vf )
-{
- struct x86_program p;
-
- if (!cpu_has_xmm) {
- vf->codegen_emit = NULL;
- return;
- }
-
- memset(&p, 0, sizeof(p));
-
- p.vf = vf;
- p.inputs_safe = 0; /* for now */
- p.outputs_safe = 1; /* for now */
- p.have_sse2 = cpu_has_xmm2;
- p.identity = x86_make_reg(file_XMM, 6);
- p.chan0 = x86_make_reg(file_XMM, 7);
-
- x86_init_func(&p.func);
-
- if (build_vertex_emit(&p)) {
- draw_vf_register_fastpath( vf, TRUE );
- }
- else {
- /* Note the failure so that we don't keep trying to codegen an
- * impossible state:
- */
- draw_vf_register_fastpath( vf, FALSE );
- x86_release_func(&p.func);
- }
-}
-
-#else
-
-void draw_vf_generate_sse_emit( struct draw_vertex_fetch *vf )
-{
- /* Dummy version for when USE_SSE_ASM not defined */
-}
-
-#endif
diff --git a/src/mesa/pipe/draw/draw_wide_prims.c b/src/mesa/pipe/draw/draw_wide_prims.c
deleted file mode 100644
index 4c7e279b20..0000000000
--- a/src/mesa/pipe/draw/draw_wide_prims.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "draw_private.h"
-
-
-struct wide_stage {
- struct draw_stage stage;
-
- float half_line_width;
- float half_point_size;
-
- uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
- uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS];
- uint num_texcoords;
-
- int psize_slot;
-};
-
-
-
-static INLINE struct wide_stage *wide_stage( struct draw_stage *stage )
-{
- return (struct wide_stage *)stage;
-}
-
-
-static void passthrough_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->point( stage->next, header );
-}
-
-static void passthrough_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->line(stage->next, header);
-}
-
-static void passthrough_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- stage->next->tri(stage->next, header);
-}
-
-
-/**
- * Draw a wide line by drawing a quad (two triangles).
- * XXX need to disable polygon stipple.
- */
-static void wide_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- const struct wide_stage *wide = wide_stage(stage);
- const float half_width = wide->half_line_width;
-
- struct prim_header tri;
-
- struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
- struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
- struct vertex_header *v2 = dup_vert(stage, header->v[1], 2);
- struct vertex_header *v3 = dup_vert(stage, header->v[1], 3);
-
- float *pos0 = v0->data[0];
- float *pos1 = v1->data[0];
- float *pos2 = v2->data[0];
- float *pos3 = v3->data[0];
-
- const float dx = FABSF(pos0[0] - pos2[0]);
- const float dy = FABSF(pos0[1] - pos2[1]);
-
- /*
- * Draw wide line as a quad (two tris) by "stretching" the line along
- * X or Y.
- * We need to tweak coords in several ways to be conformant here.
- */
-
- if (dx > dy) {
- /* x-major line */
- pos0[1] = pos0[1] - half_width - 0.25f;
- pos1[1] = pos1[1] + half_width - 0.25f;
- pos2[1] = pos2[1] - half_width - 0.25f;
- pos3[1] = pos3[1] + half_width - 0.25f;
- if (pos0[0] < pos2[0]) {
- /* left to right line */
- pos0[0] -= 0.5f;
- pos1[0] -= 0.5f;
- pos2[0] -= 0.5f;
- pos3[0] -= 0.5f;
- }
- else {
- /* right to left line */
- pos0[0] += 0.5f;
- pos1[0] += 0.5f;
- pos2[0] += 0.5f;
- pos3[0] += 0.5f;
- }
- }
- else {
- /* y-major line */
- pos0[0] = pos0[0] - half_width + 0.25f;
- pos1[0] = pos1[0] + half_width + 0.25f;
- pos2[0] = pos2[0] - half_width + 0.25f;
- pos3[0] = pos3[0] + half_width + 0.25f;
- if (pos0[1] < pos2[1]) {
- /* top to bottom line */
- pos0[1] -= 0.5f;
- pos1[1] -= 0.5f;
- pos2[1] -= 0.5f;
- pos3[1] -= 0.5f;
- }
- else {
- /* bottom to top line */
- pos0[1] += 0.5f;
- pos1[1] += 0.5f;
- pos2[1] += 0.5f;
- pos3[1] += 0.5f;
- }
- }
-
- tri.det = header->det; /* only the sign matters */
- tri.v[0] = v0;
- tri.v[1] = v2;
- tri.v[2] = v3;
- stage->next->tri( stage->next, &tri );
-
- tri.v[0] = v0;
- tri.v[1] = v3;
- tri.v[2] = v1;
- stage->next->tri( stage->next, &tri );
-}
-
-
-/**
- * Draw a wide line by drawing a quad, using geometry which will
- * fullfill GL's antialiased line requirements.
- */
-static void wide_line_aa(struct draw_stage *stage,
- struct prim_header *header)
-{
- const struct wide_stage *wide = wide_stage(stage);
- const float half_width = wide->half_line_width;
- struct prim_header tri;
- struct vertex_header *v[4];
- float *pos;
- float dx = header->v[1]->data[0][0] - header->v[0]->data[0][0];
- float dy = header->v[1]->data[0][1] - header->v[0]->data[0][1];
- const float len = sqrt(dx * dx + dy * dy);
- uint i;
-
- dx = dx * half_width / len;
- dy = dy * half_width / len;
-
- /* allocate/dup new verts */
- for (i = 0; i < 4; i++) {
- v[i] = dup_vert(stage, header->v[i/2], i);
- }
-
- /*
- * Quad for line from v0 to v1:
- *
- * 1 3
- * +-------------------------+
- * | |
- * *v0 v1*
- * | |
- * +-------------------------+
- * 0 2
- */
-
- pos = v[0]->data[0];
- pos[0] += dy;
- pos[1] -= dx;
-
- pos = v[1]->data[0];
- pos[0] -= dy;
- pos[1] += dx;
-
- pos = v[2]->data[0];
- pos[0] += dy;
- pos[1] -= dx;
-
- pos = v[3]->data[0];
- pos[0] -= dy;
- pos[1] += dx;
-
- tri.det = header->det; /* only the sign matters */
-
- tri.v[0] = v[2]; tri.v[1] = v[1]; tri.v[2] = v[0];
- stage->next->tri( stage->next, &tri );
-
- tri.v[0] = v[3]; tri.v[1] = v[1]; tri.v[2] = v[2];
- stage->next->tri( stage->next, &tri );
-
-}
-
-
-/**
- * Set the vertex texcoords for sprite mode.
- * Coords may be left untouched or set to a right-side-up or upside-down
- * orientation.
- */
-static void set_texcoords(const struct wide_stage *wide,
- struct vertex_header *v, const float tc[4])
-{
- uint i;
- for (i = 0; i < wide->num_texcoords; i++) {
- if (wide->texcoord_mode[i] != PIPE_SPRITE_COORD_NONE) {
- uint j = wide->texcoord_slot[i];
- v->data[j][0] = tc[0];
- if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT)
- v->data[j][1] = 1.0f - tc[1];
- else
- v->data[j][1] = tc[1];
- v->data[j][2] = tc[2];
- v->data[j][3] = tc[3];
- }
- }
-}
-
-
-/* If there are lots of sprite points (and why wouldn't there be?) it
- * would probably be more sensible to change hardware setup to
- * optimize this rather than doing the whole thing in software like
- * this.
- */
-static void wide_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- const struct wide_stage *wide = wide_stage(stage);
- const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
- float half_size;
- float left_adj, right_adj;
-
- struct prim_header tri;
-
- /* four dups of original vertex */
- struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
- struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
- struct vertex_header *v2 = dup_vert(stage, header->v[0], 2);
- struct vertex_header *v3 = dup_vert(stage, header->v[0], 3);
-
- float *pos0 = v0->data[0];
- float *pos1 = v1->data[0];
- float *pos2 = v2->data[0];
- float *pos3 = v3->data[0];
-
- /* point size is either per-vertex or fixed size */
- if (wide->psize_slot >= 0) {
- half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
- }
- else {
- half_size = wide->half_point_size;
- }
-
- left_adj = -half_size + 0.25f;
- right_adj = half_size + 0.25f;
-
- pos0[0] += left_adj;
- pos0[1] -= half_size;
-
- pos1[0] += left_adj;
- pos1[1] += half_size;
-
- pos2[0] += right_adj;
- pos2[1] -= half_size;
-
- pos3[0] += right_adj;
- pos3[1] += half_size;
-
- if (sprite) {
- static const float tex00[4] = { 0, 0, 0, 1 };
- static const float tex01[4] = { 0, 1, 0, 1 };
- static const float tex11[4] = { 1, 1, 0, 1 };
- static const float tex10[4] = { 1, 0, 0, 1 };
- set_texcoords( wide, v0, tex00 );
- set_texcoords( wide, v1, tex01 );
- set_texcoords( wide, v2, tex10 );
- set_texcoords( wide, v3, tex11 );
- }
-
- tri.det = header->det; /* only the sign matters */
- tri.v[0] = v0;
- tri.v[1] = v2;
- tri.v[2] = v3;
- stage->next->tri( stage->next, &tri );
-
- tri.v[0] = v0;
- tri.v[1] = v3;
- tri.v[2] = v1;
- stage->next->tri( stage->next, &tri );
-}
-
-
-static void wide_first_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct wide_stage *wide = wide_stage(stage);
- struct draw_context *draw = stage->draw;
-
- wide->half_point_size = 0.5f * draw->rasterizer->point_size;
-
- if (draw->rasterizer->point_size != 1.0) {
- stage->point = wide_point;
- }
- else {
- stage->point = passthrough_point;
- }
-
- if (draw->rasterizer->point_sprite) {
- /* find vertex shader texcoord outputs */
- const struct draw_vertex_shader *vs = draw->vertex_shader;
- uint i, j = 0;
- for (i = 0; i < vs->state->num_outputs; i++) {
- if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
- wide->texcoord_slot[j] = i;
- wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
- j++;
- }
- }
- wide->num_texcoords = j;
- }
-
- wide->psize_slot = -1;
-
- if (draw->rasterizer->point_size_per_vertex) {
- /* find PSIZ vertex output */
- const struct draw_vertex_shader *vs = draw->vertex_shader;
- uint i;
- for (i = 0; i < vs->state->num_outputs; i++) {
- if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
- wide->psize_slot = i;
- break;
- }
- }
- }
-
- stage->point( stage, header );
-}
-
-
-
-static void wide_first_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- struct wide_stage *wide = wide_stage(stage);
- struct draw_context *draw = stage->draw;
-
- wide->half_line_width = 0.5f * draw->rasterizer->line_width;
-
- if (draw->rasterizer->line_width != 1.0) {
- if (draw->rasterizer->line_smooth)
- wide->stage.line = wide_line_aa;
- else
- wide->stage.line = wide_line;
- }
- else {
- wide->stage.line = passthrough_line;
- }
-
- stage->line( stage, header );
-}
-
-
-static void wide_flush( struct draw_stage *stage, unsigned flags )
-{
- stage->line = wide_first_line;
- stage->point = wide_first_point;
- stage->next->flush( stage->next, flags );
-}
-
-
-static void draw_reset_stipple_counter( struct draw_stage *stage )
-{
- stage->next->reset_stipple_counter( stage->next );
-}
-
-
-static void wide_destroy( struct draw_stage *stage )
-{
- draw_free_tmps( stage );
- FREE( stage );
-}
-
-
-struct draw_stage *draw_wide_stage( struct draw_context *draw )
-{
- struct wide_stage *wide = CALLOC_STRUCT(wide_stage);
-
- draw_alloc_tmps( &wide->stage, 4 );
-
- wide->stage.draw = draw;
- wide->stage.next = NULL;
- wide->stage.point = wide_first_point;
- wide->stage.line = wide_first_line;
- wide->stage.tri = passthrough_tri;
- wide->stage.flush = wide_flush;
- wide->stage.reset_stipple_counter = draw_reset_stipple_counter;
- wide->stage.destroy = wide_destroy;
-
- return &wide->stage;
-}
diff --git a/src/mesa/pipe/failover/Makefile b/src/mesa/pipe/failover/Makefile
deleted file mode 100644
index 72d0895c74..0000000000
--- a/src/mesa/pipe/failover/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = failover
-
-DRIVER_SOURCES = \
- fo_state.c \
- fo_state_emit.c \
- fo_context.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-include ../Makefile.template
-
-symlinks:
-
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c
deleted file mode 100644
index 7ce4a7df17..0000000000
--- a/src/mesa/pipe/failover/fo_context.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-#include "pipe/p_context.h"
-
-#include "fo_context.h"
-#include "fo_winsys.h"
-
-
-
-static void failover_destroy( struct pipe_context *pipe )
-{
- struct failover_context *failover = failover_context( pipe );
-
- free( failover );
-}
-
-
-
-static boolean failover_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct failover_context *failover = failover_context( pipe );
-
- /* If there has been any statechange since last time, try hardware
- * rendering again:
- */
- if (failover->dirty) {
- failover->mode = FO_HW;
- }
-
- /* Try hardware:
- */
- if (failover->mode == FO_HW) {
- if (!failover->hw->draw_elements( failover->hw,
- indexBuffer,
- indexSize,
- prim,
- start,
- count )) {
-
- failover->hw->flush( failover->hw, ~0 );
- failover->mode = FO_SW;
- }
- }
-
- /* Possibly try software:
- */
- if (failover->mode == FO_SW) {
-
- if (failover->dirty)
- failover_state_emit( failover );
-
- failover->sw->draw_elements( failover->sw,
- indexBuffer,
- indexSize,
- prim,
- start,
- count );
-
- /* Be ready to switch back to hardware rendering without an
- * intervening flush. Unlikely to be much performance impact to
- * this:
- */
- failover->sw->flush( failover->sw, ~0 );
- }
-
- return TRUE;
-}
-
-
-static boolean failover_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- return failover_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-
-struct pipe_context *failover_create( struct pipe_context *hw,
- struct pipe_context *sw )
-{
- struct failover_context *failover = CALLOC_STRUCT(failover_context);
- if (failover == NULL)
- return NULL;
-
- failover->hw = hw;
- failover->sw = sw;
- failover->pipe.winsys = hw->winsys;
- failover->pipe.destroy = failover_destroy;
- failover->pipe.is_format_supported = hw->is_format_supported;
- failover->pipe.get_name = hw->get_name;
- failover->pipe.get_vendor = hw->get_vendor;
- failover->pipe.get_param = hw->get_param;
- failover->pipe.get_paramf = hw->get_paramf;
-
- failover->pipe.draw_arrays = failover_draw_arrays;
- failover->pipe.draw_elements = failover_draw_elements;
- failover->pipe.clear = hw->clear;
-
- /* No software occlusion fallback (or other optional functionality)
- * at this point - if the hardware doesn't support it, don't
- * advertise it to the application.
- */
- failover->pipe.begin_query = hw->begin_query;
- failover->pipe.end_query = hw->end_query;
-
- failover_init_state_functions( failover );
-
-#if 0
- failover->pipe.surface_alloc = hw->surface_alloc;
-#endif
- failover->pipe.get_tex_surface = hw->get_tex_surface;
-
- failover->pipe.surface_copy = hw->surface_copy;
- failover->pipe.surface_fill = hw->surface_fill;
- failover->pipe.texture_create = hw->texture_create;
- failover->pipe.texture_release = hw->texture_release;
- failover->pipe.flush = hw->flush;
-
- failover->dirty = 0;
-
- return &failover->pipe;
-}
-
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
deleted file mode 100644
index 1dc87291c9..0000000000
--- a/src/mesa/pipe/failover/fo_context.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef FO_CONTEXT_H
-#define FO_CONTEXT_H
-
-#include "pipe/p_state.h"
-#include "pipe/p_context.h"
-
-
-
-#define FO_NEW_VIEWPORT 0x1
-#define FO_NEW_RASTERIZER 0x2
-#define FO_NEW_FRAGMENT_SHADER 0x4
-#define FO_NEW_BLEND 0x8
-#define FO_NEW_CLIP 0x10
-#define FO_NEW_SCISSOR 0x20
-#define FO_NEW_STIPPLE 0x40
-#define FO_NEW_FRAMEBUFFER 0x80
-#define FO_NEW_ALPHA_TEST 0x100
-#define FO_NEW_DEPTH_STENCIL 0x200
-#define FO_NEW_SAMPLER 0x400
-#define FO_NEW_TEXTURE 0x800
-#define FO_NEW_VERTEX 0x2000
-#define FO_NEW_VERTEX_SHADER 0x4000
-#define FO_NEW_BLEND_COLOR 0x8000
-#define FO_NEW_CLEAR_COLOR 0x10000
-#define FO_NEW_VERTEX_BUFFER 0x20000
-#define FO_NEW_VERTEX_ELEMENT 0x40000
-
-
-
-#define FO_HW 0
-#define FO_SW 1
-
-struct fo_state {
- void *sw_state;
- void *hw_state;
-};
-struct failover_context {
- struct pipe_context pipe; /**< base class */
-
-
- /* The most recent drawing state as set by the driver:
- */
- const struct fo_state *blend;
- const struct fo_state *sampler[PIPE_MAX_SAMPLERS];
- const struct fo_state *depth_stencil;
- const struct fo_state *rasterizer;
- const struct fo_state *fragment_shader;
- const struct fo_state *vertex_shader;
-
- struct pipe_blend_color blend_color;
- struct pipe_clip_state clip;
- struct pipe_framebuffer_state framebuffer;
- struct pipe_poly_stipple poly_stipple;
- struct pipe_scissor_state scissor;
- struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
- struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
- struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
-
- unsigned dirty;
- unsigned dirty_sampler;
- unsigned dirty_texture;
- unsigned dirty_vertex_buffer;
- unsigned dirty_vertex_element;
-
-
- unsigned mode;
- struct pipe_context *hw;
- struct pipe_context *sw;
-};
-
-
-
-void failover_init_state_functions( struct failover_context *failover );
-void failover_state_emit( struct failover_context *failover );
-
-static INLINE struct failover_context *
-failover_context( struct pipe_context *pipe )
-{
- return (struct failover_context *)pipe;
-}
-
-
-#endif /* FO_CONTEXT_H */
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
deleted file mode 100644
index 0fc5568da1..0000000000
--- a/src/mesa/pipe/failover/fo_state.c
+++ /dev/null
@@ -1,457 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "fo_context.h"
-
-
-/* This looks like a lot of work at the moment - we're keeping a
- * duplicate copy of the state up-to-date.
- *
- * This can change in two ways:
- * - With constant state objects we would only need to save a pointer,
- * not the whole object.
- * - By adding a callback in the state tracker to re-emit state. The
- * state tracker knows the current state already and can re-emit it
- * without additional complexity.
- *
- * This works as a proof-of-concept, but a final version will have
- * lower overheads.
- */
-
-
-
-static void *
-failover_create_blend_state( struct pipe_context *pipe,
- const struct pipe_blend_state *blend )
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_blend_state(failover->sw, blend);
- state->hw_state = failover->hw->create_blend_state(failover->hw, blend);
-
- return state;
-}
-
-static void
-failover_bind_blend_state( struct pipe_context *pipe,
- void *blend )
-{
- struct failover_context *failover = failover_context(pipe);
- struct fo_state *state = (struct fo_state *)blend;
- failover->blend = state;
- failover->dirty |= FO_NEW_BLEND;
- failover->sw->bind_blend_state( failover->sw, state->sw_state );
- failover->hw->bind_blend_state( failover->hw, state->hw_state );
-}
-
-static void
-failover_delete_blend_state( struct pipe_context *pipe,
- void *blend )
-{
- struct fo_state *state = (struct fo_state*)blend;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_blend_state(failover->sw, state->sw_state);
- failover->hw->delete_blend_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-static void
-failover_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color )
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->blend_color = *blend_color;
- failover->dirty |= FO_NEW_BLEND_COLOR;
- failover->sw->set_blend_color( failover->sw, blend_color );
- failover->hw->set_blend_color( failover->hw, blend_color );
-}
-
-static void
-failover_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->clip = *clip;
- failover->dirty |= FO_NEW_CLIP;
- failover->sw->set_clip_state( failover->sw, clip );
- failover->hw->set_clip_state( failover->hw, clip );
-}
-
-
-static void *
-failover_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_depth_stencil_alpha_state(failover->sw, templ);
- state->hw_state = failover->hw->create_depth_stencil_alpha_state(failover->hw, templ);
-
- return state;
-}
-
-static void
-failover_bind_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct failover_context *failover = failover_context(pipe);
- struct fo_state *state = (struct fo_state *)depth_stencil;
- failover->depth_stencil = state;
- failover->dirty |= FO_NEW_DEPTH_STENCIL;
- failover->sw->bind_depth_stencil_alpha_state(failover->sw, state->sw_state);
- failover->hw->bind_depth_stencil_alpha_state(failover->hw, state->hw_state);
-}
-
-static void
-failover_delete_depth_stencil_state(struct pipe_context *pipe,
- void *ds)
-{
- struct fo_state *state = (struct fo_state*)ds;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_depth_stencil_alpha_state(failover->sw, state->sw_state);
- failover->hw->delete_depth_stencil_alpha_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-static void
-failover_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *framebuffer)
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->framebuffer = *framebuffer;
- failover->dirty |= FO_NEW_FRAMEBUFFER;
- failover->sw->set_framebuffer_state( failover->sw, framebuffer );
- failover->hw->set_framebuffer_state( failover->hw, framebuffer );
-}
-
-
-static void *
-failover_create_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_fs_state(failover->sw, templ);
- state->hw_state = failover->hw->create_fs_state(failover->hw, templ);
-
- return state;
-}
-
-static void
-failover_bind_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct failover_context *failover = failover_context(pipe);
- struct fo_state *state = (struct fo_state*)fs;
- failover->fragment_shader = state;
- failover->dirty |= FO_NEW_FRAGMENT_SHADER;
- failover->sw->bind_fs_state(failover->sw, state->sw_state);
- failover->hw->bind_fs_state(failover->hw, state->hw_state);
-}
-
-static void
-failover_delete_fs_state(struct pipe_context *pipe,
- void *fs)
-{
- struct fo_state *state = (struct fo_state*)fs;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_fs_state(failover->sw, state->sw_state);
- failover->hw->delete_fs_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-static void *
-failover_create_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_vs_state(failover->sw, templ);
- state->hw_state = failover->hw->create_vs_state(failover->hw, templ);
-
- return state;
-}
-
-static void
-failover_bind_vs_state(struct pipe_context *pipe,
- void *vs)
-{
- struct failover_context *failover = failover_context(pipe);
-
- struct fo_state *state = (struct fo_state*)vs;
- failover->vertex_shader = state;
- failover->dirty |= FO_NEW_VERTEX_SHADER;
- failover->sw->bind_vs_state(failover->sw, state->sw_state);
- failover->hw->bind_vs_state(failover->hw, state->hw_state);
-}
-
-static void
-failover_delete_vs_state(struct pipe_context *pipe,
- void *vs)
-{
- struct fo_state *state = (struct fo_state*)vs;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_vs_state(failover->sw, state->sw_state);
- failover->hw->delete_vs_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-static void
-failover_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->poly_stipple = *stipple;
- failover->dirty |= FO_NEW_STIPPLE;
- failover->sw->set_polygon_stipple( failover->sw, stipple );
- failover->hw->set_polygon_stipple( failover->hw, stipple );
-}
-
-
-static void *
-failover_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_rasterizer_state(failover->sw, templ);
- state->hw_state = failover->hw->create_rasterizer_state(failover->hw, templ);
-
- return state;
-}
-
-static void
-failover_bind_rasterizer_state(struct pipe_context *pipe,
- void *raster)
-{
- struct failover_context *failover = failover_context(pipe);
-
- struct fo_state *state = (struct fo_state*)raster;
- failover->rasterizer = state;
- failover->dirty |= FO_NEW_RASTERIZER;
- failover->sw->bind_rasterizer_state(failover->sw, state->sw_state);
- failover->hw->bind_rasterizer_state(failover->hw, state->hw_state);
-}
-
-static void
-failover_delete_rasterizer_state(struct pipe_context *pipe,
- void *raster)
-{
- struct fo_state *state = (struct fo_state*)raster;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_rasterizer_state(failover->sw, state->sw_state);
- failover->hw->delete_rasterizer_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-
-static void
-failover_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->scissor = *scissor;
- failover->dirty |= FO_NEW_SCISSOR;
- failover->sw->set_scissor_state( failover->sw, scissor );
- failover->hw->set_scissor_state( failover->hw, scissor );
-}
-
-
-static void *
-failover_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *templ)
-{
- struct fo_state *state = malloc(sizeof(struct fo_state));
- struct failover_context *failover = failover_context(pipe);
-
- state->sw_state = failover->sw->create_sampler_state(failover->sw, templ);
- state->hw_state = failover->hw->create_sampler_state(failover->hw, templ);
-
- return state;
-}
-
-static void
-failover_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct failover_context *failover = failover_context(pipe);
- struct fo_state *state = (struct fo_state*)sampler;
- failover->sampler[unit] = state;
- failover->dirty |= FO_NEW_SAMPLER;
- failover->dirty_sampler |= (1<<unit);
- failover->sw->bind_sampler_state(failover->sw, unit,
- state->sw_state);
- failover->hw->bind_sampler_state(failover->hw, unit,
- state->hw_state);
-}
-
-static void
-failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
-{
- struct fo_state *state = (struct fo_state*)sampler;
- struct failover_context *failover = failover_context(pipe);
-
- failover->sw->delete_sampler_state(failover->sw, state->sw_state);
- failover->hw->delete_sampler_state(failover->hw, state->hw_state);
- state->sw_state = 0;
- state->hw_state = 0;
- free(state);
-}
-
-
-static void
-failover_set_sampler_texture(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->texture[unit] = texture;
- failover->dirty |= FO_NEW_TEXTURE;
- failover->dirty_texture |= (1<<unit);
- failover->sw->set_sampler_texture( failover->sw, unit, texture );
- failover->hw->set_sampler_texture( failover->hw, unit, texture );
-}
-
-
-static void
-failover_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->viewport = *viewport;
- failover->dirty |= FO_NEW_VIEWPORT;
- failover->sw->set_viewport_state( failover->sw, viewport );
- failover->hw->set_viewport_state( failover->hw, viewport );
-}
-
-
-static void
-failover_set_vertex_buffer(struct pipe_context *pipe,
- unsigned unit,
- const struct pipe_vertex_buffer *vertex_buffer)
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->vertex_buffer[unit] = *vertex_buffer;
- failover->dirty |= FO_NEW_VERTEX_BUFFER;
- failover->dirty_vertex_buffer |= (1<<unit);
- failover->sw->set_vertex_buffer( failover->sw, unit, vertex_buffer );
- failover->hw->set_vertex_buffer( failover->hw, unit, vertex_buffer );
-}
-
-
-static void
-failover_set_vertex_element(struct pipe_context *pipe,
- unsigned unit,
- const struct pipe_vertex_element *vertex_element)
-{
- struct failover_context *failover = failover_context(pipe);
-
- failover->vertex_element[unit] = *vertex_element;
- failover->dirty |= FO_NEW_VERTEX_ELEMENT;
- failover->dirty_vertex_element |= (1<<unit);
- failover->sw->set_vertex_element( failover->sw, unit, vertex_element );
- failover->hw->set_vertex_element( failover->hw, unit, vertex_element );
-}
-
-void
-failover_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf)
-{
- struct failover_context *failover = failover_context(pipe);
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- failover->sw->set_constant_buffer(failover->sw, shader, index, buf);
- failover->hw->set_constant_buffer(failover->hw, shader, index, buf);
-}
-
-
-void
-failover_init_state_functions( struct failover_context *failover )
-{
- failover->pipe.create_blend_state = failover_create_blend_state;
- failover->pipe.bind_blend_state = failover_bind_blend_state;
- failover->pipe.delete_blend_state = failover_delete_blend_state;
- failover->pipe.create_sampler_state = failover_create_sampler_state;
- failover->pipe.bind_sampler_state = failover_bind_sampler_state;
- failover->pipe.delete_sampler_state = failover_delete_sampler_state;
- failover->pipe.create_depth_stencil_alpha_state = failover_create_depth_stencil_state;
- failover->pipe.bind_depth_stencil_alpha_state = failover_bind_depth_stencil_state;
- failover->pipe.delete_depth_stencil_alpha_state = failover_delete_depth_stencil_state;
- failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
- failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
- failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
- failover->pipe.create_fs_state = failover_create_fs_state;
- failover->pipe.bind_fs_state = failover_bind_fs_state;
- failover->pipe.delete_fs_state = failover_delete_fs_state;
- failover->pipe.create_vs_state = failover_create_vs_state;
- failover->pipe.bind_vs_state = failover_bind_vs_state;
- failover->pipe.delete_vs_state = failover_delete_vs_state;
-
- failover->pipe.set_blend_color = failover_set_blend_color;
- failover->pipe.set_clip_state = failover_set_clip_state;
- failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
- failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
- failover->pipe.set_scissor_state = failover_set_scissor_state;
- failover->pipe.set_sampler_texture = failover_set_sampler_texture;
- failover->pipe.set_viewport_state = failover_set_viewport_state;
- failover->pipe.set_vertex_buffer = failover_set_vertex_buffer;
- failover->pipe.set_vertex_element = failover_set_vertex_element;
- failover->pipe.set_constant_buffer = failover_set_constant_buffer;
-}
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
deleted file mode 100644
index c663dd4947..0000000000
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "fo_context.h"
-
-/* This looks like a lot of work at the moment - we're keeping a
- * duplicate copy of the state up-to-date.
- *
- * This can change in two ways:
- * - With constant state objects we would only need to save a pointer,
- * not the whole object.
- * - By adding a callback in the state tracker to re-emit state. The
- * state tracker knows the current state already and can re-emit it
- * without additional complexity.
- *
- * This works as a proof-of-concept, but a final version will have
- * lower overheads.
- */
-
-
-/* Bring the software pipe uptodate with current state.
- *
- * With constant state objects we would probably just send all state
- * to both rasterizers all the time???
- */
-void
-failover_state_emit( struct failover_context *failover )
-{
- unsigned i;
-
- if (failover->dirty & FO_NEW_BLEND)
- failover->sw->bind_blend_state( failover->sw,
- failover->blend->sw_state );
-
- if (failover->dirty & FO_NEW_BLEND_COLOR)
- failover->sw->set_blend_color( failover->sw, &failover->blend_color );
-
- if (failover->dirty & FO_NEW_CLIP)
- failover->sw->set_clip_state( failover->sw, &failover->clip );
-
- if (failover->dirty & FO_NEW_DEPTH_STENCIL)
- failover->sw->bind_depth_stencil_alpha_state( failover->sw,
- failover->depth_stencil->sw_state );
-
- if (failover->dirty & FO_NEW_FRAMEBUFFER)
- failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
-
- if (failover->dirty & FO_NEW_FRAGMENT_SHADER)
- failover->sw->bind_fs_state( failover->sw,
- failover->fragment_shader->sw_state );
-
- if (failover->dirty & FO_NEW_VERTEX_SHADER)
- failover->sw->bind_vs_state( failover->sw,
- failover->vertex_shader->sw_state );
-
- if (failover->dirty & FO_NEW_STIPPLE)
- failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
-
- if (failover->dirty & FO_NEW_RASTERIZER)
- failover->sw->bind_rasterizer_state( failover->sw,
- failover->rasterizer->sw_state );
-
- if (failover->dirty & FO_NEW_SCISSOR)
- failover->sw->set_scissor_state( failover->sw, &failover->scissor );
-
- if (failover->dirty & FO_NEW_VIEWPORT)
- failover->sw->set_viewport_state( failover->sw, &failover->viewport );
-
- if (failover->dirty & FO_NEW_SAMPLER) {
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- if (failover->dirty_sampler & (1<<i)) {
- failover->sw->bind_sampler_state( failover->sw, i,
- failover->sampler[i]->sw_state );
- }
- }
- }
-
- if (failover->dirty & FO_NEW_TEXTURE) {
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- if (failover->dirty_texture & (1<<i)) {
- failover->sw->set_sampler_texture( failover->sw, i,
- failover->texture[i] );
- }
- }
- }
-
- if (failover->dirty & FO_NEW_VERTEX_BUFFER) {
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (failover->dirty_vertex_buffer & (1<<i)) {
- failover->sw->set_vertex_buffer( failover->sw, i,
- &failover->vertex_buffer[i] );
- }
- }
- }
-
- if (failover->dirty & FO_NEW_VERTEX_ELEMENT) {
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (failover->dirty_vertex_element & (1<<i)) {
- failover->sw->set_vertex_element( failover->sw, i,
- &failover->vertex_element[i] );
- }
- }
- }
-
- failover->dirty = 0;
- failover->dirty_vertex_element = 0;
- failover->dirty_vertex_buffer = 0;
- failover->dirty_texture = 0;
- failover->dirty_sampler = 0;
-}
diff --git a/src/mesa/pipe/failover/fo_winsys.h b/src/mesa/pipe/failover/fo_winsys.h
deleted file mode 100644
index a8ce997a1f..0000000000
--- a/src/mesa/pipe/failover/fo_winsys.h
+++ /dev/null
@@ -1,45 +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 FO_WINSYS_H
-#define FO_WINSYS_H
-
-
-/* This is the interface that failover requires any window system
- * hosting it to implement. This is the only include file in failover
- * which is public.
- */
-
-
-struct pipe_context;
-
-
-struct pipe_context *failover_create( struct pipe_context *hw,
- struct pipe_context *sw );
-
-
-#endif /* FO_WINSYS_H */
diff --git a/src/mesa/pipe/i915simple/Makefile b/src/mesa/pipe/i915simple/Makefile
deleted file mode 100644
index 2f91de3afc..0000000000
--- a/src/mesa/pipe/i915simple/Makefile
+++ /dev/null
@@ -1,38 +0,0 @@
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i915simple
-
-DRIVER_SOURCES = \
- i915_blit.c \
- i915_clear.c \
- i915_flush.c \
- i915_context.c \
- i915_context.c \
- i915_debug.c \
- i915_debug_fp.c \
- i915_state.c \
- i915_state_immediate.c \
- i915_state_dynamic.c \
- i915_state_derived.c \
- i915_state_emit.c \
- i915_state_sampler.c \
- i915_strings.c \
- i915_prim_emit.c \
- i915_prim_vbuf.c \
- i915_texture.c \
- i915_fpc_emit.c \
- i915_fpc_translate.c \
- i915_surface.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-include ../Makefile.template
-
-symlinks:
-
diff --git a/src/mesa/pipe/i915simple/SConscript b/src/mesa/pipe/i915simple/SConscript
deleted file mode 100644
index f5fb96b995..0000000000
--- a/src/mesa/pipe/i915simple/SConscript
+++ /dev/null
@@ -1,29 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-i915simple = env.ConvenienceLibrary(
- target = 'i915simple',
- source = [
- 'i915_blit.c',
- 'i915_clear.c',
- 'i915_context.c',
- 'i915_debug.c',
- 'i915_debug_fp.c',
- 'i915_flush.c',
- 'i915_fpc_emit.c',
- 'i915_fpc_translate.c',
- 'i915_prim_emit.c',
- 'i915_prim_vbuf.c',
- 'i915_state.c',
- 'i915_state_derived.c',
- 'i915_state_dynamic.c',
- 'i915_state_emit.c',
- 'i915_state_immediate.c',
- 'i915_state_sampler.c',
- 'i915_strings.c',
- 'i915_surface.c',
- 'i915_texture.c',
- ])
-
-Export('i915simple')
diff --git a/src/mesa/pipe/i915simple/i915_batch.h b/src/mesa/pipe/i915simple/i915_batch.h
deleted file mode 100644
index fb88cd6db0..0000000000
--- a/src/mesa/pipe/i915simple/i915_batch.h
+++ /dev/null
@@ -1,54 +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 I915_BATCH_H
-#define I915_BATCH_H
-
-#include "i915_winsys.h"
-#include "i915_debug.h"
-
-#define BATCH_LOCALS
-
-#define BEGIN_BATCH( dwords, relocs ) \
- (i915->batch_start = i915->winsys->batch_start( i915->winsys, dwords, relocs ))
-
-#define OUT_BATCH( dword ) \
- i915->winsys->batch_dword( i915->winsys, dword )
-
-#define OUT_RELOC( buf, flags, delta ) \
- i915->winsys->batch_reloc( i915->winsys, buf, flags, delta )
-
-#define ADVANCE_BATCH()
-
-#define FLUSH_BATCH() do { \
- if (0) i915_dump_batchbuffer( i915 ); \
- i915->winsys->batch_flush( i915->winsys ); \
- i915->batch_start = NULL; \
- i915->hardware_dirty = ~0; \
-} while (0)
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_blit.c b/src/mesa/pipe/i915simple/i915_blit.c
deleted file mode 100644
index db4671ff55..0000000000
--- a/src/mesa/pipe/i915simple/i915_blit.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i915_context.h"
-#include "i915_winsys.h"
-#include "i915_blit.h"
-#include "i915_reg.h"
-#include "i915_batch.h"
-
-#define FILE_DEBUG_FLAG DEBUG_BLIT
-
-void
-i915_fill_blit(struct i915_context *i915,
- unsigned cpp,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- short x, short y,
- short w, short h,
- unsigned color)
-{
- unsigned BR13, CMD;
- BATCH_LOCALS;
-
- dst_pitch *= (short) cpp;
-
- switch (cpp) {
- case 1:
- case 2:
- case 3:
- BR13 = dst_pitch | (0xF0 << 16) | (1 << 24);
- CMD = XY_COLOR_BLT_CMD;
- break;
- case 4:
- BR13 = dst_pitch | (0xF0 << 16) | (1 << 24) | (1 << 25);
- CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA |
- XY_COLOR_BLT_WRITE_RGB);
- break;
- default:
- return;
- }
-
-// DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
-// __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h);
-
-
- if (!BEGIN_BATCH(6, 1)) {
- FLUSH_BATCH();
- assert(BEGIN_BATCH(6, 1));
- }
- OUT_BATCH(CMD);
- OUT_BATCH(BR13);
- OUT_BATCH((y << 16) | x);
- OUT_BATCH(((y + h) << 16) | (x + w));
- OUT_RELOC( dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
- OUT_BATCH(color);
- ADVANCE_BATCH();
-}
-
-
-void
-i915_copy_blit( struct i915_context *i915,
- unsigned do_flip,
- unsigned cpp,
- short src_pitch,
- struct pipe_buffer *src_buffer,
- unsigned src_offset,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- short src_x, short src_y,
- short dst_x, short dst_y,
- short w, short h )
-{
- unsigned CMD, BR13;
- int dst_y2 = dst_y + h;
- int dst_x2 = dst_x + w;
- BATCH_LOCALS;
-
-
- I915_DBG(i915,
- "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
- __FUNCTION__,
- src_buffer, src_pitch, src_offset, src_x, src_y,
- dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h);
-
- src_pitch *= (short) cpp;
- dst_pitch *= (short) cpp;
-
- switch (cpp) {
- case 1:
- case 2:
- case 3:
- BR13 = (((int) dst_pitch) & 0xffff) |
- (0xCC << 16) | (1 << 24);
- CMD = XY_SRC_COPY_BLT_CMD;
- break;
- case 4:
- BR13 =
- (((int) dst_pitch) & 0xffff) |
- (0xCC << 16) | (1 << 24) | (1 << 25);
- CMD =
- (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB);
- break;
- default:
- return;
- }
-
- if (dst_y2 < dst_y ||
- dst_x2 < dst_x) {
- return;
- }
-
- /* Hardware can handle negative pitches but loses the ability to do
- * proper overlapping blits in that case. We don't really have a
- * need for either at this stage.
- */
- assert (dst_pitch > 0 && src_pitch > 0);
-
-
- if (!BEGIN_BATCH(8, 2)) {
- FLUSH_BATCH();
- assert(BEGIN_BATCH(8, 2));
- }
- OUT_BATCH(CMD);
- OUT_BATCH(BR13);
- OUT_BATCH((dst_y << 16) | dst_x);
- OUT_BATCH((dst_y2 << 16) | dst_x2);
- OUT_RELOC(dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
- OUT_BATCH((src_y << 16) | src_x);
- OUT_BATCH(((int) src_pitch & 0xffff));
- OUT_RELOC(src_buffer, I915_BUFFER_ACCESS_READ, src_offset);
- ADVANCE_BATCH();
-}
-
-
diff --git a/src/mesa/pipe/i915simple/i915_blit.h b/src/mesa/pipe/i915simple/i915_blit.h
deleted file mode 100644
index 6e5b44e124..0000000000
--- a/src/mesa/pipe/i915simple/i915_blit.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef I915_BLIT_H
-#define I915_BLIT_H
-
-#include "i915_context.h"
-
-extern void i915_copy_blit(struct i915_context *i915,
- unsigned do_flip,
- unsigned cpp,
- short src_pitch,
- struct pipe_buffer *src_buffer,
- unsigned src_offset,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- short srcx, short srcy,
- short dstx, short dsty,
- short w, short h );
-
-extern void i915_fill_blit(struct i915_context *i915,
- unsigned cpp,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- short x, short y,
- short w, short h, unsigned color);
-
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_clear.c b/src/mesa/pipe/i915simple/i915_clear.c
deleted file mode 100644
index cde69daacc..0000000000
--- a/src/mesa/pipe/i915simple/i915_clear.c
+++ /dev/null
@@ -1,47 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- */
-
-
-#include "pipe/p_defines.h"
-#include "i915_context.h"
-#include "i915_state.h"
-
-
-/**
- * Clear the given surface to the specified value.
- * No masking, no scissor (clear entire buffer).
- */
-void
-i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
-}
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
deleted file mode 100644
index 497623a700..0000000000
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ /dev/null
@@ -1,320 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "i915_context.h"
-#include "i915_winsys.h"
-#include "i915_state.h"
-#include "i915_batch.h"
-#include "i915_texture.h"
-#include "i915_reg.h"
-
-#include "pipe/draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-
-
-/**
- * Query format support for creating a texture, drawing surface, etc.
- * \param format the format to test
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
- */
-static boolean
-i915_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- static const enum pipe_format tex_supported[] = {
- PIPE_FORMAT_R8G8B8A8_UNORM,
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_R5G6B5_UNORM,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_A8_L8,
- PIPE_FORMAT_YCBCR,
- PIPE_FORMAT_YCBCR_REV,
- PIPE_FORMAT_S8Z24_UNORM,
- PIPE_FORMAT_NONE /* list terminator */
- };
- static const enum pipe_format surface_supported[] = {
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_R5G6B5_UNORM,
- PIPE_FORMAT_S8Z24_UNORM,
- /*PIPE_FORMAT_R16G16B16A16_SNORM,*/
- PIPE_FORMAT_NONE /* list terminator */
- };
- const enum pipe_format *list;
- uint i;
-
- switch (type) {
- case PIPE_TEXTURE:
- list = tex_supported;
- break;
- case PIPE_SURFACE:
- list = surface_supported;
- break;
- default:
- assert(0);
- }
-
- for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
- if (list[i] == format)
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-static int
-i915_get_param(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 8;
- case PIPE_CAP_NPOT_TEXTURES:
- return 1;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 1;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 11; /* max 1024x1024 */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 11; /* max 1024x1024 */
- default:
- return 0;
- }
-}
-
-
-static float
-i915_get_paramf(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 7.5;
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0;
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 4.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0;
-
- default:
- return 0;
- }
-}
-
-
-static void i915_destroy( struct pipe_context *pipe )
-{
- struct i915_context *i915 = i915_context( pipe );
-
- draw_destroy( i915->draw );
-
- FREE( i915 );
-}
-
-
-
-
-static boolean
-i915_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned prim, unsigned start, unsigned count)
-{
- struct i915_context *i915 = i915_context( pipe );
- struct draw_context *draw = i915->draw;
- unsigned i;
-
- if (i915->dirty)
- i915_update_derived( i915 );
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (i915->vertex_buffer[i].buffer) {
- void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
- i915->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
-
- draw_set_mapped_constant_buffer(draw,
- i915->current.constants[PIPE_SHADER_VERTEX]);
-
- /* draw! */
- draw_arrays(i915->draw, prim, start, count);
-
- /*
- * unmap vertex/index buffers
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (i915->vertex_buffer[i].buffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer);
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- }
- }
- if (indexBuffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
- return TRUE;
-}
-
-
-static boolean i915_draw_arrays( struct pipe_context *pipe,
- unsigned prim, unsigned start, unsigned count)
-{
- return i915_draw_elements(pipe, NULL, 0, prim, start, count);
-}
-
-
-
-struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
- struct i915_winsys *i915_winsys,
- unsigned pci_id )
-{
- struct i915_context *i915;
- unsigned is_i945 = 0;
-
- switch (pci_id) {
- case PCI_CHIP_I915_G:
- case PCI_CHIP_I915_GM:
- break;
-
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
- case PCI_CHIP_I945_GME:
- case PCI_CHIP_G33_G:
- case PCI_CHIP_Q33_G:
- case PCI_CHIP_Q35_G:
- is_i945 = 1;
- break;
-
- default:
- pipe_winsys->printf(pipe_winsys,
- "%s: unknown pci id 0x%x, cannot create context\n",
- __FUNCTION__, pci_id);
- return NULL;
- }
-
- i915 = CALLOC_STRUCT(i915_context);
- if (i915 == NULL)
- return NULL;
-
- i915->winsys = i915_winsys;
- i915->pipe.winsys = pipe_winsys;
-
- i915->pipe.destroy = i915_destroy;
- i915->pipe.is_format_supported = i915_is_format_supported;
- i915->pipe.get_param = i915_get_param;
- i915->pipe.get_paramf = i915_get_paramf;
-
- i915->pipe.clear = i915_clear;
-
-
- i915->pipe.draw_arrays = i915_draw_arrays;
- i915->pipe.draw_elements = i915_draw_elements;
-
- /*
- * Create drawing context and plug our rendering stage into it.
- */
- i915->draw = draw_create();
- assert(i915->draw);
- if (GETENV("I915_VBUF")) {
- draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915));
- }
- else {
- draw_set_rasterize_stage(i915->draw, i915_draw_render_stage(i915));
- }
-
- i915_init_surface_functions(i915);
- i915_init_state_functions(i915);
- i915_init_flush_functions(i915);
- i915_init_string_functions(i915);
-
- i915->pci_id = pci_id;
- i915->flags.is_i945 = is_i945;
-
- i915->pipe.texture_create = i915_texture_create;
- i915->pipe.texture_release = i915_texture_release;
-
- i915->dirty = ~0;
- i915->hardware_dirty = ~0;
-
- /* Batch stream debugging is a bit hacked up at the moment:
- */
- i915->batch_start = NULL;
-
- /*
- * XXX we could plug GL selection/feedback into the drawing pipeline
- * by specifying a different setup/render stage.
- */
-
- return &i915->pipe;
-}
-
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
deleted file mode 100644
index b4ea63c3e7..0000000000
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ /dev/null
@@ -1,304 +0,0 @@
- /**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef I915_CONTEXT_H
-#define I915_CONTEXT_H
-
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "pipe/draw/draw_vertex.h"
-
-
-#define I915_TEX_UNITS 8
-
-#define I915_DYNAMIC_MODES4 0
-#define I915_DYNAMIC_DEPTHSCALE_0 1 /* just the header */
-#define I915_DYNAMIC_DEPTHSCALE_1 2
-#define I915_DYNAMIC_IAB 3
-#define I915_DYNAMIC_BC_0 4 /* just the header */
-#define I915_DYNAMIC_BC_1 5
-#define I915_DYNAMIC_BFO_0 6
-#define I915_DYNAMIC_BFO_1 7
-#define I915_DYNAMIC_STP_0 8
-#define I915_DYNAMIC_STP_1 9
-#define I915_DYNAMIC_SC_ENA_0 10
-#define I915_DYNAMIC_SC_RECT_0 11
-#define I915_DYNAMIC_SC_RECT_1 12
-#define I915_DYNAMIC_SC_RECT_2 13
-#define I915_MAX_DYNAMIC 14
-
-
-#define I915_IMMEDIATE_S0 0
-#define I915_IMMEDIATE_S1 1
-#define I915_IMMEDIATE_S2 2
-#define I915_IMMEDIATE_S3 3
-#define I915_IMMEDIATE_S4 4
-#define I915_IMMEDIATE_S5 5
-#define I915_IMMEDIATE_S6 6
-#define I915_IMMEDIATE_S7 7
-#define I915_MAX_IMMEDIATE 8
-
-/* These must mach the order of LI0_STATE_* bits, as they will be used
- * to generate hardware packets:
- */
-#define I915_CACHE_STATIC 0
-#define I915_CACHE_DYNAMIC 1 /* handled specially */
-#define I915_CACHE_SAMPLER 2
-#define I915_CACHE_MAP 3
-#define I915_CACHE_PROGRAM 4
-#define I915_CACHE_CONSTANTS 5
-#define I915_MAX_CACHE 6
-
-#define I915_MAX_CONSTANT 32
-
-
-
-struct i915_cache_context;
-
-/* Use to calculate differences between state emitted to hardware and
- * current driver-calculated state.
- */
-struct i915_state
-{
- unsigned immediate[I915_MAX_IMMEDIATE];
- unsigned dynamic[I915_MAX_DYNAMIC];
-
- float constants[PIPE_SHADER_TYPES][I915_MAX_CONSTANT][4];
- /** number of constants passed in through a constant buffer */
- uint num_user_constants[PIPE_SHADER_TYPES];
- /** user constants, plus extra constants from shader translation */
- uint num_constants[PIPE_SHADER_TYPES];
-
- uint *program;
- uint program_len;
-
- /* texture sampler state */
- unsigned sampler[I915_TEX_UNITS][3];
- unsigned sampler_enable_flags;
- unsigned sampler_enable_nr;
-
- /* texture image buffers */
- unsigned texbuffer[I915_TEX_UNITS][2];
-
- /** Describes the current hardware vertex layout */
- struct vertex_info vertex_info;
-
- unsigned id; /* track lost context events */
-};
-
-struct i915_blend_state {
- unsigned iab;
- unsigned modes4;
- unsigned LIS5;
- unsigned LIS6;
-};
-
-struct i915_depth_stencil_state {
- unsigned stencil_modes4;
- unsigned bfo[2];
- unsigned stencil_LIS5;
- unsigned depth_LIS6;
-};
-
-struct i915_rasterizer_state {
- int light_twoside : 1;
- unsigned st;
- enum interp_mode color_interp;
-
- unsigned LIS4;
- unsigned LIS7;
- unsigned sc[1];
-
- const struct pipe_rasterizer_state *templ;
-
- union { float f; unsigned u; } ds[2];
-};
-
-struct i915_sampler_state {
- unsigned state[3];
- const struct pipe_sampler_state *templ;
-};
-
-
-struct i915_texture {
- struct pipe_texture base;
-
- /* Derived from the above:
- */
- unsigned pitch;
- unsigned depth_pitch; /* per-image on i945? */
- unsigned total_height;
-
- unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
-
- /* Explicitly store the offset of each image for each cube face or
- * depth value. Pretty much have to accept that hardware formats
- * are going to be so diverse that there is no unified way to
- * compute the offsets of depth/cube images within a mipmap level,
- * so have to store them as a lookup table:
- */
- unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */
-
- /* Includes image offset tables:
- */
- unsigned level_offset[PIPE_MAX_TEXTURE_LEVELS];
-
- /* The data is held here:
- */
- struct pipe_buffer *buffer;
-};
-
-struct i915_context
-{
- struct pipe_context pipe;
- struct i915_winsys *winsys;
- struct draw_context *draw;
-
- /* The most recent drawing state as set by the driver:
- */
- const struct i915_blend_state *blend;
- const struct i915_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct i915_depth_stencil_state *depth_stencil;
- const struct i915_rasterizer_state *rasterizer;
- const struct pipe_shader_state *fs;
-
- struct pipe_blend_color blend_color;
- struct pipe_clip_state clip;
- struct pipe_constant_buffer constants[PIPE_SHADER_TYPES];
- struct pipe_framebuffer_state framebuffer;
- struct pipe_poly_stipple poly_stipple;
- struct pipe_scissor_state scissor;
- struct i915_texture *texture[PIPE_MAX_SAMPLERS];
- struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
-
- unsigned dirty;
-
- unsigned *batch_start;
-
- /** Vertex buffer */
- struct pipe_buffer *vbo;
-
- struct i915_state current;
- unsigned hardware_dirty;
-
- unsigned debug;
- unsigned pci_id;
-
- struct {
- unsigned is_i945:1;
- } flags;
-};
-
-/* A flag for each state_tracker state object:
- */
-#define I915_NEW_VIEWPORT 0x1
-#define I915_NEW_RASTERIZER 0x2
-#define I915_NEW_FS 0x4
-#define I915_NEW_BLEND 0x8
-#define I915_NEW_CLIP 0x10
-#define I915_NEW_SCISSOR 0x20
-#define I915_NEW_STIPPLE 0x40
-#define I915_NEW_FRAMEBUFFER 0x80
-#define I915_NEW_ALPHA_TEST 0x100
-#define I915_NEW_DEPTH_STENCIL 0x200
-#define I915_NEW_SAMPLER 0x400
-#define I915_NEW_TEXTURE 0x800
-#define I915_NEW_CONSTANTS 0x1000
-#define I915_NEW_VBO 0x2000
-
-
-/* Driver's internally generated state flags:
- */
-#define I915_NEW_VERTEX_FORMAT 0x10000
-
-
-/* Dirty flags for hardware emit
- */
-#define I915_HW_STATIC (1<<I915_CACHE_STATIC)
-#define I915_HW_DYNAMIC (1<<I915_CACHE_DYNAMIC)
-#define I915_HW_SAMPLER (1<<I915_CACHE_SAMPLER)
-#define I915_HW_MAP (1<<I915_CACHE_MAP)
-#define I915_HW_PROGRAM (1<<I915_CACHE_PROGRAM)
-#define I915_HW_CONSTANTS (1<<I915_CACHE_CONSTANTS)
-#define I915_HW_IMMEDIATE (1<<(I915_MAX_CACHE+0))
-#define I915_HW_INVARIENT (1<<(I915_MAX_CACHE+1))
-
-
-/***********************************************************************
- * i915_prim_emit.c:
- */
-struct draw_stage *i915_draw_render_stage( struct i915_context *i915 );
-
-
-/***********************************************************************
- * i915_prim_vbuf.c:
- */
-struct draw_stage *i915_draw_vbuf_stage( struct i915_context *i915 );
-
-
-/***********************************************************************
- * i915_state_emit.c:
- */
-void i915_emit_hardware_state(struct i915_context *i915 );
-
-
-
-/***********************************************************************
- * i915_clear.c:
- */
-void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
-
-
-/***********************************************************************
- * i915_surface.c:
- */
-void i915_init_surface_functions( struct i915_context *i915 );
-
-void i915_init_state_functions( struct i915_context *i915 );
-void i915_init_flush_functions( struct i915_context *i915 );
-void i915_init_string_functions( struct i915_context *i915 );
-
-
-
-/***********************************************************************
- * Inline conversion functions. These are better-typed than the
- * macros used previously:
- */
-static INLINE struct i915_context *
-i915_context( struct pipe_context *pipe )
-{
- return (struct i915_context *)pipe;
-}
-
-
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_debug.c b/src/mesa/pipe/i915simple/i915_debug.c
deleted file mode 100644
index 94db44e1aa..0000000000
--- a/src/mesa/pipe/i915simple/i915_debug.c
+++ /dev/null
@@ -1,901 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-//#include "imports.h"
-
-#include "i915_reg.h"
-#include "i915_context.h"
-#include "i915_winsys.h"
-#include "i915_debug.h"
-#include "pipe/p_winsys.h"
-
-
-static void
-PRINTF(
- struct debug_stream *stream,
- const char *fmt,
- ... )
-{
- va_list args;
- char buffer[256];
-
- va_start( args, fmt );
- vsprintf( buffer, fmt, args );
- stream->winsys->printf( stream->winsys, buffer );
- va_end( args );
-}
-
-
-static boolean debug( struct debug_stream *stream, const char *name, unsigned len )
-{
- unsigned i;
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
-
- if (len == 0) {
- PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]);
- assert(0);
- return FALSE;
- }
-
- if (stream->print_addresses)
- PRINTF(stream, "%08x: ", stream->offset);
-
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- for (i = 0; i < len; i++)
- PRINTF(stream, "\t0x%08x\n", ptr[i]);
- PRINTF(stream, "\n");
-
- stream->offset += len * sizeof(unsigned);
-
- return TRUE;
-}
-
-
-static const char *get_prim_name( unsigned val )
-{
- switch (val & PRIM3D_MASK) {
- case PRIM3D_TRILIST: return "TRILIST"; break;
- case PRIM3D_TRISTRIP: return "TRISTRIP"; break;
- case PRIM3D_TRISTRIP_RVRSE: return "TRISTRIP_RVRSE"; break;
- case PRIM3D_TRIFAN: return "TRIFAN"; break;
- case PRIM3D_POLY: return "POLY"; break;
- case PRIM3D_LINELIST: return "LINELIST"; break;
- case PRIM3D_LINESTRIP: return "LINESTRIP"; break;
- case PRIM3D_RECTLIST: return "RECTLIST"; break;
- case PRIM3D_POINTLIST: return "POINTLIST"; break;
- case PRIM3D_DIB: return "DIB"; break;
- case PRIM3D_CLEAR_RECT: return "CLEAR_RECT"; break;
- case PRIM3D_ZONE_INIT: return "ZONE_INIT"; break;
- default: return "????"; break;
- }
-}
-
-static boolean debug_prim( struct debug_stream *stream, const char *name,
- boolean dump_floats,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- const char *prim = get_prim_name( ptr[0] );
- unsigned i;
-
-
-
- PRINTF(stream, "%s %s (%d dwords):\n", name, prim, len);
- PRINTF(stream, "\t0x%08x\n", ptr[0]);
- for (i = 1; i < len; i++) {
- if (dump_floats)
- PRINTF(stream, "\t0x%08x // %f\n", ptr[i], *(float *)&ptr[i]);
- else
- PRINTF(stream, "\t0x%08x\n", ptr[i]);
- }
-
-
- PRINTF(stream, "\n");
-
- stream->offset += len * sizeof(unsigned);
-
- return TRUE;
-}
-
-
-
-
-static boolean debug_program( struct debug_stream *stream, const char *name, unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
-
- if (len == 0) {
- PRINTF(stream, "Error - zero length packet (0x%08x)\n", stream->ptr[0]);
- assert(0);
- return FALSE;
- }
-
- if (stream->print_addresses)
- PRINTF(stream, "%08x: ", stream->offset);
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- i915_disassemble_program( stream, ptr, len );
-
- stream->offset += len * sizeof(unsigned);
- return TRUE;
-}
-
-
-static boolean debug_chain( struct debug_stream *stream, const char *name, unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned old_offset = stream->offset + len * sizeof(unsigned);
- unsigned i;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- for (i = 0; i < len; i++)
- PRINTF(stream, "\t0x%08x\n", ptr[i]);
-
- stream->offset = ptr[1] & ~0x3;
-
- if (stream->offset < old_offset)
- PRINTF(stream, "\n... skipping backwards from 0x%x --> 0x%x ...\n\n",
- old_offset, stream->offset );
- else
- PRINTF(stream, "\n... skipping from 0x%x --> 0x%x ...\n\n",
- old_offset, stream->offset );
-
-
- return TRUE;
-}
-
-
-static boolean debug_variable_length_prim( struct debug_stream *stream )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- const char *prim = get_prim_name( ptr[0] );
- unsigned i, len;
-
- ushort *idx = (ushort *)(ptr+1);
- for (i = 0; idx[i] != 0xffff; i++)
- ;
-
- len = 1+(i+2)/2;
-
- PRINTF(stream, "3DPRIM, %s variable length %d indicies (%d dwords):\n", prim, i, len);
- for (i = 0; i < len; i++)
- PRINTF(stream, "\t0x%08x\n", ptr[i]);
- PRINTF(stream, "\n");
-
- stream->offset += len * sizeof(unsigned);
- return TRUE;
-}
-
-
-static void
-BITS(
- struct debug_stream *stream,
- unsigned dw,
- unsigned hi,
- unsigned lo,
- const char *fmt,
- ... )
-{
- va_list args;
- char buffer[256];
- unsigned himask = ~0UL >> (31 - (hi));
-
- PRINTF(stream, "\t\t ");
-
- va_start( args, fmt );
- vsprintf( buffer, fmt, args );
- stream->winsys->printf( stream->winsys, buffer );
- va_end( args );
-
- PRINTF(stream, ": 0x%x\n", ((dw) & himask) >> (lo));
-}
-
-#define MBZ( dw, hi, lo) do { \
- unsigned x = (dw) >> (lo); \
- unsigned lomask = (1 << (lo)) - 1; \
- unsigned himask; \
- himask = (1UL << (hi)) - 1; \
- assert ((x & himask & ~lomask) == 0); \
-} while (0)
-
-static void
-FLAG(
- struct debug_stream *stream,
- unsigned dw,
- unsigned bit,
- const char *fmt,
- ... )
-{
- if (((dw) >> (bit)) & 1) {
- va_list args;
- char buffer[256];
-
- PRINTF(stream, "\t\t ");
-
- va_start( args, fmt );
- vsprintf( buffer, fmt, args );
- stream->winsys->printf( stream->winsys, buffer );
- va_end( args );
-
- PRINTF(stream, "\n");
- }
-}
-
-static boolean debug_load_immediate( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned bits = (ptr[0] >> 4) & 0xff;
- unsigned j = 0;
-
- PRINTF(stream, "%s (%d dwords, flags: %x):\n", name, len, bits);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- if (bits & (1<<0)) {
- PRINTF(stream, "\t LIS0: 0x%08x\n", ptr[j]);
- PRINTF(stream, "\t vb address: 0x%08x\n", (ptr[j] & ~0x3));
- BITS(stream, ptr[j], 0, 0, "vb invalidate disable");
- j++;
- }
- if (bits & (1<<1)) {
- PRINTF(stream, "\t LIS1: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 29, 24, "vb dword width");
- BITS(stream, ptr[j], 21, 16, "vb dword pitch");
- BITS(stream, ptr[j], 15, 0, "vb max index");
- j++;
- }
- if (bits & (1<<2)) {
- int i;
- PRINTF(stream, "\t LIS2: 0x%08x\n", ptr[j]);
- for (i = 0; i < 8; i++) {
- unsigned tc = (ptr[j] >> (i * 4)) & 0xf;
- if (tc != 0xf)
- BITS(stream, tc, 3, 0, "tex coord %d", i);
- }
- j++;
- }
- if (bits & (1<<3)) {
- PRINTF(stream, "\t LIS3: 0x%08x\n", ptr[j]);
- j++;
- }
- if (bits & (1<<4)) {
- PRINTF(stream, "\t LIS4: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 31, 23, "point width");
- BITS(stream, ptr[j], 22, 19, "line width");
- FLAG(stream, ptr[j], 18, "alpha flatshade");
- FLAG(stream, ptr[j], 17, "fog flatshade");
- FLAG(stream, ptr[j], 16, "spec flatshade");
- FLAG(stream, ptr[j], 15, "rgb flatshade");
- BITS(stream, ptr[j], 14, 13, "cull mode");
- FLAG(stream, ptr[j], 12, "vfmt: point width");
- FLAG(stream, ptr[j], 11, "vfmt: specular/fog");
- FLAG(stream, ptr[j], 10, "vfmt: rgba");
- FLAG(stream, ptr[j], 9, "vfmt: depth offset");
- BITS(stream, ptr[j], 8, 6, "vfmt: position (2==xyzw)");
- FLAG(stream, ptr[j], 5, "force dflt diffuse");
- FLAG(stream, ptr[j], 4, "force dflt specular");
- FLAG(stream, ptr[j], 3, "local depth offset enable");
- FLAG(stream, ptr[j], 2, "vfmt: fp32 fog coord");
- FLAG(stream, ptr[j], 1, "sprite point");
- FLAG(stream, ptr[j], 0, "antialiasing");
- j++;
- }
- if (bits & (1<<5)) {
- PRINTF(stream, "\t LIS5: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 31, 28, "rgba write disables");
- FLAG(stream, ptr[j], 27, "force dflt point width");
- FLAG(stream, ptr[j], 26, "last pixel enable");
- FLAG(stream, ptr[j], 25, "global z offset enable");
- FLAG(stream, ptr[j], 24, "fog enable");
- BITS(stream, ptr[j], 23, 16, "stencil ref");
- BITS(stream, ptr[j], 15, 13, "stencil test");
- BITS(stream, ptr[j], 12, 10, "stencil fail op");
- BITS(stream, ptr[j], 9, 7, "stencil pass z fail op");
- BITS(stream, ptr[j], 6, 4, "stencil pass z pass op");
- FLAG(stream, ptr[j], 3, "stencil write enable");
- FLAG(stream, ptr[j], 2, "stencil test enable");
- FLAG(stream, ptr[j], 1, "color dither enable");
- FLAG(stream, ptr[j], 0, "logiop enable");
- j++;
- }
- if (bits & (1<<6)) {
- PRINTF(stream, "\t LIS6: 0x%08x\n", ptr[j]);
- FLAG(stream, ptr[j], 31, "alpha test enable");
- BITS(stream, ptr[j], 30, 28, "alpha func");
- BITS(stream, ptr[j], 27, 20, "alpha ref");
- FLAG(stream, ptr[j], 19, "depth test enable");
- BITS(stream, ptr[j], 18, 16, "depth func");
- FLAG(stream, ptr[j], 15, "blend enable");
- BITS(stream, ptr[j], 14, 12, "blend func");
- BITS(stream, ptr[j], 11, 8, "blend src factor");
- BITS(stream, ptr[j], 7, 4, "blend dst factor");
- FLAG(stream, ptr[j], 3, "depth write enable");
- FLAG(stream, ptr[j], 2, "color write enable");
- BITS(stream, ptr[j], 1, 0, "provoking vertex");
- j++;
- }
-
-
- PRINTF(stream, "\n");
-
- assert(j == len);
-
- stream->offset += len * sizeof(unsigned);
-
- return TRUE;
-}
-
-
-
-static boolean debug_load_indirect( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned bits = (ptr[0] >> 8) & 0x3f;
- unsigned i, j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- for (i = 0; i < 6; i++) {
- if (bits & (1<<i)) {
- switch (1<<(8+i)) {
- case LI0_STATE_STATIC_INDIRECT:
- PRINTF(stream, " STATIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- PRINTF(stream, " 0x%08x\n", ptr[j++]);
- break;
- case LI0_STATE_DYNAMIC_INDIRECT:
- PRINTF(stream, " DYNAMIC: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- break;
- case LI0_STATE_SAMPLER:
- PRINTF(stream, " SAMPLER: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- PRINTF(stream, " 0x%08x\n", ptr[j++]);
- break;
- case LI0_STATE_MAP:
- PRINTF(stream, " MAP: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- PRINTF(stream, " 0x%08x\n", ptr[j++]);
- break;
- case LI0_STATE_PROGRAM:
- PRINTF(stream, " PROGRAM: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- PRINTF(stream, " 0x%08x\n", ptr[j++]);
- break;
- case LI0_STATE_CONSTANTS:
- PRINTF(stream, " CONSTANTS: 0x%08x | %x\n", ptr[j]&~3, ptr[j]&3); j++;
- PRINTF(stream, " 0x%08x\n", ptr[j++]);
- break;
- default:
- assert(0);
- break;
- }
- }
- }
-
- if (bits == 0) {
- PRINTF(stream, "\t DUMMY: 0x%08x\n", ptr[j++]);
- }
-
- PRINTF(stream, "\n");
-
-
- assert(j == len);
-
- stream->offset += len * sizeof(unsigned);
-
- return TRUE;
-}
-
-static void BR13( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x\n", val);
- FLAG(stream, val, 30, "clipping enable");
- BITS(stream, val, 25, 24, "color depth (3==32bpp)");
- BITS(stream, val, 23, 16, "raster op");
- BITS(stream, val, 15, 0, "dest pitch");
-}
-
-
-static void BR22( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x\n", val);
- BITS(stream, val, 31, 16, "dest y1");
- BITS(stream, val, 15, 0, "dest x1");
-}
-
-static void BR23( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x\n", val);
- BITS(stream, val, 31, 16, "dest y2");
- BITS(stream, val, 15, 0, "dest x2");
-}
-
-static void BR09( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x -- dest address\n", val);
-}
-
-static void BR26( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x\n", val);
- BITS(stream, val, 31, 16, "src y1");
- BITS(stream, val, 15, 0, "src x1");
-}
-
-static void BR11( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x\n", val);
- BITS(stream, val, 15, 0, "src pitch");
-}
-
-static void BR12( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x -- src address\n", val);
-}
-
-static void BR16( struct debug_stream *stream,
- unsigned val )
-{
- PRINTF(stream, "\t0x%08x -- color\n", val);
-}
-
-static boolean debug_copy_blit( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- int j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- BR13(stream, ptr[j++]);
- BR22(stream, ptr[j++]);
- BR23(stream, ptr[j++]);
- BR09(stream, ptr[j++]);
- BR26(stream, ptr[j++]);
- BR11(stream, ptr[j++]);
- BR12(stream, ptr[j++]);
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_color_blit( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- int j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- BR13(stream, ptr[j++]);
- BR22(stream, ptr[j++]);
- BR23(stream, ptr[j++]);
- BR09(stream, ptr[j++]);
- BR16(stream, ptr[j++]);
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_modes4( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- int j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 21, 18, "logicop func");
- FLAG(stream, ptr[j], 17, "stencil test mask modify-enable");
- FLAG(stream, ptr[j], 16, "stencil write mask modify-enable");
- BITS(stream, ptr[j], 15, 8, "stencil test mask");
- BITS(stream, ptr[j], 7, 0, "stencil write mask");
- j++;
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_map_state( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- {
- PRINTF(stream, "\t0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 15, 0, "map mask");
- j++;
- }
-
- while (j < len) {
- {
- PRINTF(stream, "\t TMn.0: 0x%08x\n", ptr[j]);
- PRINTF(stream, "\t map address: 0x%08x\n", (ptr[j] & ~0x3));
- FLAG(stream, ptr[j], 1, "vertical line stride");
- FLAG(stream, ptr[j], 0, "vertical line stride offset");
- j++;
- }
-
- {
- PRINTF(stream, "\t TMn.1: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 31, 21, "height");
- BITS(stream, ptr[j], 20, 10, "width");
- BITS(stream, ptr[j], 9, 7, "surface format");
- BITS(stream, ptr[j], 6, 3, "texel format");
- FLAG(stream, ptr[j], 2, "use fence regs");
- FLAG(stream, ptr[j], 1, "tiled surface");
- FLAG(stream, ptr[j], 0, "tile walk ymajor");
- j++;
- }
- {
- PRINTF(stream, "\t TMn.2: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 31, 21, "dword pitch");
- BITS(stream, ptr[j], 20, 15, "cube face enables");
- BITS(stream, ptr[j], 14, 9, "max lod");
- FLAG(stream, ptr[j], 8, "mip layout right");
- BITS(stream, ptr[j], 7, 0, "depth");
- j++;
- }
- }
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_sampler_state( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- {
- PRINTF(stream, "\t0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 15, 0, "sampler mask");
- j++;
- }
-
- while (j < len) {
- {
- PRINTF(stream, "\t TSn.0: 0x%08x\n", ptr[j]);
- FLAG(stream, ptr[j], 31, "reverse gamma");
- FLAG(stream, ptr[j], 30, "planar to packed");
- FLAG(stream, ptr[j], 29, "yuv->rgb");
- BITS(stream, ptr[j], 28, 27, "chromakey index");
- BITS(stream, ptr[j], 26, 22, "base mip level");
- BITS(stream, ptr[j], 21, 20, "mip mode filter");
- BITS(stream, ptr[j], 19, 17, "mag mode filter");
- BITS(stream, ptr[j], 16, 14, "min mode filter");
- BITS(stream, ptr[j], 13, 5, "lod bias (s4.4)");
- FLAG(stream, ptr[j], 4, "shadow enable");
- FLAG(stream, ptr[j], 3, "max-aniso-4");
- BITS(stream, ptr[j], 2, 0, "shadow func");
- j++;
- }
-
- {
- PRINTF(stream, "\t TSn.1: 0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 31, 24, "min lod");
- MBZ( ptr[j], 23, 18 );
- FLAG(stream, ptr[j], 17, "kill pixel enable");
- FLAG(stream, ptr[j], 16, "keyed tex filter mode");
- FLAG(stream, ptr[j], 15, "chromakey enable");
- BITS(stream, ptr[j], 14, 12, "tcx wrap mode");
- BITS(stream, ptr[j], 11, 9, "tcy wrap mode");
- BITS(stream, ptr[j], 8, 6, "tcz wrap mode");
- FLAG(stream, ptr[j], 5, "normalized coords");
- BITS(stream, ptr[j], 4, 1, "map (surface) index");
- FLAG(stream, ptr[j], 0, "EAST deinterlacer enable");
- j++;
- }
- {
- PRINTF(stream, "\t TSn.2: 0x%08x (default color)\n", ptr[j]);
- j++;
- }
- }
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_dest_vars( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- int j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- {
- PRINTF(stream, "\t0x%08x\n", ptr[j]);
- FLAG(stream, ptr[j], 31, "early classic ztest");
- FLAG(stream, ptr[j], 30, "opengl tex default color");
- FLAG(stream, ptr[j], 29, "bypass iz");
- FLAG(stream, ptr[j], 28, "lod preclamp");
- BITS(stream, ptr[j], 27, 26, "dither pattern");
- FLAG(stream, ptr[j], 25, "linear gamma blend");
- FLAG(stream, ptr[j], 24, "debug dither");
- BITS(stream, ptr[j], 23, 20, "dstorg x");
- BITS(stream, ptr[j], 19, 16, "dstorg y");
- MBZ (ptr[j], 15, 15 );
- BITS(stream, ptr[j], 14, 12, "422 write select");
- BITS(stream, ptr[j], 11, 8, "cbuf format");
- BITS(stream, ptr[j], 3, 2, "zbuf format");
- FLAG(stream, ptr[j], 1, "vert line stride");
- FLAG(stream, ptr[j], 1, "vert line stride offset");
- j++;
- }
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean debug_buf_info( struct debug_stream *stream,
- const char *name,
- unsigned len )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- int j = 0;
-
- PRINTF(stream, "%s (%d dwords):\n", name, len);
- PRINTF(stream, "\t0x%08x\n", ptr[j++]);
-
- {
- PRINTF(stream, "\t0x%08x\n", ptr[j]);
- BITS(stream, ptr[j], 28, 28, "aux buffer id");
- BITS(stream, ptr[j], 27, 24, "buffer id (7=depth, 3=back)");
- FLAG(stream, ptr[j], 23, "use fence regs");
- FLAG(stream, ptr[j], 22, "tiled surface");
- FLAG(stream, ptr[j], 21, "tile walk ymajor");
- MBZ (ptr[j], 20, 14);
- BITS(stream, ptr[j], 13, 2, "dword pitch");
- MBZ (ptr[j], 2, 0);
- j++;
- }
-
- PRINTF(stream, "\t0x%08x -- buffer base address\n", ptr[j++]);
-
- stream->offset += len * sizeof(unsigned);
- assert(j == len);
- return TRUE;
-}
-
-static boolean i915_debug_packet( struct debug_stream *stream )
-{
- unsigned *ptr = (unsigned *)(stream->ptr + stream->offset);
- unsigned cmd = *ptr;
-
- switch (((cmd >> 29) & 0x7)) {
- case 0x0:
- switch ((cmd >> 23) & 0x3f) {
- case 0x0:
- return debug(stream, "MI_NOOP", 1);
- case 0x3:
- return debug(stream, "MI_WAIT_FOR_EVENT", 1);
- case 0x4:
- return debug(stream, "MI_FLUSH", 1);
- case 0xA:
- debug(stream, "MI_BATCH_BUFFER_END", 1);
- return FALSE;
- case 0x22:
- return debug(stream, "MI_LOAD_REGISTER_IMM", 3);
- case 0x31:
- return debug_chain(stream, "MI_BATCH_BUFFER_START", 2);
- default:
- (void)debug(stream, "UNKNOWN 0x0 case!", 1);
- assert(0);
- break;
- }
- break;
- case 0x1:
- (void) debug(stream, "UNKNOWN 0x1 case!", 1);
- assert(0);
- break;
- case 0x2:
- switch ((cmd >> 22) & 0xff) {
- case 0x50:
- return debug_color_blit(stream, "XY_COLOR_BLT", (cmd & 0xff) + 2);
- case 0x53:
- return debug_copy_blit(stream, "XY_SRC_COPY_BLT", (cmd & 0xff) + 2);
- default:
- return debug(stream, "blit command", (cmd & 0xff) + 2);
- }
- break;
- case 0x3:
- switch ((cmd >> 24) & 0x1f) {
- case 0x6:
- return debug(stream, "3DSTATE_ANTI_ALIASING", 1);
- case 0x7:
- return debug(stream, "3DSTATE_RASTERIZATION_RULES", 1);
- case 0x8:
- return debug(stream, "3DSTATE_BACKFACE_STENCIL_OPS", 2);
- case 0x9:
- return debug(stream, "3DSTATE_BACKFACE_STENCIL_MASKS", 1);
- case 0xb:
- return debug(stream, "3DSTATE_INDEPENDENT_ALPHA_BLEND", 1);
- case 0xc:
- return debug(stream, "3DSTATE_MODES5", 1);
- case 0xd:
- return debug_modes4(stream, "3DSTATE_MODES4", 1);
- case 0x15:
- return debug(stream, "3DSTATE_FOG_COLOR", 1);
- case 0x16:
- return debug(stream, "3DSTATE_COORD_SET_BINDINGS", 1);
- case 0x1c:
- /* 3DState16NP */
- switch((cmd >> 19) & 0x1f) {
- case 0x10:
- return debug(stream, "3DSTATE_SCISSOR_ENABLE", 1);
- case 0x11:
- return debug(stream, "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE", 1);
- default:
- (void) debug(stream, "UNKNOWN 0x1c case!", 1);
- assert(0);
- break;
- }
- break;
- case 0x1d:
- /* 3DStateMW */
- switch ((cmd >> 16) & 0xff) {
- case 0x0:
- return debug_map_state(stream, "3DSTATE_MAP_STATE", (cmd & 0x1f) + 2);
- case 0x1:
- return debug_sampler_state(stream, "3DSTATE_SAMPLER_STATE", (cmd & 0x1f) + 2);
- case 0x4:
- return debug_load_immediate(stream, "3DSTATE_LOAD_STATE_IMMEDIATE", (cmd & 0xf) + 2);
- case 0x5:
- return debug_program(stream, "3DSTATE_PIXEL_SHADER_PROGRAM", (cmd & 0x1ff) + 2);
- case 0x6:
- return debug(stream, "3DSTATE_PIXEL_SHADER_CONSTANTS", (cmd & 0xff) + 2);
- case 0x7:
- return debug_load_indirect(stream, "3DSTATE_LOAD_INDIRECT", (cmd & 0xff) + 2);
- case 0x80:
- return debug(stream, "3DSTATE_DRAWING_RECTANGLE", (cmd & 0xffff) + 2);
- case 0x81:
- return debug(stream, "3DSTATE_SCISSOR_RECTANGLE", (cmd & 0xffff) + 2);
- case 0x83:
- return debug(stream, "3DSTATE_SPAN_STIPPLE", (cmd & 0xffff) + 2);
- case 0x85:
- return debug_dest_vars(stream, "3DSTATE_DEST_BUFFER_VARS", (cmd & 0xffff) + 2);
- case 0x88:
- return debug(stream, "3DSTATE_CONSTANT_BLEND_COLOR", (cmd & 0xffff) + 2);
- case 0x89:
- return debug(stream, "3DSTATE_FOG_MODE", (cmd & 0xffff) + 2);
- case 0x8e:
- return debug_buf_info(stream, "3DSTATE_BUFFER_INFO", (cmd & 0xffff) + 2);
- case 0x97:
- return debug(stream, "3DSTATE_DEPTH_OFFSET_SCALE", (cmd & 0xffff) + 2);
- case 0x98:
- return debug(stream, "3DSTATE_DEFAULT_Z", (cmd & 0xffff) + 2);
- case 0x99:
- return debug(stream, "3DSTATE_DEFAULT_DIFFUSE", (cmd & 0xffff) + 2);
- case 0x9a:
- return debug(stream, "3DSTATE_DEFAULT_SPECULAR", (cmd & 0xffff) + 2);
- case 0x9c:
- return debug(stream, "3DSTATE_CLEAR_PARAMETERS", (cmd & 0xffff) + 2);
- default:
- assert(0);
- return 0;
- }
- break;
- case 0x1e:
- if (cmd & (1 << 23))
- return debug(stream, "???", (cmd & 0xffff) + 1);
- else
- return debug(stream, "", 1);
- break;
- case 0x1f:
- if ((cmd & (1 << 23)) == 0)
- return debug_prim(stream, "3DPRIM (inline)", 1, (cmd & 0x1ffff) + 2);
- else if (cmd & (1 << 17))
- {
- if ((cmd & 0xffff) == 0)
- return debug_variable_length_prim(stream);
- else
- return debug_prim(stream, "3DPRIM (indexed)", 0, (((cmd & 0xffff) + 1) / 2) + 1);
- }
- else
- return debug_prim(stream, "3DPRIM (indirect sequential)", 0, 2);
- break;
- default:
- return debug(stream, "", 0);
- }
- default:
- assert(0);
- return 0;
- }
-
- assert(0);
- return 0;
-}
-
-
-
-void
-i915_dump_batchbuffer( struct i915_context *i915 )
-{
- struct debug_stream stream;
- unsigned *start = i915->batch_start;
- unsigned *end = i915->winsys->batch_start( i915->winsys, 0, 0 );
- unsigned long bytes = (unsigned long) (end - start) * 4;
- boolean done = FALSE;
-
- stream.offset = 0;
- stream.ptr = (char *)start;
- stream.print_addresses = 0;
- stream.winsys = i915->pipe.winsys;
-
- if (!start || !end) {
- stream.winsys->printf( stream.winsys, "\n\nBATCH: ???\n");
- return;
- }
-
- stream.winsys->printf( stream.winsys, "\n\nBATCH: (%d)\n", bytes / 4);
-
- while (!done &&
- stream.offset < bytes)
- {
- if (!i915_debug_packet( &stream ))
- break;
-
- assert(stream.offset <= bytes &&
- stream.offset >= 0);
- }
-
- stream.winsys->printf( stream.winsys, "END-BATCH\n\n\n");
-}
-
-
diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h
deleted file mode 100644
index 0bcd094233..0000000000
--- a/src/mesa/pipe/i915simple/i915_debug.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef I915_DEBUG_H
-#define I915_DEBUG_H
-
-#include <stdarg.h>
-
-struct i915_context;
-
-struct debug_stream
-{
- unsigned offset; /* current gtt offset */
- char *ptr; /* pointer to gtt offset zero */
- char *end; /* pointer to gtt offset zero */
- unsigned print_addresses;
- struct pipe_winsys *winsys;
-};
-
-
-/* Internal functions
- */
-void i915_disassemble_program(struct debug_stream *stream,
- const unsigned *program, unsigned sz);
-
-void i915_print_ureg(const char *msg, unsigned ureg);
-
-
-#define DEBUG_BATCH 0x1
-#define DEBUG_BLIT 0x2
-#define DEBUG_BUFFER 0x4
-#define DEBUG_CONSTANTS 0x8
-#define DEBUG_CONTEXT 0x10
-#define DEBUG_DRAW 0x20
-#define DEBUG_DYNAMIC 0x40
-#define DEBUG_FLUSH 0x80
-#define DEBUG_MAP 0x100
-#define DEBUG_PROGRAM 0x200
-#define DEBUG_REGIONS 0x400
-#define DEBUG_SAMPLER 0x800
-#define DEBUG_STATIC 0x1000
-#define DEBUG_SURFACE 0x2000
-#define DEBUG_WINSYS 0x4000
-
-#include "pipe/p_compiler.h"
-
-#if defined(DEBUG) && defined(FILE_DEBUG_FLAG)
-
-#include "pipe/p_winsys.h"
-
-static INLINE void
-I915_DBG(
- struct i915_context *i915,
- const char *fmt,
- ... )
-{
- if ((i915)->debug & FILE_DEBUG_FLAG) {
- va_list args;
- char buffer[256];
-
- va_start( args, fmt );
- vsprintf( buffer, fmt, args );
- i915->pipe.winsys->printf( i915->pipe.winsys, buffer );
- va_end( args );
- }
-}
-
-#else
-
-static INLINE void
-I915_DBG(
- struct i915_context *i915,
- const char *fmt,
- ... )
-{
- (void) i915;
- (void) fmt;
-}
-
-#endif
-
-
-void i915_dump_batchbuffer( struct i915_context *i915 );
-
-
-
-void i915_debug_init( struct i915_context *i915 );
-
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_debug_fp.c b/src/mesa/pipe/i915simple/i915_debug_fp.c
deleted file mode 100644
index ebfdb3d93c..0000000000
--- a/src/mesa/pipe/i915simple/i915_debug_fp.c
+++ /dev/null
@@ -1,366 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i915_reg.h"
-#include "i915_debug.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-
-
-static void
-PRINTF(
- struct debug_stream *stream,
- const char *fmt,
- ... )
-{
- va_list args;
- char buffer[256];
-
- va_start( args, fmt );
- vsprintf( buffer, fmt, args );
- stream->winsys->printf( stream->winsys, buffer );
- va_end( args );
-}
-
-
-static const char *opcodes[0x20] = {
- "NOP",
- "ADD",
- "MOV",
- "MUL",
- "MAD",
- "DP2ADD",
- "DP3",
- "DP4",
- "FRC",
- "RCP",
- "RSQ",
- "EXP",
- "LOG",
- "CMP",
- "MIN",
- "MAX",
- "FLR",
- "MOD",
- "TRC",
- "SGE",
- "SLT",
- "TEXLD",
- "TEXLDP",
- "TEXLDB",
- "TEXKILL",
- "DCL",
- "0x1a",
- "0x1b",
- "0x1c",
- "0x1d",
- "0x1e",
- "0x1f",
-};
-
-
-static const int args[0x20] = {
- 0, /* 0 nop */
- 2, /* 1 add */
- 1, /* 2 mov */
- 2, /* 3 m ul */
- 3, /* 4 mad */
- 3, /* 5 dp2add */
- 2, /* 6 dp3 */
- 2, /* 7 dp4 */
- 1, /* 8 frc */
- 1, /* 9 rcp */
- 1, /* a rsq */
- 1, /* b exp */
- 1, /* c log */
- 3, /* d cmp */
- 2, /* e min */
- 2, /* f max */
- 1, /* 10 flr */
- 1, /* 11 mod */
- 1, /* 12 trc */
- 2, /* 13 sge */
- 2, /* 14 slt */
- 1,
- 1,
- 1,
- 1,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
-};
-
-
-static const char *regname[0x8] = {
- "R",
- "T",
- "CONST",
- "S",
- "OC",
- "OD",
- "U",
- "UNKNOWN",
-};
-
-static void
-print_reg_type_nr(struct debug_stream *stream, unsigned type, unsigned nr)
-{
- switch (type) {
- case REG_TYPE_T:
- switch (nr) {
- case T_DIFFUSE:
- PRINTF(stream, "T_DIFFUSE");
- return;
- case T_SPECULAR:
- PRINTF(stream, "T_SPECULAR");
- return;
- case T_FOG_W:
- PRINTF(stream, "T_FOG_W");
- return;
- default:
- PRINTF(stream, "T_TEX%d", nr);
- return;
- }
- case REG_TYPE_OC:
- if (nr == 0) {
- PRINTF(stream, "oC");
- return;
- }
- break;
- case REG_TYPE_OD:
- if (nr == 0) {
- PRINTF(stream, "oD");
- return;
- }
- break;
- default:
- break;
- }
-
- PRINTF(stream, "%s[%d]", regname[type], nr);
-}
-
-#define REG_SWIZZLE_MASK 0x7777
-#define REG_NEGATE_MASK 0x8888
-
-#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \
- (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \
- (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \
- (SRC_W << A2_SRC2_CHANNEL_W_SHIFT))
-
-
-static void
-print_reg_neg_swizzle(struct debug_stream *stream, unsigned reg)
-{
- int i;
-
- if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW &&
- (reg & REG_NEGATE_MASK) == 0)
- return;
-
- PRINTF(stream, ".");
-
- for (i = 3; i >= 0; i--) {
- if (reg & (1 << ((i * 4) + 3)))
- PRINTF(stream, "-");
-
- switch ((reg >> (i * 4)) & 0x7) {
- case 0:
- PRINTF(stream, "x");
- break;
- case 1:
- PRINTF(stream, "y");
- break;
- case 2:
- PRINTF(stream, "z");
- break;
- case 3:
- PRINTF(stream, "w");
- break;
- case 4:
- PRINTF(stream, "0");
- break;
- case 5:
- PRINTF(stream, "1");
- break;
- default:
- PRINTF(stream, "?");
- break;
- }
- }
-}
-
-
-static void
-print_src_reg(struct debug_stream *stream, unsigned dword)
-{
- unsigned nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK;
- unsigned type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK;
- print_reg_type_nr(stream, type, nr);
- print_reg_neg_swizzle(stream, dword);
-}
-
-
-static void
-print_dest_reg(struct debug_stream *stream, unsigned dword)
-{
- unsigned nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK;
- unsigned type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK;
- print_reg_type_nr(stream, type, nr);
- if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL)
- return;
- PRINTF(stream, ".");
- if (dword & A0_DEST_CHANNEL_X)
- PRINTF(stream, "x");
- if (dword & A0_DEST_CHANNEL_Y)
- PRINTF(stream, "y");
- if (dword & A0_DEST_CHANNEL_Z)
- PRINTF(stream, "z");
- if (dword & A0_DEST_CHANNEL_W)
- PRINTF(stream, "w");
-}
-
-
-#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT))
-#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT))
-#define GET_SRC2_REG(r) (r)
-
-
-static void
-print_arith_op(struct debug_stream *stream,
- unsigned opcode, const unsigned * program)
-{
- if (opcode != A0_NOP) {
- print_dest_reg(stream, program[0]);
- if (program[0] & A0_DEST_SATURATE)
- PRINTF(stream, " = SATURATE ");
- else
- PRINTF(stream, " = ");
- }
-
- PRINTF(stream, "%s ", opcodes[opcode]);
-
- print_src_reg(stream, GET_SRC0_REG(program[0], program[1]));
- if (args[opcode] == 1) {
- PRINTF(stream, "\n");
- return;
- }
-
- PRINTF(stream, ", ");
- print_src_reg(stream, GET_SRC1_REG(program[1], program[2]));
- if (args[opcode] == 2) {
- PRINTF(stream, "\n");
- return;
- }
-
- PRINTF(stream, ", ");
- print_src_reg(stream, GET_SRC2_REG(program[2]));
- PRINTF(stream, "\n");
- return;
-}
-
-
-static void
-print_tex_op(struct debug_stream *stream,
- unsigned opcode, const unsigned * program)
-{
- print_dest_reg(stream, program[0] | A0_DEST_CHANNEL_ALL);
- PRINTF(stream, " = ");
-
- PRINTF(stream, "%s ", opcodes[opcode]);
-
- PRINTF(stream, "S[%d],", program[0] & T0_SAMPLER_NR_MASK);
-
- print_reg_type_nr(stream,
- (program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) &
- REG_TYPE_MASK,
- (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK);
- PRINTF(stream, "\n");
-}
-
-static void
-print_texkil_op(struct debug_stream *stream,
- unsigned opcode, const unsigned * program)
-{
- PRINTF(stream, "TEXKIL ");
-
- print_reg_type_nr(stream,
- (program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) &
- REG_TYPE_MASK,
- (program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK);
- PRINTF(stream, "\n");
-}
-
-static void
-print_dcl_op(struct debug_stream *stream,
- unsigned opcode, const unsigned * program)
-{
- PRINTF(stream, "%s ", opcodes[opcode]);
- print_dest_reg(stream,
- program[0] | A0_DEST_CHANNEL_ALL);
- PRINTF(stream, "\n");
-}
-
-
-void
-i915_disassemble_program(struct debug_stream *stream,
- const unsigned * program, unsigned sz)
-{
- unsigned size = program[0] & 0x1ff;
- unsigned i;
-
- PRINTF(stream, "\t\tBEGIN\n");
-
- assert(size + 2 == sz);
-
- program++;
- for (i = 1; i < sz; i += 3, program += 3) {
- unsigned opcode = program[0] & (0x1f << 24);
-
- PRINTF(stream, "\t\t");
-
- if ((int) opcode >= A0_NOP && opcode <= A0_SLT)
- print_arith_op(stream, opcode >> 24, program);
- else if (opcode >= T0_TEXLD && opcode < T0_TEXKILL)
- print_tex_op(stream, opcode >> 24, program);
- else if (opcode == T0_TEXKILL)
- print_texkil_op(stream, opcode >> 24, program);
- else if (opcode == D0_DCL)
- print_dcl_op(stream, opcode >> 24, program);
- else
- PRINTF(stream, "Unknown opcode 0x%x\n", opcode);
- }
-
- PRINTF(stream, "\t\tEND\n\n");
-}
-
-
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
deleted file mode 100644
index 3c2069b827..0000000000
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ /dev/null
@@ -1,81 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_defines.h"
-#include "i915_context.h"
-#include "i915_reg.h"
-#include "i915_batch.h"
-
-
-/**
- * In future we may want a fence-like interface instead of finish.
- */
-static void i915_flush( struct pipe_context *pipe,
- unsigned flags )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- /* Do we need to emit an MI_FLUSH command to flush the hardware
- * caches?
- */
- if (flags & (PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE)) {
- unsigned flush = MI_FLUSH;
-
- if (!(flags & PIPE_FLUSH_RENDER_CACHE))
- flush |= INHIBIT_FLUSH_RENDER_CACHE;
-
- if (flags & PIPE_FLUSH_TEXTURE_CACHE)
- flush |= FLUSH_MAP_CACHE;
-
- if (!BEGIN_BATCH(1, 0)) {
- FLUSH_BATCH();
- assert(BEGIN_BATCH(1, 0));
- }
- OUT_BATCH( flush );
- ADVANCE_BATCH();
- }
-
- /* If there are no flags, just flush pending commands to hardware:
- */
- FLUSH_BATCH();
-
- if (flags & PIPE_FLUSH_WAIT) {
- i915->winsys->batch_finish(i915->winsys);
- }
-}
-
-
-
-void i915_init_flush_functions( struct i915_context *i915 )
-{
- i915->pipe.flush = i915_flush;
-}
diff --git a/src/mesa/pipe/i915simple/i915_fpc.h b/src/mesa/pipe/i915simple/i915_fpc.h
deleted file mode 100644
index 8c7b68aefb..0000000000
--- a/src/mesa/pipe/i915simple/i915_fpc.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef I915_FPC_H
-#define I915_FPC_H
-
-#include "pipe/p_util.h"
-
-#include "i915_context.h"
-#include "i915_reg.h"
-
-
-
-#define I915_PROGRAM_SIZE 192
-
-
-
-/**
- * Program translation state
- */
-struct i915_fp_compile {
- const struct pipe_shader_state *shader;
-
- struct vertex_info *vertex_info;
-
- uint declarations[I915_PROGRAM_SIZE];
- uint program[I915_PROGRAM_SIZE];
-
- uint input_semantic_name[PIPE_MAX_SHADER_INPUTS];
- uint input_semantic_index[PIPE_MAX_SHADER_INPUTS];
-
- uint output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
- uint output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
-
- /** points into the i915->current.constants array: */
- float (*constants)[4];
- uint num_constants;
- uint constant_flags[I915_MAX_CONSTANT]; /**< status of each constant */
-
- uint *csr; /**< Cursor, points into program. */
-
- uint *decl; /**< Cursor, points into declarations. */
-
- uint decl_s; /**< flags for which s regs need to be decl'd */
- uint decl_t; /**< flags for which t regs need to be decl'd */
-
- uint temp_flag; /**< Tracks temporary regs which are in use */
- uint utemp_flag; /**< Tracks TYPE_U temporary regs which are in use */
-
- uint nr_tex_indirect;
- uint nr_tex_insn;
- uint nr_alu_insn;
- uint nr_decl_insn;
-
- boolean error; /**< Set if i915_program_error() is called */
- uint wpos_tex;
- uint NumNativeInstructions;
- uint NumNativeAluInstructions;
- uint NumNativeTexInstructions;
- uint NumNativeTexIndirections;
-};
-
-
-/* Having zero and one in here makes the definition of swizzle a lot
- * easier.
- */
-#define UREG_TYPE_SHIFT 29
-#define UREG_NR_SHIFT 24
-#define UREG_CHANNEL_X_NEGATE_SHIFT 23
-#define UREG_CHANNEL_X_SHIFT 20
-#define UREG_CHANNEL_Y_NEGATE_SHIFT 19
-#define UREG_CHANNEL_Y_SHIFT 16
-#define UREG_CHANNEL_Z_NEGATE_SHIFT 15
-#define UREG_CHANNEL_Z_SHIFT 12
-#define UREG_CHANNEL_W_NEGATE_SHIFT 11
-#define UREG_CHANNEL_W_SHIFT 8
-#define UREG_CHANNEL_ZERO_NEGATE_MBZ 5
-#define UREG_CHANNEL_ZERO_SHIFT 4
-#define UREG_CHANNEL_ONE_NEGATE_MBZ 1
-#define UREG_CHANNEL_ONE_SHIFT 0
-
-#define UREG_BAD 0xffffffff /* not a valid ureg */
-
-#define X SRC_X
-#define Y SRC_Y
-#define Z SRC_Z
-#define W SRC_W
-#define ZERO SRC_ZERO
-#define ONE SRC_ONE
-
-/* Construct a ureg:
- */
-#define UREG( type, nr ) (((type)<< UREG_TYPE_SHIFT) | \
- ((nr) << UREG_NR_SHIFT) | \
- (X << UREG_CHANNEL_X_SHIFT) | \
- (Y << UREG_CHANNEL_Y_SHIFT) | \
- (Z << UREG_CHANNEL_Z_SHIFT) | \
- (W << UREG_CHANNEL_W_SHIFT) | \
- (ZERO << UREG_CHANNEL_ZERO_SHIFT) | \
- (ONE << UREG_CHANNEL_ONE_SHIFT))
-
-#define GET_CHANNEL_SRC( reg, channel ) ((reg<<(channel*4)) & (0xf<<20))
-#define CHANNEL_SRC( src, channel ) (src>>(channel*4))
-
-#define GET_UREG_TYPE(reg) (((reg)>>UREG_TYPE_SHIFT)&REG_TYPE_MASK)
-#define GET_UREG_NR(reg) (((reg)>>UREG_NR_SHIFT)&REG_NR_MASK)
-
-
-
-#define UREG_XYZW_CHANNEL_MASK 0x00ffff00
-
-/* One neat thing about the UREG representation:
- */
-static INLINE int
-swizzle(int reg, uint x, uint y, uint z, uint w)
-{
- assert(x <= SRC_ONE);
- assert(y <= SRC_ONE);
- assert(z <= SRC_ONE);
- assert(w <= SRC_ONE);
- return ((reg & ~UREG_XYZW_CHANNEL_MASK) |
- CHANNEL_SRC(GET_CHANNEL_SRC(reg, x), 0) |
- CHANNEL_SRC(GET_CHANNEL_SRC(reg, y), 1) |
- CHANNEL_SRC(GET_CHANNEL_SRC(reg, z), 2) |
- CHANNEL_SRC(GET_CHANNEL_SRC(reg, w), 3));
-}
-
-
-
-/***********************************************************************
- * Public interface for the compiler
- */
-extern void i915_translate_fragment_program( struct i915_context *i915 );
-
-
-
-extern uint i915_get_temp(struct i915_fp_compile *p);
-extern uint i915_get_utemp(struct i915_fp_compile *p);
-extern void i915_release_utemps(struct i915_fp_compile *p);
-
-
-extern uint i915_emit_texld(struct i915_fp_compile *p,
- uint dest,
- uint destmask,
- uint sampler, uint coord, uint op);
-
-extern uint i915_emit_arith(struct i915_fp_compile *p,
- uint op,
- uint dest,
- uint mask,
- uint saturate,
- uint src0, uint src1, uint src2);
-
-extern uint i915_emit_decl(struct i915_fp_compile *p,
- uint type, uint nr, uint d0_flags);
-
-
-extern uint i915_emit_const1f(struct i915_fp_compile *p, float c0);
-
-extern uint i915_emit_const2f(struct i915_fp_compile *p,
- float c0, float c1);
-
-extern uint i915_emit_const4fv(struct i915_fp_compile *p,
- const float * c);
-
-extern uint i915_emit_const4f(struct i915_fp_compile *p,
- float c0, float c1,
- float c2, float c3);
-
-
-/*======================================================================
- * i915_fpc_debug.c
- */
-extern void i915_disassemble_program(const uint * program, uint sz);
-
-
-/*======================================================================
- * i915_fpc_translate.c
- */
-
-extern void
-i915_program_error(struct i915_fp_compile *p, const char *msg, ...);
-
-extern void
-i915_translate_fragment_program(struct i915_context *i915);
-
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_fpc_emit.c b/src/mesa/pipe/i915simple/i915_fpc_emit.c
deleted file mode 100644
index 74924ff0a1..0000000000
--- a/src/mesa/pipe/i915simple/i915_fpc_emit.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "i915_reg.h"
-#include "i915_context.h"
-#include "i915_fpc.h"
-
-
-#define A0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
-#define D0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
-#define T0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
-#define A0_SRC0( reg ) (((reg)&UREG_MASK)>>UREG_A0_SRC0_SHIFT_LEFT)
-#define A1_SRC0( reg ) (((reg)&UREG_MASK)<<UREG_A1_SRC0_SHIFT_RIGHT)
-#define A1_SRC1( reg ) (((reg)&UREG_MASK)>>UREG_A1_SRC1_SHIFT_LEFT)
-#define A2_SRC1( reg ) (((reg)&UREG_MASK)<<UREG_A2_SRC1_SHIFT_RIGHT)
-#define A2_SRC2( reg ) (((reg)&UREG_MASK)>>UREG_A2_SRC2_SHIFT_LEFT)
-
-/* These are special, and don't have swizzle/negate bits.
- */
-#define T0_SAMPLER( reg ) (GET_UREG_NR(reg)<<T0_SAMPLER_NR_SHIFT)
-#define T1_ADDRESS_REG( reg ) ((GET_UREG_NR(reg)<<T1_ADDRESS_REG_NR_SHIFT) | \
- (GET_UREG_TYPE(reg)<<T1_ADDRESS_REG_TYPE_SHIFT))
-
-
-/* Macros for translating UREG's into the various register fields used
- * by the I915 programmable unit.
- */
-#define UREG_A0_DEST_SHIFT_LEFT (UREG_TYPE_SHIFT - A0_DEST_TYPE_SHIFT)
-#define UREG_A0_SRC0_SHIFT_LEFT (UREG_TYPE_SHIFT - A0_SRC0_TYPE_SHIFT)
-#define UREG_A1_SRC0_SHIFT_RIGHT (A1_SRC0_CHANNEL_W_SHIFT - UREG_CHANNEL_W_SHIFT)
-#define UREG_A1_SRC1_SHIFT_LEFT (UREG_TYPE_SHIFT - A1_SRC1_TYPE_SHIFT)
-#define UREG_A2_SRC1_SHIFT_RIGHT (A2_SRC1_CHANNEL_W_SHIFT - UREG_CHANNEL_W_SHIFT)
-#define UREG_A2_SRC2_SHIFT_LEFT (UREG_TYPE_SHIFT - A2_SRC2_TYPE_SHIFT)
-
-#define UREG_MASK 0xffffff00
-#define UREG_TYPE_NR_MASK ((REG_TYPE_MASK << UREG_TYPE_SHIFT) | \
- (REG_NR_MASK << UREG_NR_SHIFT))
-
-
-#define I915_CONSTFLAG_PARAM 0x1f
-
-uint
-i915_get_temp(struct i915_fp_compile *p)
-{
- int bit = ffs(~p->temp_flag);
- if (!bit) {
- i915_program_error(p, "i915_get_temp: out of temporaries\n");
- return 0;
- }
-
- p->temp_flag |= 1 << (bit - 1);
- return UREG(REG_TYPE_R, (bit - 1));
-}
-
-
-uint
-i915_get_utemp(struct i915_fp_compile * p)
-{
- int bit = ffs(~p->utemp_flag);
- if (!bit) {
- i915_program_error(p, "i915_get_utemp: out of temporaries\n");
- return 0;
- }
-
- p->utemp_flag |= 1 << (bit - 1);
- return UREG(REG_TYPE_U, (bit - 1));
-}
-
-void
-i915_release_utemps(struct i915_fp_compile *p)
-{
- p->utemp_flag = ~0x7;
-}
-
-
-uint
-i915_emit_decl(struct i915_fp_compile *p,
- uint type, uint nr, uint d0_flags)
-{
- uint reg = UREG(type, nr);
-
- if (type == REG_TYPE_T) {
- if (p->decl_t & (1 << nr))
- return reg;
-
- p->decl_t |= (1 << nr);
- }
- else if (type == REG_TYPE_S) {
- if (p->decl_s & (1 << nr))
- return reg;
-
- p->decl_s |= (1 << nr);
- }
- else
- return reg;
-
- *(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
- *(p->decl++) = D1_MBZ;
- *(p->decl++) = D2_MBZ;
-
- p->nr_decl_insn++;
- return reg;
-}
-
-uint
-i915_emit_arith(struct i915_fp_compile * p,
- uint op,
- uint dest,
- uint mask,
- uint saturate, uint src0, uint src1, uint src2)
-{
- uint c[3];
- uint nr_const = 0;
-
- assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
- dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest));
- assert(dest);
-
- if (GET_UREG_TYPE(src0) == REG_TYPE_CONST)
- c[nr_const++] = 0;
- if (GET_UREG_TYPE(src1) == REG_TYPE_CONST)
- c[nr_const++] = 1;
- if (GET_UREG_TYPE(src2) == REG_TYPE_CONST)
- c[nr_const++] = 2;
-
- /* Recursively call this function to MOV additional const values
- * into temporary registers. Use utemp registers for this -
- * currently shouldn't be possible to run out, but keep an eye on
- * this.
- */
- if (nr_const > 1) {
- uint s[3], first, i, old_utemp_flag;
-
- s[0] = src0;
- s[1] = src1;
- s[2] = src2;
- old_utemp_flag = p->utemp_flag;
-
- first = GET_UREG_NR(s[c[0]]);
- for (i = 1; i < nr_const; i++) {
- if (GET_UREG_NR(s[c[i]]) != first) {
- uint tmp = i915_get_utemp(p);
-
- i915_emit_arith(p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0,
- s[c[i]], 0, 0);
- s[c[i]] = tmp;
- }
- }
-
- src0 = s[0];
- src1 = s[1];
- src2 = s[2];
- p->utemp_flag = old_utemp_flag; /* restore */
- }
-
- *(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0));
- *(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1));
- *(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2));
-
- p->nr_alu_insn++;
- return dest;
-}
-
-uint i915_emit_texld( struct i915_fp_compile *p,
- uint dest,
- uint destmask,
- uint sampler,
- uint coord,
- uint op )
-{
- uint k = UREG(GET_UREG_TYPE(coord), GET_UREG_NR(coord));
- if (coord != k) {
- /* No real way to work around this in the general case - need to
- * allocate and declare a new temporary register (a utemp won't
- * do). Will fallback for now.
- */
- i915_program_error(p, "Can't (yet) swizzle TEX arguments");
- assert(0);
- return 0;
- }
-
- /* Don't worry about saturate as we only support
- */
- if (destmask != A0_DEST_CHANNEL_ALL) {
- uint tmp = i915_get_utemp(p);
- i915_emit_texld( p, tmp, A0_DEST_CHANNEL_ALL, sampler, coord, op );
- i915_emit_arith( p, A0_MOV, dest, destmask, 0, tmp, 0, 0 );
- return dest;
- }
- else {
- assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
- assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
-
- if (GET_UREG_TYPE(coord) != REG_TYPE_T) {
- p->nr_tex_indirect++;
- }
-
- *(p->csr++) = (op |
- T0_DEST( dest ) |
- T0_SAMPLER( sampler ));
-
- *(p->csr++) = T1_ADDRESS_REG( coord );
- *(p->csr++) = T2_MBZ;
-
- p->nr_tex_insn++;
- return dest;
- }
-}
-
-
-uint
-i915_emit_const1f(struct i915_fp_compile * p, float c0)
-{
- unsigned reg, idx;
-
- if (c0 == 0.0)
- return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO);
- if (c0 == 1.0)
- return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE);
-
- for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
- if (p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
- continue;
- for (idx = 0; idx < 4; idx++) {
- if (!(p->constant_flags[reg] & (1 << idx)) ||
- p->constants[reg][idx] == c0) {
- p->constants[reg][idx] = c0;
- p->constant_flags[reg] |= 1 << idx;
- if (reg + 1 > p->num_constants)
- p->num_constants = reg + 1;
- return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE);
- }
- }
- }
-
- i915_program_error(p, "i915_emit_const1f: out of constants\n");
- return 0;
-}
-
-uint
-i915_emit_const2f(struct i915_fp_compile * p, float c0, float c1)
-{
- unsigned reg, idx;
-
- if (c0 == 0.0)
- return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W);
- if (c0 == 1.0)
- return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W);
-
- if (c1 == 0.0)
- return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W);
- if (c1 == 1.0)
- return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
-
- for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
- if (p->constant_flags[reg] == 0xf ||
- p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
- continue;
- for (idx = 0; idx < 3; idx++) {
- if (!(p->constant_flags[reg] & (3 << idx))) {
- p->constants[reg][idx + 0] = c0;
- p->constants[reg][idx + 1] = c1;
- p->constant_flags[reg] |= 3 << idx;
- if (reg + 1 > p->num_constants)
- p->num_constants = reg + 1;
- return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO, ONE);
- }
- }
- }
-
- i915_program_error(p, "i915_emit_const2f: out of constants\n");
- return 0;
-}
-
-
-
-uint
-i915_emit_const4f(struct i915_fp_compile * p,
- float c0, float c1, float c2, float c3)
-{
- unsigned reg;
-
- for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
- if (p->constant_flags[reg] == 0xf &&
- p->constants[reg][0] == c0 &&
- p->constants[reg][1] == c1 &&
- p->constants[reg][2] == c2 &&
- p->constants[reg][3] == c3) {
- return UREG(REG_TYPE_CONST, reg);
- }
- else if (p->constant_flags[reg] == 0) {
-
- p->constants[reg][0] = c0;
- p->constants[reg][1] = c1;
- p->constants[reg][2] = c2;
- p->constants[reg][3] = c3;
- p->constant_flags[reg] = 0xf;
- if (reg + 1 > p->num_constants)
- p->num_constants = reg + 1;
- return UREG(REG_TYPE_CONST, reg);
- }
- }
-
- i915_program_error(p, "i915_emit_const4f: out of constants\n");
- return 0;
-}
-
-
-uint
-i915_emit_const4fv(struct i915_fp_compile * p, const float * c)
-{
- return i915_emit_const4f(p, c[0], c[1], c[2], c[3]);
-}
-
-
-#if 00000/*UNUSED*/
-/* Reserve a slot in the constant file for a Mesa state parameter.
- * These will later need to be tracked on statechanges, but that is
- * done elsewhere.
- */
-uint
-i915_emit_param4fv(struct i915_fp_compile * p, const float * values)
-{
- struct i915_fragment_program *fp = p->fp;
- int i;
-
- for (i = 0; i < fp->nr_params; i++) {
- if (fp->param[i].values == values)
- return UREG(REG_TYPE_CONST, fp->param[i].reg);
- }
-
- if (p->constants->nr_constants == I915_MAX_CONSTANT ||
- fp->nr_params == I915_MAX_CONSTANT) {
- i915_program_error(p, "i915_emit_param4fv: out of constants\n");
- return 0;
- }
-
- {
- int reg = p->constants->nr_constants++;
- int i = fp->nr_params++;
-
- assert (p->constant_flags[reg] == 0);
- p->constant_flags[reg] = I915_CONSTFLAG_PARAM;
-
- fp->param[i].values = values;
- fp->param[i].reg = reg;
-
- return UREG(REG_TYPE_CONST, reg);
- }
-}
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_fpc_translate.c b/src/mesa/pipe/i915simple/i915_fpc_translate.c
deleted file mode 100644
index 868f0c7e04..0000000000
--- a/src/mesa/pipe/i915simple/i915_fpc_translate.c
+++ /dev/null
@@ -1,1135 +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.
- *
- **************************************************************************/
-
-
-#include <stdarg.h>
-
-#include "i915_reg.h"
-#include "i915_context.h"
-#include "i915_fpc.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-
-#include "pipe/draw/draw_vertex.h"
-
-
-/**
- * Simple pass-through fragment shader to use when we don't have
- * a real shader (or it fails to compile for some reason).
- */
-static unsigned passthrough[] =
-{
- _3DSTATE_PIXEL_SHADER_PROGRAM | ((2*3)-1),
-
- /* declare input color:
- */
- (D0_DCL |
- (REG_TYPE_T << D0_TYPE_SHIFT) |
- (T_DIFFUSE << D0_NR_SHIFT) |
- D0_CHANNEL_ALL),
- 0,
- 0,
-
- /* move to output color:
- */
- (A0_MOV |
- (REG_TYPE_OC << A0_DEST_TYPE_SHIFT) |
- A0_DEST_CHANNEL_ALL |
- (REG_TYPE_T << A0_SRC0_TYPE_SHIFT) |
- (T_DIFFUSE << A0_SRC0_NR_SHIFT)),
- 0x01230000, /* .xyzw */
- 0
-};
-
-
-/* 1, -1/3!, 1/5!, -1/7! */
-static const float sin_constants[4] = { 1.0,
- -1.0f / (3 * 2 * 1),
- 1.0f / (5 * 4 * 3 * 2 * 1),
- -1.0f / (7 * 6 * 5 * 4 * 3 * 2 * 1)
-};
-
-/* 1, -1/2!, 1/4!, -1/6! */
-static const float cos_constants[4] = { 1.0,
- -1.0f / (2 * 1),
- 1.0f / (4 * 3 * 2 * 1),
- -1.0f / (6 * 5 * 4 * 3 * 2 * 1)
-};
-
-
-
-/**
- * component-wise negation of ureg
- */
-static INLINE int
-negate(int reg, int x, int y, int z, int w)
-{
- /* Another neat thing about the UREG representation */
- return reg ^ (((x & 1) << UREG_CHANNEL_X_NEGATE_SHIFT) |
- ((y & 1) << UREG_CHANNEL_Y_NEGATE_SHIFT) |
- ((z & 1) << UREG_CHANNEL_Z_NEGATE_SHIFT) |
- ((w & 1) << UREG_CHANNEL_W_NEGATE_SHIFT));
-}
-
-
-static void
-i915_use_passthrough_shader(struct i915_context *i915)
-{
- debug_printf("**** Using i915 pass-through fragment shader\n");
-
- i915->current.program = (uint *) MALLOC(sizeof(passthrough));
- if (i915->current.program) {
- memcpy(i915->current.program, passthrough, sizeof(passthrough));
- i915->current.program_len = Elements(passthrough);
- }
-
- i915->current.num_constants[PIPE_SHADER_FRAGMENT] = 0;
- i915->current.num_user_constants[PIPE_SHADER_FRAGMENT] = 0;
-}
-
-
-void
-i915_program_error(struct i915_fp_compile *p, const char *msg, ...)
-{
- va_list args;
- char buffer[1024];
-
- debug_printf("i915_program_error: ");
- va_start( args, msg );
- vsprintf( buffer, msg, args );
- va_end( args );
- debug_printf(buffer);
- debug_printf("\n");
-
- p->error = 1;
-}
-
-
-
-/**
- * Construct a ureg for the given source register. Will emit
- * constants, apply swizzling and negation as needed.
- */
-static uint
-src_vector(struct i915_fp_compile *p,
- const struct tgsi_full_src_register *source)
-{
- uint index = source->SrcRegister.Index;
- uint src, sem_name, sem_ind;
-
- switch (source->SrcRegister.File) {
- case TGSI_FILE_TEMPORARY:
- if (source->SrcRegister.Index >= I915_MAX_TEMPORARY) {
- i915_program_error(p, "Exceeded max temporary reg");
- return 0;
- }
- src = UREG(REG_TYPE_R, index);
- break;
- case TGSI_FILE_INPUT:
- /* XXX: Packing COL1, FOGC into a single attribute works for
- * texenv programs, but will fail for real fragment programs
- * that use these attributes and expect them to be a full 4
- * components wide. Could use a texcoord to pass these
- * attributes if necessary, but that won't work in the general
- * case.
- *
- * We also use a texture coordinate to pass wpos when possible.
- */
-
- /* use vertex format info to map a slot number to a VF attrib */
- assert(index < p->vertex_info->num_attribs);
-
- sem_name = p->input_semantic_name[index];
- sem_ind = p->input_semantic_index[index];
-
- switch (sem_name) {
- case TGSI_SEMANTIC_POSITION:
- debug_printf("SKIP SEM POS\n");
- /*
- assert(p->wpos_tex != -1);
- src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL);
- */
- break;
- case TGSI_SEMANTIC_COLOR:
- if (sem_ind == 0) {
- src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
- }
- else {
- /* secondary color */
- assert(sem_ind == 1);
- src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ);
- src = swizzle(src, X, Y, Z, ONE);
- }
- break;
- case TGSI_SEMANTIC_FOG:
- src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W);
- src = swizzle(src, W, W, W, W);
- break;
- case TGSI_SEMANTIC_GENERIC:
- /* usually a texcoord */
- src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + sem_ind, D0_CHANNEL_ALL);
- break;
- default:
- i915_program_error(p, "Bad source->Index");
- return 0;
- }
- break;
-
- case TGSI_FILE_IMMEDIATE:
- /* XXX unfinished - need to append immediates onto const buffer */
- /* fall-through */
- case TGSI_FILE_CONSTANT:
- src = UREG(REG_TYPE_CONST, index);
- break;
-
- default:
- i915_program_error(p, "Bad source->File");
- return 0;
- }
-
- if (source->SrcRegister.Extended) {
- src = swizzle(src,
- source->SrcRegisterExtSwz.ExtSwizzleX,
- source->SrcRegisterExtSwz.ExtSwizzleY,
- source->SrcRegisterExtSwz.ExtSwizzleZ,
- source->SrcRegisterExtSwz.ExtSwizzleW);
- }
- else {
- src = swizzle(src,
- source->SrcRegister.SwizzleX,
- source->SrcRegister.SwizzleY,
- source->SrcRegister.SwizzleZ,
- source->SrcRegister.SwizzleW);
- }
-
-
- /* There's both negate-all-components and per-component negation.
- * Try to handle both here.
- */
- {
- int nx = source->SrcRegisterExtSwz.NegateX;
- int ny = source->SrcRegisterExtSwz.NegateY;
- int nz = source->SrcRegisterExtSwz.NegateZ;
- int nw = source->SrcRegisterExtSwz.NegateW;
- if (source->SrcRegister.Negate) {
- nx = !nx;
- ny = !ny;
- nz = !nz;
- nw = !nw;
- }
- src = negate(src, nx, ny, nz, nw);
- }
-
- /* no abs() or post-abs negation */
-#if 0
- /* XXX assertions disabled to allow arbfplight.c to run */
- /* XXX enable these assertions, or fix things */
- assert(!source->SrcRegisterExtMod.Absolute);
- assert(!source->SrcRegisterExtMod.Negate);
-#endif
- return src;
-}
-
-
-/**
- * Construct a ureg for a destination register.
- */
-static uint
-get_result_vector(struct i915_fp_compile *p,
- const struct tgsi_full_dst_register *dest)
-{
- switch (dest->DstRegister.File) {
- case TGSI_FILE_OUTPUT:
- {
- uint sem_name = p->output_semantic_name[dest->DstRegister.Index];
- switch (sem_name) {
- case TGSI_SEMANTIC_POSITION:
- return UREG(REG_TYPE_OD, 0);
- case TGSI_SEMANTIC_COLOR:
- return UREG(REG_TYPE_OC, 0);
- default:
- i915_program_error(p, "Bad inst->DstReg.Index/semantics");
- return 0;
- }
- }
- case TGSI_FILE_TEMPORARY:
- return UREG(REG_TYPE_R, dest->DstRegister.Index);
- default:
- i915_program_error(p, "Bad inst->DstReg.File");
- return 0;
- }
-}
-
-
-/**
- * Compute flags for saturation and writemask.
- */
-static uint
-get_result_flags(const struct tgsi_full_instruction *inst)
-{
- const uint writeMask
- = inst->FullDstRegisters[0].DstRegister.WriteMask;
- uint flags = 0x0;
-
- if (inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE)
- flags |= A0_DEST_SATURATE;
-
- if (writeMask & TGSI_WRITEMASK_X)
- flags |= A0_DEST_CHANNEL_X;
- if (writeMask & TGSI_WRITEMASK_Y)
- flags |= A0_DEST_CHANNEL_Y;
- if (writeMask & TGSI_WRITEMASK_Z)
- flags |= A0_DEST_CHANNEL_Z;
- if (writeMask & TGSI_WRITEMASK_W)
- flags |= A0_DEST_CHANNEL_W;
-
- return flags;
-}
-
-
-/**
- * Convert TGSI_TEXTURE_x token to DO_SAMPLE_TYPE_x token
- */
-static uint
-translate_tex_src_target(struct i915_fp_compile *p, uint tex)
-{
- switch (tex) {
- case TGSI_TEXTURE_1D:
- return D0_SAMPLE_TYPE_2D;
- case TGSI_TEXTURE_2D:
- return D0_SAMPLE_TYPE_2D;
- case TGSI_TEXTURE_RECT:
- return D0_SAMPLE_TYPE_2D;
- case TGSI_TEXTURE_3D:
- return D0_SAMPLE_TYPE_VOLUME;
- case TGSI_TEXTURE_CUBE:
- return D0_SAMPLE_TYPE_CUBE;
- default:
- i915_program_error(p, "TexSrc type");
- return 0;
- }
-}
-
-
-/**
- * Generate texel lookup instruction.
- */
-static void
-emit_tex(struct i915_fp_compile *p,
- const struct tgsi_full_instruction *inst,
- uint opcode)
-{
- uint texture = inst->InstructionExtTexture.Texture;
- uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
- uint tex = translate_tex_src_target( p, texture );
- uint sampler = i915_emit_decl(p, REG_TYPE_S, unit, tex);
- uint coord = src_vector( p, &inst->FullSrcRegisters[0]);
-
- i915_emit_texld( p,
- get_result_vector( p, &inst->FullDstRegisters[0] ),
- get_result_flags( inst ),
- sampler,
- coord,
- opcode);
-}
-
-
-/**
- * Generate a simple arithmetic instruction
- * \param opcode the i915 opcode
- * \param numArgs the number of input/src arguments
- */
-static void
-emit_simple_arith(struct i915_fp_compile *p,
- const struct tgsi_full_instruction *inst,
- uint opcode, uint numArgs)
-{
- uint arg1, arg2, arg3;
-
- assert(numArgs <= 3);
-
- arg1 = (numArgs < 1) ? 0 : src_vector( p, &inst->FullSrcRegisters[0] );
- arg2 = (numArgs < 2) ? 0 : src_vector( p, &inst->FullSrcRegisters[1] );
- arg3 = (numArgs < 3) ? 0 : src_vector( p, &inst->FullSrcRegisters[2] );
-
- i915_emit_arith( p,
- opcode,
- get_result_vector( p, &inst->FullDstRegisters[0]),
- get_result_flags( inst ), 0,
- arg1,
- arg2,
- arg3 );
-}
-
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
-/*
- * Translate TGSI instruction to i915 instruction.
- *
- * Possible concerns:
- *
- * SIN, COS -- could use another taylor step?
- * LIT -- results seem a little different to sw mesa
- * LOG -- different to mesa on negative numbers, but this is conformant.
- */
-static void
-i915_translate_instruction(struct i915_fp_compile *p,
- const struct tgsi_full_instruction *inst)
-{
- uint writemask;
- uint src0, src1, src2, flags;
- uint tmp = 0;
-
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ABS:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- i915_emit_arith(p,
- A0_MAX,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- src0, negate(src0, 1, 1, 1, 1), 0);
- break;
-
- case TGSI_OPCODE_ADD:
- emit_simple_arith(p, inst, A0_ADD, 2);
- break;
-
- case TGSI_OPCODE_CMP:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
- src2 = src_vector(p, &inst->FullSrcRegisters[2]);
- i915_emit_arith(p, A0_CMP,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst),
- 0, src0, src2, src1); /* NOTE: order of src2, src1 */
- break;
-
- case TGSI_OPCODE_COS:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_X, 0,
- src0, i915_emit_const1f(p, 1.0f / (float) (M_PI * 2.0)), 0);
-
- i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
-
- /* By choosing different taylor constants, could get rid of this mul:
- */
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_X, 0,
- tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0);
-
- /*
- * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
- * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1
- * t0 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1
- * result = DP4 t0, cos_constants
- */
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XY, 0,
- swizzle(tmp, X, X, ONE, ONE),
- swizzle(tmp, X, ONE, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XYZ, 0,
- swizzle(tmp, X, Y, X, ONE),
- swizzle(tmp, X, X, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XYZ, 0,
- swizzle(tmp, X, X, Z, ONE),
- swizzle(tmp, Z, ONE, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_DP4,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(tmp, ONE, Z, Y, X),
- i915_emit_const4fv(p, cos_constants), 0);
- break;
-
- case TGSI_OPCODE_DP3:
- emit_simple_arith(p, inst, A0_DP3, 2);
- break;
-
- case TGSI_OPCODE_DP4:
- emit_simple_arith(p, inst, A0_DP4, 2);
- break;
-
- case TGSI_OPCODE_DPH:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
-
- i915_emit_arith(p,
- A0_DP4,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, X, Y, Z, ONE), src1, 0);
- break;
-
- case TGSI_OPCODE_DST:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
-
- /* result[0] = 1 * 1;
- * result[1] = a[1] * b[1];
- * result[2] = a[2] * 1;
- * result[3] = 1 * b[3];
- */
- i915_emit_arith(p,
- A0_MUL,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, ONE, Y, Z, ONE),
- swizzle(src1, ONE, Y, ONE, W), 0);
- break;
-
- case TGSI_OPCODE_END:
- /* no-op */
- break;
-
- case TGSI_OPCODE_EX2:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-
- i915_emit_arith(p,
- A0_EXP,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, X, X, X, X), 0, 0);
- break;
-
- case TGSI_OPCODE_FLR:
- emit_simple_arith(p, inst, A0_FLR, 1);
- break;
-
- case TGSI_OPCODE_FRC:
- emit_simple_arith(p, inst, A0_FRC, 1);
- break;
-
- case TGSI_OPCODE_KIL:
- /* unconditional kill */
- assert(0); /* not tested yet */
-#if 0
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- i915_emit_texld(p, tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */
- 0, src0, T0_TEXKILL);
-#endif
- break;
-
- case TGSI_OPCODE_KILP:
- /* kill if src[0].x < 0 || src[0].y < 0 ... */
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- i915_emit_texld(p, tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */
- 0, src0, T0_TEXKILL);
- break;
-
- case TGSI_OPCODE_LG2:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-
- i915_emit_arith(p,
- A0_LOG,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, X, X, X, X), 0, 0);
- break;
-
- case TGSI_OPCODE_LIT:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- /* tmp = max( a.xyzw, a.00zw )
- * XXX: Clamp tmp.w to -128..128
- * tmp.y = log(tmp.y)
- * tmp.y = tmp.w * tmp.y
- * tmp.y = exp(tmp.y)
- * result = cmp (a.11-x1, a.1x01, a.1xy1 )
- */
- i915_emit_arith(p, A0_MAX, tmp, A0_DEST_CHANNEL_ALL, 0,
- src0, swizzle(src0, ZERO, ZERO, Z, W), 0);
-
- i915_emit_arith(p, A0_LOG, tmp, A0_DEST_CHANNEL_Y, 0,
- swizzle(tmp, Y, Y, Y, Y), 0, 0);
-
- i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_Y, 0,
- swizzle(tmp, ZERO, Y, ZERO, ZERO),
- swizzle(tmp, ZERO, W, ZERO, ZERO), 0);
-
- i915_emit_arith(p, A0_EXP, tmp, A0_DEST_CHANNEL_Y, 0,
- swizzle(tmp, Y, Y, Y, Y), 0, 0);
-
- i915_emit_arith(p, A0_CMP,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- negate(swizzle(tmp, ONE, ONE, X, ONE), 0, 0, 1, 0),
- swizzle(tmp, ONE, X, ZERO, ONE),
- swizzle(tmp, ONE, X, Y, ONE));
-
- break;
-
- case TGSI_OPCODE_LRP:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
- src2 = src_vector(p, &inst->FullSrcRegisters[2]);
- flags = get_result_flags(inst);
- tmp = i915_get_utemp(p);
-
- /* b*a + c*(1-a)
- *
- * b*a + c - ca
- *
- * tmp = b*a + c,
- * result = (-c)*a + tmp
- */
- i915_emit_arith(p, A0_MAD, tmp,
- flags & A0_DEST_CHANNEL_ALL, 0, src1, src0, src2);
-
- i915_emit_arith(p, A0_MAD,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- flags, 0, negate(src2, 1, 1, 1, 1), src0, tmp);
- break;
-
- case TGSI_OPCODE_MAD:
- emit_simple_arith(p, inst, A0_MAD, 3);
- break;
-
- case TGSI_OPCODE_MAX:
- emit_simple_arith(p, inst, A0_MAX, 2);
- break;
-
- case TGSI_OPCODE_MIN:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
- tmp = i915_get_utemp(p);
- flags = get_result_flags(inst);
-
- i915_emit_arith(p,
- A0_MAX,
- tmp, flags & A0_DEST_CHANNEL_ALL, 0,
- negate(src0, 1, 1, 1, 1),
- negate(src1, 1, 1, 1, 1), 0);
-
- i915_emit_arith(p,
- A0_MOV,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- flags, 0, negate(tmp, 1, 1, 1, 1), 0, 0);
- break;
-
- case TGSI_OPCODE_MOV:
- /* aka TGSI_OPCODE_SWZ */
- emit_simple_arith(p, inst, A0_MOV, 1);
- break;
-
- case TGSI_OPCODE_MUL:
- emit_simple_arith(p, inst, A0_MUL, 2);
- break;
-
- case TGSI_OPCODE_POW:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
- tmp = i915_get_utemp(p);
- flags = get_result_flags(inst);
-
- /* XXX: masking on intermediate values, here and elsewhere.
- */
- i915_emit_arith(p,
- A0_LOG,
- tmp, A0_DEST_CHANNEL_X, 0,
- swizzle(src0, X, X, X, X), 0, 0);
-
- i915_emit_arith(p, A0_MUL, tmp, A0_DEST_CHANNEL_X, 0, tmp, src1, 0);
-
- i915_emit_arith(p,
- A0_EXP,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- flags, 0, swizzle(tmp, X, X, X, X), 0, 0);
- break;
-
- case TGSI_OPCODE_RET:
- /* XXX: no-op? */
- break;
-
- case TGSI_OPCODE_RCP:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-
- i915_emit_arith(p,
- A0_RCP,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, X, X, X, X), 0, 0);
- break;
-
- case TGSI_OPCODE_RSQ:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
-
- i915_emit_arith(p,
- A0_RSQ,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, X, X, X, X), 0, 0);
- break;
-
- case TGSI_OPCODE_SCS:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- /*
- * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
- * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
- * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x
- * scs.x = DP4 t1, sin_constants
- * t1 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1
- * scs.y = DP4 t1, cos_constants
- */
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XY, 0,
- swizzle(src0, X, X, ONE, ONE),
- swizzle(src0, X, ONE, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_ALL, 0,
- swizzle(tmp, X, Y, X, Y),
- swizzle(tmp, X, X, ONE, ONE), 0);
-
- writemask = inst->FullDstRegisters[0].DstRegister.WriteMask;
-
- if (writemask & TGSI_WRITEMASK_Y) {
- uint tmp1;
-
- if (writemask & TGSI_WRITEMASK_X)
- tmp1 = i915_get_utemp(p);
- else
- tmp1 = tmp;
-
- i915_emit_arith(p,
- A0_MUL,
- tmp1, A0_DEST_CHANNEL_ALL, 0,
- swizzle(tmp, X, Y, Y, W),
- swizzle(tmp, X, Z, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_DP4,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- A0_DEST_CHANNEL_Y, 0,
- swizzle(tmp1, W, Z, Y, X),
- i915_emit_const4fv(p, sin_constants), 0);
- }
-
- if (writemask & TGSI_WRITEMASK_X) {
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XYZ, 0,
- swizzle(tmp, X, X, Z, ONE),
- swizzle(tmp, Z, ONE, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_DP4,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- A0_DEST_CHANNEL_X, 0,
- swizzle(tmp, ONE, Z, Y, X),
- i915_emit_const4fv(p, cos_constants), 0);
- }
- break;
-
- case TGSI_OPCODE_SGE:
- emit_simple_arith(p, inst, A0_SGE, 2);
- break;
-
- case TGSI_OPCODE_SIN:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- tmp = i915_get_utemp(p);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_X, 0,
- src0, i915_emit_const1f(p, 1.0f / (float) (M_PI * 2.0)), 0);
-
- i915_emit_arith(p, A0_MOD, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0);
-
- /* By choosing different taylor constants, could get rid of this mul:
- */
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_X, 0,
- tmp, i915_emit_const1f(p, (float) (M_PI * 2.0)), 0);
-
- /*
- * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
- * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
- * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x
- * result = DP4 t1.wzyx, sin_constants
- */
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_XY, 0,
- swizzle(tmp, X, X, ONE, ONE),
- swizzle(tmp, X, ONE, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_ALL, 0,
- swizzle(tmp, X, Y, X, Y),
- swizzle(tmp, X, X, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_ALL, 0,
- swizzle(tmp, X, Y, Y, W),
- swizzle(tmp, X, Z, ONE, ONE), 0);
-
- i915_emit_arith(p,
- A0_DP4,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(tmp, W, Z, Y, X),
- i915_emit_const4fv(p, sin_constants), 0);
- break;
-
- case TGSI_OPCODE_SLT:
- emit_simple_arith(p, inst, A0_SLT, 2);
- break;
-
- case TGSI_OPCODE_SUB:
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
-
- i915_emit_arith(p,
- A0_ADD,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- src0, negate(src1, 1, 1, 1, 1), 0);
- break;
-
- case TGSI_OPCODE_TEX:
- if (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide
- == TGSI_EXTSWIZZLE_W) {
- emit_tex(p, inst, T0_TEXLDP);
- }
- else {
- emit_tex(p, inst, T0_TEXLD);
- }
- break;
-
- case TGSI_OPCODE_TXB:
- emit_tex(p, inst, T0_TEXLDB);
- break;
-
- case TGSI_OPCODE_XPD:
- /* Cross product:
- * result.x = src0.y * src1.z - src0.z * src1.y;
- * result.y = src0.z * src1.x - src0.x * src1.z;
- * result.z = src0.x * src1.y - src0.y * src1.x;
- * result.w = undef;
- */
- src0 = src_vector(p, &inst->FullSrcRegisters[0]);
- src1 = src_vector(p, &inst->FullSrcRegisters[1]);
- tmp = i915_get_utemp(p);
-
- i915_emit_arith(p,
- A0_MUL,
- tmp, A0_DEST_CHANNEL_ALL, 0,
- swizzle(src0, Z, X, Y, ONE),
- swizzle(src1, Y, Z, X, ONE), 0);
-
- i915_emit_arith(p,
- A0_MAD,
- get_result_vector(p, &inst->FullDstRegisters[0]),
- get_result_flags(inst), 0,
- swizzle(src0, Y, Z, X, ONE),
- swizzle(src1, Z, X, Y, ONE),
- negate(tmp, 1, 1, 1, 0));
- break;
-
- default:
- i915_program_error(p, "bad opcode %d", inst->Instruction.Opcode);
- return;
- }
-
- i915_release_utemps(p);
-}
-
-
-/**
- * Translate TGSI fragment shader into i915 hardware instructions.
- * \param p the translation state
- * \param tokens the TGSI token array
- */
-static void
-i915_translate_instructions(struct i915_fp_compile *p,
- const struct tgsi_token *tokens)
-{
- struct tgsi_parse_context parse;
-
- tgsi_parse_init( &parse, tokens );
-
- while( !tgsi_parse_end_of_tokens( &parse ) ) {
-
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- if (parse.FullToken.FullDeclaration.Declaration.File
- == TGSI_FILE_INPUT) {
- /* save input register info for use in src_vector() */
- uint ind, sem, semi;
- ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
- semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
- /*debug_printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
- p->input_semantic_name[ind] = sem;
- p->input_semantic_index[ind] = semi;
- }
- else if (parse.FullToken.FullDeclaration.Declaration.File
- == TGSI_FILE_OUTPUT) {
- /* save output register info for use in get_result_vector() */
- uint ind, sem, semi;
- ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
- semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
- /*debug_printf("FS Output DECL [%u] sem %u\n", ind, sem);*/
- p->output_semantic_name[ind] = sem;
- p->output_semantic_index[ind] = semi;
- }
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- /* XXX append the immediate to the const buffer... */
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- i915_translate_instruction(p, &parse.FullToken.FullInstruction);
- break;
-
- default:
- assert( 0 );
- }
-
- } /* while */
-
- tgsi_parse_free (&parse);
-}
-
-
-static struct i915_fp_compile *
-i915_init_compile(struct i915_context *i915,
- const struct pipe_shader_state *fs)
-{
- struct i915_fp_compile *p = CALLOC_STRUCT(i915_fp_compile);
-
- p->shader = i915->fs;
-
- p->vertex_info = &i915->current.vertex_info;
-
- /* new constants found during translation get appended after the
- * user-provided constants.
- */
- p->constants = i915->current.constants[PIPE_SHADER_FRAGMENT];
- p->num_constants = i915->current.num_user_constants[PIPE_SHADER_FRAGMENT];
-
- p->nr_tex_indirect = 1; /* correct? */
- p->nr_tex_insn = 0;
- p->nr_alu_insn = 0;
- p->nr_decl_insn = 0;
-
- memset(p->constant_flags, 0, sizeof(p->constant_flags));
-
- p->csr = p->program;
- p->decl = p->declarations;
- p->decl_s = 0;
- p->decl_t = 0;
- p->temp_flag = 0xffff000;
- p->utemp_flag = ~0x7;
-
- p->wpos_tex = -1;
-
- /* initialize the first program word */
- *(p->decl++) = _3DSTATE_PIXEL_SHADER_PROGRAM;
-
- return p;
-}
-
-
-/* Copy compile results to the fragment program struct and destroy the
- * compilation context.
- */
-static void
-i915_fini_compile(struct i915_context *i915, struct i915_fp_compile *p)
-{
- unsigned long program_size = (unsigned long) (p->csr - p->program);
- unsigned long decl_size = (unsigned long) (p->decl - p->declarations);
-
- if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
- i915_program_error(p, "Exceeded max nr indirect texture lookups");
-
- if (p->nr_tex_insn > I915_MAX_TEX_INSN)
- i915_program_error(p, "Exceeded max TEX instructions");
-
- if (p->nr_alu_insn > I915_MAX_ALU_INSN)
- i915_program_error(p, "Exceeded max ALU instructions");
-
- if (p->nr_decl_insn > I915_MAX_DECL_INSN)
- i915_program_error(p, "Exceeded max DECL instructions");
-
- /* free old program, if present */
- if (i915->current.program) {
- FREE(i915->current.program);
- i915->current.program_len = 0;
- }
-
- if (p->error) {
- p->NumNativeInstructions = 0;
- p->NumNativeAluInstructions = 0;
- p->NumNativeTexInstructions = 0;
- p->NumNativeTexIndirections = 0;
-
- i915_use_passthrough_shader(i915);
- }
- else {
- p->NumNativeInstructions
- = p->nr_alu_insn + p->nr_tex_insn + p->nr_decl_insn;
- p->NumNativeAluInstructions = p->nr_alu_insn;
- p->NumNativeTexInstructions = p->nr_tex_insn;
- p->NumNativeTexIndirections = p->nr_tex_indirect;
-
- /* patch in the program length */
- p->declarations[0] |= program_size + decl_size - 2;
-
- /* Copy compilation results to fragment program struct:
- */
- i915->current.program
- = (uint *) MALLOC((program_size + decl_size) * sizeof(uint));
- if (i915->current.program) {
- i915->current.program_len = program_size + decl_size;
-
- memcpy(i915->current.program,
- p->declarations,
- decl_size * sizeof(uint));
-
- memcpy(i915->current.program + decl_size,
- p->program,
- program_size * sizeof(uint));
- }
-
- /* update number of constants */
- i915->current.num_constants[PIPE_SHADER_FRAGMENT] = p->num_constants;
- assert(i915->current.num_constants[PIPE_SHADER_FRAGMENT]
- >= i915->current.num_user_constants[PIPE_SHADER_FRAGMENT]);
- }
-
- /* Release the compilation struct:
- */
- FREE(p);
-}
-
-
-/**
- * Find an unused texture coordinate slot to use for fragment WPOS.
- * Update p->fp->wpos_tex with the result (-1 if no used texcoord slot is found).
- */
-static void
-i915_find_wpos_space(struct i915_fp_compile *p)
-{
-#if 0
- const uint inputs
- = p->shader->inputs_read | (1 << TGSI_ATTRIB_POS); /*XXX hack*/
- uint i;
-
- p->wpos_tex = -1;
-
- if (inputs & (1 << TGSI_ATTRIB_POS)) {
- for (i = 0; i < I915_TEX_UNITS; i++) {
- if ((inputs & (1 << (TGSI_ATTRIB_TEX0 + i))) == 0) {
- p->wpos_tex = i;
- return;
- }
- }
-
- i915_program_error(p, "No free texcoord for wpos value");
- }
-#else
- if (p->shader->input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
- /* frag shader using the fragment position input */
-#if 0
- assert(0);
-#endif
- }
-#endif
-}
-
-
-
-
-/**
- * Rather than trying to intercept and jiggle depth writes during
- * emit, just move the value into its correct position at the end of
- * the program:
- */
-static void
-i915_fixup_depth_write(struct i915_fp_compile *p)
-{
- /* XXX assuming pos/depth is always in output[0] */
- if (p->shader->output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
- const uint depth = UREG(REG_TYPE_OD, 0);
-
- i915_emit_arith(p,
- A0_MOV, /* opcode */
- depth, /* dest reg */
- A0_DEST_CHANNEL_W, /* write mask */
- 0, /* saturate? */
- swizzle(depth, X, Y, Z, Z), /* src0 */
- 0, 0 /* src1, src2 */);
- }
-}
-
-
-void
-i915_translate_fragment_program( struct i915_context *i915 )
-{
- struct i915_fp_compile *p = i915_init_compile(i915, i915->fs);
- const struct tgsi_token *tokens = i915->fs->tokens;
-
- i915_find_wpos_space(p);
-
- i915_translate_instructions(p, tokens);
- i915_fixup_depth_write(p);
-
- i915_fini_compile(i915, p);
-}
diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c
deleted file mode 100644
index c4a706c37d..0000000000
--- a/src/mesa/pipe/i915simple/i915_prim_emit.c
+++ /dev/null
@@ -1,215 +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.
- *
- **************************************************************************/
-
-
-#include "pipe/draw/draw_private.h"
-#include "pipe/p_util.h"
-
-#include "i915_context.h"
-#include "i915_winsys.h"
-#include "i915_reg.h"
-#include "i915_state.h"
-#include "i915_batch.h"
-
-
-
-/**
- * Primitive emit to hardware. No support for vertex buffers or any
- * nice fast paths.
- */
-struct setup_stage {
- struct draw_stage stage; /**< This must be first (base class) */
-
- struct i915_context *i915;
-};
-
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct setup_stage *setup_stage( struct draw_stage *stage )
-{
- return (struct setup_stage *)stage;
-}
-
-
-/**
- * Extract the needed fields from vertex_header and emit i915 dwords.
- * Recall that the vertices are constructed by the 'draw' module and
- * have a couple of slots at the beginning (1-dword header, 4-dword
- * clip pos) that we ignore here.
- */
-static INLINE void
-emit_hw_vertex( struct i915_context *i915,
- const struct vertex_header *vertex)
-{
- const struct vertex_info *vinfo = &i915->current.vertex_info;
- uint i;
- uint count = 0; /* for debug/sanity */
-
- for (i = 0; i < vinfo->num_attribs; i++) {
- switch (vinfo->emit[i]) {
- case EMIT_OMIT:
- /* no-op */
- break;
- case EMIT_1F:
- OUT_BATCH( fui(vertex->data[i][0]) );
- count++;
- break;
- case EMIT_2F:
- OUT_BATCH( fui(vertex->data[i][0]) );
- OUT_BATCH( fui(vertex->data[i][1]) );
- count += 2;
- break;
- case EMIT_3F:
- OUT_BATCH( fui(vertex->data[i][0]) );
- OUT_BATCH( fui(vertex->data[i][1]) );
- OUT_BATCH( fui(vertex->data[i][2]) );
- count += 3;
- break;
- case EMIT_4F:
- OUT_BATCH( fui(vertex->data[i][0]) );
- OUT_BATCH( fui(vertex->data[i][1]) );
- OUT_BATCH( fui(vertex->data[i][2]) );
- OUT_BATCH( fui(vertex->data[i][3]) );
- count += 4;
- break;
- case EMIT_4UB:
- OUT_BATCH( pack_ub4(float_to_ubyte( vertex->data[i][2] ),
- float_to_ubyte( vertex->data[i][1] ),
- float_to_ubyte( vertex->data[i][0] ),
- float_to_ubyte( vertex->data[i][3] )) );
- count += 1;
- break;
- default:
- assert(0);
- }
- }
- assert(count == vinfo->size);
-}
-
-
-
-static INLINE void
-emit_prim( struct draw_stage *stage,
- struct prim_header *prim,
- unsigned hwprim,
- unsigned nr )
-{
- struct i915_context *i915 = setup_stage(stage)->i915;
- unsigned vertex_size = i915->current.vertex_info.size * 4; /* in bytes */
- unsigned i;
-
- assert(vertex_size >= 12); /* never smaller than 12 bytes */
-
- if (i915->dirty)
- i915_update_derived( i915 );
-
- if (i915->hardware_dirty)
- i915_emit_hardware_state( i915 );
-
- if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) {
- FLUSH_BATCH();
-
- /* Make sure state is re-emitted after a flush:
- */
- i915_update_derived( i915 );
- i915_emit_hardware_state( i915 );
-
- if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) {
- assert(0);
- return;
- }
- }
-
- /* Emit each triangle as a single primitive. I told you this was
- * simple.
- */
- OUT_BATCH(_3DPRIMITIVE |
- hwprim |
- ((4 + vertex_size * nr)/4 - 2));
-
- for (i = 0; i < nr; i++)
- emit_hw_vertex(i915, prim->v[i]);
-}
-
-
-static void
-setup_tri( struct draw_stage *stage, struct prim_header *prim )
-{
- emit_prim( stage, prim, PRIM3D_TRILIST, 3 );
-}
-
-
-static void
-setup_line(struct draw_stage *stage, struct prim_header *prim)
-{
- emit_prim( stage, prim, PRIM3D_LINELIST, 2 );
-}
-
-
-static void
-setup_point(struct draw_stage *stage, struct prim_header *prim)
-{
- emit_prim( stage, prim, PRIM3D_POINTLIST, 1 );
-}
-
-
-static void setup_flush( struct draw_stage *stage, unsigned flags )
-{
-}
-
-static void reset_stipple_counter( struct draw_stage *stage )
-{
-}
-
-static void render_destroy( struct draw_stage *stage )
-{
- FREE( stage );
-}
-
-
-/**
- * Create a new primitive setup/render stage. This gets plugged into
- * the 'draw' module's pipeline.
- */
-struct draw_stage *i915_draw_render_stage( struct i915_context *i915 )
-{
- struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
-
- setup->i915 = i915;
- setup->stage.draw = i915->draw;
- setup->stage.point = setup_point;
- setup->stage.line = setup_line;
- setup->stage.tri = setup_tri;
- setup->stage.flush = setup_flush;
- setup->stage.reset_stipple_counter = reset_stipple_counter;
- setup->stage.destroy = render_destroy;
-
- return &setup->stage;
-}
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
deleted file mode 100644
index e069773fd4..0000000000
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Build post-transformation, post-clipping vertex buffers and element
- * lists by hooking into the end of the primitive pipeline and
- * manipulating the vertex_id field in the vertex headers.
- *
- * XXX: work in progress
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- * \author Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/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 "i915_context.h"
-#include "i915_reg.h"
-#include "i915_winsys.h"
-#include "i915_batch.h"
-#include "i915_state.h"
-
-
-/**
- * Primitive renderer for i915.
- */
-struct i915_vbuf_render {
- struct vbuf_render base;
-
- struct i915_context *i915;
-
- /** Vertex size in bytes */
- unsigned vertex_size;
-
- /** Hardware primitive */
- unsigned hwprim;
-};
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct i915_vbuf_render *
-i915_vbuf_render( struct vbuf_render *render )
-{
- assert(render);
- return (struct i915_vbuf_render *)render;
-}
-
-
-static const struct vertex_info *
-i915_vbuf_render_get_vertex_info( struct vbuf_render *render )
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
- struct i915_context *i915 = i915_render->i915;
- return &i915->current.vertex_info;
-}
-
-
-static void *
-i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
- ushort vertex_size,
- ushort nr_vertices )
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
- struct i915_context *i915 = i915_render->i915;
- struct pipe_winsys *winsys = i915->pipe.winsys;
- size_t size = (size_t)vertex_size * (size_t)nr_vertices;
-
- /* FIXME: handle failure */
- assert(!i915->vbo);
- i915->vbo = winsys->buffer_create(winsys, 64, I915_BUFFER_USAGE_LIT_VERTEX,
- size);
-
- i915->dirty |= I915_NEW_VBO;
-
- return winsys->buffer_map(winsys,
- i915->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
-}
-
-
-static void
-i915_vbuf_render_set_primitive( struct vbuf_render *render,
- unsigned prim )
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
-
- switch(prim) {
- case PIPE_PRIM_POINTS:
- i915_render->hwprim = PRIM3D_POINTLIST;
- break;
- case PIPE_PRIM_LINES:
- i915_render->hwprim = PRIM3D_LINELIST;
- break;
- case PIPE_PRIM_TRIANGLES:
- i915_render->hwprim = PRIM3D_TRILIST;
- break;
- default:
- assert(0);
- }
-}
-
-
-static void
-i915_vbuf_render_draw( struct vbuf_render *render,
- const ushort *indices,
- uint nr_indices)
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
- struct i915_context *i915 = i915_render->i915;
- unsigned i;
-
- assert(nr_indices);
-
- assert((i915->dirty & ~I915_NEW_VBO) == 0);
-
- if (i915->dirty)
- i915_update_derived( i915 );
-
- if (i915->hardware_dirty)
- i915_emit_hardware_state( i915 );
-
- if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) {
- FLUSH_BATCH();
-
- /* Make sure state is re-emitted after a flush:
- */
- i915_update_derived( i915 );
- i915_emit_hardware_state( i915 );
-
- if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) {
- assert(0);
- return;
- }
- }
-
- OUT_BATCH( _3DPRIMITIVE |
- PRIM_INDIRECT |
- i915_render->hwprim |
- PRIM_INDIRECT_ELTS |
- nr_indices );
- for (i = 0; i + 1 < nr_indices; i += 2) {
- OUT_BATCH( indices[i] |
- (indices[i + 1] << 16) );
- }
- if (i < nr_indices) {
- OUT_BATCH( indices[i] );
- }
-}
-
-
-static void
-i915_vbuf_render_release_vertices( struct vbuf_render *render,
- void *vertices,
- unsigned vertex_size,
- unsigned vertices_used )
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
- struct i915_context *i915 = i915_render->i915;
- struct pipe_winsys *winsys = i915->pipe.winsys;
-
- assert(i915->vbo);
- winsys->buffer_unmap(winsys, i915->vbo);
- pipe_buffer_reference(winsys, &i915->vbo, NULL);
-}
-
-
-static void
-i915_vbuf_render_destroy( struct vbuf_render *render )
-{
- struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
- FREE(i915_render);
-}
-
-
-/**
- * Create a new primitive render.
- */
-static struct vbuf_render *
-i915_vbuf_render_create( struct i915_context *i915 )
-{
- struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
-
- i915_render->i915 = i915;
-
- i915_render->base.max_vertex_buffer_bytes = 128*1024;
-
- /* NOTE: it must be such that state and vertices indices fit in a single
- * batch buffer.
- */
- i915_render->base.max_indices = 16*1024;
-
- i915_render->base.get_vertex_info = i915_vbuf_render_get_vertex_info;
- i915_render->base.allocate_vertices = i915_vbuf_render_allocate_vertices;
- i915_render->base.set_primitive = i915_vbuf_render_set_primitive;
- i915_render->base.draw = i915_vbuf_render_draw;
- i915_render->base.release_vertices = i915_vbuf_render_release_vertices;
- i915_render->base.destroy = i915_vbuf_render_destroy;
-
- return &i915_render->base;
-}
-
-
-/**
- * Create a new primitive vbuf/render stage.
- */
-struct draw_stage *i915_draw_vbuf_stage( struct i915_context *i915 )
-{
- struct vbuf_render *render;
- struct draw_stage *stage;
-
- render = i915_vbuf_render_create(i915);
- if(!render)
- return NULL;
-
- stage = draw_vbuf_stage( i915->draw, render );
- if(!stage) {
- render->destroy(render);
- return NULL;
- }
-
- return stage;
-}
diff --git a/src/mesa/pipe/i915simple/i915_reg.h b/src/mesa/pipe/i915simple/i915_reg.h
deleted file mode 100644
index 04620fec68..0000000000
--- a/src/mesa/pipe/i915simple/i915_reg.h
+++ /dev/null
@@ -1,978 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef I915_REG_H
-#define I915_REG_H
-
-
-#define I915_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
-
-#define CMD_3D (0x3<<29)
-
-#define PRIM3D_INLINE (CMD_3D | (0x1f<<24))
-#define PRIM3D_TRILIST (0x0<<18)
-#define PRIM3D_TRISTRIP (0x1<<18)
-#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
-#define PRIM3D_TRIFAN (0x3<<18)
-#define PRIM3D_POLY (0x4<<18)
-#define PRIM3D_LINELIST (0x5<<18)
-#define PRIM3D_LINESTRIP (0x6<<18)
-#define PRIM3D_RECTLIST (0x7<<18)
-#define PRIM3D_POINTLIST (0x8<<18)
-#define PRIM3D_DIB (0x9<<18)
-#define PRIM3D_CLEAR_RECT (0xa<<18)
-#define PRIM3D_ZONE_INIT (0xd<<18)
-#define PRIM3D_MASK (0x1f<<18)
-
-/* p137 */
-#define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24))
-#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
-#define AA_LINE_ECAAR_WIDTH_0_5 0
-#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
-#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
-#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
-#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
-#define AA_LINE_REGION_WIDTH_0_5 0
-#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
-#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
-#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
-
-/* 3DSTATE_BACKFACE_STENCIL_OPS, p138*/
-#define _3DSTATE_BACKFACE_STENCIL_OPS (CMD_3D | (0x8<<24))
-#define BFO_ENABLE_STENCIL_REF (1<<23)
-#define BFO_STENCIL_REF_SHIFT 15
-#define BFO_STENCIL_REF_MASK (0xff<<15)
-#define BFO_ENABLE_STENCIL_FUNCS (1<<14)
-#define BFO_STENCIL_TEST_SHIFT 11
-#define BFO_STENCIL_TEST_MASK (0x7<<11)
-#define BFO_STENCIL_FAIL_SHIFT 8
-#define BFO_STENCIL_FAIL_MASK (0x7<<8)
-#define BFO_STENCIL_PASS_Z_FAIL_SHIFT 5
-#define BFO_STENCIL_PASS_Z_FAIL_MASK (0x7<<5)
-#define BFO_STENCIL_PASS_Z_PASS_SHIFT 2
-#define BFO_STENCIL_PASS_Z_PASS_MASK (0x7<<2)
-#define BFO_ENABLE_STENCIL_TWO_SIDE (1<<1)
-#define BFO_STENCIL_TWO_SIDE (1<<0)
-
-
-/* 3DSTATE_BACKFACE_STENCIL_MASKS, p140 */
-#define _3DSTATE_BACKFACE_STENCIL_MASKS (CMD_3D | (0x9<<24))
-#define BFM_ENABLE_STENCIL_TEST_MASK (1<<17)
-#define BFM_ENABLE_STENCIL_WRITE_MASK (1<<16)
-#define BFM_STENCIL_TEST_MASK_SHIFT 8
-#define BFM_STENCIL_TEST_MASK_MASK (0xff<<8)
-#define BFM_STENCIL_WRITE_MASK_SHIFT 0
-#define BFM_STENCIL_WRITE_MASK_MASK (0xff<<0)
-
-
-
-/* 3DSTATE_BIN_CONTROL p141 */
-
-/* p143 */
-#define _3DSTATE_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
-/* Dword 1 */
-#define BUF_3D_ID_COLOR_BACK (0x3<<24)
-#define BUF_3D_ID_DEPTH (0x7<<24)
-#define BUF_3D_USE_FENCE (1<<23)
-#define BUF_3D_TILED_SURFACE (1<<22)
-#define BUF_3D_TILE_WALK_X 0
-#define BUF_3D_TILE_WALK_Y (1<<21)
-#define BUF_3D_PITCH(x) (((x)/4)<<2)
-/* Dword 2 */
-#define BUF_3D_ADDR(x) ((x) & ~0x3)
-
-
-/* 3DSTATE_CHROMA_KEY */
-
-/* 3DSTATE_CLEAR_PARAMETERS, p150 */
-#define _3DSTATE_CLEAR_PARAMETERS (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5)
-/* Dword 1 */
-#define CLEARPARAM_CLEAR_RECT (1 << 16)
-#define CLEARPARAM_ZONE_INIT (0 << 16)
-#define CLEARPARAM_WRITE_COLOR (1 << 2)
-#define CLEARPARAM_WRITE_DEPTH (1 << 1)
-#define CLEARPARAM_WRITE_STENCIL (1 << 0)
-
-/* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */
-#define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
-
-
-
-/* 3DSTATE_COORD_SET_BINDINGS, p154 */
-#define _3DSTATE_COORD_SET_BINDINGS (CMD_3D | (0x16<<24))
-#define CSB_TCB(iunit, eunit) ((eunit)<<(iunit*3))
-
-/* p156 */
-#define _3DSTATE_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
-
-/* p157 */
-#define _3DSTATE_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
-
-/* p158 */
-#define _3DSTATE_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
-
-
-/* 3DSTATE_DEPTH_OFFSET_SCALE, p159 */
-#define _3DSTATE_DEPTH_OFFSET_SCALE (CMD_3D | (0x1d<<24) | (0x97<<16))
-/* scale in dword 1 */
-
-
-/* 3DSTATE_DEPTH_SUBRECT_DISABLE, p160 */
-#define _3DSTATE_DEPTH_SUBRECT_DISABLE (CMD_3D | (0x1c<<24) | (0x11<<19) | 0x2)
-
-/* p161 */
-#define _3DSTATE_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
-/* Dword 1 */
-#define TEX_DEFAULT_COLOR_OGL (0<<30)
-#define TEX_DEFAULT_COLOR_D3D (1<<30)
-#define ZR_EARLY_DEPTH (1<<29)
-#define LOD_PRECLAMP_OGL (1<<28)
-#define LOD_PRECLAMP_D3D (0<<28)
-#define DITHER_FULL_ALWAYS (0<<26)
-#define DITHER_FULL_ON_FB_BLEND (1<<26)
-#define DITHER_CLAMPED_ALWAYS (2<<26)
-#define LINEAR_GAMMA_BLEND_32BPP (1<<25)
-#define DEBUG_DISABLE_ENH_DITHER (1<<24)
-#define DSTORG_HORT_BIAS(x) ((x)<<20)
-#define DSTORG_VERT_BIAS(x) ((x)<<16)
-#define COLOR_4_2_2_CHNL_WRT_ALL 0
-#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
-#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
-#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
-#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
-#define COLOR_BUF_8BIT 0
-#define COLOR_BUF_RGB555 (1<<8)
-#define COLOR_BUF_RGB565 (2<<8)
-#define COLOR_BUF_ARGB8888 (3<<8)
-#define DEPTH_FRMT_16_FIXED 0
-#define DEPTH_FRMT_16_FLOAT (1<<2)
-#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
-#define VERT_LINE_STRIDE_1 (1<<1)
-#define VERT_LINE_STRIDE_0 (0<<1)
-#define VERT_LINE_STRIDE_OFS_1 1
-#define VERT_LINE_STRIDE_OFS_0 0
-
-/* p166 */
-#define _3DSTATE_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
-/* Dword 1 */
-#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
-#define DRAW_DITHER_OFS_X(x) ((x)<<26)
-#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
-/* Dword 2 */
-#define DRAW_YMIN(x) ((x)<<16)
-#define DRAW_XMIN(x) (x)
-/* Dword 3 */
-#define DRAW_YMAX(x) ((x)<<16)
-#define DRAW_XMAX(x) (x)
-/* Dword 4 */
-#define DRAW_YORG(x) ((x)<<16)
-#define DRAW_XORG(x) (x)
-
-
-/* 3DSTATE_FILTER_COEFFICIENTS_4X4, p170 */
-
-/* 3DSTATE_FILTER_COEFFICIENTS_6X5, p172 */
-
-
-/* _3DSTATE_FOG_COLOR, p173 */
-#define _3DSTATE_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
-#define FOG_COLOR_RED(x) ((x)<<16)
-#define FOG_COLOR_GREEN(x) ((x)<<8)
-#define FOG_COLOR_BLUE(x) (x)
-
-/* _3DSTATE_FOG_MODE, p174 */
-#define _3DSTATE_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
-/* Dword 1 */
-#define FMC1_FOGFUNC_MODIFY_ENABLE (1<<31)
-#define FMC1_FOGFUNC_VERTEX (0<<28)
-#define FMC1_FOGFUNC_PIXEL_EXP (1<<28)
-#define FMC1_FOGFUNC_PIXEL_EXP2 (2<<28)
-#define FMC1_FOGFUNC_PIXEL_LINEAR (3<<28)
-#define FMC1_FOGFUNC_MASK (3<<28)
-#define FMC1_FOGINDEX_MODIFY_ENABLE (1<<27)
-#define FMC1_FOGINDEX_Z (0<<25)
-#define FMC1_FOGINDEX_W (1<<25)
-#define FMC1_C1_C2_MODIFY_ENABLE (1<<24)
-#define FMC1_DENSITY_MODIFY_ENABLE (1<<23)
-#define FMC1_C1_ONE (1<<13)
-#define FMC1_C1_MASK (0xffff<<4)
-/* Dword 2 */
-#define FMC2_C2_ONE (1<<16)
-/* Dword 3 */
-#define FMC3_D_ONE (1<<16)
-
-
-
-/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p177 */
-#define _3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
-#define IAB_MODIFY_ENABLE (1<<23)
-#define IAB_ENABLE (1<<22)
-#define IAB_MODIFY_FUNC (1<<21)
-#define IAB_FUNC_SHIFT 16
-#define IAB_MODIFY_SRC_FACTOR (1<<11)
-#define IAB_SRC_FACTOR_SHIFT 6
-#define IAB_SRC_FACTOR_MASK (BLENDFACT_MASK<<6)
-#define IAB_MODIFY_DST_FACTOR (1<<5)
-#define IAB_DST_FACTOR_SHIFT 0
-#define IAB_DST_FACTOR_MASK (BLENDFACT_MASK<<0)
-
-
-#define BLENDFUNC_ADD 0x0
-#define BLENDFUNC_SUBTRACT 0x1
-#define BLENDFUNC_REVERSE_SUBTRACT 0x2
-#define BLENDFUNC_MIN 0x3
-#define BLENDFUNC_MAX 0x4
-#define BLENDFUNC_MASK 0x7
-
-/* 3DSTATE_LOAD_INDIRECT, p180 */
-
-#define _3DSTATE_LOAD_INDIRECT (CMD_3D|(0x1d<<24)|(0x7<<16))
-#define LI0_STATE_STATIC_INDIRECT (0x01<<8)
-#define LI0_STATE_DYNAMIC_INDIRECT (0x02<<8)
-#define LI0_STATE_SAMPLER (0x04<<8)
-#define LI0_STATE_MAP (0x08<<8)
-#define LI0_STATE_PROGRAM (0x10<<8)
-#define LI0_STATE_CONSTANTS (0x20<<8)
-
-#define SIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define SIS0_FORCE_LOAD (1<<1)
-#define SIS0_BUFFER_VALID (1<<0)
-#define SIS1_BUFFER_LENGTH(x) ((x)&0xff)
-
-#define DIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define DIS0_BUFFER_RESET (1<<1)
-#define DIS0_BUFFER_VALID (1<<0)
-
-#define SSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define SSB0_FORCE_LOAD (1<<1)
-#define SSB0_BUFFER_VALID (1<<0)
-#define SSB1_BUFFER_LENGTH(x) ((x)&0xff)
-
-#define MSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define MSB0_FORCE_LOAD (1<<1)
-#define MSB0_BUFFER_VALID (1<<0)
-#define MSB1_BUFFER_LENGTH(x) ((x)&0xff)
-
-#define PSP0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define PSP0_FORCE_LOAD (1<<1)
-#define PSP0_BUFFER_VALID (1<<0)
-#define PSP1_BUFFER_LENGTH(x) ((x)&0xff)
-
-#define PSC0_BUFFER_ADDRESS(x) ((x)&~0x3)
-#define PSC0_FORCE_LOAD (1<<1)
-#define PSC0_BUFFER_VALID (1<<0)
-#define PSC1_BUFFER_LENGTH(x) ((x)&0xff)
-
-
-
-
-
-/* _3DSTATE_RASTERIZATION_RULES */
-#define _3DSTATE_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
-#define ENABLE_POINT_RASTER_RULE (1<<15)
-#define OGL_POINT_RASTER_RULE (1<<13)
-#define ENABLE_TEXKILL_3D_4D (1<<10)
-#define TEXKILL_3D (0<<9)
-#define TEXKILL_4D (1<<9)
-#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
-#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
-#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
-#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
-
-/* _3DSTATE_SCISSOR_ENABLE, p256 */
-#define _3DSTATE_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
-#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
-#define DISABLE_SCISSOR_RECT (1<<1)
-
-/* _3DSTATE_SCISSOR_RECTANGLE_0, p257 */
-#define _3DSTATE_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
-/* Dword 1 */
-#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
-#define SCISSOR_RECT_0_XMIN(x) (x)
-/* Dword 2 */
-#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
-#define SCISSOR_RECT_0_XMAX(x) (x)
-
-/* p189 */
-#define _3DSTATE_LOAD_STATE_IMMEDIATE_1 ((0x3<<29)|(0x1d<<24)|(0x04<<16))
-#define I1_LOAD_S(n) (1<<(4+n))
-
-#define S0_VB_OFFSET_MASK 0xffffffc
-#define S0_AUTO_CACHE_INV_DISABLE (1<<0)
-
-#define S1_VERTEX_WIDTH_SHIFT 24
-#define S1_VERTEX_WIDTH_MASK (0x3f<<24)
-#define S1_VERTEX_PITCH_SHIFT 16
-#define S1_VERTEX_PITCH_MASK (0x3f<<16)
-
-#define TEXCOORDFMT_2D 0x0
-#define TEXCOORDFMT_3D 0x1
-#define TEXCOORDFMT_4D 0x2
-#define TEXCOORDFMT_1D 0x3
-#define TEXCOORDFMT_2D_16 0x4
-#define TEXCOORDFMT_4D_16 0x5
-#define TEXCOORDFMT_NOT_PRESENT 0xf
-#define S2_TEXCOORD_FMT0_MASK 0xf
-#define S2_TEXCOORD_FMT1_SHIFT 4
-#define S2_TEXCOORD_FMT(unit, type) ((type)<<(unit*4))
-#define S2_TEXCOORD_NONE (~0)
-
-/* S3 not interesting */
-
-#define S4_POINT_WIDTH_SHIFT 23
-#define S4_POINT_WIDTH_MASK (0x1ff<<23)
-#define S4_LINE_WIDTH_SHIFT 19
-#define S4_LINE_WIDTH_ONE (0x2<<19)
-#define S4_LINE_WIDTH_MASK (0xf<<19)
-#define S4_FLATSHADE_ALPHA (1<<18)
-#define S4_FLATSHADE_FOG (1<<17)
-#define S4_FLATSHADE_SPECULAR (1<<16)
-#define S4_FLATSHADE_COLOR (1<<15)
-#define S4_CULLMODE_BOTH (0<<13)
-#define S4_CULLMODE_NONE (1<<13)
-#define S4_CULLMODE_CW (2<<13)
-#define S4_CULLMODE_CCW (3<<13)
-#define S4_CULLMODE_MASK (3<<13)
-#define S4_VFMT_POINT_WIDTH (1<<12)
-#define S4_VFMT_SPEC_FOG (1<<11)
-#define S4_VFMT_COLOR (1<<10)
-#define S4_VFMT_DEPTH_OFFSET (1<<9)
-#define S4_VFMT_XYZ (1<<6)
-#define S4_VFMT_XYZW (2<<6)
-#define S4_VFMT_XY (3<<6)
-#define S4_VFMT_XYW (4<<6)
-#define S4_VFMT_XYZW_MASK (7<<6)
-#define S4_FORCE_DEFAULT_DIFFUSE (1<<5)
-#define S4_FORCE_DEFAULT_SPECULAR (1<<4)
-#define S4_LOCAL_DEPTH_OFFSET_ENABLE (1<<3)
-#define S4_VFMT_FOG_PARAM (1<<2)
-#define S4_SPRITE_POINT_ENABLE (1<<1)
-#define S4_LINE_ANTIALIAS_ENABLE (1<<0)
-
-#define S4_VFMT_MASK (S4_VFMT_POINT_WIDTH | \
- S4_VFMT_SPEC_FOG | \
- S4_VFMT_COLOR | \
- S4_VFMT_DEPTH_OFFSET | \
- S4_VFMT_XYZW_MASK | \
- S4_VFMT_FOG_PARAM)
-
-
-#define S5_WRITEDISABLE_ALPHA (1<<31)
-#define S5_WRITEDISABLE_RED (1<<30)
-#define S5_WRITEDISABLE_GREEN (1<<29)
-#define S5_WRITEDISABLE_BLUE (1<<28)
-#define S5_WRITEDISABLE_MASK (0xf<<28)
-#define S5_FORCE_DEFAULT_POINT_SIZE (1<<27)
-#define S5_LAST_PIXEL_ENABLE (1<<26)
-#define S5_GLOBAL_DEPTH_OFFSET_ENABLE (1<<25)
-#define S5_FOG_ENABLE (1<<24)
-#define S5_STENCIL_REF_SHIFT 16
-#define S5_STENCIL_REF_MASK (0xff<<16)
-#define S5_STENCIL_TEST_FUNC_SHIFT 13
-#define S5_STENCIL_TEST_FUNC_MASK (0x7<<13)
-#define S5_STENCIL_FAIL_SHIFT 10
-#define S5_STENCIL_FAIL_MASK (0x7<<10)
-#define S5_STENCIL_PASS_Z_FAIL_SHIFT 7
-#define S5_STENCIL_PASS_Z_FAIL_MASK (0x7<<7)
-#define S5_STENCIL_PASS_Z_PASS_SHIFT 4
-#define S5_STENCIL_PASS_Z_PASS_MASK (0x7<<4)
-#define S5_STENCIL_WRITE_ENABLE (1<<3)
-#define S5_STENCIL_TEST_ENABLE (1<<2)
-#define S5_COLOR_DITHER_ENABLE (1<<1)
-#define S5_LOGICOP_ENABLE (1<<0)
-
-
-#define S6_ALPHA_TEST_ENABLE (1<<31)
-#define S6_ALPHA_TEST_FUNC_SHIFT 28
-#define S6_ALPHA_TEST_FUNC_MASK (0x7<<28)
-#define S6_ALPHA_REF_SHIFT 20
-#define S6_ALPHA_REF_MASK (0xff<<20)
-#define S6_DEPTH_TEST_ENABLE (1<<19)
-#define S6_DEPTH_TEST_FUNC_SHIFT 16
-#define S6_DEPTH_TEST_FUNC_MASK (0x7<<16)
-#define S6_CBUF_BLEND_ENABLE (1<<15)
-#define S6_CBUF_BLEND_FUNC_SHIFT 12
-#define S6_CBUF_BLEND_FUNC_MASK (0x7<<12)
-#define S6_CBUF_SRC_BLEND_FACT_SHIFT 8
-#define S6_CBUF_SRC_BLEND_FACT_MASK (0xf<<8)
-#define S6_CBUF_DST_BLEND_FACT_SHIFT 4
-#define S6_CBUF_DST_BLEND_FACT_MASK (0xf<<4)
-#define S6_DEPTH_WRITE_ENABLE (1<<3)
-#define S6_COLOR_WRITE_ENABLE (1<<2)
-#define S6_TRISTRIP_PV_SHIFT 0
-#define S6_TRISTRIP_PV_MASK (0x3<<0)
-
-#define S7_DEPTH_OFFSET_CONST_MASK ~0
-
-
-
-#define DST_BLND_FACT(f) ((f)<<S6_CBUF_DST_BLEND_FACT_SHIFT)
-#define SRC_BLND_FACT(f) ((f)<<S6_CBUF_SRC_BLEND_FACT_SHIFT)
-#define DST_ABLND_FACT(f) ((f)<<IAB_DST_FACTOR_SHIFT)
-#define SRC_ABLND_FACT(f) ((f)<<IAB_SRC_FACTOR_SHIFT)
-
-
-
-
-/* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */
-
-/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
-#define _3DSTATE_MAP_PALETTE_LOAD_32 (CMD_3D|(0x1d<<24)|(0x8f<<16))
-/* subsequent dwords up to length (max 16) are ARGB8888 color values */
-
-/* _3DSTATE_MODES_4, p218 */
-#define _3DSTATE_MODES_4_CMD (CMD_3D|(0x0d<<24))
-#define ENABLE_LOGIC_OP_FUNC (1<<23)
-#define LOGIC_OP_FUNC(x) ((x)<<18)
-#define LOGICOP_MASK (0xf<<18)
-#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
-#define ENABLE_STENCIL_TEST_MASK (1<<17)
-#define STENCIL_TEST_MASK(x) (((x)&0xff)<<8)
-#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
-#define ENABLE_STENCIL_WRITE_MASK (1<<16)
-#define STENCIL_WRITE_MASK(x) ((x)&0xff)
-
-/* _3DSTATE_MODES_5, p220 */
-#define _3DSTATE_MODES_5_CMD (CMD_3D|(0x0c<<24))
-#define PIPELINE_FLUSH_RENDER_CACHE (1<<18)
-#define PIPELINE_FLUSH_TEXTURE_CACHE (1<<16)
-
-
-/* p221 */
-#define _3DSTATE_PIXEL_SHADER_CONSTANTS (CMD_3D|(0x1d<<24)|(0x6<<16))
-#define PS1_REG(n) (1<<(n))
-#define PS2_CONST_X(n) (n)
-#define PS3_CONST_Y(n) (n)
-#define PS4_CONST_Z(n) (n)
-#define PS5_CONST_W(n) (n)
-
-/* p222 */
-
-
-#define I915_MAX_TEX_INDIRECT 4
-#define I915_MAX_TEX_INSN 32
-#define I915_MAX_ALU_INSN 64
-#define I915_MAX_DECL_INSN 27
-#define I915_MAX_TEMPORARY 16
-
-
-/* Each instruction is 3 dwords long, though most don't require all
- * this space. Maximum of 123 instructions. Smaller maxes per insn
- * type.
- */
-#define _3DSTATE_PIXEL_SHADER_PROGRAM (CMD_3D|(0x1d<<24)|(0x5<<16))
-
-#define REG_TYPE_R 0 /* temporary regs, no need to
- * dcl, must be written before
- * read -- Preserved between
- * phases.
- */
-#define REG_TYPE_T 1 /* Interpolated values, must be
- * dcl'ed before use.
- *
- * 0..7: texture coord,
- * 8: diffuse spec,
- * 9: specular color,
- * 10: fog parameter in w.
- */
-#define REG_TYPE_CONST 2 /* Restriction: only one const
- * can be referenced per
- * instruction, though it may be
- * selected for multiple inputs.
- * Constants not initialized
- * default to zero.
- */
-#define REG_TYPE_S 3 /* sampler */
-#define REG_TYPE_OC 4 /* output color (rgba) */
-#define REG_TYPE_OD 5 /* output depth (w), xyz are
- * temporaries. If not written,
- * interpolated depth is used?
- */
-#define REG_TYPE_U 6 /* unpreserved temporaries */
-#define REG_TYPE_MASK 0x7
-#define REG_NR_MASK 0xf
-
-
-/* REG_TYPE_T:
- */
-#define T_TEX0 0
-#define T_TEX1 1
-#define T_TEX2 2
-#define T_TEX3 3
-#define T_TEX4 4
-#define T_TEX5 5
-#define T_TEX6 6
-#define T_TEX7 7
-#define T_DIFFUSE 8
-#define T_SPECULAR 9
-#define T_FOG_W 10 /* interpolated fog is in W coord */
-
-/* Arithmetic instructions */
-
-/* .replicate_swizzle == selection and replication of a particular
- * scalar channel, ie., .xxxx, .yyyy, .zzzz or .wwww
- */
-#define A0_NOP (0x0<<24) /* no operation */
-#define A0_ADD (0x1<<24) /* dst = src0 + src1 */
-#define A0_MOV (0x2<<24) /* dst = src0 */
-#define A0_MUL (0x3<<24) /* dst = src0 * src1 */
-#define A0_MAD (0x4<<24) /* dst = src0 * src1 + src2 */
-#define A0_DP2ADD (0x5<<24) /* dst.xyzw = src0.xy dot src1.xy + src2.replicate_swizzle */
-#define A0_DP3 (0x6<<24) /* dst.xyzw = src0.xyz dot src1.xyz */
-#define A0_DP4 (0x7<<24) /* dst.xyzw = src0.xyzw dot src1.xyzw */
-#define A0_FRC (0x8<<24) /* dst = src0 - floor(src0) */
-#define A0_RCP (0x9<<24) /* dst.xyzw = 1/(src0.replicate_swizzle) */
-#define A0_RSQ (0xa<<24) /* dst.xyzw = 1/(sqrt(abs(src0.replicate_swizzle))) */
-#define A0_EXP (0xb<<24) /* dst.xyzw = exp2(src0.replicate_swizzle) */
-#define A0_LOG (0xc<<24) /* dst.xyzw = log2(abs(src0.replicate_swizzle)) */
-#define A0_CMP (0xd<<24) /* dst = (src0 >= 0.0) ? src1 : src2 */
-#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */
-#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */
-#define A0_FLR (0x10<<24) /* dst = floor(src0) */
-#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */
-#define A0_TRC (0x12<<24) /* dst = int(src0) */
-#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */
-#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */
-#define A0_DEST_SATURATE (1<<22)
-#define A0_DEST_TYPE_SHIFT 19
-/* Allow: R, OC, OD, U */
-#define A0_DEST_NR_SHIFT 14
-/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
-#define A0_DEST_CHANNEL_X (1<<10)
-#define A0_DEST_CHANNEL_Y (2<<10)
-#define A0_DEST_CHANNEL_Z (4<<10)
-#define A0_DEST_CHANNEL_W (8<<10)
-#define A0_DEST_CHANNEL_ALL (0xf<<10)
-#define A0_DEST_CHANNEL_SHIFT 10
-#define A0_SRC0_TYPE_SHIFT 7
-#define A0_SRC0_NR_SHIFT 2
-
-#define A0_DEST_CHANNEL_XY (A0_DEST_CHANNEL_X|A0_DEST_CHANNEL_Y)
-#define A0_DEST_CHANNEL_XYZ (A0_DEST_CHANNEL_XY|A0_DEST_CHANNEL_Z)
-
-
-#define SRC_X 0
-#define SRC_Y 1
-#define SRC_Z 2
-#define SRC_W 3
-#define SRC_ZERO 4
-#define SRC_ONE 5
-
-#define A1_SRC0_CHANNEL_X_NEGATE (1<<31)
-#define A1_SRC0_CHANNEL_X_SHIFT 28
-#define A1_SRC0_CHANNEL_Y_NEGATE (1<<27)
-#define A1_SRC0_CHANNEL_Y_SHIFT 24
-#define A1_SRC0_CHANNEL_Z_NEGATE (1<<23)
-#define A1_SRC0_CHANNEL_Z_SHIFT 20
-#define A1_SRC0_CHANNEL_W_NEGATE (1<<19)
-#define A1_SRC0_CHANNEL_W_SHIFT 16
-#define A1_SRC1_TYPE_SHIFT 13
-#define A1_SRC1_NR_SHIFT 8
-#define A1_SRC1_CHANNEL_X_NEGATE (1<<7)
-#define A1_SRC1_CHANNEL_X_SHIFT 4
-#define A1_SRC1_CHANNEL_Y_NEGATE (1<<3)
-#define A1_SRC1_CHANNEL_Y_SHIFT 0
-
-#define A2_SRC1_CHANNEL_Z_NEGATE (1<<31)
-#define A2_SRC1_CHANNEL_Z_SHIFT 28
-#define A2_SRC1_CHANNEL_W_NEGATE (1<<27)
-#define A2_SRC1_CHANNEL_W_SHIFT 24
-#define A2_SRC2_TYPE_SHIFT 21
-#define A2_SRC2_NR_SHIFT 16
-#define A2_SRC2_CHANNEL_X_NEGATE (1<<15)
-#define A2_SRC2_CHANNEL_X_SHIFT 12
-#define A2_SRC2_CHANNEL_Y_NEGATE (1<<11)
-#define A2_SRC2_CHANNEL_Y_SHIFT 8
-#define A2_SRC2_CHANNEL_Z_NEGATE (1<<7)
-#define A2_SRC2_CHANNEL_Z_SHIFT 4
-#define A2_SRC2_CHANNEL_W_NEGATE (1<<3)
-#define A2_SRC2_CHANNEL_W_SHIFT 0
-
-
-
-/* Texture instructions */
-#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared
- * sampler and address, and output
- * filtered texel data to destination
- * register */
-#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a
- * perspective divide of the texture
- * coordinate .xyz values by .w before
- * sampling. */
-#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the
- * computed LOD by w. Only S4.6 two's
- * comp is used. This implies that a
- * float to fixed conversion is
- * done. */
-#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling
- * operation. Simply kills the pixel
- * if any channel of the address
- * register is < 0.0. */
-#define T0_DEST_TYPE_SHIFT 19
-/* Allow: R, OC, OD, U */
-/* Note: U (unpreserved) regs do not retain their values between
- * phases (cannot be used for feedback)
- *
- * Note: oC and OD registers can only be used as the destination of a
- * texture instruction once per phase (this is an implementation
- * restriction).
- */
-#define T0_DEST_NR_SHIFT 14
-/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
-#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */
-#define T0_SAMPLER_NR_MASK (0xf<<0)
-
-#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */
-/* Allow R, T, OC, OD -- R, OC, OD are 'dependent' reads, new program phase */
-#define T1_ADDRESS_REG_NR_SHIFT 17
-#define T2_MBZ 0
-
-/* Declaration instructions */
-#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib)
- * register or an s (sampler)
- * register. */
-#define D0_SAMPLE_TYPE_SHIFT 22
-#define D0_SAMPLE_TYPE_2D (0x0<<22)
-#define D0_SAMPLE_TYPE_CUBE (0x1<<22)
-#define D0_SAMPLE_TYPE_VOLUME (0x2<<22)
-#define D0_SAMPLE_TYPE_MASK (0x3<<22)
-
-#define D0_TYPE_SHIFT 19
-/* Allow: T, S */
-#define D0_NR_SHIFT 14
-/* Allow T: 0..10, S: 0..15 */
-#define D0_CHANNEL_X (1<<10)
-#define D0_CHANNEL_Y (2<<10)
-#define D0_CHANNEL_Z (4<<10)
-#define D0_CHANNEL_W (8<<10)
-#define D0_CHANNEL_ALL (0xf<<10)
-#define D0_CHANNEL_NONE (0<<10)
-
-#define D0_CHANNEL_XY (D0_CHANNEL_X|D0_CHANNEL_Y)
-#define D0_CHANNEL_XYZ (D0_CHANNEL_XY|D0_CHANNEL_Z)
-
-/* I915 Errata: Do not allow (xz), (xw), (xzw) combinations for diffuse
- * or specular declarations.
- *
- * For T dcls, only allow: (x), (xy), (xyz), (w), (xyzw)
- *
- * Must be zero for S (sampler) dcls
- */
-#define D1_MBZ 0
-#define D2_MBZ 0
-
-
-
-/* p207 */
-#define _3DSTATE_MAP_STATE (CMD_3D|(0x1d<<24)|(0x0<<16))
-
-#define MS1_MAPMASK_SHIFT 0
-#define MS1_MAPMASK_MASK (0x8fff<<0)
-
-#define MS2_UNTRUSTED_SURFACE (1<<31)
-#define MS2_ADDRESS_MASK 0xfffffffc
-#define MS2_VERTICAL_LINE_STRIDE (1<<1)
-#define MS2_VERTICAL_OFFSET (1<<1)
-
-#define MS3_HEIGHT_SHIFT 21
-#define MS3_WIDTH_SHIFT 10
-#define MS3_PALETTE_SELECT (1<<9)
-#define MS3_MAPSURF_FORMAT_SHIFT 7
-#define MS3_MAPSURF_FORMAT_MASK (0x7<<7)
-#define MAPSURF_8BIT (1<<7)
-#define MAPSURF_16BIT (2<<7)
-#define MAPSURF_32BIT (3<<7)
-#define MAPSURF_422 (5<<7)
-#define MAPSURF_COMPRESSED (6<<7)
-#define MAPSURF_4BIT_INDEXED (7<<7)
-#define MS3_MT_FORMAT_MASK (0x7 << 3)
-#define MS3_MT_FORMAT_SHIFT 3
-#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
-#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
-#define MT_8BIT_L8 (1<<3)
-#define MT_8BIT_A8 (4<<3)
-#define MT_8BIT_MONO8 (5<<3)
-#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
-#define MT_16BIT_ARGB1555 (1<<3)
-#define MT_16BIT_ARGB4444 (2<<3)
-#define MT_16BIT_AY88 (3<<3)
-#define MT_16BIT_88DVDU (5<<3)
-#define MT_16BIT_BUMP_655LDVDU (6<<3)
-#define MT_16BIT_I16 (7<<3)
-#define MT_16BIT_L16 (8<<3)
-#define MT_16BIT_A16 (9<<3)
-#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
-#define MT_32BIT_ABGR8888 (1<<3)
-#define MT_32BIT_XRGB8888 (2<<3)
-#define MT_32BIT_XBGR8888 (3<<3)
-#define MT_32BIT_QWVU8888 (4<<3)
-#define MT_32BIT_AXVU8888 (5<<3)
-#define MT_32BIT_LXVU8888 (6<<3)
-#define MT_32BIT_XLVU8888 (7<<3)
-#define MT_32BIT_ARGB2101010 (8<<3)
-#define MT_32BIT_ABGR2101010 (9<<3)
-#define MT_32BIT_AWVU2101010 (0xA<<3)
-#define MT_32BIT_GR1616 (0xB<<3)
-#define MT_32BIT_VU1616 (0xC<<3)
-#define MT_32BIT_xI824 (0xD<<3)
-#define MT_32BIT_xA824 (0xE<<3)
-#define MT_32BIT_xL824 (0xF<<3)
-#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
-#define MT_422_YCRCB_NORMAL (1<<3)
-#define MT_422_YCRCB_SWAPUV (2<<3)
-#define MT_422_YCRCB_SWAPUVY (3<<3)
-#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
-#define MT_COMPRESS_DXT2_3 (1<<3)
-#define MT_COMPRESS_DXT4_5 (2<<3)
-#define MT_COMPRESS_FXT1 (3<<3)
-#define MT_COMPRESS_DXT1_RGB (4<<3)
-#define MS3_USE_FENCE_REGS (1<<2)
-#define MS3_TILED_SURFACE (1<<1)
-#define MS3_TILE_WALK (1<<0)
-
-#define MS4_PITCH_SHIFT 21
-#define MS4_CUBE_FACE_ENA_NEGX (1<<20)
-#define MS4_CUBE_FACE_ENA_POSX (1<<19)
-#define MS4_CUBE_FACE_ENA_NEGY (1<<18)
-#define MS4_CUBE_FACE_ENA_POSY (1<<17)
-#define MS4_CUBE_FACE_ENA_NEGZ (1<<16)
-#define MS4_CUBE_FACE_ENA_POSZ (1<<15)
-#define MS4_CUBE_FACE_ENA_MASK (0x3f<<15)
-#define MS4_MAX_LOD_SHIFT 9
-#define MS4_MAX_LOD_MASK (0x3f<<9)
-#define MS4_MIP_LAYOUT_LEGACY (0<<8)
-#define MS4_MIP_LAYOUT_BELOW_LPT (0<<8)
-#define MS4_MIP_LAYOUT_RIGHT_LPT (1<<8)
-#define MS4_VOLUME_DEPTH_SHIFT 0
-#define MS4_VOLUME_DEPTH_MASK (0xff<<0)
-
-/* p244 */
-#define _3DSTATE_SAMPLER_STATE (CMD_3D|(0x1d<<24)|(0x1<<16))
-
-#define SS1_MAPMASK_SHIFT 0
-#define SS1_MAPMASK_MASK (0x8fff<<0)
-
-#define SS2_REVERSE_GAMMA_ENABLE (1<<31)
-#define SS2_PACKED_TO_PLANAR_ENABLE (1<<30)
-#define SS2_COLORSPACE_CONVERSION (1<<29)
-#define SS2_CHROMAKEY_SHIFT 27
-#define SS2_BASE_MIP_LEVEL_SHIFT 22
-#define SS2_BASE_MIP_LEVEL_MASK (0x1f<<22)
-#define SS2_MIP_FILTER_SHIFT 20
-#define SS2_MIP_FILTER_MASK (0x3<<20)
-#define MIPFILTER_NONE 0
-#define MIPFILTER_NEAREST 1
-#define MIPFILTER_LINEAR 3
-#define SS2_MAG_FILTER_SHIFT 17
-#define SS2_MAG_FILTER_MASK (0x7<<17)
-#define FILTER_NEAREST 0
-#define FILTER_LINEAR 1
-#define FILTER_ANISOTROPIC 2
-#define FILTER_4X4_1 3
-#define FILTER_4X4_2 4
-#define FILTER_4X4_FLAT 5
-#define FILTER_6X5_MONO 6 /* XXX - check */
-#define SS2_MIN_FILTER_SHIFT 14
-#define SS2_MIN_FILTER_MASK (0x7<<14)
-#define SS2_LOD_BIAS_SHIFT 5
-#define SS2_LOD_BIAS_ONE (0x10<<5)
-#define SS2_LOD_BIAS_MASK (0x1ff<<5)
-/* Shadow requires:
- * MT_X8{I,L,A}24 or MT_{I,L,A}16 texture format
- * FILTER_4X4_x MIN and MAG filters
- */
-#define SS2_SHADOW_ENABLE (1<<4)
-#define SS2_MAX_ANISO_MASK (1<<3)
-#define SS2_MAX_ANISO_2 (0<<3)
-#define SS2_MAX_ANISO_4 (1<<3)
-#define SS2_SHADOW_FUNC_SHIFT 0
-#define SS2_SHADOW_FUNC_MASK (0x7<<0)
-/* SS2_SHADOW_FUNC values: see COMPAREFUNC_* */
-
-#define SS3_MIN_LOD_SHIFT 24
-#define SS3_MIN_LOD_ONE (0x10<<24)
-#define SS3_MIN_LOD_MASK (0xff<<24)
-#define SS3_KILL_PIXEL_ENABLE (1<<17)
-#define SS3_TCX_ADDR_MODE_SHIFT 12
-#define SS3_TCX_ADDR_MODE_MASK (0x7<<12)
-#define TEXCOORDMODE_WRAP 0
-#define TEXCOORDMODE_MIRROR 1
-#define TEXCOORDMODE_CLAMP_EDGE 2
-#define TEXCOORDMODE_CUBE 3
-#define TEXCOORDMODE_CLAMP_BORDER 4
-#define TEXCOORDMODE_MIRROR_ONCE 5
-#define SS3_TCY_ADDR_MODE_SHIFT 9
-#define SS3_TCY_ADDR_MODE_MASK (0x7<<9)
-#define SS3_TCZ_ADDR_MODE_SHIFT 6
-#define SS3_TCZ_ADDR_MODE_MASK (0x7<<6)
-#define SS3_NORMALIZED_COORDS (1<<5)
-#define SS3_TEXTUREMAP_INDEX_SHIFT 1
-#define SS3_TEXTUREMAP_INDEX_MASK (0xf<<1)
-#define SS3_DEINTERLACER_ENABLE (1<<0)
-
-#define SS4_BORDER_COLOR_MASK (~0)
-
-/* 3DSTATE_SPAN_STIPPLE, p258
- */
-#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
-#define ST1_ENABLE (1<<16)
-#define ST1_MASK (0xffff)
-
-#define _3DSTATE_DEFAULT_Z ((0x3<<29)|(0x1d<<24)|(0x98<<16))
-#define _3DSTATE_DEFAULT_DIFFUSE ((0x3<<29)|(0x1d<<24)|(0x99<<16))
-#define _3DSTATE_DEFAULT_SPECULAR ((0x3<<29)|(0x1d<<24)|(0x9a<<16))
-
-
-#define MI_FLUSH ((0<<29)|(4<<23))
-#define FLUSH_MAP_CACHE (1<<0)
-#define INHIBIT_FLUSH_RENDER_CACHE (1<<2)
-
-
-#define CMD_3D (0x3<<29)
-
-
-#define _3DPRIMITIVE ((0x3<<29)|(0x1f<<24))
-#define PRIM_INDIRECT (1<<23)
-#define PRIM_INLINE (0<<23)
-#define PRIM_INDIRECT_SEQUENTIAL (0<<17)
-#define PRIM_INDIRECT_ELTS (1<<17)
-
-#define PRIM3D_TRILIST (0x0<<18)
-#define PRIM3D_TRISTRIP (0x1<<18)
-#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
-#define PRIM3D_TRIFAN (0x3<<18)
-#define PRIM3D_POLY (0x4<<18)
-#define PRIM3D_LINELIST (0x5<<18)
-#define PRIM3D_LINESTRIP (0x6<<18)
-#define PRIM3D_RECTLIST (0x7<<18)
-#define PRIM3D_POINTLIST (0x8<<18)
-#define PRIM3D_DIB (0x9<<18)
-#define PRIM3D_MASK (0x1f<<18)
-
-#define I915PACKCOLOR4444(r,g,b,a) \
- ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-#define I915PACKCOLOR1555(r,g,b,a) \
- ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define I915PACKCOLOR565(r,g,b) \
- ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define I915PACKCOLOR8888(r,g,b,a) \
- ((a<<24) | (r<<16) | (g<<8) | b)
-
-
-
-
-#define BR00_BITBLT_CLIENT 0x40000000
-#define BR00_OP_COLOR_BLT 0x10000000
-#define BR00_OP_SRC_COPY_BLT 0x10C00000
-#define BR13_SOLID_PATTERN 0x80000000
-
-#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
-#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
-#define XY_COLOR_BLT_WRITE_RGB (1<<20)
-
-#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
-#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
-#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
-
-#define MI_WAIT_FOR_EVENT ((0x3<<23))
-#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
-#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
-
-#define MI_BATCH_BUFFER (0x30<<23)
-#define MI_BATCH_BUFFER_START (0x31<<23)
-#define MI_BATCH_BUFFER_END (0xa<<23)
-
-
-
-#define COMPAREFUNC_ALWAYS 0
-#define COMPAREFUNC_NEVER 0x1
-#define COMPAREFUNC_LESS 0x2
-#define COMPAREFUNC_EQUAL 0x3
-#define COMPAREFUNC_LEQUAL 0x4
-#define COMPAREFUNC_GREATER 0x5
-#define COMPAREFUNC_NOTEQUAL 0x6
-#define COMPAREFUNC_GEQUAL 0x7
-
-#define STENCILOP_KEEP 0
-#define STENCILOP_ZERO 0x1
-#define STENCILOP_REPLACE 0x2
-#define STENCILOP_INCRSAT 0x3
-#define STENCILOP_DECRSAT 0x4
-#define STENCILOP_INCR 0x5
-#define STENCILOP_DECR 0x6
-#define STENCILOP_INVERT 0x7
-
-#define LOGICOP_CLEAR 0
-#define LOGICOP_NOR 0x1
-#define LOGICOP_AND_INV 0x2
-#define LOGICOP_COPY_INV 0x3
-#define LOGICOP_AND_RVRSE 0x4
-#define LOGICOP_INV 0x5
-#define LOGICOP_XOR 0x6
-#define LOGICOP_NAND 0x7
-#define LOGICOP_AND 0x8
-#define LOGICOP_EQUIV 0x9
-#define LOGICOP_NOOP 0xa
-#define LOGICOP_OR_INV 0xb
-#define LOGICOP_COPY 0xc
-#define LOGICOP_OR_RVRSE 0xd
-#define LOGICOP_OR 0xe
-#define LOGICOP_SET 0xf
-
-#define BLENDFACT_ZERO 0x01
-#define BLENDFACT_ONE 0x02
-#define BLENDFACT_SRC_COLR 0x03
-#define BLENDFACT_INV_SRC_COLR 0x04
-#define BLENDFACT_SRC_ALPHA 0x05
-#define BLENDFACT_INV_SRC_ALPHA 0x06
-#define BLENDFACT_DST_ALPHA 0x07
-#define BLENDFACT_INV_DST_ALPHA 0x08
-#define BLENDFACT_DST_COLR 0x09
-#define BLENDFACT_INV_DST_COLR 0x0a
-#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
-#define BLENDFACT_CONST_COLOR 0x0c
-#define BLENDFACT_INV_CONST_COLOR 0x0d
-#define BLENDFACT_CONST_ALPHA 0x0e
-#define BLENDFACT_INV_CONST_ALPHA 0x0f
-#define BLENDFACT_MASK 0x0f
-
-#define PCI_CHIP_I915_G 0x2582
-#define PCI_CHIP_I915_GM 0x2592
-#define PCI_CHIP_I945_G 0x2772
-#define PCI_CHIP_I945_GM 0x27A2
-#define PCI_CHIP_I945_GME 0x27AE
-#define PCI_CHIP_G33_G 0x29C2
-#define PCI_CHIP_Q35_G 0x29B2
-#define PCI_CHIP_Q33_G 0x29D2
-
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
deleted file mode 100644
index abd5571b88..0000000000
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/draw/draw_context.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-
-#include "i915_context.h"
-#include "i915_reg.h"
-#include "i915_state.h"
-#include "i915_state_inlines.h"
-
-
-/* The i915 (and related graphics cores) do not support GL_CLAMP. The
- * Intel drivers for "other operating systems" implement GL_CLAMP as
- * GL_CLAMP_TO_EDGE, so the same is done here.
- */
-static unsigned
-translate_wrap_mode(unsigned wrap)
-{
- switch (wrap) {
- case PIPE_TEX_WRAP_REPEAT:
- return TEXCOORDMODE_WRAP;
- case PIPE_TEX_WRAP_CLAMP:
- return TEXCOORDMODE_CLAMP_EDGE; /* not quite correct */
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- return TEXCOORDMODE_CLAMP_EDGE;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- return TEXCOORDMODE_CLAMP_BORDER;
-// case PIPE_TEX_WRAP_MIRRORED_REPEAT:
-// return TEXCOORDMODE_MIRROR;
- default:
- return TEXCOORDMODE_WRAP;
- }
-}
-
-static unsigned translate_img_filter( unsigned filter )
-{
- switch (filter) {
- case PIPE_TEX_FILTER_NEAREST:
- return FILTER_NEAREST;
- case PIPE_TEX_FILTER_LINEAR:
- return FILTER_LINEAR;
- default:
- assert(0);
- return FILTER_NEAREST;
- }
-}
-
-static unsigned translate_mip_filter( unsigned filter )
-{
- switch (filter) {
- case PIPE_TEX_MIPFILTER_NONE:
- return MIPFILTER_NONE;
- case PIPE_TEX_MIPFILTER_NEAREST:
- return MIPFILTER_NEAREST;
- case PIPE_TEX_FILTER_LINEAR:
- return MIPFILTER_LINEAR;
- default:
- assert(0);
- return MIPFILTER_NONE;
- }
-}
-
-
-/* None of this state is actually used for anything yet.
- */
-static void *
-i915_create_blend_state(struct pipe_context *pipe,
- const struct pipe_blend_state *blend)
-{
- struct i915_blend_state *cso_data = CALLOC_STRUCT( i915_blend_state );
-
- {
- unsigned eqRGB = blend->rgb_func;
- unsigned srcRGB = blend->rgb_src_factor;
- unsigned dstRGB = blend->rgb_dst_factor;
-
- unsigned eqA = blend->alpha_func;
- unsigned srcA = blend->alpha_src_factor;
- unsigned dstA = blend->alpha_dst_factor;
-
- /* Special handling for MIN/MAX filter modes handled at
- * state_tracker level.
- */
-
- if (srcA != srcRGB ||
- dstA != dstRGB ||
- eqA != eqRGB) {
-
- cso_data->iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
- IAB_MODIFY_ENABLE |
- IAB_ENABLE |
- IAB_MODIFY_FUNC |
- IAB_MODIFY_SRC_FACTOR |
- IAB_MODIFY_DST_FACTOR |
- SRC_ABLND_FACT(i915_translate_blend_factor(srcA)) |
- DST_ABLND_FACT(i915_translate_blend_factor(dstA)) |
- (i915_translate_blend_func(eqA) << IAB_FUNC_SHIFT));
- }
- else {
- cso_data->iab = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
- IAB_MODIFY_ENABLE |
- 0);
- }
- }
-
- cso_data->modes4 |= (_3DSTATE_MODES_4_CMD |
- ENABLE_LOGIC_OP_FUNC |
- LOGIC_OP_FUNC(i915_translate_logic_op(blend->logicop_func)));
-
- if (blend->logicop_enable)
- cso_data->LIS5 |= S5_LOGICOP_ENABLE;
-
- if (blend->dither)
- cso_data->LIS5 |= S5_COLOR_DITHER_ENABLE;
-
- if ((blend->colormask & PIPE_MASK_R) == 0)
- cso_data->LIS5 |= S5_WRITEDISABLE_RED;
-
- if ((blend->colormask & PIPE_MASK_G) == 0)
- cso_data->LIS5 |= S5_WRITEDISABLE_GREEN;
-
- if ((blend->colormask & PIPE_MASK_B) == 0)
- cso_data->LIS5 |= S5_WRITEDISABLE_BLUE;
-
- if ((blend->colormask & PIPE_MASK_A) == 0)
- cso_data->LIS5 |= S5_WRITEDISABLE_ALPHA;
-
- if (blend->blend_enable) {
- unsigned funcRGB = blend->rgb_func;
- unsigned srcRGB = blend->rgb_src_factor;
- unsigned dstRGB = blend->rgb_dst_factor;
-
- cso_data->LIS6 |= (S6_CBUF_BLEND_ENABLE |
- SRC_BLND_FACT(i915_translate_blend_factor(srcRGB)) |
- DST_BLND_FACT(i915_translate_blend_factor(dstRGB)) |
- (i915_translate_blend_func(funcRGB) << S6_CBUF_BLEND_FUNC_SHIFT));
- }
-
- return cso_data;
-}
-
-static void i915_bind_blend_state(struct pipe_context *pipe,
- void *blend)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->blend = (struct i915_blend_state*)blend;
-
- i915->dirty |= I915_NEW_BLEND;
-}
-
-
-static void i915_delete_blend_state(struct pipe_context *pipe, void *blend)
-{
- FREE(blend);
-}
-
-static void i915_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->blend_color = *blend_color;
-
- i915->dirty |= I915_NEW_BLEND;
-}
-
-static void *
-i915_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
-{
- struct i915_sampler_state *cso = CALLOC_STRUCT( i915_sampler_state );
- const unsigned ws = sampler->wrap_s;
- const unsigned wt = sampler->wrap_t;
- const unsigned wr = sampler->wrap_r;
- unsigned minFilt, magFilt;
- unsigned mipFilt;
-
- cso->templ = sampler;
-
- mipFilt = translate_mip_filter(sampler->min_mip_filter);
- if (sampler->max_anisotropy > 1.0) {
- minFilt = FILTER_ANISOTROPIC;
- magFilt = FILTER_ANISOTROPIC;
- if (sampler->max_anisotropy > 2.0) {
- cso->state[0] |= SS2_MAX_ANISO_4;
- }
- }
- else {
- minFilt = translate_img_filter( sampler->min_img_filter );
- magFilt = translate_img_filter( sampler->mag_img_filter );
- }
-
- {
- int b = (int) (sampler->lod_bias * 16.0);
- b = CLAMP(b, -256, 255);
- cso->state[0] |= ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK);
- }
-
- /* Shadow:
- */
- if (sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE)
- {
- cso->state[0] |= (SS2_SHADOW_ENABLE |
- i915_translate_compare_func(sampler->compare_func));
-
- minFilt = FILTER_4X4_FLAT;
- magFilt = FILTER_4X4_FLAT;
- }
-
- cso->state[0] |= ((minFilt << SS2_MIN_FILTER_SHIFT) |
- (mipFilt << SS2_MIP_FILTER_SHIFT) |
- (magFilt << SS2_MAG_FILTER_SHIFT));
-
- cso->state[1] |=
- ((translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT) |
- (translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT) |
- (translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT));
-
- if (sampler->normalized_coords)
- cso->state[1] |= SS3_NORMALIZED_COORDS;
-
- if (0) /* XXX not tested yet */
- {
- int minlod = (int) (16.0 * sampler->min_lod);
- minlod = CLAMP(minlod, 0, 16 * 11);
- cso->state[1] |= (minlod << SS3_MIN_LOD_SHIFT);
- }
-
- {
- ubyte r = float_to_ubyte(sampler->border_color[0]);
- ubyte g = float_to_ubyte(sampler->border_color[1]);
- ubyte b = float_to_ubyte(sampler->border_color[2]);
- ubyte a = float_to_ubyte(sampler->border_color[3]);
- cso->state[2] = I915PACKCOLOR8888(r, g, b, a);
- }
- return cso;
-}
-
-static void i915_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- assert(unit < PIPE_MAX_SAMPLERS);
- i915->sampler[unit] = (const struct i915_sampler_state*)sampler;
-
- i915->dirty |= I915_NEW_SAMPLER;
-}
-
-static void i915_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
-{
- FREE(sampler);
-}
-
-
-/** XXX move someday? Or consolidate all these simple state setters
- * into one file.
- */
-
-static void *
-i915_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
-{
- struct i915_depth_stencil_state *cso = CALLOC_STRUCT( i915_depth_stencil_state );
-
- {
- int testmask = depth_stencil->stencil[0].value_mask & 0xff;
- int writemask = depth_stencil->stencil[0].write_mask & 0xff;
-
- cso->stencil_modes4 |= (_3DSTATE_MODES_4_CMD |
- ENABLE_STENCIL_TEST_MASK |
- STENCIL_TEST_MASK(testmask) |
- ENABLE_STENCIL_WRITE_MASK |
- STENCIL_WRITE_MASK(writemask));
- }
-
- if (depth_stencil->stencil[0].enabled) {
- int test = i915_translate_compare_func(depth_stencil->stencil[0].func);
- int fop = i915_translate_stencil_op(depth_stencil->stencil[0].fail_op);
- int dfop = i915_translate_stencil_op(depth_stencil->stencil[0].zfail_op);
- int dpop = i915_translate_stencil_op(depth_stencil->stencil[0].zpass_op);
- int ref = depth_stencil->stencil[0].ref_value & 0xff;
-
- cso->stencil_LIS5 |= (S5_STENCIL_TEST_ENABLE |
- S5_STENCIL_WRITE_ENABLE |
- (ref << S5_STENCIL_REF_SHIFT) |
- (test << S5_STENCIL_TEST_FUNC_SHIFT) |
- (fop << S5_STENCIL_FAIL_SHIFT) |
- (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
- (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT));
- }
-
- if (depth_stencil->stencil[1].enabled) {
- int test = i915_translate_compare_func(depth_stencil->stencil[1].func);
- int fop = i915_translate_stencil_op(depth_stencil->stencil[1].fail_op);
- int dfop = i915_translate_stencil_op(depth_stencil->stencil[1].zfail_op);
- int dpop = i915_translate_stencil_op(depth_stencil->stencil[1].zpass_op);
- int ref = depth_stencil->stencil[1].ref_value & 0xff;
- int tmask = depth_stencil->stencil[1].value_mask & 0xff;
- int wmask = depth_stencil->stencil[1].write_mask & 0xff;
-
- cso->bfo[0] = (_3DSTATE_BACKFACE_STENCIL_OPS |
- BFO_ENABLE_STENCIL_FUNCS |
- BFO_ENABLE_STENCIL_TWO_SIDE |
- BFO_ENABLE_STENCIL_REF |
- BFO_STENCIL_TWO_SIDE |
- (ref << BFO_STENCIL_REF_SHIFT) |
- (test << BFO_STENCIL_TEST_SHIFT) |
- (fop << BFO_STENCIL_FAIL_SHIFT) |
- (dfop << BFO_STENCIL_PASS_Z_FAIL_SHIFT) |
- (dpop << BFO_STENCIL_PASS_Z_PASS_SHIFT));
-
- cso->bfo[1] = (_3DSTATE_BACKFACE_STENCIL_MASKS |
- BFM_ENABLE_STENCIL_TEST_MASK |
- BFM_ENABLE_STENCIL_WRITE_MASK |
- (tmask << BFM_STENCIL_TEST_MASK_SHIFT) |
- (wmask << BFM_STENCIL_WRITE_MASK_SHIFT));
- }
- else {
- /* This actually disables two-side stencil: The bit set is a
- * modify-enable bit to indicate we are changing the two-side
- * setting. Then there is a symbolic zero to show that we are
- * setting the flag to zero/off.
- */
- cso->bfo[0] = (_3DSTATE_BACKFACE_STENCIL_OPS |
- BFO_ENABLE_STENCIL_TWO_SIDE |
- 0);
- cso->bfo[1] = 0;
- }
-
- if (depth_stencil->depth.enabled) {
- int func = i915_translate_compare_func(depth_stencil->depth.func);
-
- cso->depth_LIS6 |= (S6_DEPTH_TEST_ENABLE |
- (func << S6_DEPTH_TEST_FUNC_SHIFT));
-
- if (depth_stencil->depth.writemask)
- cso->depth_LIS6 |= S6_DEPTH_WRITE_ENABLE;
- }
-
- if (depth_stencil->alpha.enabled) {
- int test = i915_translate_compare_func(depth_stencil->alpha.func);
- ubyte refByte = float_to_ubyte(depth_stencil->alpha.ref);
-
- cso->depth_LIS6 |= (S6_ALPHA_TEST_ENABLE |
- (test << S6_ALPHA_TEST_FUNC_SHIFT) |
- (((unsigned) refByte) << S6_ALPHA_REF_SHIFT));
- }
-
- return cso;
-}
-
-static void i915_bind_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->depth_stencil = (const struct i915_depth_stencil_state *)depth_stencil;
-
- i915->dirty |= I915_NEW_DEPTH_STENCIL;
-}
-
-static void i915_delete_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- FREE(depth_stencil);
-}
-
-
-static void i915_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- memcpy( &i915->scissor, scissor, sizeof(*scissor) );
- i915->dirty |= I915_NEW_SCISSOR;
-}
-
-
-static void i915_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
-}
-
-
-static void * i915_create_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- return 0;
-}
-
-static void i915_bind_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->fs = (struct pipe_shader_state *)fs;
-
- i915->dirty |= I915_NEW_FS;
-}
-
-static void i915_delete_fs_state(struct pipe_context *pipe, void *shader)
-{
- /*do nothing*/
-}
-
-static void *
-i915_create_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- /* just pass-through to draw module */
- return draw_create_vertex_shader(i915->draw, templ);
-}
-
-static void i915_bind_vs_state(struct pipe_context *pipe, void *shader)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- /* just pass-through to draw module */
- draw_bind_vertex_shader(i915->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void i915_delete_vs_state(struct pipe_context *pipe, void *shader)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- /* just pass-through to draw module */
- draw_delete_vertex_shader(i915->draw, (struct draw_vertex_shader *) shader);
-}
-
-static void i915_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf)
-{
- struct i915_context *i915 = i915_context(pipe);
- struct pipe_winsys *ws = pipe->winsys;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- /* Make a copy of shader constants.
- * During fragment program translation we may add additional
- * constants to the array.
- *
- * We want to consider the situation where some user constants
- * (ex: a material color) may change frequently but the shader program
- * stays the same. In that case we should only be updating the first
- * N constants, leaving any extras from shader translation alone.
- */
- {
- void *mapped;
- if (buf->size &&
- (mapped = ws->buffer_map(ws, buf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ))) {
- memcpy(i915->current.constants[shader], mapped, buf->size);
- ws->buffer_unmap(ws, buf->buffer);
- i915->current.num_user_constants[shader]
- = buf->size / (4 * sizeof(float));
- }
- else {
- i915->current.num_user_constants[shader] = 0;
- }
- }
-
- i915->dirty |= I915_NEW_CONSTANTS;
-}
-
-
-static void i915_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler,
- struct pipe_texture *texture)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->texture[sampler] = (struct i915_texture*)texture; /* ptr, not struct */
-
- i915->dirty |= I915_NEW_TEXTURE;
-}
-
-
-
-static void i915_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->framebuffer = *fb; /* struct copy */
-
- i915->dirty |= I915_NEW_FRAMEBUFFER;
-}
-
-
-
-static void i915_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- draw_set_clip_state(i915->draw, clip);
-
- i915->dirty |= I915_NEW_CLIP;
-}
-
-
-
-/* Called when driver state tracker notices changes to the viewport
- * matrix:
- */
-static void i915_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->viewport = *viewport; /* struct copy */
-
- /* pass the viewport info to the draw module */
- draw_set_viewport_state(i915->draw, &i915->viewport);
-
- i915->dirty |= I915_NEW_VIEWPORT;
-}
-
-
-static void *
-i915_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *rasterizer)
-{
- struct i915_rasterizer_state *cso = CALLOC_STRUCT( i915_rasterizer_state );
-
- cso->templ = rasterizer;
- cso->color_interp = rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
- cso->light_twoside = rasterizer->light_twoside;
- cso->ds[0].u = _3DSTATE_DEPTH_OFFSET_SCALE;
- cso->ds[1].f = rasterizer->offset_scale;
- if (rasterizer->poly_stipple_enable) {
- cso->st |= ST1_ENABLE;
- }
-
- if (rasterizer->scissor)
- cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT;
- else
- cso->sc[0] = _3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT;
-
- switch (rasterizer->cull_mode) {
- case PIPE_WINDING_NONE:
- cso->LIS4 |= S4_CULLMODE_NONE;
- break;
- case PIPE_WINDING_CW:
- cso->LIS4 |= S4_CULLMODE_CW;
- break;
- case PIPE_WINDING_CCW:
- cso->LIS4 |= S4_CULLMODE_CCW;
- break;
- case PIPE_WINDING_BOTH:
- cso->LIS4 |= S4_CULLMODE_BOTH;
- break;
- }
-
- {
- int line_width = CLAMP((int)(rasterizer->line_width * 2), 1, 0xf);
-
- cso->LIS4 |= line_width << S4_LINE_WIDTH_SHIFT;
-
- if (rasterizer->line_smooth)
- cso->LIS4 |= S4_LINE_ANTIALIAS_ENABLE;
- }
-
- {
- int point_size = CLAMP((int) rasterizer->point_size, 1, 0xff);
-
- cso->LIS4 |= point_size << S4_POINT_WIDTH_SHIFT;
- }
-
- if (rasterizer->flatshade) {
- cso->LIS4 |= (S4_FLATSHADE_ALPHA |
- S4_FLATSHADE_COLOR |
- S4_FLATSHADE_SPECULAR);
- }
-
- cso->LIS7 = fui( rasterizer->offset_units );
-
-
- return cso;
-}
-
-static void i915_bind_rasterizer_state( struct pipe_context *pipe,
- void *setup )
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->rasterizer = (struct i915_rasterizer_state *)setup;
-
- /* pass-through to draw module */
- draw_set_rasterizer_state(i915->draw, i915->rasterizer->templ);
-
- i915->dirty |= I915_NEW_RASTERIZER;
-}
-
-static void i915_delete_rasterizer_state(struct pipe_context *pipe,
- void *setup)
-{
- FREE(setup);
-}
-
-static void i915_set_vertex_buffer( struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_buffer *buffer )
-{
- struct i915_context *i915 = i915_context(pipe);
- i915->vertex_buffer[index] = *buffer;
- /* pass-through to draw module */
- draw_set_vertex_buffer(i915->draw, index, buffer);
-}
-
-static void i915_set_vertex_element( struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_element *element)
-{
- struct i915_context *i915 = i915_context(pipe);
- /* pass-through to draw module */
- draw_set_vertex_element(i915->draw, index, element);
-}
-
-
-
-void
-i915_init_state_functions( struct i915_context *i915 )
-{
- i915->pipe.create_blend_state = i915_create_blend_state;
- i915->pipe.bind_blend_state = i915_bind_blend_state;
- i915->pipe.delete_blend_state = i915_delete_blend_state;
-
- i915->pipe.create_sampler_state = i915_create_sampler_state;
- i915->pipe.bind_sampler_state = i915_bind_sampler_state;
- i915->pipe.delete_sampler_state = i915_delete_sampler_state;
-
- i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state;
- i915->pipe.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state;
- i915->pipe.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state;
-
- i915->pipe.create_rasterizer_state = i915_create_rasterizer_state;
- i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state;
- i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state;
- i915->pipe.create_fs_state = i915_create_fs_state;
- i915->pipe.bind_fs_state = i915_bind_fs_state;
- i915->pipe.delete_fs_state = i915_delete_fs_state;
- i915->pipe.create_vs_state = i915_create_vs_state;
- i915->pipe.bind_vs_state = i915_bind_vs_state;
- i915->pipe.delete_vs_state = i915_delete_vs_state;
-
- i915->pipe.set_blend_color = i915_set_blend_color;
- i915->pipe.set_clip_state = i915_set_clip_state;
- i915->pipe.set_constant_buffer = i915_set_constant_buffer;
- i915->pipe.set_framebuffer_state = i915_set_framebuffer_state;
-
- i915->pipe.set_polygon_stipple = i915_set_polygon_stipple;
- i915->pipe.set_scissor_state = i915_set_scissor_state;
- i915->pipe.set_sampler_texture = i915_set_sampler_texture;
- i915->pipe.set_viewport_state = i915_set_viewport_state;
- i915->pipe.set_vertex_buffer = i915_set_vertex_buffer;
- i915->pipe.set_vertex_element = i915_set_vertex_element;
-}
diff --git a/src/mesa/pipe/i915simple/i915_state.h b/src/mesa/pipe/i915simple/i915_state.h
deleted file mode 100644
index 86c6b0027d..0000000000
--- a/src/mesa/pipe/i915simple/i915_state.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef I915_STATE_H
-#define I915_STATE_H
-
-struct i915_context;
-
-
-struct i915_tracked_state {
- unsigned dirty;
- void (*update)( struct i915_context * );
-};
-
-void i915_update_immediate( struct i915_context *i915 );
-void i915_update_dynamic( struct i915_context *i915 );
-void i915_update_derived( struct i915_context *i915 );
-void i915_update_samplers( struct i915_context *i915 );
-void i915_update_textures(struct i915_context *i915);
-
-void i915_emit_hardware_state( struct i915_context *i915 );
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_state_derived.c b/src/mesa/pipe/i915simple/i915_state_derived.c
deleted file mode 100644
index 653983e4a9..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_derived.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "pipe/p_util.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_vertex.h"
-#include "i915_context.h"
-#include "i915_state.h"
-#include "i915_reg.h"
-#include "i915_fpc.h"
-#include "pipe/p_shader_tokens.h"
-
-
-/**
- * Determine which post-transform / pre-rasterization vertex attributes
- * we need.
- * Derived from: fs, setup states.
- */
-static void calculate_vertex_layout( struct i915_context *i915 )
-{
- const struct pipe_shader_state *fs = i915->fs;
- const enum interp_mode colorInterp = i915->rasterizer->color_interp;
- struct vertex_info vinfo;
- uint front0 = 0, back0 = 0, front1 = 0, back1 = 0;
- boolean needW = 0;
- uint i;
- boolean texCoords[8];
- uint src = 0;
-
- memset(texCoords, 0, sizeof(texCoords));
- memset(&vinfo, 0, sizeof(vinfo));
-
- /* pos */
- draw_emit_vertex_attr(&vinfo, EMIT_3F, INTERP_LINEAR, src++);
- /* Note: we'll set the S4_VFMT_XYZ[W] bits below */
-
- for (i = 0; i < fs->num_inputs; i++) {
- switch (fs->input_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- break;
- case TGSI_SEMANTIC_COLOR:
- if (fs->input_semantic_index[i] == 0) {
- front0 = draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src++);
- vinfo.hwfmt[0] |= S4_VFMT_COLOR;
- }
- else {
- assert(fs->input_semantic_index[i] == 1);
- front1 = draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src++);
- vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
- }
- break;
- case TGSI_SEMANTIC_GENERIC:
- /* usually a texcoord */
- {
- const uint unit = fs->input_semantic_index[i];
- uint hwtc;
- texCoords[unit] = TRUE;
- draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE, src++);
- hwtc = TEXCOORDFMT_4D;
- needW = TRUE;
- vinfo.hwfmt[1] |= hwtc << (unit * 4);
- }
- break;
- case TGSI_SEMANTIC_FOG:
- debug_printf("i915 fogcoord not implemented yet\n");
- draw_emit_vertex_attr(&vinfo, EMIT_1F, INTERP_PERSPECTIVE, src++);
- break;
- default:
- assert(0);
- }
-
- }
-
- /* finish up texcoord fields */
- for (i = 0; i < 8; i++) {
- if (!texCoords[i]) {
- const uint hwtc = TEXCOORDFMT_NOT_PRESENT;
- vinfo.hwfmt[1] |= hwtc << (i* 4);
- }
- }
-
- /* go back and fill in the vertex position info now that we have needW */
- if (needW) {
- vinfo.hwfmt[0] |= S4_VFMT_XYZW;
- vinfo.emit[0] = EMIT_4F;
- }
- else {
- vinfo.hwfmt[0] |= S4_VFMT_XYZ;
- vinfo.emit[0] = EMIT_3F;
- }
-
- /* Additional attributes required for setup: Just twosided
- * lighting. Edgeflag is dealt with specially by setting bits in
- * the vertex header.
- */
- if (i915->rasterizer->light_twoside) {
- if (front0) {
- back0 = draw_emit_vertex_attr(&vinfo, EMIT_OMIT, colorInterp, src++);
- }
- if (back0) {
- back1 = draw_emit_vertex_attr(&vinfo, EMIT_OMIT, colorInterp, src++);
- }
- }
-
- draw_compute_vertex_size(&vinfo);
-
- if (memcmp(&i915->current.vertex_info, &vinfo, sizeof(vinfo))) {
- /* Need to set this flag so that the LIS2/4 registers get set.
- * It also means the i915_update_immediate() function must be called
- * after this one, in i915_update_derived().
- */
- i915->dirty |= I915_NEW_VERTEX_FORMAT;
-
- memcpy(&i915->current.vertex_info, &vinfo, sizeof(vinfo));
- }
-}
-
-
-
-
-/* Hopefully this will remain quite simple, otherwise need to pull in
- * something like the state tracker mechanism.
- */
-void i915_update_derived( struct i915_context *i915 )
-{
- if (i915->dirty & (I915_NEW_RASTERIZER | I915_NEW_FS))
- calculate_vertex_layout( i915 );
-
- if (i915->dirty & (I915_NEW_SAMPLER | I915_NEW_TEXTURE))
- i915_update_samplers(i915);
-
- if (i915->dirty & I915_NEW_TEXTURE)
- i915_update_textures(i915);
-
- if (i915->dirty)
- i915_update_immediate( i915 );
-
- if (i915->dirty)
- i915_update_dynamic( i915 );
-
- if (i915->dirty & I915_NEW_FS) {
- i915_translate_fragment_program(i915);
- i915->hardware_dirty |= I915_HW_PROGRAM; /* XXX right? */
- }
-
- /* HW emit currently references framebuffer state directly:
- */
- if (i915->dirty & I915_NEW_FRAMEBUFFER)
- i915->hardware_dirty |= I915_HW_STATIC;
-
- i915->dirty = 0;
-}
diff --git a/src/mesa/pipe/i915simple/i915_state_dynamic.c b/src/mesa/pipe/i915simple/i915_state_dynamic.c
deleted file mode 100644
index 8cfbdddd19..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_dynamic.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "i915_batch.h"
-#include "i915_state_inlines.h"
-#include "i915_context.h"
-#include "i915_reg.h"
-#include "i915_state.h"
-#include "pipe/p_util.h"
-
-#define FILE_DEBUG_FLAG DEBUG_STATE
-
-/* State that we have chosen to store in the DYNAMIC segment of the
- * i915 indirect state mechanism.
- *
- * Can't cache these in the way we do the static state, as there is no
- * start/size in the command packet, instead an 'end' value that gets
- * incremented.
- *
- * Additionally, there seems to be a requirement to re-issue the full
- * (active) state every time a 4kb boundary is crossed.
- */
-
-static INLINE void set_dynamic_indirect( struct i915_context *i915,
- unsigned offset,
- const unsigned *src,
- unsigned dwords )
-{
- unsigned i;
-
- for (i = 0; i < dwords; i++)
- i915->current.dynamic[offset + i] = src[i];
-
- i915->hardware_dirty |= I915_HW_DYNAMIC;
-}
-
-
-/***********************************************************************
- * Modes4: stencil masks and logicop
- */
-static void upload_MODES4( struct i915_context *i915 )
-{
- unsigned modes4 = 0;
-
- /* I915_NEW_STENCIL */
- modes4 |= i915->depth_stencil->stencil_modes4;
- /* I915_NEW_BLEND */
- modes4 |= i915->blend->modes4;
-
- /* Always, so that we know when state is in-active:
- */
- set_dynamic_indirect( i915,
- I915_DYNAMIC_MODES4,
- &modes4,
- 1 );
-}
-
-const struct i915_tracked_state i915_upload_MODES4 = {
- I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
- upload_MODES4
-};
-
-
-
-
-/***********************************************************************
- */
-
-static void upload_BFO( struct i915_context *i915 )
-{
- set_dynamic_indirect( i915,
- I915_DYNAMIC_BFO_0,
- &(i915->depth_stencil->bfo[0]),
- 2 );
-}
-
-const struct i915_tracked_state i915_upload_BFO = {
- I915_NEW_DEPTH_STENCIL,
- upload_BFO
-};
-
-
-/***********************************************************************
- */
-
-
-static void upload_BLENDCOLOR( struct i915_context *i915 )
-{
- unsigned bc[2];
-
- memset( bc, 0, sizeof(bc) );
-
- /* I915_NEW_BLEND {_COLOR}
- */
- {
- const float *color = i915->blend_color.color;
-
- bc[0] = _3DSTATE_CONST_BLEND_COLOR_CMD;
- bc[1] = pack_ui32_float4( color[0],
- color[1],
- color[2],
- color[3] );
- }
-
- set_dynamic_indirect( i915,
- I915_DYNAMIC_BC_0,
- bc,
- 2 );
-}
-
-const struct i915_tracked_state i915_upload_BLENDCOLOR = {
- I915_NEW_BLEND,
- upload_BLENDCOLOR
-};
-
-/***********************************************************************
- */
-
-
-static void upload_IAB( struct i915_context *i915 )
-{
- unsigned iab = i915->blend->iab;
-
-
- set_dynamic_indirect( i915,
- I915_DYNAMIC_IAB,
- &iab,
- 1 );
-}
-
-const struct i915_tracked_state i915_upload_IAB = {
- I915_NEW_BLEND,
- upload_IAB
-};
-
-
-/***********************************************************************
- */
-
-
-
-static void upload_DEPTHSCALE( struct i915_context *i915 )
-{
- set_dynamic_indirect( i915,
- I915_DYNAMIC_DEPTHSCALE_0,
- &(i915->rasterizer->ds[0].u),
- 2 );
-}
-
-const struct i915_tracked_state i915_upload_DEPTHSCALE = {
- I915_NEW_RASTERIZER,
- upload_DEPTHSCALE
-};
-
-
-
-/***********************************************************************
- * Polygon stipple
- *
- * The i915 supports a 4x4 stipple natively, GL wants 32x32.
- * Fortunately stipple is usually a repeating pattern.
- *
- * XXX: does stipple pattern need to be adjusted according to
- * the window position?
- *
- * XXX: possibly need workaround for conform paths test.
- */
-
-static void upload_STIPPLE( struct i915_context *i915 )
-{
- unsigned st[2];
-
- st[0] = _3DSTATE_STIPPLE;
- st[1] = 0;
-
- /* I915_NEW_RASTERIZER
- */
- st[1] |= i915->rasterizer->st;
-
-
- /* I915_NEW_STIPPLE
- */
- {
- const ubyte *mask = (const ubyte *)i915->poly_stipple.stipple;
- ubyte p[4];
-
- p[0] = mask[12] & 0xf;
- p[1] = mask[8] & 0xf;
- p[2] = mask[4] & 0xf;
- p[3] = mask[0] & 0xf;
-
- /* Not sure what to do about fallbacks, so for now just dont:
- */
- st[1] |= ((p[0] << 0) |
- (p[1] << 4) |
- (p[2] << 8) |
- (p[3] << 12));
- }
-
-
- set_dynamic_indirect( i915,
- I915_DYNAMIC_STP_0,
- &st[0],
- 2 );
-}
-
-
-const struct i915_tracked_state i915_upload_STIPPLE = {
- I915_NEW_RASTERIZER | I915_NEW_STIPPLE,
- upload_STIPPLE
-};
-
-
-
-/***********************************************************************
- * Scissor.
- */
-static void upload_SCISSOR_ENABLE( struct i915_context *i915 )
-{
- set_dynamic_indirect( i915,
- I915_DYNAMIC_SC_ENA_0,
- &(i915->rasterizer->sc[0]),
- 1 );
-}
-
-const struct i915_tracked_state i915_upload_SCISSOR_ENABLE = {
- I915_NEW_RASTERIZER,
- upload_SCISSOR_ENABLE
-};
-
-
-
-static void upload_SCISSOR_RECT( struct i915_context *i915 )
-{
- unsigned x1 = i915->scissor.minx;
- unsigned y1 = i915->scissor.miny;
- unsigned x2 = i915->scissor.maxx;
- unsigned y2 = i915->scissor.maxy;
- unsigned sc[3];
-
- sc[0] = _3DSTATE_SCISSOR_RECT_0_CMD;
- sc[1] = (y1 << 16) | (x1 & 0xffff);
- sc[2] = (y2 << 16) | (x2 & 0xffff);
-
- set_dynamic_indirect( i915,
- I915_DYNAMIC_SC_RECT_0,
- &sc[0],
- 3 );
-}
-
-
-const struct i915_tracked_state i915_upload_SCISSOR_RECT = {
- I915_NEW_SCISSOR,
- upload_SCISSOR_RECT
-};
-
-
-
-
-
-
-static const struct i915_tracked_state *atoms[] = {
- &i915_upload_MODES4,
- &i915_upload_BFO,
- &i915_upload_BLENDCOLOR,
- &i915_upload_IAB,
- &i915_upload_DEPTHSCALE,
- &i915_upload_STIPPLE,
- &i915_upload_SCISSOR_ENABLE,
- &i915_upload_SCISSOR_RECT
-};
-
-/* These will be dynamic indirect state commands, but for now just end
- * up on the batch buffer with everything else.
- */
-void i915_update_dynamic( struct i915_context *i915 )
-{
- int i;
-
- for (i = 0; i < Elements(atoms); i++)
- if (i915->dirty & atoms[i]->dirty)
- atoms[i]->update( i915 );
-}
-
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c
deleted file mode 100644
index 3339287f49..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_emit.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i915_reg.h"
-#include "i915_context.h"
-#include "i915_winsys.h"
-#include "i915_batch.h"
-#include "i915_reg.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-
-static unsigned translate_format( enum pipe_format format )
-{
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return COLOR_BUF_ARGB8888;
- case PIPE_FORMAT_R5G6B5_UNORM:
- return COLOR_BUF_RGB565;
- default:
- assert(0);
- return 0;
- }
-}
-
-static unsigned translate_depth_format( enum pipe_format zformat )
-{
- switch (zformat) {
- case PIPE_FORMAT_S8Z24_UNORM:
- return DEPTH_FRMT_24_FIXED_8_OTHER;
- case PIPE_FORMAT_Z16_UNORM:
- return DEPTH_FRMT_16_FIXED;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-/**
- * Examine framebuffer state to determine width, height.
- */
-static boolean
-framebuffer_size(const struct pipe_framebuffer_state *fb,
- uint *width, uint *height)
-{
- if (fb->cbufs[0]) {
- *width = fb->cbufs[0]->width;
- *height = fb->cbufs[0]->height;
- return TRUE;
- }
- else if (fb->zsbuf) {
- *width = fb->zsbuf->width;
- *height = fb->zsbuf->height;
- return TRUE;
- }
- else {
- *width = *height = 0;
- return FALSE;
- }
-}
-
-
-/* Push the state into the sarea and/or texture memory.
- */
-void
-i915_emit_hardware_state(struct i915_context *i915 )
-{
- /* XXX: there must be an easier way */
- const unsigned dwords = ( 14 +
- 7 +
- I915_MAX_DYNAMIC +
- 8 +
- 2 + I915_TEX_UNITS*3 +
- 2 + I915_TEX_UNITS*3 +
- 2 + I915_MAX_CONSTANT*4 +
- i915->current.program_len +
- 6
- ) * 3/2; /* plus 50% margin */
- const unsigned relocs = ( I915_TEX_UNITS +
- 3
- ) * 3/2; /* plus 50% margin */
-
-#if 0
- debug_printf("i915_emit_hardware_state: %d dwords, %d relocs\n", dwords, relocs);
-#endif
-
- if(!BEGIN_BATCH(dwords, relocs)) {
- FLUSH_BATCH();
- assert(BEGIN_BATCH(dwords, relocs));
- }
-
- /* 14 dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_INVARIENT)
- {
- OUT_BATCH(_3DSTATE_AA_CMD |
- AA_LINE_ECAAR_WIDTH_ENABLE |
- AA_LINE_ECAAR_WIDTH_1_0 |
- AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0);
-
- OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
- OUT_BATCH(0);
-
- OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
- OUT_BATCH(0);
-
- OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
- OUT_BATCH(0);
-
- OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS |
- CSB_TCB(0, 0) |
- CSB_TCB(1, 1) |
- CSB_TCB(2, 2) |
- CSB_TCB(3, 3) |
- CSB_TCB(4, 4) |
- CSB_TCB(5, 5) |
- CSB_TCB(6, 6) |
- CSB_TCB(7, 7));
-
- OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
- ENABLE_POINT_RASTER_RULE |
- OGL_POINT_RASTER_RULE |
- ENABLE_LINE_STRIP_PROVOKE_VRTX |
- ENABLE_TRI_FAN_PROVOKE_VRTX |
- LINE_STRIP_PROVOKE_VRTX(1) |
- TRI_FAN_PROVOKE_VRTX(2) |
- ENABLE_TEXKILL_3D_4D |
- TEXKILL_4D);
-
- /* Need to initialize this to zero.
- */
- OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S(3) | (0));
- OUT_BATCH(0);
-
- OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
-
- /* disable indirect state for now
- */
- OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0);
- OUT_BATCH(0);
- }
-
- /* 7 dwords, 1 relocs */
- if (i915->hardware_dirty & I915_HW_IMMEDIATE)
- {
- OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
- I1_LOAD_S(0) |
- I1_LOAD_S(1) |
- I1_LOAD_S(2) |
- I1_LOAD_S(4) |
- I1_LOAD_S(5) |
- I1_LOAD_S(6) |
- (5));
-
- if(i915->vbo)
- OUT_RELOC(i915->vbo,
- I915_BUFFER_ACCESS_READ,
- i915->current.immediate[I915_IMMEDIATE_S0]);
- else
- /* FIXME: we should not do this */
- OUT_BATCH(0);
- OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S1]);
- OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S2]);
- OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S4]);
- OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S5]);
- OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S6]);
- }
-
- /* I915_MAX_DYNAMIC dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_DYNAMIC)
- {
- int i;
- for (i = 0; i < I915_MAX_DYNAMIC; i++) {
- OUT_BATCH(i915->current.dynamic[i]);
- }
- }
-
- /* 8 dwords, 2 relocs */
- if (i915->hardware_dirty & I915_HW_STATIC)
- {
- struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
- struct pipe_surface *depth_surface = i915->framebuffer.zsbuf;
-
- if (cbuf_surface) {
- unsigned pitch = (cbuf_surface->pitch * cbuf_surface->cpp);
-
- OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
-
- OUT_BATCH(BUF_3D_ID_COLOR_BACK |
- BUF_3D_PITCH(pitch) | /* pitch in bytes */
- BUF_3D_USE_FENCE);
-
- OUT_RELOC(cbuf_surface->buffer,
- I915_BUFFER_ACCESS_WRITE,
- 0);
- }
-
- /* What happens if no zbuf??
- */
- if (depth_surface) {
- unsigned zpitch = (depth_surface->pitch * depth_surface->cpp);
-
- OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
-
- OUT_BATCH(BUF_3D_ID_DEPTH |
- BUF_3D_PITCH(zpitch) | /* pitch in bytes */
- BUF_3D_USE_FENCE);
-
- OUT_RELOC(depth_surface->buffer,
- I915_BUFFER_ACCESS_WRITE,
- 0);
- }
-
- {
- unsigned cformat, zformat = 0;
-
- if (cbuf_surface)
- cformat = cbuf_surface->format;
- else
- cformat = PIPE_FORMAT_A8R8G8B8_UNORM; /* arbitrary */
- cformat = translate_format(cformat);
-
- if (depth_surface)
- zformat = translate_depth_format( i915->framebuffer.zsbuf->format );
-
- OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
- OUT_BATCH(DSTORG_HORT_BIAS(0x8) | /* .5 */
- DSTORG_VERT_BIAS(0x8) | /* .5 */
- LOD_PRECLAMP_OGL |
- TEX_DEFAULT_COLOR_OGL |
- cformat |
- zformat );
- }
- }
-
-#if 01
- /* texture images */
- /* 2 + I915_TEX_UNITS*3 dwords, I915_TEX_UNITS relocs */
- if (i915->hardware_dirty & (I915_HW_MAP | I915_HW_SAMPLER))
- {
- /* XXX: we were refering to sampler state
- * (current.sampler_enable_nr) below, but only checking
- * I915_HW_MAP above. Should probably calculate the enabled
- * flags separately - but there will be further rework of
- * state so perhaps not necessary yet.
- */
- const uint nr = i915->current.sampler_enable_nr;
- if (nr) {
- const uint enabled = i915->current.sampler_enable_flags;
- uint unit;
- uint count = 0;
- OUT_BATCH(_3DSTATE_MAP_STATE | (3 * nr));
- OUT_BATCH(enabled);
- for (unit = 0; unit < I915_TEX_UNITS; unit++) {
- if (enabled & (1 << unit)) {
- struct pipe_buffer *buf =
- i915->texture[unit]->buffer;
- uint offset = 0;
- assert(buf);
-
- count++;
-
- OUT_RELOC(buf,
- I915_BUFFER_ACCESS_READ,
- offset);
- OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */
- OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */
- }
- }
- assert(count == nr);
- }
- }
-#endif
-
-#if 01
- /* samplers */
- /* 2 + I915_TEX_UNITS*3 dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_SAMPLER)
- {
- if (i915->current.sampler_enable_nr) {
- int i;
-
- OUT_BATCH( _3DSTATE_SAMPLER_STATE |
- (3 * i915->current.sampler_enable_nr) );
-
- OUT_BATCH( i915->current.sampler_enable_flags );
-
- for (i = 0; i < I915_TEX_UNITS; i++) {
- if (i915->current.sampler_enable_flags & (1<<i)) {
- OUT_BATCH( i915->current.sampler[i][0] );
- OUT_BATCH( i915->current.sampler[i][1] );
- OUT_BATCH( i915->current.sampler[i][2] );
- }
- }
- }
- }
-#endif
-
- /* constants */
- /* 2 + I915_MAX_CONSTANT*4 dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_PROGRAM)
- {
- const uint nr = i915->current.num_constants[PIPE_SHADER_FRAGMENT];
- assert(nr <= I915_MAX_CONSTANT);
- if (nr > 0) {
- const uint *c
- = (const uint *) i915->current.constants[PIPE_SHADER_FRAGMENT];
- uint i;
- OUT_BATCH( _3DSTATE_PIXEL_SHADER_CONSTANTS | (nr * 4) );
- OUT_BATCH( (1 << (nr - 1)) | ((1 << (nr - 1)) - 1) );
- for (i = 0; i < nr; i++) {
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- OUT_BATCH(*c++);
- }
- }
- }
-
- /* Fragment program */
- /* i915->current.program_len dwords, 0 relocs */
- if (i915->hardware_dirty & I915_HW_PROGRAM)
- {
- uint i;
- /* we should always have, at least, a pass-through program */
- assert(i915->current.program_len > 0);
- for (i = 0; i < i915->current.program_len; i++) {
- OUT_BATCH(i915->current.program[i]);
- }
- }
-
- /* drawing surface size */
- /* 6 dwords, 0 relocs */
- {
- uint w, h;
- boolean k = framebuffer_size(&i915->framebuffer, &w, &h);
- assert(k);
-
- OUT_BATCH(_3DSTATE_DRAW_RECT_CMD);
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(((w - 1) & 0xffff) | ((h - 1) << 16));
- OUT_BATCH(0);
- OUT_BATCH(0);
- }
-
-
- i915->hardware_dirty = 0;
-}
diff --git a/src/mesa/pipe/i915simple/i915_state_immediate.c b/src/mesa/pipe/i915simple/i915_state_immediate.c
deleted file mode 100644
index 07031fc6c5..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_immediate.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "i915_state_inlines.h"
-#include "i915_context.h"
-#include "i915_state.h"
-#include "i915_reg.h"
-#include "p_util.h"
-
-
-/* All state expressable with the LOAD_STATE_IMMEDIATE_1 packet.
- * Would like to opportunistically recombine all these fragments into
- * a single packet containing only what has changed, but for now emit
- * as multiple packets.
- */
-
-
-
-
-/***********************************************************************
- * S0,S1: Vertex buffer state.
- */
-static void upload_S0S1(struct i915_context *i915)
-{
- unsigned LIS0, LIS1;
-
- /* INTEL_NEW_VBO */
- /* TODO: re-use vertex buffers here? */
- LIS0 = 0;
-
- /* INTEL_NEW_VERTEX_SIZE -- do this where the vertex size is calculated!
- */
- {
- unsigned vertex_size = i915->current.vertex_info.size;
-
- LIS1 = ((vertex_size << 24) |
- (vertex_size << 16));
- }
-
- /* INTEL_NEW_VBO */
- /* TODO: use a vertex generation number to track vbo changes */
- if (1 ||
- i915->current.immediate[I915_IMMEDIATE_S0] != LIS0 ||
- i915->current.immediate[I915_IMMEDIATE_S1] != LIS1)
- {
- i915->current.immediate[I915_IMMEDIATE_S0] = LIS0;
- i915->current.immediate[I915_IMMEDIATE_S1] = LIS1;
- i915->hardware_dirty |= I915_HW_IMMEDIATE;
- }
-}
-
-const struct i915_tracked_state i915_upload_S0S1 = {
- I915_NEW_VBO | I915_NEW_VERTEX_FORMAT,
- upload_S0S1
-};
-
-
-
-
-/***********************************************************************
- * S4: Vertex format, rasterization state
- */
-static void upload_S2S4(struct i915_context *i915)
-{
- unsigned LIS2, LIS4;
-
- /* I915_NEW_VERTEX_FORMAT */
- {
- LIS2 = i915->current.vertex_info.hwfmt[1];
- LIS4 = i915->current.vertex_info.hwfmt[0];
- /*
- debug_printf("LIS2: 0x%x LIS4: 0x%x\n", LIS2, LIS4);
- */
- assert(LIS4); /* should never be zero? */
- }
-
- LIS4 |= i915->rasterizer->LIS4;
-
- if (LIS2 != i915->current.immediate[I915_IMMEDIATE_S2] ||
- LIS4 != i915->current.immediate[I915_IMMEDIATE_S4]) {
-
- i915->current.immediate[I915_IMMEDIATE_S2] = LIS2;
- i915->current.immediate[I915_IMMEDIATE_S4] = LIS4;
- i915->hardware_dirty |= I915_HW_IMMEDIATE;
- }
-}
-
-
-const struct i915_tracked_state i915_upload_S2S4 = {
- I915_NEW_RASTERIZER | I915_NEW_VERTEX_FORMAT,
- upload_S2S4
-};
-
-
-
-/***********************************************************************
- *
- */
-static void upload_S5( struct i915_context *i915 )
-{
- unsigned LIS5 = 0;
-
- LIS5 |= i915->depth_stencil->stencil_LIS5;
-
- LIS5 |= i915->blend->LIS5;
-
-#if 0
- /* I915_NEW_RASTERIZER */
- if (i915->state.Polygon->OffsetFill) {
- LIS5 |= S5_GLOBAL_DEPTH_OFFSET_ENABLE;
- }
-#endif
-
-
- if (LIS5 != i915->current.immediate[I915_IMMEDIATE_S5]) {
- i915->current.immediate[I915_IMMEDIATE_S5] = LIS5;
- i915->hardware_dirty |= I915_HW_IMMEDIATE;
- }
-}
-
-const struct i915_tracked_state i915_upload_S5 = {
- (I915_NEW_DEPTH_STENCIL | I915_NEW_BLEND | I915_NEW_RASTERIZER),
- upload_S5
-};
-
-
-/***********************************************************************
- */
-static void upload_S6( struct i915_context *i915 )
-{
- unsigned LIS6 = (S6_COLOR_WRITE_ENABLE |
- (2 << S6_TRISTRIP_PV_SHIFT));
-
- /* I915_NEW_BLEND
- */
- LIS6 |= i915->blend->LIS6;
-
- /* I915_NEW_DEPTH
- */
- LIS6 |= i915->depth_stencil->depth_LIS6;
-
- if (LIS6 != i915->current.immediate[I915_IMMEDIATE_S6]) {
- i915->current.immediate[I915_IMMEDIATE_S6] = LIS6;
- i915->hardware_dirty |= I915_HW_IMMEDIATE;
- }
-}
-
-const struct i915_tracked_state i915_upload_S6 = {
- I915_NEW_BLEND | I915_NEW_DEPTH_STENCIL,
- upload_S6
-};
-
-
-/***********************************************************************
- */
-static void upload_S7( struct i915_context *i915 )
-{
- unsigned LIS7;
-
- /* I915_NEW_RASTERIZER
- */
- LIS7 = i915->rasterizer->LIS7;
-
- if (LIS7 != i915->current.immediate[I915_IMMEDIATE_S7]) {
- i915->current.immediate[I915_IMMEDIATE_S7] = LIS7;
- i915->hardware_dirty |= I915_HW_IMMEDIATE;
- }
-}
-
-const struct i915_tracked_state i915_upload_S7 = {
- I915_NEW_RASTERIZER,
- upload_S7
-};
-
-
-static const struct i915_tracked_state *atoms[] = {
- &i915_upload_S0S1,
- &i915_upload_S2S4,
- &i915_upload_S5,
- &i915_upload_S6,
- &i915_upload_S7
-};
-
-/*
- */
-void i915_update_immediate( struct i915_context *i915 )
-{
- int i;
-
- for (i = 0; i < Elements(atoms); i++)
- if (i915->dirty & atoms[i]->dirty)
- atoms[i]->update( i915 );
-}
diff --git a/src/mesa/pipe/i915simple/i915_state_inlines.h b/src/mesa/pipe/i915simple/i915_state_inlines.h
deleted file mode 100644
index 0934ac79a4..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_inlines.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef I915_STATE_INLINES_H
-#define I915_STATE_INLINES_H
-
-#include "p_compiler.h"
-#include "p_defines.h"
-#include "i915_reg.h"
-
-
-static INLINE unsigned
-i915_translate_compare_func(unsigned func)
-{
- switch (func) {
- case PIPE_FUNC_NEVER:
- return COMPAREFUNC_NEVER;
- case PIPE_FUNC_LESS:
- return COMPAREFUNC_LESS;
- case PIPE_FUNC_LEQUAL:
- return COMPAREFUNC_LEQUAL;
- case PIPE_FUNC_GREATER:
- return COMPAREFUNC_GREATER;
- case PIPE_FUNC_GEQUAL:
- return COMPAREFUNC_GEQUAL;
- case PIPE_FUNC_NOTEQUAL:
- return COMPAREFUNC_NOTEQUAL;
- case PIPE_FUNC_EQUAL:
- return COMPAREFUNC_EQUAL;
- case PIPE_FUNC_ALWAYS:
- return COMPAREFUNC_ALWAYS;
- default:
- return COMPAREFUNC_ALWAYS;
- }
-}
-
-static INLINE unsigned
-i915_translate_stencil_op(unsigned op)
-{
- switch (op) {
- case PIPE_STENCIL_OP_KEEP:
- return STENCILOP_KEEP;
- case PIPE_STENCIL_OP_ZERO:
- return STENCILOP_ZERO;
- case PIPE_STENCIL_OP_REPLACE:
- return STENCILOP_REPLACE;
- case PIPE_STENCIL_OP_INCR:
- return STENCILOP_INCRSAT;
- case PIPE_STENCIL_OP_DECR:
- return STENCILOP_DECRSAT;
- case PIPE_STENCIL_OP_INCR_WRAP:
- return STENCILOP_INCR;
- case PIPE_STENCIL_OP_DECR_WRAP:
- return STENCILOP_DECR;
- case PIPE_STENCIL_OP_INVERT:
- return STENCILOP_INVERT;
- default:
- return STENCILOP_ZERO;
- }
-}
-
-static INLINE unsigned
-i915_translate_blend_factor(unsigned factor)
-{
- switch (factor) {
- case PIPE_BLENDFACTOR_ZERO:
- return BLENDFACT_ZERO;
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- return BLENDFACT_SRC_ALPHA;
- case PIPE_BLENDFACTOR_ONE:
- return BLENDFACT_ONE;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- return BLENDFACT_SRC_COLR;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- return BLENDFACT_INV_SRC_COLR;
- case PIPE_BLENDFACTOR_DST_COLOR:
- return BLENDFACT_DST_COLR;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- return BLENDFACT_INV_DST_COLR;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- return BLENDFACT_INV_SRC_ALPHA;
- case PIPE_BLENDFACTOR_DST_ALPHA:
- return BLENDFACT_DST_ALPHA;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- return BLENDFACT_INV_DST_ALPHA;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- return BLENDFACT_SRC_ALPHA_SATURATE;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- return BLENDFACT_CONST_COLOR;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- return BLENDFACT_INV_CONST_COLOR;
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- return BLENDFACT_CONST_ALPHA;
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- return BLENDFACT_INV_CONST_ALPHA;
- default:
- return BLENDFACT_ZERO;
- }
-}
-
-static INLINE unsigned
-i915_translate_blend_func(unsigned mode)
-{
- switch (mode) {
- case PIPE_BLEND_ADD:
- return BLENDFUNC_ADD;
- case PIPE_BLEND_MIN:
- return BLENDFUNC_MIN;
- case PIPE_BLEND_MAX:
- return BLENDFUNC_MAX;
- case PIPE_BLEND_SUBTRACT:
- return BLENDFUNC_SUBTRACT;
- case PIPE_BLEND_REVERSE_SUBTRACT:
- return BLENDFUNC_REVERSE_SUBTRACT;
- default:
- return 0;
- }
-}
-
-
-static INLINE unsigned
-i915_translate_logic_op(unsigned opcode)
-{
- switch (opcode) {
- case PIPE_LOGICOP_CLEAR:
- return LOGICOP_CLEAR;
- case PIPE_LOGICOP_AND:
- return LOGICOP_AND;
- case PIPE_LOGICOP_AND_REVERSE:
- return LOGICOP_AND_RVRSE;
- case PIPE_LOGICOP_COPY:
- return LOGICOP_COPY;
- case PIPE_LOGICOP_COPY_INVERTED:
- return LOGICOP_COPY_INV;
- case PIPE_LOGICOP_AND_INVERTED:
- return LOGICOP_AND_INV;
- case PIPE_LOGICOP_NOOP:
- return LOGICOP_NOOP;
- case PIPE_LOGICOP_XOR:
- return LOGICOP_XOR;
- case PIPE_LOGICOP_OR:
- return LOGICOP_OR;
- case PIPE_LOGICOP_OR_INVERTED:
- return LOGICOP_OR_INV;
- case PIPE_LOGICOP_NOR:
- return LOGICOP_NOR;
- case PIPE_LOGICOP_EQUIV:
- return LOGICOP_EQUIV;
- case PIPE_LOGICOP_INVERT:
- return LOGICOP_INV;
- case PIPE_LOGICOP_OR_REVERSE:
- return LOGICOP_OR_RVRSE;
- case PIPE_LOGICOP_NAND:
- return LOGICOP_NAND;
- case PIPE_LOGICOP_SET:
- return LOGICOP_SET;
- default:
- return LOGICOP_SET;
- }
-}
-
-
-
-static INLINE boolean i915_validate_vertices( unsigned hw_prim, unsigned nr )
-{
- boolean ok;
-
- switch (hw_prim) {
- case PRIM3D_POINTLIST:
- ok = (nr >= 1);
- assert(ok);
- break;
- case PRIM3D_LINELIST:
- ok = (nr >= 2) && (nr % 2) == 0;
- assert(ok);
- break;
- case PRIM3D_LINESTRIP:
- ok = (nr >= 2);
- assert(ok);
- break;
- case PRIM3D_TRILIST:
- ok = (nr >= 3) && (nr % 3) == 0;
- assert(ok);
- break;
- case PRIM3D_TRISTRIP:
- ok = (nr >= 3);
- assert(ok);
- break;
- case PRIM3D_TRIFAN:
- ok = (nr >= 3);
- assert(ok);
- break;
- case PRIM3D_POLY:
- ok = (nr >= 3);
- assert(ok);
- break;
- default:
- assert(0);
- ok = 0;
- break;
- }
-
- return ok;
-}
-
-#endif
diff --git a/src/mesa/pipe/i915simple/i915_state_sampler.c b/src/mesa/pipe/i915simple/i915_state_sampler.c
deleted file mode 100644
index 9c1a5bbbd6..0000000000
--- a/src/mesa/pipe/i915simple/i915_state_sampler.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "pipe/p_util.h"
-
-#include "i915_state_inlines.h"
-#include "i915_context.h"
-#include "i915_reg.h"
-#include "i915_state.h"
-
-
-/**
- * Compute i915 texture sampling state.
- *
- * Recalculate all state from scratch. Perhaps not the most
- * efficient, but this has gotten complex enough that we need
- * something which is understandable and reliable.
- * \param state returns the 3 words of compute state
- */
-static void update_sampler(struct i915_context *i915,
- uint unit,
- const struct i915_sampler_state *sampler,
- const struct i915_texture *tex,
- unsigned state[3] )
-{
- const struct pipe_texture *pt = &tex->base;
-
- /* Need to do this after updating the maps, which call the
- * intel_finalize_mipmap_tree and hence can update firstLevel:
- */
- state[0] = sampler->state[0];
- state[1] = sampler->state[1];
- state[2] = sampler->state[2];
-
- if (pt->format == PIPE_FORMAT_YCBCR ||
- pt->format == PIPE_FORMAT_YCBCR_REV)
- state[0] |= SS2_COLORSPACE_CONVERSION;
-
- /* 3D textures don't seem to respect the border color.
- * Fallback if there's ever a danger that they might refer to
- * it.
- *
- * Effectively this means fallback on 3D clamp or
- * clamp_to_border.
- *
- * XXX: Check if this is true on i945.
- * XXX: Check if this bug got fixed in release silicon.
- */
-#if 0
- {
- const unsigned ws = sampler->templ->wrap_s;
- const unsigned wt = sampler->templ->wrap_t;
- const unsigned wr = sampler->templ->wrap_r;
- if (pt->target == PIPE_TEXTURE_3D &&
- (sampler->templ->min_img_filter != PIPE_TEX_FILTER_NEAREST ||
- sampler->templ->mag_img_filter != PIPE_TEX_FILTER_NEAREST) &&
- (ws == PIPE_TEX_WRAP_CLAMP ||
- wt == PIPE_TEX_WRAP_CLAMP ||
- wr == PIPE_TEX_WRAP_CLAMP ||
- ws == PIPE_TEX_WRAP_CLAMP_TO_BORDER ||
- wt == PIPE_TEX_WRAP_CLAMP_TO_BORDER ||
- wr == PIPE_TEX_WRAP_CLAMP_TO_BORDER)) {
- if (i915->strict_conformance) {
- assert(0);
- /* sampler->fallback = true; */
- /* TODO */
- }
- }
- }
-#endif
-
- state[1] |= (unit << SS3_TEXTUREMAP_INDEX_SHIFT);
-}
-
-
-void i915_update_samplers( struct i915_context *i915 )
-{
- uint unit;
-
- i915->current.sampler_enable_nr = 0;
- i915->current.sampler_enable_flags = 0x0;
-
- for (unit = 0; unit < I915_TEX_UNITS; unit++) {
- /* determine unit enable/disable by looking for a bound texture */
- /* could also examine the fragment program? */
- if (i915->texture[unit]) {
- update_sampler( i915,
- unit,
- i915->sampler[unit], /* sampler state */
- i915->texture[unit], /* texture */
- i915->current.sampler[unit] /* the result */
- );
-
- i915->current.sampler_enable_nr++;
- i915->current.sampler_enable_flags |= (1 << unit);
- }
- }
-
- i915->hardware_dirty |= I915_HW_SAMPLER;
-}
-
-
-static uint
-translate_texture_format(enum pipe_format pipeFormat)
-{
- switch (pipeFormat) {
- case PIPE_FORMAT_U_L8:
- return MAPSURF_8BIT | MT_8BIT_L8;
- case PIPE_FORMAT_U_I8:
- return MAPSURF_8BIT | MT_8BIT_I8;
- case PIPE_FORMAT_U_A8:
- return MAPSURF_8BIT | MT_8BIT_A8;
- case PIPE_FORMAT_U_A8_L8:
- return MAPSURF_16BIT | MT_16BIT_AY88;
- case PIPE_FORMAT_R5G6B5_UNORM:
- return MAPSURF_16BIT | MT_16BIT_RGB565;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- return MAPSURF_16BIT | MT_16BIT_ARGB1555;
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- return MAPSURF_16BIT | MT_16BIT_ARGB4444;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- return MAPSURF_32BIT | MT_32BIT_ARGB8888;
- case PIPE_FORMAT_YCBCR_REV:
- return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
- case PIPE_FORMAT_YCBCR:
- return (MAPSURF_422 | MT_422_YCRCB_SWAPY);
-#if 0
- case PIPE_FORMAT_RGB_FXT1:
- case PIPE_FORMAT_RGBA_FXT1:
- return (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
-#endif
- case PIPE_FORMAT_Z16_UNORM:
- return (MAPSURF_16BIT | MT_16BIT_L16);
-#if 0
- case PIPE_FORMAT_RGBA_DXT1:
- case PIPE_FORMAT_RGB_DXT1:
- return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
- case PIPE_FORMAT_RGBA_DXT3:
- return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
- case PIPE_FORMAT_RGBA_DXT5:
- return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
-#endif
- case PIPE_FORMAT_S8Z24_UNORM:
- return (MAPSURF_32BIT | MT_32BIT_xL824);
- default:
- debug_printf("i915: translate_texture_format() bad image format %x\n",
- pipeFormat);
- assert(0);
- return 0;
- }
-}
-
-
-static void
-i915_update_texture(struct i915_context *i915, uint unit,
- uint state[6])
-{
- const struct i915_texture *tex = i915->texture[unit];
- const struct pipe_texture *pt = &tex->base;
- uint format, pitch;
- const uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
- const uint num_levels = pt->last_level;
-
- assert(tex);
- assert(width);
- assert(height);
- assert(depth);
-
- format = translate_texture_format(pt->format);
- pitch = tex->pitch * pt->cpp;
-
- assert(format);
- assert(pitch);
-
- /* MS3 state */
- state[0] =
- (((height - 1) << MS3_HEIGHT_SHIFT)
- | ((width - 1) << MS3_WIDTH_SHIFT)
- | format
- | MS3_USE_FENCE_REGS);
-
- /* MS4 state */
- state[1] =
- ((((pitch / 4) - 1) << MS4_PITCH_SHIFT)
- | MS4_CUBE_FACE_ENA_MASK
- | ((num_levels * 4) << MS4_MAX_LOD_SHIFT)
- | ((depth - 1) << MS4_VOLUME_DEPTH_SHIFT));
-}
-
-
-void
-i915_update_textures(struct i915_context *i915)
-{
- uint unit;
-
- for (unit = 0; unit < I915_TEX_UNITS; unit++) {
- /* determine unit enable/disable by looking for a bound texture */
- /* could also examine the fragment program? */
- if (i915->texture[unit]) {
- i915_update_texture(i915, unit, i915->current.texbuffer[unit]);
- }
- }
-
- i915->hardware_dirty |= I915_HW_MAP;
-}
diff --git a/src/mesa/pipe/i915simple/i915_strings.c b/src/mesa/pipe/i915simple/i915_strings.c
deleted file mode 100644
index c713bf7208..0000000000
--- a/src/mesa/pipe/i915simple/i915_strings.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "i915_context.h"
-#include "i915_reg.h"
-
-
-static const char *i915_get_vendor( struct pipe_context *pipe )
-{
- return "Tungsten Graphics, Inc.";
-}
-
-
-static const char *i915_get_name( struct pipe_context *pipe )
-{
- static char buffer[128];
- const char *chipset;
-
- switch (i915_context(pipe)->pci_id) {
- case PCI_CHIP_I915_G:
- chipset = "915G";
- break;
- case PCI_CHIP_I915_GM:
- chipset = "915GM";
- break;
- case PCI_CHIP_I945_G:
- chipset = "945G";
- break;
- case PCI_CHIP_I945_GM:
- chipset = "945GM";
- break;
- case PCI_CHIP_I945_GME:
- chipset = "945GME";
- break;
- case PCI_CHIP_G33_G:
- chipset = "G33";
- break;
- case PCI_CHIP_Q35_G:
- chipset = "Q35";
- break;
- case PCI_CHIP_Q33_G:
- chipset = "Q33";
- break;
- default:
- chipset = "unknown";
- break;
- }
-
- sprintf(buffer, "pipe/i915 (chipset: %s)", chipset);
- return buffer;
-}
-
-
-void
-i915_init_string_functions(struct i915_context *i915)
-{
- i915->pipe.get_name = i915_get_name;
- i915->pipe.get_vendor = i915_get_vendor;
-}
diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c
deleted file mode 100644
index 6d4b8a0aa9..0000000000
--- a/src/mesa/pipe/i915simple/i915_surface.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "i915_context.h"
-#include "i915_blit.h"
-#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 "pipe/util/p_tile.h"
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static struct pipe_surface *
-i915_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
-{
- struct i915_texture *tex = (struct i915_texture *)pt;
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
-
- offset = tex->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset += tex->image_offset[level][face] * pt->cpp;
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset += tex->image_offset[level][zslice] * pt->cpp;
- }
- else {
- assert(face == 0);
- assert(zslice == 0);
- }
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->refcount);
- assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = tex->pitch;
- ps->offset = offset;
- }
- return ps;
-}
-
-
-
-/* Assumes all values are within bounds -- no checking at this level -
- * do it higher up if required.
- */
-static void
-i915_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy, unsigned width, unsigned height)
-{
- assert( dst != src );
- assert( dst->cpp == src->cpp );
-
- if (0) {
- pipe_copy_rect(pipe_surface_map(dst),
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- do_flip ? -src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
-
- pipe_surface_unmap(src);
- pipe_surface_unmap(dst);
- }
- else {
- i915_copy_blit( i915_context(pipe),
- do_flip,
- dst->cpp,
- (short) src->pitch, src->buffer, src->offset,
- (short) dst->pitch, dst->buffer, dst->offset,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
- }
-}
-
-/* Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map + (y * dst->pitch + x) * dst->cpp;
-}
-
-
-static void
-i915_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- if (0) {
- unsigned i, j;
- void *dst_map = pipe_surface_map(dst);
-
- switch (dst->cpp) {
- case 1: {
- ubyte *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
- case 2: {
- ushort *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
- case 4: {
- unsigned *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe_surface_unmap( dst );
- }
- else {
- i915_fill_blit( i915_context(pipe),
- dst->cpp,
- (short) dst->pitch,
- dst->buffer, dst->offset,
- (short) dstx, (short) dsty,
- (short) width, (short) height,
- value );
- }
-}
-
-
-void
-i915_init_surface_functions(struct i915_context *i915)
-{
- i915->pipe.get_tex_surface = i915_get_tex_surface;
-
- i915->pipe.surface_copy = i915_surface_copy;
- i915->pipe.surface_fill = i915_surface_fill;
-}
diff --git a/src/mesa/pipe/i915simple/i915_texture.c b/src/mesa/pipe/i915simple/i915_texture.c
deleted file mode 100644
index 6d37ae3d74..0000000000
--- a/src/mesa/pipe/i915simple/i915_texture.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Michel Dänzer <michel@tungstengraphics.com>
- */
-
-#include "pipe/p_state.h"
-#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 "i915_context.h"
-#include "i915_texture.h"
-#include "i915_debug.h"
-
-
-static unsigned minify( unsigned d )
-{
- return MAX2(1, d>>1);
-}
-
-
-
-static void
-i915_miptree_set_level_info(struct i915_texture *tex,
- unsigned level,
- unsigned nr_images,
- unsigned x, unsigned y, unsigned w, unsigned h, unsigned d)
-{
- struct pipe_texture *pt = &tex->base;
-
- assert(level < PIPE_MAX_TEXTURE_LEVELS);
-
- pt->width[level] = w;
- pt->height[level] = h;
- pt->depth[level] = d;
-
- tex->level_offset[level] = (x + y * tex->pitch) * pt->cpp;
- tex->nr_images[level] = nr_images;
-
- /*
- DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
- level, w, h, d, x, y, tex->level_offset[level]);
- */
-
- /* Not sure when this would happen, but anyway:
- */
- if (tex->image_offset[level]) {
- FREE(tex->image_offset[level]);
- tex->image_offset[level] = NULL;
- }
-
- assert(nr_images);
- assert(!tex->image_offset[level]);
-
- tex->image_offset[level] = (unsigned *) MALLOC(nr_images * sizeof(unsigned));
- tex->image_offset[level][0] = 0;
-}
-
-
-static void
-i915_miptree_set_image_offset(struct i915_texture *tex,
- unsigned level, unsigned img, unsigned x, unsigned y)
-{
- if (img == 0 && level == 0)
- assert(x == 0 && y == 0);
-
- assert(img < tex->nr_images[level]);
-
- tex->image_offset[level][img] = (x + y * tex->pitch);
-
- /*
- DBG("%s level %d img %d pos %d,%d image_offset %x\n",
- __FUNCTION__, level, img, x, y, tex->image_offset[level][img]);
- */
-}
-
-
-static void
-i945_miptree_layout_2d( struct i915_texture *tex )
-{
- struct pipe_texture *pt = &tex->base;
- int align_h = 2, align_w = 4;
- unsigned level;
- unsigned x = 0;
- unsigned y = 0;
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
-
- tex->pitch = pt->width[0];
-
- /* May need to adjust pitch to accomodate the placement of
- * the 2nd mipmap level. This occurs when the alignment
- * constraints of mipmap placement push the right edge of the
- * 2nd mipmap level out past the width of its parent.
- */
- if (pt->last_level > 0) {
- unsigned mip1_width = align_int(minify(pt->width[0]), align_w)
- + minify(minify(pt->width[0]));
-
- if (mip1_width > pt->width[0])
- tex->pitch = mip1_width;
- }
-
- /* Pitch must be a whole number of dwords, even though we
- * express it in texels.
- */
- tex->pitch = align_int(tex->pitch * pt->cpp, 4) / pt->cpp;
- tex->total_height = 0;
-
- for (level = 0; level <= pt->last_level; level++) {
- unsigned img_height;
-
- i915_miptree_set_level_info(tex, level, 1, x, y, width, height, 1);
-
- if (pt->compressed)
- img_height = MAX2(1, height/4);
- else
- img_height = align_int(height, align_h);
-
-
- /* Because the images are packed better, the final offset
- * might not be the maximal one:
- */
- tex->total_height = MAX2(tex->total_height, y + img_height);
-
- /* Layout_below: step right after second mipmap level.
- */
- if (level == 1) {
- x += align_int(width, align_w);
- }
- else {
- y += img_height;
- }
-
- width = minify(width);
- height = minify(height);
- }
-}
-
-
-static const int initial_offsets[6][2] = {
- {0, 0},
- {0, 2},
- {1, 0},
- {1, 2},
- {1, 1},
- {1, 3}
-};
-
-static const int step_offsets[6][2] = {
- {0, 2},
- {0, 2},
- {-1, 2},
- {-1, 2},
- {-1, 1},
- {-1, 1}
-};
-
-
-static boolean
-i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
-{
- struct pipe_texture *pt = &tex->base;
- unsigned level;
-
- switch (pt->target) {
- case PIPE_TEXTURE_CUBE: {
- const unsigned dim = pt->width[0];
- unsigned face;
- unsigned lvlWidth = pt->width[0], lvlHeight = pt->height[0];
-
- assert(lvlWidth == lvlHeight); /* cubemap images are square */
-
- /* double pitch for cube layouts */
- tex->pitch = ((dim * pt->cpp * 2 + 3) & ~3) / pt->cpp;
- tex->total_height = dim * 4;
-
- for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 6,
- 0, 0,
- /*OLD: tex->pitch, tex->total_height,*/
- lvlWidth, lvlHeight,
- 1);
- lvlWidth /= 2;
- lvlHeight /= 2;
- }
-
- for (face = 0; face < 6; face++) {
- unsigned x = initial_offsets[face][0] * dim;
- unsigned y = initial_offsets[face][1] * dim;
- unsigned d = dim;
-
- for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_image_offset(tex, level, face, x, y);
- d >>= 1;
- x += step_offsets[face][0] * d;
- y += step_offsets[face][1] * d;
- }
- }
- break;
- }
- case PIPE_TEXTURE_3D:{
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned depth = pt->depth[0];
- unsigned stack_height = 0;
-
- /* Calculate the size of a single slice.
- */
- tex->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp;
-
- /* XXX: hardware expects/requires 9 levels at minimum.
- */
- for (level = 0; level <= MAX2(8, pt->last_level);
- level++) {
- i915_miptree_set_level_info(tex, level, depth, 0, tex->total_height,
- width, height, depth);
-
-
- stack_height += MAX2(2, height);
-
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
- }
-
- /* Fixup depth image_offsets:
- */
- depth = pt->depth[0];
- for (level = 0; level <= pt->last_level; level++) {
- unsigned i;
- for (i = 0; i < depth; i++)
- i915_miptree_set_image_offset(tex, level, i,
- 0, i * stack_height);
-
- depth = minify(depth);
- }
-
-
- /* Multiply slice size by texture depth for total size. It's
- * remarkable how wasteful of memory the i915 texture layouts
- * are. They are largely fixed in the i945.
- */
- tex->total_height = stack_height * pt->depth[0];
- break;
- }
-
- default:{
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned img_height;
-
- tex->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp;
- tex->total_height = 0;
-
- for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 1,
- 0, tex->total_height,
- width, height, 1);
-
- if (pt->compressed)
- img_height = MAX2(1, height / 4);
- else
- img_height = (MAX2(2, height) + 1) & ~1;
-
- tex->total_height += img_height;
-
- width = minify(width);
- height = minify(height);
- }
- break;
- }
- }
- /*
- DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
- tex->pitch,
- tex->total_height, pt->cpp, tex->pitch * tex->total_height * pt->cpp);
- */
-
- return TRUE;
-}
-
-
-static boolean
-i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
-{
- struct pipe_texture *pt = &tex->base;
- unsigned level;
-
- switch (pt->target) {
- case PIPE_TEXTURE_CUBE:{
- const unsigned dim = pt->width[0];
- unsigned face;
- unsigned lvlWidth = pt->width[0], lvlHeight = pt->height[0];
-
- assert(lvlWidth == lvlHeight); /* cubemap images are square */
-
- /* Depending on the size of the largest images, pitch can be
- * determined either by the old-style packing of cubemap faces,
- * or the final row of 4x4, 2x2 and 1x1 faces below this.
- */
- if (dim > 32)
- tex->pitch = ((dim * pt->cpp * 2 + 3) & ~3) / pt->cpp;
- else
- tex->pitch = 14 * 8;
-
- tex->total_height = dim * 4 + 4;
-
- /* Set all the levels to effectively occupy the whole rectangular region.
- */
- for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 6,
- 0, 0,
- lvlWidth, lvlHeight, 1);
- lvlWidth /= 2;
- lvlHeight /= 2;
- }
-
-
- for (face = 0; face < 6; face++) {
- unsigned x = initial_offsets[face][0] * dim;
- unsigned y = initial_offsets[face][1] * dim;
- unsigned d = dim;
-
- if (dim == 4 && face >= 4) {
- y = tex->total_height - 4;
- x = (face - 4) * 8;
- }
- else if (dim < 4 && (face > 0)) {
- y = tex->total_height - 4;
- x = face * 8;
- }
-
- for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_image_offset(tex, level, face, x, y);
-
- d >>= 1;
-
- switch (d) {
- case 4:
- switch (face) {
- case PIPE_TEX_FACE_POS_X:
- case PIPE_TEX_FACE_NEG_X:
- x += step_offsets[face][0] * d;
- y += step_offsets[face][1] * d;
- break;
- case PIPE_TEX_FACE_POS_Y:
- case PIPE_TEX_FACE_NEG_Y:
- y += 12;
- x -= 8;
- break;
- case PIPE_TEX_FACE_POS_Z:
- case PIPE_TEX_FACE_NEG_Z:
- y = tex->total_height - 4;
- x = (face - 4) * 8;
- break;
- }
-
- case 2:
- y = tex->total_height - 4;
- x = 16 + face * 8;
- break;
-
- case 1:
- x += 48;
- break;
-
- default:
- x += step_offsets[face][0] * d;
- y += step_offsets[face][1] * d;
- break;
- }
- }
- }
- break;
- }
- case PIPE_TEXTURE_3D:{
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned depth = pt->depth[0];
- unsigned pack_x_pitch, pack_x_nr;
- unsigned pack_y_pitch;
- unsigned level;
-
- tex->pitch = ((pt->width[0] * pt->cpp + 3) & ~3) / pt->cpp;
- tex->total_height = 0;
-
- pack_y_pitch = MAX2(pt->height[0], 2);
- pack_x_pitch = tex->pitch;
- pack_x_nr = 1;
-
- for (level = 0; level <= pt->last_level; level++) {
- unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
- int x = 0;
- int y = 0;
- unsigned q, j;
-
- i915_miptree_set_level_info(tex, level, nr_images,
- 0, tex->total_height,
- width, height, depth);
-
- for (q = 0; q < nr_images;) {
- for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) {
- i915_miptree_set_image_offset(tex, level, q, x, y);
- x += pack_x_pitch;
- }
-
- x = 0;
- y += pack_y_pitch;
- }
-
-
- tex->total_height += y;
-
- if (pack_x_pitch > 4) {
- pack_x_pitch >>= 1;
- pack_x_nr <<= 1;
- assert(pack_x_pitch * pack_x_nr <= tex->pitch);
- }
-
- if (pack_y_pitch > 2) {
- pack_y_pitch >>= 1;
- }
-
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
- }
- break;
- }
-
- case PIPE_TEXTURE_1D:
- case PIPE_TEXTURE_2D:
-// case PIPE_TEXTURE_RECTANGLE:
- i945_miptree_layout_2d(tex);
- break;
- default:
- assert(0);
- return FALSE;
- }
-
- /*
- DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
- tex->pitch,
- tex->total_height, pt->cpp, tex->pitch * tex->total_height * pt->cpp);
- */
-
- return TRUE;
-}
-
-
-struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
-{
- struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
-
- if (tex) {
- struct i915_context *i915 = i915_context(pipe);
-
- tex->base = *templat;
-
- if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
- i915_miptree_layout(pipe, tex))
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
- PIPE_BUFFER_USAGE_PIXEL,
- tex->pitch * tex->base.cpp *
- tex->total_height);
-
- if (!tex->buffer) {
- FREE(tex);
- return NULL;
- }
- }
-
- return &tex->base;
-}
-
-
-void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
-{
- if (!*pt)
- return;
-
- /*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
- */
- if (--(*pt)->refcount <= 0) {
- struct i915_texture *tex = (struct i915_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
-
- pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
-
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- FREE(tex->image_offset[i]);
-
- FREE(tex);
- }
- *pt = NULL;
-}
diff --git a/src/mesa/pipe/i915simple/i915_texture.h b/src/mesa/pipe/i915simple/i915_texture.h
deleted file mode 100644
index 330d111dc7..0000000000
--- a/src/mesa/pipe/i915simple/i915_texture.h
+++ /dev/null
@@ -1,17 +0,0 @@
-
-#ifndef I915_TEXTURE_H
-#define I915_TEXTURE_H
-
-struct pipe_context;
-struct pipe_texture;
-
-
-struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
-extern void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-
-#endif /* I915_TEXTURE_H */
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
deleted file mode 100644
index fe49710852..0000000000
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * This is the interface that i915simple requires any window system
- * hosting it to implement. This is the only include file in i915simple
- * which is public.
- *
- */
-
-#ifndef I915_WINSYS_H
-#define I915_WINSYS_H
-
-
-#include "pipe/p_defines.h"
-
-
-/* Pipe drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-
-struct pipe_buffer;
-struct pipe_winsys;
-
-
-/**
- * Additional winsys interface for i915simple.
- *
- * It is an over-simple batchbuffer mechanism. Will want to improve the
- * performance of this, perhaps based on the cmdstream stuff. It
- * would be pretty impossible to implement swz on top of this
- * interface.
- *
- * Will also need additions/changes to implement static/dynamic
- * indirect state.
- */
-struct i915_winsys {
-
- /**
- * Reserve space on batch buffer.
- *
- * Returns a null pointer if there is insufficient space in the batch buffer
- * to hold the requested number of dwords and relocations.
- *
- * The number of dwords should also include the number of relocations.
- */
- unsigned *(*batch_start)( struct i915_winsys *sws,
- unsigned dwords,
- unsigned relocs );
-
- void (*batch_dword)( struct i915_winsys *sws,
- unsigned dword );
-
- /**
- * Emit a relocation to a buffer.
- *
- * Used not only when the buffer addresses are not pinned, but also to
- * ensure refered buffers will not be destroyed until the current batch
- * buffer execution is finished.
- *
- * The access flags is a combination of I915_BUFFER_ACCESS_WRITE and
- * I915_BUFFER_ACCESS_READ macros.
- */
- void (*batch_reloc)( struct i915_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta );
-
- void (*batch_flush)( struct i915_winsys *sws );
- void (*batch_finish)( struct i915_winsys *sws );
-};
-
-#define I915_BUFFER_ACCESS_WRITE 0x1
-#define I915_BUFFER_ACCESS_READ 0x2
-
-#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-
-
-struct pipe_context *i915_create( struct pipe_winsys *,
- struct i915_winsys *,
- unsigned pci_id );
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/Makefile b/src/mesa/pipe/i965simple/Makefile
deleted file mode 100644
index 48c00ab50b..0000000000
--- a/src/mesa/pipe/i965simple/Makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i965simple
-
-DRIVER_SOURCES = \
- brw_blit.c \
- brw_flush.c \
- brw_strings.c \
- brw_surface.c \
- brw_cc.c \
- brw_clip.c \
- brw_clip_line.c \
- brw_clip_point.c \
- brw_clip_state.c \
- brw_clip_tri.c \
- brw_clip_util.c \
- brw_context.c \
- brw_curbe.c \
- brw_draw.c \
- brw_draw_upload.c \
- brw_eu.c \
- brw_eu_debug.c \
- brw_eu_emit.c \
- brw_eu_util.c \
- brw_gs.c \
- brw_gs_emit.c \
- brw_gs_state.c \
- brw_misc_state.c \
- brw_sf.c \
- brw_sf_emit.c \
- brw_sf_state.c \
- brw_shader_info.c \
- brw_state.c \
- brw_state_batch.c \
- brw_state_cache.c \
- brw_state_pool.c \
- brw_state_upload.c \
- brw_tex_layout.c \
- brw_urb.c \
- brw_util.c \
- brw_vs.c \
- brw_vs_emit.c \
- brw_vs_state.c \
- brw_wm.c \
- brw_wm_iz.c \
- brw_wm_decl.c \
- brw_wm_glsl.c \
- brw_wm_sampler_state.c \
- brw_wm_state.c \
- brw_wm_surface_state.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(COMMON_BM_SOURCES) \
- $(MINIGLX_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I.
-
-include ../Makefile.template
-
-symlinks:
diff --git a/src/mesa/pipe/i965simple/SConscript b/src/mesa/pipe/i965simple/SConscript
deleted file mode 100644
index 74621de84c..0000000000
--- a/src/mesa/pipe/i965simple/SConscript
+++ /dev/null
@@ -1,55 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-i965simple = env.ConvenienceLibrary(
- target = 'i965simple',
- source = [
- 'brw_blit.c',
- 'brw_cc.c',
- 'brw_clip.c',
- 'brw_clip_line.c',
- 'brw_clip_point.c',
- 'brw_clip_state.c',
- 'brw_clip_tri.c',
- 'brw_clip_util.c',
- 'brw_context.c',
- 'brw_curbe.c',
- 'brw_draw.c',
- 'brw_draw_upload.c',
- 'brw_eu.c',
- 'brw_eu_debug.c',
- 'brw_eu_emit.c',
- 'brw_eu_util.c',
- 'brw_flush.c',
- 'brw_gs.c',
- 'brw_gs_emit.c',
- 'brw_gs_state.c',
- 'brw_misc_state.c',
- 'brw_sf.c',
- 'brw_sf_emit.c',
- 'brw_sf_state.c',
- 'brw_shader_info.c',
- 'brw_state.c',
- 'brw_state_batch.c',
- 'brw_state_cache.c',
- 'brw_state_pool.c',
- 'brw_state_upload.c',
- 'brw_strings.c',
- 'brw_surface.c',
- 'brw_tex_layout.c',
- 'brw_urb.c',
- 'brw_util.c',
- 'brw_vs.c',
- 'brw_vs_emit.c',
- 'brw_vs_state.c',
- 'brw_wm.c',
- 'brw_wm_decl.c',
- 'brw_wm_glsl.c',
- 'brw_wm_iz.c',
- 'brw_wm_sampler_state.c',
- 'brw_wm_state.c',
- 'brw_wm_surface_state.c',
- ])
-
-Export('i965simple')
diff --git a/src/mesa/pipe/i965simple/brw_batch.h b/src/mesa/pipe/i965simple/brw_batch.h
deleted file mode 100644
index 5f5932a488..0000000000
--- a/src/mesa/pipe/i965simple/brw_batch.h
+++ /dev/null
@@ -1,59 +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 BRW_BATCH_H
-#define BRW_BATCH_H
-
-#include "brw_winsys.h"
-
-#define BATCH_LOCALS
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS 0x2
-
-#define BEGIN_BATCH( dwords, relocs ) \
- brw->winsys->batch_start(brw->winsys, dwords, relocs)
-
-#define OUT_BATCH( dword ) \
- brw->winsys->batch_dword(brw->winsys, dword)
-
-#define OUT_RELOC( buf, flags, delta ) \
- brw->winsys->batch_reloc(brw->winsys, buf, flags, delta)
-
-#define ADVANCE_BATCH() \
- brw->winsys->batch_end( brw->winsys )
-
-/* XXX: this is bogus - need proper handling for out-of-memory in batchbuffer.
- */
-#define FLUSH_BATCH(fence) do { \
- brw->winsys->batch_flush(brw->winsys, fence); \
- brw->hardware_dirty = ~0; \
-} while (0)
-
-#define BRW_BATCH_STRUCT(brw, s) brw_batchbuffer_data( brw->winsys, (s), sizeof(*(s)))
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_blit.c b/src/mesa/pipe/i965simple/brw_blit.c
deleted file mode 100644
index 8494f70493..0000000000
--- a/src/mesa/pipe/i965simple/brw_blit.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdio.h>
-#include <errno.h>
-
-#include "brw_batch.h"
-#include "brw_blit.h"
-#include "brw_context.h"
-#include "brw_reg.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_winsys.h"
-
-#define FILE_DEBUG_FLAG DEBUG_BLIT
-
-void brw_fill_blit(struct brw_context *brw,
- unsigned cpp,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- boolean dst_tiled,
- short x, short y,
- short w, short h,
- unsigned color)
-{
- unsigned BR13, CMD;
- BATCH_LOCALS;
-
- dst_pitch *= cpp;
-
- switch(cpp) {
- case 1:
- case 2:
- case 3:
- BR13 = (0xF0 << 16) | (1<<24);
- CMD = XY_COLOR_BLT_CMD;
- break;
- case 4:
- BR13 = (0xF0 << 16) | (1<<24) | (1<<25);
- CMD = XY_COLOR_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
- break;
- default:
- return;
- }
-
- if (dst_tiled) {
- CMD |= XY_DST_TILED;
- dst_pitch /= 4;
- }
-
- BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH( CMD );
- OUT_BATCH( dst_pitch | BR13 );
- OUT_BATCH( (y << 16) | x );
- OUT_BATCH( ((y+h) << 16) | (x+w) );
- OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE, dst_offset );
- OUT_BATCH( color );
- ADVANCE_BATCH();
-}
-
-static unsigned translate_raster_op(unsigned logicop)
-{
- switch(logicop) {
- case PIPE_LOGICOP_CLEAR: return 0x00;
- case PIPE_LOGICOP_AND: return 0x88;
- case PIPE_LOGICOP_AND_REVERSE: return 0x44;
- case PIPE_LOGICOP_COPY: return 0xCC;
- case PIPE_LOGICOP_AND_INVERTED: return 0x22;
- case PIPE_LOGICOP_NOOP: return 0xAA;
- case PIPE_LOGICOP_XOR: return 0x66;
- case PIPE_LOGICOP_OR: return 0xEE;
- case PIPE_LOGICOP_NOR: return 0x11;
- case PIPE_LOGICOP_EQUIV: return 0x99;
- case PIPE_LOGICOP_INVERT: return 0x55;
- case PIPE_LOGICOP_OR_REVERSE: return 0xDD;
- case PIPE_LOGICOP_COPY_INVERTED: return 0x33;
- case PIPE_LOGICOP_OR_INVERTED: return 0xBB;
- case PIPE_LOGICOP_NAND: return 0x77;
- case PIPE_LOGICOP_SET: return 0xFF;
- default: return 0;
- }
-}
-
-
-/* Copy BitBlt
- */
-void brw_copy_blit(struct brw_context *brw,
- unsigned do_flip,
- unsigned cpp,
- short src_pitch,
- struct pipe_buffer *src_buffer,
- unsigned src_offset,
- boolean src_tiled,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- boolean dst_tiled,
- short src_x, short src_y,
- short dst_x, short dst_y,
- short w, short h,
- unsigned logic_op)
-{
- unsigned CMD, BR13;
- int dst_y2 = dst_y + h;
- int dst_x2 = dst_x + w;
- BATCH_LOCALS;
-
-
- DBG("%s src:buf(%d)/%d %d,%d dst:buf(%d)/%d %d,%d sz:%dx%d op:%d\n",
- __FUNCTION__,
- src_buffer, src_pitch, src_x, src_y,
- dst_buffer, dst_pitch, dst_x, dst_y,
- w,h,logic_op);
-
- assert( logic_op - PIPE_LOGICOP_CLEAR >= 0 );
- assert( logic_op - PIPE_LOGICOP_CLEAR < 0x10 );
-
- src_pitch *= cpp;
- dst_pitch *= cpp;
-
- switch(cpp) {
- case 1:
- case 2:
- case 3:
- BR13 = (translate_raster_op(logic_op) << 16) | (1<<24);
- CMD = XY_SRC_COPY_BLT_CMD;
- break;
- case 4:
- BR13 = (translate_raster_op(logic_op) << 16) | (1<<24) |
- (1<<25);
- CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
- break;
- default:
- return;
- }
-
- if (src_tiled) {
- CMD |= XY_SRC_TILED;
- src_pitch /= 4;
- }
-
- if (dst_tiled) {
- CMD |= XY_DST_TILED;
- dst_pitch /= 4;
- }
-
- if (dst_y2 < dst_y ||
- dst_x2 < dst_x) {
- return;
- }
-
- dst_pitch &= 0xffff;
- src_pitch &= 0xffff;
-
- /* Initial y values don't seem to work with negative pitches. If
- * we adjust the offsets manually (below), it seems to work fine.
- *
- * On the other hand, if we always adjust, the hardware doesn't
- * know which blit directions to use, so overlapping copypixels get
- * the wrong result.
- */
- if (dst_pitch > 0 && src_pitch > 0) {
- BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH( CMD );
- OUT_BATCH( dst_pitch | BR13 );
- OUT_BATCH( (dst_y << 16) | dst_x );
- OUT_BATCH( (dst_y2 << 16) | dst_x2 );
- OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE,
- dst_offset );
- OUT_BATCH( (src_y << 16) | src_x );
- OUT_BATCH( src_pitch );
- OUT_RELOC( src_buffer, BRW_BUFFER_ACCESS_READ,
- src_offset );
- ADVANCE_BATCH();
- }
- else {
- BEGIN_BATCH(8, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH( CMD );
- OUT_BATCH( (dst_pitch & 0xffff) | BR13 );
- OUT_BATCH( (0 << 16) | dst_x );
- OUT_BATCH( (h << 16) | dst_x2 );
- OUT_RELOC( dst_buffer, BRW_BUFFER_ACCESS_WRITE,
- dst_offset + dst_y * dst_pitch );
- OUT_BATCH( (src_pitch & 0xffff) );
- OUT_RELOC( src_buffer, BRW_BUFFER_ACCESS_READ,
- src_offset + src_y * src_pitch );
- ADVANCE_BATCH();
- }
-}
-
-
-
diff --git a/src/mesa/pipe/i965simple/brw_blit.h b/src/mesa/pipe/i965simple/brw_blit.h
deleted file mode 100644
index 111c5d91d3..0000000000
--- a/src/mesa/pipe/i965simple/brw_blit.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BRW_BLIT_H
-#define BRW_BLIT_H
-
-#include "pipe/p_compiler.h"
-
-struct pipe_buffer;
-struct brw_context;
-
-void brw_fill_blit(struct brw_context *intel,
- unsigned cpp,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- boolean dst_tiled,
- short x, short y,
- short w, short h,
- unsigned color);
-void brw_copy_blit(struct brw_context *intel,
- unsigned do_flip,
- unsigned cpp,
- short src_pitch,
- struct pipe_buffer *src_buffer,
- unsigned src_offset,
- boolean src_tiled,
- short dst_pitch,
- struct pipe_buffer *dst_buffer,
- unsigned dst_offset,
- boolean dst_tiled,
- short src_x, short src_y,
- short dst_x, short dst_y,
- short w, short h,
- unsigned logic_op);
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_cc.c b/src/mesa/pipe/i965simple/brw_cc.c
deleted file mode 100644
index 337e4f95f6..0000000000
--- a/src/mesa/pipe/i965simple/brw_cc.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "brw_util.h"
-
-
-static int brw_translate_compare_func(int func)
-{
- switch(func) {
- case PIPE_FUNC_NEVER:
- return BRW_COMPAREFUNCTION_NEVER;
- case PIPE_FUNC_LESS:
- return BRW_COMPAREFUNCTION_LESS;
- case PIPE_FUNC_LEQUAL:
- return BRW_COMPAREFUNCTION_LEQUAL;
- case PIPE_FUNC_GREATER:
- return BRW_COMPAREFUNCTION_GREATER;
- case PIPE_FUNC_GEQUAL:
- return BRW_COMPAREFUNCTION_GEQUAL;
- case PIPE_FUNC_NOTEQUAL:
- return BRW_COMPAREFUNCTION_NOTEQUAL;
- case PIPE_FUNC_EQUAL:
- return BRW_COMPAREFUNCTION_EQUAL;
- case PIPE_FUNC_ALWAYS:
- return BRW_COMPAREFUNCTION_ALWAYS;
- }
-
- debug_printf("Unknown value in %s: %x\n", __FUNCTION__, func);
- return BRW_COMPAREFUNCTION_ALWAYS;
-}
-
-static int brw_translate_stencil_op(int op)
-{
- switch(op) {
- case PIPE_STENCIL_OP_KEEP:
- return BRW_STENCILOP_KEEP;
- case PIPE_STENCIL_OP_ZERO:
- return BRW_STENCILOP_ZERO;
- case PIPE_STENCIL_OP_REPLACE:
- return BRW_STENCILOP_REPLACE;
- case PIPE_STENCIL_OP_INCR:
- return BRW_STENCILOP_INCRSAT;
- case PIPE_STENCIL_OP_DECR:
- return BRW_STENCILOP_DECRSAT;
- case PIPE_STENCIL_OP_INCR_WRAP:
- return BRW_STENCILOP_INCR;
- case PIPE_STENCIL_OP_DECR_WRAP:
- return BRW_STENCILOP_DECR;
- case PIPE_STENCIL_OP_INVERT:
- return BRW_STENCILOP_INVERT;
- default:
- return BRW_STENCILOP_ZERO;
- }
-}
-
-
-static int brw_translate_logic_op(int opcode)
-{
- switch(opcode) {
- case PIPE_LOGICOP_CLEAR:
- return BRW_LOGICOPFUNCTION_CLEAR;
- case PIPE_LOGICOP_AND:
- return BRW_LOGICOPFUNCTION_AND;
- case PIPE_LOGICOP_AND_REVERSE:
- return BRW_LOGICOPFUNCTION_AND_REVERSE;
- case PIPE_LOGICOP_COPY:
- return BRW_LOGICOPFUNCTION_COPY;
- case PIPE_LOGICOP_COPY_INVERTED:
- return BRW_LOGICOPFUNCTION_COPY_INVERTED;
- case PIPE_LOGICOP_AND_INVERTED:
- return BRW_LOGICOPFUNCTION_AND_INVERTED;
- case PIPE_LOGICOP_NOOP:
- return BRW_LOGICOPFUNCTION_NOOP;
- case PIPE_LOGICOP_XOR:
- return BRW_LOGICOPFUNCTION_XOR;
- case PIPE_LOGICOP_OR:
- return BRW_LOGICOPFUNCTION_OR;
- case PIPE_LOGICOP_OR_INVERTED:
- return BRW_LOGICOPFUNCTION_OR_INVERTED;
- case PIPE_LOGICOP_NOR:
- return BRW_LOGICOPFUNCTION_NOR;
- case PIPE_LOGICOP_EQUIV:
- return BRW_LOGICOPFUNCTION_EQUIV;
- case PIPE_LOGICOP_INVERT:
- return BRW_LOGICOPFUNCTION_INVERT;
- case PIPE_LOGICOP_OR_REVERSE:
- return BRW_LOGICOPFUNCTION_OR_REVERSE;
- case PIPE_LOGICOP_NAND:
- return BRW_LOGICOPFUNCTION_NAND;
- case PIPE_LOGICOP_SET:
- return BRW_LOGICOPFUNCTION_SET;
- default:
- return BRW_LOGICOPFUNCTION_SET;
- }
-}
-
-
-static void upload_cc_vp( struct brw_context *brw )
-{
- struct brw_cc_viewport ccv;
-
- memset(&ccv, 0, sizeof(ccv));
-
- ccv.min_depth = 0.0;
- ccv.max_depth = 1.0;
-
- brw->cc.vp_gs_offset = brw_cache_data( &brw->cache[BRW_CC_VP], &ccv );
-}
-
-const struct brw_tracked_state brw_cc_vp = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_cc_vp
-};
-
-
-static void upload_cc_unit( struct brw_context *brw )
-{
- struct brw_cc_unit_state cc;
-
- memset(&cc, 0, sizeof(cc));
-
- /* BRW_NEW_DEPTH_STENCIL */
- if (brw->attribs.DepthStencil->stencil[0].enabled) {
- cc.cc0.stencil_enable = brw->attribs.DepthStencil->stencil[0].enabled;
- cc.cc0.stencil_func = brw_translate_compare_func(brw->attribs.DepthStencil->stencil[0].func);
- cc.cc0.stencil_fail_op = brw_translate_stencil_op(brw->attribs.DepthStencil->stencil[0].fail_op);
- cc.cc0.stencil_pass_depth_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil[0].zfail_op);
- cc.cc0.stencil_pass_depth_pass_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil[0].zpass_op);
- cc.cc1.stencil_ref = brw->attribs.DepthStencil->stencil[0].ref_value;
- cc.cc1.stencil_write_mask = brw->attribs.DepthStencil->stencil[0].write_mask;
- cc.cc1.stencil_test_mask = brw->attribs.DepthStencil->stencil[0].value_mask;
-
- if (brw->attribs.DepthStencil->stencil[1].enabled) {
- cc.cc0.bf_stencil_enable = brw->attribs.DepthStencil->stencil[1].enabled;
- cc.cc0.bf_stencil_func = brw_translate_compare_func(
- brw->attribs.DepthStencil->stencil[1].func);
- cc.cc0.bf_stencil_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil[1].fail_op);
- cc.cc0.bf_stencil_pass_depth_fail_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil[1].zfail_op);
- cc.cc0.bf_stencil_pass_depth_pass_op = brw_translate_stencil_op(
- brw->attribs.DepthStencil->stencil[1].zpass_op);
- cc.cc1.bf_stencil_ref = brw->attribs.DepthStencil->stencil[1].ref_value;
- cc.cc2.bf_stencil_write_mask = brw->attribs.DepthStencil->stencil[1].write_mask;
- cc.cc2.bf_stencil_test_mask = brw->attribs.DepthStencil->stencil[1].value_mask;
- }
-
- /* Not really sure about this:
- */
- if (brw->attribs.DepthStencil->stencil[0].write_mask ||
- brw->attribs.DepthStencil->stencil[1].write_mask)
- cc.cc0.stencil_write_enable = 1;
- }
-
- /* BRW_NEW_BLEND */
- if (brw->attribs.Blend->logicop_enable) {
- cc.cc2.logicop_enable = 1;
- cc.cc5.logicop_func = brw_translate_logic_op( brw->attribs.Blend->logicop_func );
- }
- else if (brw->attribs.Blend->blend_enable) {
- int eqRGB = brw->attribs.Blend->rgb_func;
- int eqA = brw->attribs.Blend->alpha_func;
- int srcRGB = brw->attribs.Blend->rgb_src_factor;
- int dstRGB = brw->attribs.Blend->rgb_dst_factor;
- int srcA = brw->attribs.Blend->alpha_src_factor;
- int dstA = brw->attribs.Blend->alpha_dst_factor;
-
- if (eqRGB == PIPE_BLEND_MIN || eqRGB == PIPE_BLEND_MAX) {
- srcRGB = dstRGB = PIPE_BLENDFACTOR_ONE;
- }
-
- if (eqA == PIPE_BLEND_MIN || eqA == PIPE_BLEND_MAX) {
- srcA = dstA = PIPE_BLENDFACTOR_ONE;
- }
-
- cc.cc6.dest_blend_factor = brw_translate_blend_factor(dstRGB);
- cc.cc6.src_blend_factor = brw_translate_blend_factor(srcRGB);
- cc.cc6.blend_function = brw_translate_blend_equation( eqRGB );
-
- cc.cc5.ia_dest_blend_factor = brw_translate_blend_factor(dstA);
- cc.cc5.ia_src_blend_factor = brw_translate_blend_factor(srcA);
- cc.cc5.ia_blend_function = brw_translate_blend_equation( eqA );
-
- cc.cc3.blend_enable = 1;
- cc.cc3.ia_blend_enable = (srcA != srcRGB ||
- dstA != dstRGB ||
- eqA != eqRGB);
- }
-
- /* BRW_NEW_ALPHATEST
- */
- if (brw->attribs.DepthStencil->alpha.enabled) {
- cc.cc3.alpha_test = 1;
- 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.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
- }
-
- if (brw->attribs.Blend->dither) {
- cc.cc5.dither_enable = 1;
- cc.cc6.y_dither_offset = 0;
- cc.cc6.x_dither_offset = 0;
- }
-
- if (brw->attribs.DepthStencil->depth.enabled) {
- cc.cc2.depth_test = brw->attribs.DepthStencil->depth.enabled;
- cc.cc2.depth_test_function = brw_translate_compare_func(brw->attribs.DepthStencil->depth.func);
- cc.cc2.depth_write_enable = brw->attribs.DepthStencil->depth.writemask;
- }
-
- /* CACHE_NEW_CC_VP */
- cc.cc4.cc_viewport_state_offset = brw->cc.vp_gs_offset >> 5;
-
- if (BRW_DEBUG & DEBUG_STATS)
- cc.cc5.statistics_enable = 1;
-
- brw->cc.state_gs_offset = brw_cache_data( &brw->cache[BRW_CC_UNIT], &cc );
-}
-
-const struct brw_tracked_state brw_cc_unit = {
- .dirty = {
- .brw = BRW_NEW_DEPTH_STENCIL | BRW_NEW_BLEND | BRW_NEW_ALPHA_TEST,
- .cache = CACHE_NEW_CC_VP
- },
- .update = upload_cc_unit
-};
-
diff --git a/src/mesa/pipe/i965simple/brw_clip.c b/src/mesa/pipe/i965simple/brw_clip.c
deleted file mode 100644
index 268124cc53..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_state.h"
-#include "brw_clip.h"
-
-#define FRONT_UNFILLED_BIT 0x1
-#define BACK_UNFILLED_BIT 0x2
-
-
-static void compile_clip_prog( struct brw_context *brw,
- struct brw_clip_prog_key *key )
-{
- struct brw_clip_compile c;
- const unsigned *program;
- unsigned program_size;
- unsigned delta;
- unsigned i;
-
- memset(&c, 0, sizeof(c));
-
- /* Begin the compilation:
- */
- brw_init_compile(&c.func);
-
- c.func.single_program_flow = 1;
-
- c.key = *key;
-
-
- /* Need to locate the two positions present in vertex + header.
- * These are currently hardcoded:
- */
- c.header_position_offset = ATTR_SIZE;
-
- for (i = 0, delta = REG_SIZE; i < PIPE_MAX_SHADER_OUTPUTS; i++)
- if (c.key.attrs & (1<<i)) {
- c.offset[i] = delta;
- delta += ATTR_SIZE;
- }
-
- c.nr_attrs = brw_count_bits(c.key.attrs);
- c.nr_regs = (c.nr_attrs + 1) / 2 + 1; /* are vertices packed, or reg-aligned? */
- c.nr_bytes = c.nr_regs * REG_SIZE;
-
- c.prog_data.clip_mode = c.key.clip_mode; /* XXX */
-
- /* For some reason the thread is spawned with only 4 channels
- * unmasked.
- */
- brw_set_mask_control(&c.func, BRW_MASK_DISABLE);
-
-
- /* Would ideally have the option of producing a program which could
- * do all three:
- */
- switch (key->primitive) {
- case PIPE_PRIM_TRIANGLES:
-#if 0
- if (key->do_unfilled)
- brw_emit_unfilled_clip( &c );
- else
-#endif
- brw_emit_tri_clip( &c );
- break;
- case PIPE_PRIM_LINES:
- brw_emit_line_clip( &c );
- break;
- case PIPE_PRIM_POINTS:
- brw_emit_point_clip( &c );
- break;
- default:
- assert(0);
- return;
- }
-
-
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- /* Upload
- */
- brw->clip.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_CLIP_PROG],
- &c.key,
- sizeof(c.key),
- program,
- program_size,
- &c.prog_data,
- &brw->clip.prog_data );
-}
-
-
-static boolean search_cache( struct brw_context *brw,
- struct brw_clip_prog_key *key )
-{
- return brw_search_cache(&brw->cache[BRW_CLIP_PROG],
- key, sizeof(*key),
- &brw->clip.prog_data,
- &brw->clip.prog_gs_offset);
-}
-
-
-
-
-/* Calculate interpolants for triangle and line rasterization.
- */
-static void upload_clip_prog(struct brw_context *brw)
-{
- struct brw_clip_prog_key key;
-
- memset(&key, 0, sizeof(key));
-
- /* Populate the key:
- */
- /* BRW_NEW_REDUCED_PRIMITIVE */
- key.primitive = brw->reduced_primitive;
- /* CACHE_NEW_VS_PROG */
- key.attrs = brw->vs.prog_data->outputs_written;
- /* BRW_NEW_RASTER */
- key.do_flat_shading = (brw->attribs.Raster->flatshade);
- /* BRW_NEW_CLIP */
- key.nr_userclip = brw->attribs.Clip.nr; /* XXX */
-
-#if 0
- key.clip_mode = BRW_CLIPMODE_NORMAL;
-
- if (key.primitive == PIPE_PRIM_TRIANGLES) {
- if (brw->attribs.Raster->cull_mode == PIPE_WINDING_BOTH)
- key.clip_mode = BRW_CLIPMODE_REJECT_ALL;
- else {
- if (brw->attribs.Raster->fill_cw != PIPE_POLYGON_MODE_FILL ||
- brw->attribs.Raster->fill_ccw != PIPE_POLYGON_MODE_FILL)
- key.do_unfilled = 1;
-
- /* Most cases the fixed function units will handle. Cases where
- * one or more polygon faces are unfilled will require help:
- */
- if (key.do_unfilled) {
- key.clip_mode = BRW_CLIPMODE_CLIP_NON_REJECTED;
-
- if (brw->attribs.Raster->offset_cw ||
- brw->attribs.Raster->offset_ccw) {
- key.offset_units = brw->attribs.Raster->offset_units;
- key.offset_factor = brw->attribs.Raster->offset_scale;
- }
- key.fill_ccw = brw->attribs.Raster->fill_ccw;
- key.fill_cw = brw->attribs.Raster->fill_cw;
- key.offset_ccw = brw->attribs.Raster->offset_ccw;
- key.offset_cw = brw->attribs.Raster->offset_cw;
- if (brw->attribs.Raster->light_twoside &&
- key.fill_cw != CLIP_CULL)
- key.copy_bfc_cw = 1;
- }
- }
- }
-#else
- key.clip_mode = BRW_CLIPMODE_ACCEPT_ALL;
-#endif
-
- if (!search_cache(brw, &key))
- compile_clip_prog( brw, &key );
-}
-
-const struct brw_tracked_state brw_clip_prog = {
- .dirty = {
- .brw = (BRW_NEW_RASTERIZER |
- BRW_NEW_CLIP |
- BRW_NEW_REDUCED_PRIMITIVE),
- .cache = CACHE_NEW_VS_PROG
- },
- .update = upload_clip_prog
-};
diff --git a/src/mesa/pipe/i965simple/brw_clip.h b/src/mesa/pipe/i965simple/brw_clip.h
deleted file mode 100644
index a89d08b791..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef BRW_CLIP_H
-#define BRW_CLIP_H
-
-
-#include "brw_context.h"
-#include "brw_eu.h"
-
-#define MAX_VERTS (3+6+6)
-
-/* Note that if unfilled primitives are being emitted, we have to fix
- * up polygon offset and flatshading at this point:
- */
-struct brw_clip_prog_key {
- unsigned attrs:32;
- unsigned primitive:4;
- unsigned nr_userclip:3;
- unsigned do_flat_shading:1;
- unsigned do_unfilled:1;
- unsigned fill_cw:2; /* includes cull information */
- unsigned fill_ccw:2; /* includes cull information */
- unsigned offset_cw:1;
- unsigned offset_ccw:1;
- unsigned pad0:17;
-
- unsigned copy_bfc_cw:1;
- unsigned copy_bfc_ccw:1;
- unsigned clip_mode:3;
- unsigned pad1:27;
-
- float offset_factor;
- float offset_units;
-};
-
-
-#define CLIP_LINE 0
-#define CLIP_POINT 1
-#define CLIP_FILL 2
-#define CLIP_CULL 3
-
-
-#define PRIM_MASK (0x1f)
-
-struct brw_clip_compile {
- struct brw_compile func;
- struct brw_clip_prog_key key;
- struct brw_clip_prog_data prog_data;
-
- struct {
- struct brw_reg R0;
- struct brw_reg vertex[MAX_VERTS];
-
- struct brw_reg t;
- struct brw_reg t0, t1;
- struct brw_reg dp0, dp1;
-
- struct brw_reg dpPrev;
- struct brw_reg dp;
- struct brw_reg loopcount;
- struct brw_reg nr_verts;
- struct brw_reg planemask;
-
- struct brw_reg inlist;
- struct brw_reg outlist;
- struct brw_reg freelist;
-
- struct brw_reg dir;
- struct brw_reg tmp0, tmp1;
- struct brw_reg offset;
-
- struct brw_reg fixed_planes;
- struct brw_reg plane_equation;
- } reg;
-
- /* 3 different ways of expressing vertex size:
- */
- unsigned nr_attrs;
- unsigned nr_regs;
- unsigned nr_bytes;
-
- unsigned first_tmp;
- unsigned last_tmp;
-
- boolean need_direction;
-
- unsigned last_mrf;
-
- unsigned header_position_offset;
- unsigned offset[PIPE_ATTRIB_MAX];
-};
-
-#define ATTR_SIZE (4*4)
-
-/* Points are only culled, so no need for a clip routine, however it
- * works out easier to have a dummy one.
- */
-void brw_emit_unfilled_clip( struct brw_clip_compile *c );
-void brw_emit_tri_clip( struct brw_clip_compile *c );
-void brw_emit_line_clip( struct brw_clip_compile *c );
-void brw_emit_point_clip( struct brw_clip_compile *c );
-
-/* brw_clip_tri.c, for use by the unfilled clip routine:
- */
-void brw_clip_tri_init_vertices( struct brw_clip_compile *c );
-void brw_clip_tri_flat_shade( struct brw_clip_compile *c );
-void brw_clip_tri( struct brw_clip_compile *c );
-void brw_clip_tri_emit_polygon( struct brw_clip_compile *c );
-void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
- unsigned nr_verts );
-
-
-/* Utils:
- */
-
-void brw_clip_interp_vertex( struct brw_clip_compile *c,
- struct brw_indirect dest_ptr,
- struct brw_indirect v0_ptr, /* from */
- struct brw_indirect v1_ptr, /* to */
- struct brw_reg t0,
- boolean force_edgeflag );
-
-void brw_clip_init_planes( struct brw_clip_compile *c );
-
-void brw_clip_emit_vue(struct brw_clip_compile *c,
- struct brw_indirect vert,
- boolean allocate,
- boolean eot,
- unsigned header);
-
-void brw_clip_kill_thread(struct brw_clip_compile *c);
-
-struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c );
-struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c );
-
-void brw_clip_copy_colors( struct brw_clip_compile *c,
- unsigned to, unsigned from );
-
-void brw_clip_init_clipmask( struct brw_clip_compile *c );
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_clip_line.c b/src/mesa/pipe/i965simple/brw_clip_line.c
deleted file mode 100644
index 75d9e5fcda..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_line.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_clip.h"
-
-
-
-static void brw_clip_line_alloc_regs( struct brw_clip_compile *c )
-{
- unsigned i = 0,j;
-
- /* Register usage is static, precompute here:
- */
- c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
-
- if (c->key.nr_userclip) {
- c->reg.fixed_planes = brw_vec4_grf(i, 0);
- i += (6 + c->key.nr_userclip + 1) / 2;
-
- c->prog_data.curb_read_length = (6 + c->key.nr_userclip + 1) / 2;
- }
- else
- c->prog_data.curb_read_length = 0;
-
-
- /* Payload vertices plus space for more generated vertices:
- */
- for (j = 0; j < 4; j++) {
- c->reg.vertex[j] = brw_vec4_grf(i, 0);
- i += c->nr_regs;
- }
-
- c->reg.t = brw_vec1_grf(i, 0);
- c->reg.t0 = brw_vec1_grf(i, 1);
- c->reg.t1 = brw_vec1_grf(i, 2);
- c->reg.planemask = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
- c->reg.plane_equation = brw_vec4_grf(i, 4);
- i++;
-
- c->reg.dp0 = brw_vec1_grf(i, 0); /* fixme - dp4 will clobber r.1,2,3 */
- c->reg.dp1 = brw_vec1_grf(i, 4);
- i++;
-
- if (!c->key.nr_userclip) {
- c->reg.fixed_planes = brw_vec8_grf(i, 0);
- i++;
- }
-
-
- c->first_tmp = i;
- c->last_tmp = i;
-
- c->prog_data.urb_read_length = c->nr_regs; /* ? */
- c->prog_data.total_grf = i;
-}
-
-
-
-/* Line clipping, more or less following the following algorithm:
- *
- * for (p=0;p<MAX_PLANES;p++) {
- * if (clipmask & (1 << p)) {
- * float dp0 = DOTPROD( vtx0, plane[p] );
- * float dp1 = DOTPROD( vtx1, plane[p] );
- *
- * if (IS_NEGATIVE(dp1)) {
- * float t = dp1 / (dp1 - dp0);
- * if (t > t1) t1 = t;
- * } else {
- * float t = dp0 / (dp0 - dp1);
- * if (t > t0) t0 = t;
- * }
- *
- * if (t0 + t1 >= 1.0)
- * return;
- * }
- * }
- *
- * interp( ctx, newvtx0, vtx0, vtx1, t0 );
- * interp( ctx, newvtx1, vtx1, vtx0, t1 );
- *
- */
-static void clip_and_emit_line( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_indirect vtx0 = brw_indirect(0, 0);
- struct brw_indirect vtx1 = brw_indirect(1, 0);
- struct brw_indirect newvtx0 = brw_indirect(2, 0);
- struct brw_indirect newvtx1 = brw_indirect(3, 0);
- struct brw_indirect plane_ptr = brw_indirect(4, 0);
- struct brw_instruction *plane_loop;
- struct brw_instruction *plane_active;
- struct brw_instruction *is_negative;
- struct brw_instruction *is_neg2;
- struct brw_instruction *not_culled;
- struct brw_reg v1_null_ud = retype(vec1(brw_null_reg()), BRW_REGISTER_TYPE_UD);
-
- brw_MOV(p, get_addr_reg(vtx0), brw_address(c->reg.vertex[0]));
- brw_MOV(p, get_addr_reg(vtx1), brw_address(c->reg.vertex[1]));
- brw_MOV(p, get_addr_reg(newvtx0), brw_address(c->reg.vertex[2]));
- brw_MOV(p, get_addr_reg(newvtx1), brw_address(c->reg.vertex[3]));
- brw_MOV(p, get_addr_reg(plane_ptr), brw_clip_plane0_address(c));
-
- /* Note: init t0, t1 together:
- */
- brw_MOV(p, vec2(c->reg.t0), brw_imm_f(0));
-
- brw_clip_init_planes(c);
- brw_clip_init_clipmask(c);
-
- /* -ve rhw workaround */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
- brw_imm_ud(1<<20));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(0x3f));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- plane_loop = brw_DO(p, BRW_EXECUTE_1);
- {
- /* if (planemask & 1)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_AND(p, v1_null_ud, c->reg.planemask, brw_imm_ud(1));
-
- plane_active = brw_IF(p, BRW_EXECUTE_1);
- {
- if (c->key.nr_userclip)
- brw_MOV(p, c->reg.plane_equation, deref_4f(plane_ptr, 0));
- else
- brw_MOV(p, c->reg.plane_equation, deref_4b(plane_ptr, 0));
-
-#if 0
- /* dp = DP4(vtx->position, plane)
- */
- brw_DP4(p, vec4(c->reg.dp0), deref_4f(vtx0, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
-
- /* if (IS_NEGATIVE(dp1))
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
- brw_DP4(p, vec4(c->reg.dp1), deref_4f(vtx1, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
-#else
- #warning "disabled"
-#endif
- is_negative = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_ADD(p, c->reg.t, c->reg.dp1, negate(c->reg.dp0));
- brw_math_invert(p, c->reg.t, c->reg.t);
- brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp1);
-
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t1 );
- brw_MOV(p, c->reg.t1, c->reg.t);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- }
- is_negative = brw_ELSE(p, is_negative);
- {
- /* Coming back in. We know that both cannot be negative
- * because the line would have been culled in that case.
- */
-
- /* If both are positive, do nothing */
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.dp0, brw_imm_f(0.0));
- is_neg2 = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_ADD(p, c->reg.t, c->reg.dp0, negate(c->reg.dp1));
- brw_math_invert(p, c->reg.t, c->reg.t);
- brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp0);
-
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_G, c->reg.t, c->reg.t0 );
- brw_MOV(p, c->reg.t0, c->reg.t);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- }
- brw_ENDIF(p, is_neg2);
- }
- brw_ENDIF(p, is_negative);
- }
- brw_ENDIF(p, plane_active);
-
- /* plane_ptr++;
- */
- brw_ADD(p, get_addr_reg(plane_ptr), get_addr_reg(plane_ptr), brw_clip_plane_stride(c));
-
- /* while (planemask>>=1) != 0
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
- }
- brw_WHILE(p, plane_loop);
-
- brw_ADD(p, c->reg.t, c->reg.t0, c->reg.t1);
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.t, brw_imm_f(1.0));
- not_culled = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_interp_vertex(c, newvtx0, vtx0, vtx1, c->reg.t0, FALSE);
- brw_clip_interp_vertex(c, newvtx1, vtx1, vtx0, c->reg.t1, FALSE);
-
- brw_clip_emit_vue(c, newvtx0, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_START);
- brw_clip_emit_vue(c, newvtx1, 0, 1, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_END);
- }
- brw_ENDIF(p, not_culled);
- brw_clip_kill_thread(c);
-}
-
-
-
-void brw_emit_line_clip( struct brw_clip_compile *c )
-{
- brw_clip_line_alloc_regs(c);
-
- if (c->key.do_flat_shading)
- brw_clip_copy_colors(c, 0, 1);
-
- clip_and_emit_line(c);
-}
diff --git a/src/mesa/pipe/i965simple/brw_clip_point.c b/src/mesa/pipe/i965simple/brw_clip_point.c
deleted file mode 100644
index 6fce7210d1..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_point.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_clip.h"
-
-
-/* Point clipping, nothing to do?
- */
-void brw_emit_point_clip( struct brw_clip_compile *c )
-{
- /* Send an empty message to kill the thread:
- */
- brw_clip_tri_alloc_regs(c, 0);
- brw_clip_kill_thread(c);
-}
diff --git a/src/mesa/pipe/i965simple/brw_clip_state.c b/src/mesa/pipe/i965simple/brw_clip_state.c
deleted file mode 100644
index ea5c05a279..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_state.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "pipe/p_util.h"
-
-
-static void upload_clip_unit( struct brw_context *brw )
-{
- struct brw_clip_unit_state clip;
-
- memset(&clip, 0, sizeof(clip));
-
- /* CACHE_NEW_CLIP_PROG */
- clip.thread0.grf_reg_count =
- align(brw->clip.prog_data->total_grf, 16) / 16 - 1;
- clip.thread0.kernel_start_pointer = brw->clip.prog_gs_offset >> 6;
- clip.thread3.urb_entry_read_length = brw->clip.prog_data->urb_read_length;
- clip.thread3.const_urb_entry_read_length = brw->clip.prog_data->curb_read_length;
- clip.clip5.clip_mode = brw->clip.prog_data->clip_mode;
-
- /* BRW_NEW_CURBE_OFFSETS */
- clip.thread3.const_urb_entry_read_offset = brw->curbe.clip_start * 2;
-
- /* BRW_NEW_URB_FENCE */
- clip.thread4.nr_urb_entries = brw->urb.nr_clip_entries;
- clip.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
- clip.thread4.max_threads = 1; /* 2 threads */
-
- if (BRW_DEBUG & DEBUG_STATS)
- clip.thread4.stats_enable = 1;
-
- /* CONSTANT */
- clip.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
- clip.thread1.single_program_flow = 1;
- clip.thread3.dispatch_grf_start_reg = 1;
- clip.thread3.urb_entry_read_offset = 0;
- clip.clip5.userclip_enable_flags = 0x7f;
- clip.clip5.userclip_must_clip = 1;
- clip.clip5.guard_band_enable = 0;
- clip.clip5.viewport_z_clip_enable = 1;
- clip.clip5.viewport_xy_clip_enable = 1;
- clip.clip5.vertex_position_space = BRW_CLIP_NDCSPACE;
- clip.clip5.api_mode = BRW_CLIP_API_OGL;
- clip.clip6.clipper_viewport_state_ptr = 0;
- clip.viewport_xmin = -1;
- clip.viewport_xmax = 1;
- clip.viewport_ymin = -1;
- clip.viewport_ymax = 1;
-
- brw->clip.state_gs_offset = brw_cache_data( &brw->cache[BRW_CLIP_UNIT], &clip );
-}
-
-
-const struct brw_tracked_state brw_clip_unit = {
- .dirty = {
- .brw = (BRW_NEW_CURBE_OFFSETS |
- BRW_NEW_URB_FENCE),
- .cache = CACHE_NEW_CLIP_PROG
- },
- .update = upload_clip_unit
-};
diff --git a/src/mesa/pipe/i965simple/brw_clip_tri.c b/src/mesa/pipe/i965simple/brw_clip_tri.c
deleted file mode 100644
index c5da7b825e..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_tri.c
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_clip.h"
-
-static struct brw_reg get_tmp( struct brw_clip_compile *c )
-{
- struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0);
-
- if (++c->last_tmp > c->prog_data.total_grf)
- c->prog_data.total_grf = c->last_tmp;
-
- return tmp;
-}
-
-static void release_tmps( struct brw_clip_compile *c )
-{
- c->last_tmp = c->first_tmp;
-}
-
-
-void brw_clip_tri_alloc_regs( struct brw_clip_compile *c,
- unsigned nr_verts )
-{
- unsigned i = 0,j;
-
- /* Register usage is static, precompute here:
- */
- c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
-
- if (c->key.nr_userclip) {
- c->reg.fixed_planes = brw_vec4_grf(i, 0);
- i += (6 + c->key.nr_userclip + 1) / 2;
-
- c->prog_data.curb_read_length = (6 + c->key.nr_userclip + 1) / 2;
- }
- else
- c->prog_data.curb_read_length = 0;
-
-
- /* Payload vertices plus space for more generated vertices:
- */
- for (j = 0; j < nr_verts; j++) {
- c->reg.vertex[j] = brw_vec4_grf(i, 0);
- i += c->nr_regs;
- }
-
- if (c->nr_attrs & 1) {
- for (j = 0; j < 3; j++) {
- unsigned delta = c->nr_attrs*16 + 32;
- brw_MOV(&c->func, byte_offset(c->reg.vertex[j], delta), brw_imm_f(0));
- }
- }
-
- c->reg.t = brw_vec1_grf(i, 0);
- c->reg.loopcount = retype(brw_vec1_grf(i, 1), BRW_REGISTER_TYPE_UD);
- c->reg.nr_verts = retype(brw_vec1_grf(i, 2), BRW_REGISTER_TYPE_UD);
- c->reg.planemask = retype(brw_vec1_grf(i, 3), BRW_REGISTER_TYPE_UD);
- c->reg.plane_equation = brw_vec4_grf(i, 4);
- i++;
-
- c->reg.dpPrev = brw_vec1_grf(i, 0); /* fixme - dp4 will clobber r.1,2,3 */
- c->reg.dp = brw_vec1_grf(i, 4);
- i++;
-
- c->reg.inlist = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
- i++;
-
- c->reg.outlist = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
- i++;
-
- c->reg.freelist = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, i, 0);
- i++;
-
- if (!c->key.nr_userclip) {
- c->reg.fixed_planes = brw_vec8_grf(i, 0);
- i++;
- }
-
- if (c->key.do_unfilled) {
- c->reg.dir = brw_vec4_grf(i, 0);
- c->reg.offset = brw_vec4_grf(i, 4);
- i++;
- c->reg.tmp0 = brw_vec4_grf(i, 0);
- c->reg.tmp1 = brw_vec4_grf(i, 4);
- i++;
- }
-
- c->first_tmp = i;
- c->last_tmp = i;
-
- c->prog_data.urb_read_length = c->nr_regs; /* ? */
- c->prog_data.total_grf = i;
-}
-
-
-
-void brw_clip_tri_init_vertices( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
- struct brw_instruction *is_rev;
-
- /* Initial list of indices for incoming vertexes:
- */
- brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_EQ,
- tmp0,
- brw_imm_ud(_3DPRIM_TRISTRIP_REVERSE));
-
- /* XXX: Is there an easier way to do this? Need to reverse every
- * second tristrip element: Can ignore sometimes?
- */
- is_rev = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_MOV(p, get_element(c->reg.inlist, 0), brw_address(c->reg.vertex[1]) );
- brw_MOV(p, get_element(c->reg.inlist, 1), brw_address(c->reg.vertex[0]) );
- if (c->need_direction)
- brw_MOV(p, c->reg.dir, brw_imm_f(-1));
- }
- is_rev = brw_ELSE(p, is_rev);
- {
- brw_MOV(p, get_element(c->reg.inlist, 0), brw_address(c->reg.vertex[0]) );
- brw_MOV(p, get_element(c->reg.inlist, 1), brw_address(c->reg.vertex[1]) );
- if (c->need_direction)
- brw_MOV(p, c->reg.dir, brw_imm_f(1));
- }
- brw_ENDIF(p, is_rev);
-
- brw_MOV(p, get_element(c->reg.inlist, 2), brw_address(c->reg.vertex[2]) );
- brw_MOV(p, brw_vec8_grf(c->reg.outlist.nr, 0), brw_imm_f(0));
- brw_MOV(p, c->reg.nr_verts, brw_imm_ud(3));
-}
-
-
-
-void brw_clip_tri_flat_shade( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *is_poly;
- struct brw_reg tmp0 = c->reg.loopcount; /* handy temporary */
-
- brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_EQ,
- tmp0,
- brw_imm_ud(_3DPRIM_POLYGON));
-
- is_poly = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_copy_colors(c, 1, 0);
- brw_clip_copy_colors(c, 2, 0);
- }
- is_poly = brw_ELSE(p, is_poly);
- {
- brw_clip_copy_colors(c, 0, 2);
- brw_clip_copy_colors(c, 1, 2);
- }
- brw_ENDIF(p, is_poly);
-}
-
-
-
-/* Use mesa's clipping algorithms, translated to GEN4 assembly.
- */
-void brw_clip_tri( struct brw_clip_compile *c )
-{
-#if 0
- struct brw_compile *p = &c->func;
- struct brw_indirect vtx = brw_indirect(0, 0);
- struct brw_indirect vtxPrev = brw_indirect(1, 0);
- struct brw_indirect vtxOut = brw_indirect(2, 0);
- struct brw_indirect plane_ptr = brw_indirect(3, 0);
- struct brw_indirect inlist_ptr = brw_indirect(4, 0);
- struct brw_indirect outlist_ptr = brw_indirect(5, 0);
- struct brw_indirect freelist_ptr = brw_indirect(6, 0);
- struct brw_instruction *plane_loop;
- struct brw_instruction *plane_active;
- struct brw_instruction *vertex_loop;
- struct brw_instruction *next_test;
- struct brw_instruction *prev_test;
-
- brw_MOV(p, get_addr_reg(vtxPrev), brw_address(c->reg.vertex[2]) );
- brw_MOV(p, get_addr_reg(plane_ptr), brw_clip_plane0_address(c));
- brw_MOV(p, get_addr_reg(inlist_ptr), brw_address(c->reg.inlist));
- brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
-
- brw_MOV(p, get_addr_reg(freelist_ptr), brw_address(c->reg.vertex[3]) );
-
- plane_loop = brw_DO(p, BRW_EXECUTE_1);
- {
- /* if (planemask & 1)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_AND(p, vec1(brw_null_reg()), c->reg.planemask, brw_imm_ud(1));
-
- plane_active = brw_IF(p, BRW_EXECUTE_1);
- {
- /* vtxOut = freelist_ptr++
- */
- brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(freelist_ptr) );
- brw_ADD(p, get_addr_reg(freelist_ptr), get_addr_reg(freelist_ptr), brw_imm_uw(c->nr_regs * REG_SIZE));
-
- if (c->key.nr_userclip)
- brw_MOV(p, c->reg.plane_equation, deref_4f(plane_ptr, 0));
- else
- brw_MOV(p, c->reg.plane_equation, deref_4b(plane_ptr, 0));
-
- brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
- brw_MOV(p, c->reg.nr_verts, brw_imm_ud(0));
-
- vertex_loop = brw_DO(p, BRW_EXECUTE_1);
- {
- /* vtx = *input_ptr;
- */
- brw_MOV(p, get_addr_reg(vtx), deref_1uw(inlist_ptr, 0));
-
- /* IS_NEGATIVE(prev) */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
- brw_DP4(p, vec4(c->reg.dpPrev), deref_4f(vtxPrev, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- prev_test = brw_IF(p, BRW_EXECUTE_1);
- {
- /* IS_POSITIVE(next)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_GE);
- brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- next_test = brw_IF(p, BRW_EXECUTE_1);
- {
-
- /* Coming back in.
- */
- brw_ADD(p, c->reg.t, c->reg.dpPrev, negate(c->reg.dp));
- brw_math_invert(p, c->reg.t, c->reg.t);
- brw_MUL(p, c->reg.t, c->reg.t, c->reg.dpPrev);
-
- /* If (vtxOut == 0) vtxOut = vtxPrev
- */
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
- brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtxPrev) );
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- brw_clip_interp_vertex(c, vtxOut, vtxPrev, vtx, c->reg.t, FALSE);
-
- /* *outlist_ptr++ = vtxOut;
- * nr_verts++;
- * vtxOut = 0;
- */
- brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
- brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
- brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
- brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
- }
- brw_ENDIF(p, next_test);
-
- }
- prev_test = brw_ELSE(p, prev_test);
- {
- /* *outlist_ptr++ = vtxPrev;
- * nr_verts++;
- */
- brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxPrev));
- brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
- brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
-
- /* IS_NEGATIVE(next)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
- brw_DP4(p, vec4(c->reg.dp), deref_4f(vtx, c->offset[VERT_RESULT_HPOS]), c->reg.plane_equation);
- next_test = brw_IF(p, BRW_EXECUTE_1);
- {
- /* Going out of bounds. Avoid division by zero as we
- * know dp != dpPrev from DIFFERENT_SIGNS, above.
- */
- brw_ADD(p, c->reg.t, c->reg.dp, negate(c->reg.dpPrev));
- brw_math_invert(p, c->reg.t, c->reg.t);
- brw_MUL(p, c->reg.t, c->reg.t, c->reg.dp);
-
- /* If (vtxOut == 0) vtxOut = vtx
- */
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_EQ, get_addr_reg(vtxOut), brw_imm_uw(0) );
- brw_MOV(p, get_addr_reg(vtxOut), get_addr_reg(vtx) );
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- brw_clip_interp_vertex(c, vtxOut, vtx, vtxPrev, c->reg.t, TRUE);
-
- /* *outlist_ptr++ = vtxOut;
- * nr_verts++;
- * vtxOut = 0;
- */
- brw_MOV(p, deref_1uw(outlist_ptr, 0), get_addr_reg(vtxOut));
- brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_uw(sizeof(short)));
- brw_ADD(p, c->reg.nr_verts, c->reg.nr_verts, brw_imm_ud(1));
- brw_MOV(p, get_addr_reg(vtxOut), brw_imm_uw(0) );
- }
- brw_ENDIF(p, next_test);
- }
- brw_ENDIF(p, prev_test);
-
- /* vtxPrev = vtx;
- * inlist_ptr++;
- */
- brw_MOV(p, get_addr_reg(vtxPrev), get_addr_reg(vtx));
- brw_ADD(p, get_addr_reg(inlist_ptr), get_addr_reg(inlist_ptr), brw_imm_uw(sizeof(short)));
-
- /* while (--loopcount != 0)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
- }
- brw_WHILE(p, vertex_loop);
-
- /* vtxPrev = *(outlist_ptr-1) OR: outlist[nr_verts-1]
- * inlist = outlist
- * inlist_ptr = &inlist[0]
- * outlist_ptr = &outlist[0]
- */
- brw_ADD(p, get_addr_reg(outlist_ptr), get_addr_reg(outlist_ptr), brw_imm_w(-2));
- brw_MOV(p, get_addr_reg(vtxPrev), deref_1uw(outlist_ptr, 0));
- brw_MOV(p, brw_vec8_grf(c->reg.inlist.nr, 0), brw_vec8_grf(c->reg.outlist.nr, 0));
- brw_MOV(p, get_addr_reg(inlist_ptr), brw_address(c->reg.inlist));
- brw_MOV(p, get_addr_reg(outlist_ptr), brw_address(c->reg.outlist));
- }
- brw_ENDIF(p, plane_active);
-
- /* plane_ptr++;
- */
- brw_ADD(p, get_addr_reg(plane_ptr), get_addr_reg(plane_ptr), brw_clip_plane_stride(c));
-
- /* nr_verts >= 3
- */
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_GE,
- c->reg.nr_verts,
- brw_imm_ud(3));
-
- /* && (planemask>>=1) != 0
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_SHR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud(1));
- }
- brw_WHILE(p, plane_loop);
-#else
- #warning "disabled"
-#endif
-}
-
-
-
-void brw_clip_tri_emit_polygon(struct brw_clip_compile *c)
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *loop, *if_insn;
-
- /* for (loopcount = nr_verts-2; loopcount > 0; loopcount--)
- */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_G);
- brw_ADD(p,
- c->reg.loopcount,
- c->reg.nr_verts,
- brw_imm_d(-2));
-
- if_insn = brw_IF(p, BRW_EXECUTE_1);
- {
- struct brw_indirect v0 = brw_indirect(0, 0);
- struct brw_indirect vptr = brw_indirect(1, 0);
-
- brw_MOV(p, get_addr_reg(vptr), brw_address(c->reg.inlist));
- brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
-
- brw_clip_emit_vue(c, v0, 1, 0, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_START));
-
- brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
- brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
-
- loop = brw_DO(p, BRW_EXECUTE_1);
- {
- brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_TRIFAN << 2));
-
- brw_ADD(p, get_addr_reg(vptr), get_addr_reg(vptr), brw_imm_uw(2));
- brw_MOV(p, get_addr_reg(v0), deref_1uw(vptr, 0));
-
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
- }
- brw_WHILE(p, loop);
-
- brw_clip_emit_vue(c, v0, 0, 1, ((_3DPRIM_TRIFAN << 2) | R02_PRIM_END));
- }
- brw_ENDIF(p, if_insn);
-}
-
-static void do_clip_tri( struct brw_clip_compile *c )
-{
- brw_clip_init_planes(c);
-
- brw_clip_tri(c);
-}
-
-
-static void maybe_do_clip_tri( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *do_clip;
-
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
- do_clip = brw_IF(p, BRW_EXECUTE_1);
- {
- do_clip_tri(c);
- }
- brw_ENDIF(p, do_clip);
-}
-
-static void brw_clip_test( struct brw_clip_compile *c )
-{
-#if 0
- struct brw_reg t = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
- struct brw_reg t1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
- struct brw_reg t2 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
- struct brw_reg t3 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
-
- struct brw_reg v0 = get_tmp(c);
- struct brw_reg v1 = get_tmp(c);
- struct brw_reg v2 = get_tmp(c);
-
- struct brw_indirect vt0 = brw_indirect(0, 0);
- struct brw_indirect vt1 = brw_indirect(1, 0);
- struct brw_indirect vt2 = brw_indirect(2, 0);
-
- struct brw_compile *p = &c->func;
-
- brw_MOV(p, get_addr_reg(vt0), brw_address(c->reg.vertex[0]));
- brw_MOV(p, get_addr_reg(vt1), brw_address(c->reg.vertex[1]));
- brw_MOV(p, get_addr_reg(vt2), brw_address(c->reg.vertex[2]));
- brw_MOV(p, v0, deref_4f(vt0, c->offset[VERT_RESULT_HPOS]));
- brw_MOV(p, v1, deref_4f(vt1, c->offset[VERT_RESULT_HPOS]));
- brw_MOV(p, v2, deref_4f(vt2, c->offset[VERT_RESULT_HPOS]));
-
- /* test nearz, xmin, ymin plane */
- brw_CMP(p, t1, BRW_CONDITIONAL_LE, negate(v0), get_element(v0, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, t2, BRW_CONDITIONAL_LE, negate(v1), get_element(v1, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, t3, BRW_CONDITIONAL_LE, negate(v2), get_element(v2, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_XOR(p, t, t1, t2);
- brw_XOR(p, t1, t2, t3);
- brw_OR(p, t, t, t1);
-
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 0), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<5)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 1), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<3)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 2), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<1)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- /* test farz, xmax, ymax plane */
- brw_CMP(p, t1, BRW_CONDITIONAL_L, v0, get_element(v0, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, t2, BRW_CONDITIONAL_L, v1, get_element(v1, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, t3, BRW_CONDITIONAL_L, v2, get_element(v2, 3));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- brw_XOR(p, t, t1, t2);
- brw_XOR(p, t1, t2, t3);
- brw_OR(p, t, t, t1);
-
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 0), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<4)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 1), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<2)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_NZ,
- get_element(t, 2), brw_imm_ud(0));
- brw_OR(p, c->reg.planemask, c->reg.planemask, brw_imm_ud((1<<0)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- release_tmps(c);
-#else
- #warning "disabled"
-#endif
-}
-
-
-void brw_emit_tri_clip( struct brw_clip_compile *c )
-{
- struct brw_instruction *neg_rhw;
- struct brw_compile *p = &c->func;
- brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
- brw_clip_tri_init_vertices(c);
- brw_clip_init_clipmask(c);
-
- /* if -ve rhw workaround bit is set,
- do cliptest */
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_AND(p, brw_null_reg(), get_element_ud(c->reg.R0, 2),
- brw_imm_ud(1<<20));
- neg_rhw = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_test(c);
- }
- brw_ENDIF(p, neg_rhw);
-
- /* Can't push into do_clip_tri because with polygon (or quad)
- * flatshading, need to apply the flatshade here because we don't
- * respect the PV when converting to trifan for emit:
- */
- if (c->key.do_flat_shading)
- brw_clip_tri_flat_shade(c);
-
- if (c->key.clip_mode == BRW_CLIPMODE_NORMAL)
- do_clip_tri(c);
- else
- maybe_do_clip_tri(c);
-
- brw_clip_tri_emit_polygon(c);
-
- /* Send an empty message to kill the thread:
- */
- brw_clip_kill_thread(c);
-}
diff --git a/src/mesa/pipe/i965simple/brw_clip_unfilled.c b/src/mesa/pipe/i965simple/brw_clip_unfilled.c
deleted file mode 100644
index b774a76dd6..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_unfilled.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_clip.h"
-
-
-
-/* This is performed against the original triangles, so no indirection
- * required:
-BZZZT!
- */
-static void compute_tri_direction( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg e = c->reg.tmp0;
- struct brw_reg f = c->reg.tmp1;
- struct brw_reg v0 = byte_offset(c->reg.vertex[0], c->offset[VERT_RESULT_HPOS]);
- struct brw_reg v1 = byte_offset(c->reg.vertex[1], c->offset[VERT_RESULT_HPOS]);
- struct brw_reg v2 = byte_offset(c->reg.vertex[2], c->offset[VERT_RESULT_HPOS]);
-
-
- /* Calculate the vectors of two edges of the triangle:
- */
- brw_ADD(p, e, v0, negate(v2));
- brw_ADD(p, f, v1, negate(v2));
-
- /* Take their crossproduct:
- */
- brw_set_access_mode(p, BRW_ALIGN_16);
- brw_MUL(p, vec4(brw_null_reg()), brw_swizzle(e, 1,2,0,3), brw_swizzle(f,2,0,1,3));
- brw_MAC(p, vec4(e), negate(brw_swizzle(e, 2,0,1,3)), brw_swizzle(f,1,2,0,3));
- brw_set_access_mode(p, BRW_ALIGN_1);
-
- brw_MUL(p, c->reg.dir, c->reg.dir, vec4(e));
-}
-
-
-static void cull_direction( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *ccw;
- unsigned conditional;
-
- assert (!(c->key.fill_ccw == CLIP_CULL &&
- c->key.fill_cw == CLIP_CULL));
-
- if (c->key.fill_ccw == CLIP_CULL)
- conditional = BRW_CONDITIONAL_GE;
- else
- conditional = BRW_CONDITIONAL_L;
-
- brw_CMP(p,
- vec1(brw_null_reg()),
- conditional,
- get_element(c->reg.dir, 2),
- brw_imm_f(0));
-
- ccw = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_kill_thread(c);
- }
- brw_ENDIF(p, ccw);
-}
-
-
-
-static void copy_bfc( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *ccw;
- unsigned conditional;
-
- /* Do we have any colors to copy?
- */
- if (!(c->offset[VERT_RESULT_COL0] && c->offset[VERT_RESULT_BFC0]) &&
- !(c->offset[VERT_RESULT_COL1] && c->offset[VERT_RESULT_BFC1]))
- return;
-
- /* In some wierd degnerate cases we can end up testing the
- * direction twice, once for culling and once for bfc copying. Oh
- * well, that's what you get for setting wierd GL state.
- */
- if (c->key.copy_bfc_ccw)
- conditional = BRW_CONDITIONAL_GE;
- else
- conditional = BRW_CONDITIONAL_L;
-
- brw_CMP(p,
- vec1(brw_null_reg()),
- conditional,
- get_element(c->reg.dir, 2),
- brw_imm_f(0));
-
- ccw = brw_IF(p, BRW_EXECUTE_1);
- {
- unsigned i;
-
- for (i = 0; i < 3; i++) {
- if (c->offset[VERT_RESULT_COL0] && c->offset[VERT_RESULT_BFC0])
- brw_MOV(p,
- byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_COL0]),
- byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_BFC0]));
-
- if (c->offset[VERT_RESULT_COL1] && c->offset[VERT_RESULT_BFC1])
- brw_MOV(p,
- byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_COL1]),
- byte_offset(c->reg.vertex[i], c->offset[VERT_RESULT_BFC1]));
- }
- }
- brw_ENDIF(p, ccw);
-}
-
-
-
-
-/*
- float iz = 1.0 / dir.z;
- float ac = dir.x * iz;
- float bc = dir.y * iz;
- offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
- offset += MAX2( abs(ac), abs(bc) ) * ctx->Polygon.OffsetFactor;
- offset *= MRD;
-*/
-static void compute_offset( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg off = c->reg.offset;
- struct brw_reg dir = c->reg.dir;
-
- brw_math_invert(p, get_element(off, 2), get_element(dir, 2));
- brw_MUL(p, vec2(off), dir, get_element(off, 2));
-
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_GE,
- brw_abs(get_element(off, 0)),
- brw_abs(get_element(off, 1)));
-
- brw_SEL(p, vec1(off), brw_abs(get_element(off, 0)), brw_abs(get_element(off, 1)));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- brw_MUL(p, vec1(off), off, brw_imm_f(c->key.offset_factor));
- brw_ADD(p, vec1(off), off, brw_imm_f(c->key.offset_units));
-}
-
-
-static void merge_edgeflags( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *is_poly;
- struct brw_reg tmp0 = get_element_ud(c->reg.tmp0, 0);
-
- brw_AND(p, tmp0, get_element_ud(c->reg.R0, 2), brw_imm_ud(PRIM_MASK));
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_EQ,
- tmp0,
- brw_imm_ud(_3DPRIM_POLYGON));
-
- /* Get away with using reg.vertex because we know that this is not
- * a _3DPRIM_TRISTRIP_REVERSE:
- */
- is_poly = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
- brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<8));
- brw_MOV(p, byte_offset(c->reg.vertex[0], c->offset[VERT_RESULT_EDGE]), brw_imm_f(0));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- brw_set_conditionalmod(p, BRW_CONDITIONAL_EQ);
- brw_AND(p, vec1(brw_null_reg()), get_element_ud(c->reg.R0, 2), brw_imm_ud(1<<9));
- brw_MOV(p, byte_offset(c->reg.vertex[2], c->offset[VERT_RESULT_EDGE]), brw_imm_f(0));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- }
- brw_ENDIF(p, is_poly);
-}
-
-
-
-static void apply_one_offset( struct brw_clip_compile *c,
- struct brw_indirect vert )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg pos = deref_4f(vert, c->offset[VERT_RESULT_HPOS]);
- struct brw_reg z = get_element(pos, 2);
-
- brw_ADD(p, z, z, vec1(c->reg.offset));
-}
-
-
-
-/***********************************************************************
- * Output clipped polygon as an unfilled primitive:
- */
-static void emit_lines(struct brw_clip_compile *c,
- boolean do_offset)
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *loop;
- struct brw_instruction *draw_edge;
- struct brw_indirect v0 = brw_indirect(0, 0);
- struct brw_indirect v1 = brw_indirect(1, 0);
- struct brw_indirect v0ptr = brw_indirect(2, 0);
- struct brw_indirect v1ptr = brw_indirect(3, 0);
-
- /* Need a seperate loop for offset:
- */
- if (do_offset) {
- brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
- brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
-
- loop = brw_DO(p, BRW_EXECUTE_1);
- {
- brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
- brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
-
- apply_one_offset(c, v0);
-
- brw_set_conditionalmod(p, BRW_CONDITIONAL_G);
- brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
- }
- brw_WHILE(p, loop);
- }
-
- /* v1ptr = &inlist[nr_verts]
- * *v1ptr = v0
- */
- brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
- brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
- brw_ADD(p, get_addr_reg(v1ptr), get_addr_reg(v0ptr), retype(c->reg.nr_verts, BRW_REGISTER_TYPE_UW));
- brw_ADD(p, get_addr_reg(v1ptr), get_addr_reg(v1ptr), retype(c->reg.nr_verts, BRW_REGISTER_TYPE_UW));
- brw_MOV(p, deref_1uw(v1ptr, 0), deref_1uw(v0ptr, 0));
-
- loop = brw_DO(p, BRW_EXECUTE_1);
- {
- brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
- brw_MOV(p, get_addr_reg(v1), deref_1uw(v0ptr, 2));
- brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
-
- /* draw edge if edgeflag != 0 */
- brw_CMP(p,
- vec1(brw_null_reg()), BRW_CONDITIONAL_NZ,
- deref_1f(v0, c->offset[VERT_RESULT_EDGE]),
- brw_imm_f(0));
- draw_edge = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_START);
- brw_clip_emit_vue(c, v1, 1, 0, (_3DPRIM_LINESTRIP << 2) | R02_PRIM_END);
- }
- brw_ENDIF(p, draw_edge);
-
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
- }
- brw_WHILE(p, loop);
-}
-
-
-
-static void emit_points(struct brw_clip_compile *c,
- boolean do_offset )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *loop;
- struct brw_instruction *draw_point;
-
- struct brw_indirect v0 = brw_indirect(0, 0);
- struct brw_indirect v0ptr = brw_indirect(2, 0);
-
- brw_MOV(p, c->reg.loopcount, c->reg.nr_verts);
- brw_MOV(p, get_addr_reg(v0ptr), brw_address(c->reg.inlist));
-
- loop = brw_DO(p, BRW_EXECUTE_1);
- {
- brw_MOV(p, get_addr_reg(v0), deref_1uw(v0ptr, 0));
- brw_ADD(p, get_addr_reg(v0ptr), get_addr_reg(v0ptr), brw_imm_uw(2));
-
- /* draw if edgeflag != 0
- */
- brw_CMP(p,
- vec1(brw_null_reg()), BRW_CONDITIONAL_NZ,
- deref_1f(v0, c->offset[VERT_RESULT_EDGE]),
- brw_imm_f(0));
- draw_point = brw_IF(p, BRW_EXECUTE_1);
- {
- if (do_offset)
- apply_one_offset(c, v0);
-
- brw_clip_emit_vue(c, v0, 1, 0, (_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END);
- }
- brw_ENDIF(p, draw_point);
-
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- brw_ADD(p, c->reg.loopcount, c->reg.loopcount, brw_imm_d(-1));
- }
- brw_WHILE(p, loop);
-}
-
-
-
-
-
-
-
-static void emit_primitives( struct brw_clip_compile *c,
- unsigned mode,
- boolean do_offset )
-{
- switch (mode) {
- case CLIP_FILL:
- brw_clip_tri_emit_polygon(c);
- break;
-
- case CLIP_LINE:
- emit_lines(c, do_offset);
- break;
-
- case CLIP_POINT:
- emit_points(c, do_offset);
- break;
-
- case CLIP_CULL:
- assert(0);
- break;
- }
-}
-
-
-
-static void emit_unfilled_primitives( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *ccw;
-
- /* Direction culling has already been done.
- */
- if (c->key.fill_ccw != c->key.fill_cw &&
- c->key.fill_ccw != CLIP_CULL &&
- c->key.fill_cw != CLIP_CULL)
- {
- brw_CMP(p,
- vec1(brw_null_reg()),
- BRW_CONDITIONAL_GE,
- get_element(c->reg.dir, 2),
- brw_imm_f(0));
-
- ccw = brw_IF(p, BRW_EXECUTE_1);
- {
- emit_primitives(c, c->key.fill_ccw, c->key.offset_ccw);
- }
- ccw = brw_ELSE(p, ccw);
- {
- emit_primitives(c, c->key.fill_cw, c->key.offset_cw);
- }
- brw_ENDIF(p, ccw);
- }
- else if (c->key.fill_cw != CLIP_CULL) {
- emit_primitives(c, c->key.fill_cw, c->key.offset_cw);
- }
- else if (c->key.fill_ccw != CLIP_CULL) {
- emit_primitives(c, c->key.fill_ccw, c->key.offset_ccw);
- }
-}
-
-
-
-
-static void check_nr_verts( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *if_insn;
-
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_L, c->reg.nr_verts, brw_imm_d(3));
- if_insn = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_kill_thread(c);
- }
- brw_ENDIF(p, if_insn);
-}
-
-
-void brw_emit_unfilled_clip( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *do_clip;
-
-
- c->need_direction = ((c->key.offset_ccw || c->key.offset_cw) ||
- (c->key.fill_ccw != c->key.fill_cw) ||
- c->key.fill_ccw == CLIP_CULL ||
- c->key.fill_cw == CLIP_CULL ||
- c->key.copy_bfc_cw ||
- c->key.copy_bfc_ccw);
-
- brw_clip_tri_alloc_regs(c, 3 + c->key.nr_userclip + 6);
- brw_clip_tri_init_vertices(c);
-
- assert(c->offset[VERT_RESULT_EDGE]);
-
- if (c->key.fill_ccw == CLIP_CULL &&
- c->key.fill_cw == CLIP_CULL) {
- brw_clip_kill_thread(c);
- return;
- }
-
- merge_edgeflags(c);
-
- /* Need to use the inlist indirection here:
- */
- if (c->need_direction)
- compute_tri_direction(c);
-
- if (c->key.fill_ccw == CLIP_CULL ||
- c->key.fill_cw == CLIP_CULL)
- cull_direction(c);
-
- if (c->key.offset_ccw ||
- c->key.offset_cw)
- compute_offset(c);
-
- if (c->key.copy_bfc_ccw ||
- c->key.copy_bfc_cw)
- copy_bfc(c);
-
- /* Need to do this whether we clip or not:
- */
- if (c->key.do_flat_shading)
- brw_clip_tri_flat_shade(c);
-
- brw_clip_init_clipmask(c);
- brw_CMP(p, vec1(brw_null_reg()), BRW_CONDITIONAL_NZ, c->reg.planemask, brw_imm_ud(0));
- do_clip = brw_IF(p, BRW_EXECUTE_1);
- {
- brw_clip_init_planes(c);
- brw_clip_tri(c);
- check_nr_verts(c);
- }
- brw_ENDIF(p, do_clip);
-
- emit_unfilled_primitives(c);
- brw_clip_kill_thread(c);
-}
-
-
-
diff --git a/src/mesa/pipe/i965simple/brw_clip_util.c b/src/mesa/pipe/i965simple/brw_clip_util.c
deleted file mode 100644
index 6d58ceafff..0000000000
--- a/src/mesa/pipe/i965simple/brw_clip_util.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_clip.h"
-
-
-
-
-
-static struct brw_reg get_tmp( struct brw_clip_compile *c )
-{
- struct brw_reg tmp = brw_vec4_grf(c->last_tmp, 0);
-
- if (++c->last_tmp > c->prog_data.total_grf)
- c->prog_data.total_grf = c->last_tmp;
-
- return tmp;
-}
-
-static void release_tmp( struct brw_clip_compile *c, struct brw_reg tmp )
-{
- if (tmp.nr == c->last_tmp-1)
- c->last_tmp--;
-}
-
-
-static struct brw_reg make_plane_ud(unsigned x, unsigned y, unsigned z, unsigned w)
-{
- return brw_imm_ud((w<<24) | (z<<16) | (y<<8) | x);
-}
-
-
-void brw_clip_init_planes( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
-
- if (!c->key.nr_userclip) {
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 0), make_plane_ud( 0, 0, 0xff, 1));
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 1), make_plane_ud( 0, 0, 1, 1));
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 2), make_plane_ud( 0, 0xff, 0, 1));
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 3), make_plane_ud( 0, 1, 0, 1));
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 4), make_plane_ud(0xff, 0, 0, 1));
- brw_MOV(p, get_element_ud(c->reg.fixed_planes, 5), make_plane_ud( 1, 0, 0, 1));
- }
-}
-
-
-
-#define W 3
-
-/* Project 'pos' to screen space (or back again), overwrite with results:
- */
-static void brw_clip_project_position(struct brw_clip_compile *c, struct brw_reg pos )
-{
- struct brw_compile *p = &c->func;
-
- /* calc rhw
- */
- brw_math_invert(p, get_element(pos, W), get_element(pos, W));
-
- /* value.xyz *= value.rhw
- */
- brw_set_access_mode(p, BRW_ALIGN_16);
- brw_MUL(p, brw_writemask(pos, TGSI_WRITEMASK_XYZ), pos, brw_swizzle1(pos, W));
- brw_set_access_mode(p, BRW_ALIGN_1);
-}
-
-
-static void brw_clip_project_vertex( struct brw_clip_compile *c,
- struct brw_indirect vert_addr )
-{
-#if 0
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = get_tmp(c);
-
- /* Fixup position. Extract from the original vertex and re-project
- * to screen space:
- */
- brw_MOV(p, tmp, deref_4f(vert_addr, c->offset[VERT_RESULT_HPOS]));
- brw_clip_project_position(c, tmp);
- brw_MOV(p, deref_4f(vert_addr, c->header_position_offset), tmp);
-
- release_tmp(c, tmp);
-#else
- #warning "disabled"
-#endif
-}
-
-
-
-
-/* Interpolate between two vertices and put the result into a0.0.
- * Increment a0.0 accordingly.
- */
-void brw_clip_interp_vertex( struct brw_clip_compile *c,
- struct brw_indirect dest_ptr,
- struct brw_indirect v0_ptr, /* from */
- struct brw_indirect v1_ptr, /* to */
- struct brw_reg t0,
- boolean force_edgeflag)
-{
-#if 0
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = get_tmp(c);
- unsigned i;
-
- /* Just copy the vertex header:
- */
- brw_copy_indirect_to_indirect(p, dest_ptr, v0_ptr, 1);
-
- /* Iterate over each attribute (could be done in pairs?)
- */
- for (i = 0; i < c->nr_attrs; i++) {
- unsigned delta = i*16 + 32;
-
- if (delta == c->offset[VERT_RESULT_EDGE]) {
- if (force_edgeflag)
- brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(1));
- else
- brw_MOV(p, deref_4f(dest_ptr, delta), deref_4f(v0_ptr, delta));
- }
- else {
- /* Interpolate:
- *
- * New = attr0 + t*attr1 - t*attr0
- */
- brw_MUL(p,
- vec4(brw_null_reg()),
- deref_4f(v1_ptr, delta),
- t0);
-
- brw_MAC(p,
- tmp,
- negate(deref_4f(v0_ptr, delta)),
- t0);
-
- brw_ADD(p,
- deref_4f(dest_ptr, delta),
- deref_4f(v0_ptr, delta),
- tmp);
- }
- }
-
- if (i & 1) {
- unsigned delta = i*16 + 32;
- brw_MOV(p, deref_4f(dest_ptr, delta), brw_imm_f(0));
- }
-
- release_tmp(c, tmp);
-
- /* Recreate the projected (NDC) coordinate in the new vertex
- * header:
- */
- brw_clip_project_vertex(c, dest_ptr );
-#else
- #warning "disabled"
-#endif
-}
-
-
-
-
-#define MAX_MRF 16
-
-void brw_clip_emit_vue(struct brw_clip_compile *c,
- struct brw_indirect vert,
- boolean allocate,
- boolean eot,
- unsigned header)
-{
- struct brw_compile *p = &c->func;
- unsigned start = c->last_mrf;
-
- assert(!(allocate && eot));
-
- /* Cycle through mrf regs - probably futile as we have to wait for
- * the allocation response anyway. Also, the order this function
- * is invoked doesn't correspond to the order the instructions will
- * be executed, so it won't have any effect in many cases.
- */
-#if 0
- if (start + c->nr_regs + 1 >= MAX_MRF)
- start = 0;
-
- c->last_mrf = start + c->nr_regs + 1;
-#endif
-
- /* Copy the vertex from vertn into m1..mN+1:
- */
- brw_copy_from_indirect(p, brw_message_reg(start+1), vert, c->nr_regs);
-
- /* Overwrite PrimType and PrimStart in the message header, for
- * each vertex in turn:
- */
- brw_MOV(p, get_element_ud(c->reg.R0, 2), brw_imm_ud(header));
-
-
- /* Send each vertex as a seperate write to the urb. This
- * is different to the concept in brw_sf_emit.c, where
- * subsequent writes are used to build up a single urb
- * entry. Each of these writes instantiates a seperate
- * urb entry - (I think... what about 'allocate'?)
- */
- brw_urb_WRITE(p,
- allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
- start,
- c->reg.R0,
- allocate,
- 1, /* used */
- c->nr_regs + 1, /* msg length */
- allocate ? 1 : 0, /* response_length */
- eot, /* eot */
- 1, /* writes_complete */
- 0, /* urb offset */
- BRW_URB_SWIZZLE_NONE);
-}
-
-
-
-void brw_clip_kill_thread(struct brw_clip_compile *c)
-{
- struct brw_compile *p = &c->func;
-
- /* Send an empty message to kill the thread and release any
- * allocated urb entry:
- */
- brw_urb_WRITE(p,
- retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
- 0,
- c->reg.R0,
- 0, /* allocate */
- 0, /* used */
- 0, /* msg len */
- 0, /* response len */
- 1, /* eot */
- 1, /* writes complete */
- 0,
- BRW_URB_SWIZZLE_NONE);
-}
-
-
-
-
-struct brw_reg brw_clip_plane0_address( struct brw_clip_compile *c )
-{
- return brw_address(c->reg.fixed_planes);
-}
-
-
-struct brw_reg brw_clip_plane_stride( struct brw_clip_compile *c )
-{
- if (c->key.nr_userclip) {
- return brw_imm_uw(16);
- }
- else {
- return brw_imm_uw(4);
- }
-}
-
-
-/* If flatshading, distribute color from provoking vertex prior to
- * clipping.
- */
-void brw_clip_copy_colors( struct brw_clip_compile *c,
- unsigned to, unsigned from )
-{
-#if 0
- struct brw_compile *p = &c->func;
-
- if (c->offset[VERT_RESULT_COL0])
- brw_MOV(p,
- byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_COL0]),
- byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_COL0]));
-
- if (c->offset[VERT_RESULT_COL1])
- brw_MOV(p,
- byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_COL1]),
- byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_COL1]));
-
- if (c->offset[VERT_RESULT_BFC0])
- brw_MOV(p,
- byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_BFC0]),
- byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_BFC0]));
-
- if (c->offset[VERT_RESULT_BFC1])
- brw_MOV(p,
- byte_offset(c->reg.vertex[to], c->offset[VERT_RESULT_BFC1]),
- byte_offset(c->reg.vertex[from], c->offset[VERT_RESULT_BFC1]));
-#else
- #warning "disabled"
-#endif
-}
-
-
-
-void brw_clip_init_clipmask( struct brw_clip_compile *c )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg incoming = get_element_ud(c->reg.R0, 2);
-
- /* Shift so that lowest outcode bit is rightmost:
- */
- brw_SHR(p, c->reg.planemask, incoming, brw_imm_ud(26));
-
- if (c->key.nr_userclip) {
- struct brw_reg tmp = retype(vec1(get_tmp(c)), BRW_REGISTER_TYPE_UD);
-
- /* Rearrange userclip outcodes so that they come directly after
- * the fixed plane bits.
- */
- brw_AND(p, tmp, incoming, brw_imm_ud(0x3f<<14));
- brw_SHR(p, tmp, tmp, brw_imm_ud(8));
- brw_OR(p, c->reg.planemask, c->reg.planemask, tmp);
-
- release_tmp(c, tmp);
- }
-}
-
diff --git a/src/mesa/pipe/i965simple/brw_context.c b/src/mesa/pipe/i965simple/brw_context.c
deleted file mode 100644
index 5e58701e91..0000000000
--- a/src/mesa/pipe/i965simple/brw_context.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_draw.h"
-#include "brw_vs.h"
-#include "brw_tex_layout.h"
-#include "brw_winsys.h"
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_context.h"
-#include "pipe/p_util.h"
-
-/***************************************
- * Mesa's Driver Functions
- ***************************************/
-
-#ifndef BRW_DEBUG
-int BRW_DEBUG = (0);
-#endif
-
-static void brw_destroy(struct pipe_context *pipe)
-{
- struct brw_context *brw = brw_context(pipe);
-
- FREE(brw);
-}
-
-static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- int x, y, w, h;
- /* FIXME: corny... */
-
- x = 0;
- y = 0;
- w = ps->width;
- h = ps->height;
-
- pipe->surface_fill(pipe, ps, x, y, w, h, clearValue);
-}
-
-
-static int
-brw_get_param(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 8;
- case PIPE_CAP_NPOT_TEXTURES:
- return 1;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 1;
- case PIPE_CAP_GLSL:
- return 0;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 11; /* max 1024x1024 */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 11; /* max 1024x1024 */
- default:
- return 0;
- }
-}
-
-
-static float
-brw_get_paramf(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 7.5;
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0;
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 4.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0;
-
- default:
- return 0;
- }
-}
-
-static boolean
-brw_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
-#if 0
- /* XXX: This is broken -- rewrite if still needed. */
- static const unsigned tex_supported[] = {
- PIPE_FORMAT_U_R8_G8_B8_A8,
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_L8_A8,
- PIPE_FORMAT_YCBCR,
- PIPE_FORMAT_YCBCR_REV,
- PIPE_FORMAT_S8_Z24,
- };
-
-
- /* Actually a lot more than this - add later:
- */
- static const unsigned render_supported[] = {
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
- };
-
- /*
- */
- static const unsigned z_stencil_supported[] = {
- PIPE_FORMAT_U_Z16,
- PIPE_FORMAT_U_Z32,
- PIPE_FORMAT_S8_Z24,
- };
-
- switch (type) {
- case PIPE_RENDER_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
- case PIPE_TEX_FORMAT:
- *numFormats = Elements(tex_supported);
- return render_supported;
-
- case PIPE_Z_STENCIL_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
- default:
- *numFormats = 0;
- return NULL;
- }
-#else
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- };
- return FALSE;
-#endif
-}
-
-
-
-
-struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
- struct brw_winsys *brw_winsys,
- unsigned pci_id)
-{
- struct brw_context *brw;
-
- pipe_winsys->printf(pipe_winsys,
- "%s: creating brw_context with pci id 0x%x\n",
- __FUNCTION__, pci_id);
-
- brw = CALLOC_STRUCT(brw_context);
- if (brw == NULL)
- return NULL;
-
- brw->winsys = brw_winsys;
- brw->pipe.winsys = pipe_winsys;
-
- brw->pipe.destroy = brw_destroy;
- brw->pipe.is_format_supported = brw_is_format_supported;
- brw->pipe.get_param = brw_get_param;
- brw->pipe.get_paramf = brw_get_paramf;
- brw->pipe.clear = brw_clear;
- brw->pipe.texture_create = brw_texture_create;
- brw->pipe.texture_release = brw_texture_release;
-
- brw_init_surface_functions(brw);
- brw_init_state_functions(brw);
- brw_init_flush_functions(brw);
- brw_init_string_functions(brw);
- brw_init_draw_functions( brw );
-
-
- brw_init_state( brw );
-
- brw->pci_id = pci_id;
- brw->dirty = ~0;
- brw->hardware_dirty = ~0;
-
- memset(&brw->wm.bind, ~0, sizeof(brw->wm.bind));
-
- return &brw->pipe;
-}
-
diff --git a/src/mesa/pipe/i965simple/brw_context.h b/src/mesa/pipe/i965simple/brw_context.h
deleted file mode 100644
index 65664d853d..0000000000
--- a/src/mesa/pipe/i965simple/brw_context.h
+++ /dev/null
@@ -1,690 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRWCONTEXT_INC
-#define BRWCONTEXT_INC
-
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-
-#include "brw_structs.h"
-#include "brw_winsys.h"
-
-
-/* Glossary:
- *
- * URB - uniform resource buffer. A mid-sized buffer which is
- * partitioned between the fixed function units and used for passing
- * values (vertices, primitives, constants) between them.
- *
- * CURBE - constant URB entry. An urb region (entry) used to hold
- * constant values which the fixed function units can be instructed to
- * preload into the GRF when spawining a thread.
- *
- * VUE - vertex URB entry. An urb entry holding a vertex and usually
- * a vertex header. The header contains control information and
- * things like primitive type, Begin/end flags and clip codes.
- *
- * PUE - primitive URB entry. An urb entry produced by the setup (SF)
- * unit holding rasterization and interpolation parameters.
- *
- * GRF - general register file. One of several register files
- * addressable by programmed threads. The inputs (r0, payload, curbe,
- * urb) of the thread are preloaded to this area before the thread is
- * spawned. The registers are individually 8 dwords wide and suitable
- * for general usage. Registers holding thread input values are not
- * special and may be overwritten.
- *
- * MRF - message register file. Threads communicate (and terminate)
- * by sending messages. Message parameters are placed in contigous
- * MRF registers. All program output is via these messages. URB
- * entries are populated by sending a message to the shared URB
- * function containing the new data, together with a control word,
- * often an unmodified copy of R0.
- *
- * R0 - GRF register 0. Typically holds control information used when
- * sending messages to other threads.
- *
- * EU or GEN4 EU: The name of the programmable subsystem of the
- * i965 hardware. Threads are executed by the EU, the registers
- * described above are part of the EU architecture.
- *
- * Fixed function units:
- *
- * CS - Command streamer. Notional first unit, little software
- * interaction. Holds the URB entries used for constant data, ie the
- * CURBEs.
- *
- * VF/VS - Vertex Fetch / Vertex Shader. The fixed function part of
- * this unit is responsible for pulling vertices out of vertex buffers
- * in vram and injecting them into the processing pipe as VUEs. If
- * enabled, it first passes them to a VS thread which is a good place
- * for the driver to implement any active vertex shader.
- *
- * GS - Geometry Shader. This corresponds to a new DX10 concept. If
- * enabled, incoming strips etc are passed to GS threads in individual
- * line/triangle/point units. The GS thread may perform arbitary
- * computation and emit whatever primtives with whatever vertices it
- * chooses. This makes GS an excellent place to implement GL's
- * unfilled polygon modes, though of course it is capable of much
- * more. Additionally, GS is used to translate away primitives not
- * handled by latter units, including Quads and Lineloops.
- *
- * CS - Clipper. Mesa's clipping algorithms are imported to run on
- * this unit. The fixed function part performs cliptesting against
- * the 6 fixed clipplanes and makes descisions on whether or not the
- * incoming primitive needs to be passed to a thread for clipping.
- * User clip planes are handled via cooperation with the VS thread.
- *
- * SF - Strips Fans or Setup: Triangles are prepared for
- * rasterization. Interpolation coefficients are calculated.
- * Flatshading and two-side lighting usually performed here.
- *
- * WM - Windower. Interpolation of vertex attributes performed here.
- * Fragment shader implemented here. SIMD aspects of EU taken full
- * advantage of, as pixels are processed in blocks of 16.
- *
- * CC - Color Calculator. No EU threads associated with this unit.
- * Handles blending and (presumably) depth and stencil testing.
- */
-
-#define BRW_MAX_CURBE (32*16)
-
-struct brw_context;
-struct brw_winsys;
-
-
-/* Raised when we receive new state across the pipe interface:
- */
-#define BRW_NEW_VIEWPORT 0x1
-#define BRW_NEW_RASTERIZER 0x2
-#define BRW_NEW_FS 0x4
-#define BRW_NEW_BLEND 0x8
-#define BRW_NEW_CLIP 0x10
-#define BRW_NEW_SCISSOR 0x20
-#define BRW_NEW_STIPPLE 0x40
-#define BRW_NEW_FRAMEBUFFER 0x80
-#define BRW_NEW_ALPHA_TEST 0x100
-#define BRW_NEW_DEPTH_STENCIL 0x200
-#define BRW_NEW_SAMPLER 0x400
-#define BRW_NEW_TEXTURE 0x800
-#define BRW_NEW_CONSTANTS 0x1000
-#define BRW_NEW_VBO 0x2000
-#define BRW_NEW_VS 0x4000
-
-/* Raised for other internal events:
- */
-#define BRW_NEW_URB_FENCE 0x10000
-#define BRW_NEW_PSP 0x20000
-#define BRW_NEW_CURBE_OFFSETS 0x40000
-#define BRW_NEW_REDUCED_PRIMITIVE 0x80000
-#define BRW_NEW_PRIMITIVE 0x100000
-#define BRW_NEW_SCENE 0x200000
-#define BRW_NEW_SF_LINKAGE 0x400000
-
-extern int BRW_DEBUG;
-
-#define DEBUG_TEXTURE 0x1
-#define DEBUG_STATE 0x2
-#define DEBUG_IOCTL 0x4
-#define DEBUG_PRIMS 0x8
-#define DEBUG_VERTS 0x10
-#define DEBUG_FALLBACKS 0x20
-#define DEBUG_VERBOSE 0x40
-#define DEBUG_DRI 0x80
-#define DEBUG_DMA 0x100
-#define DEBUG_SANITY 0x200
-#define DEBUG_SYNC 0x400
-#define DEBUG_SLEEP 0x800
-#define DEBUG_PIXEL 0x1000
-#define DEBUG_STATS 0x2000
-#define DEBUG_TILE 0x4000
-#define DEBUG_SINGLE_THREAD 0x8000
-#define DEBUG_WM 0x10000
-#define DEBUG_URB 0x20000
-#define DEBUG_VS 0x40000
-#define DEBUG_BATCH 0x80000
-#define DEBUG_BUFMGR 0x100000
-#define DEBUG_BLIT 0x200000
-#define DEBUG_REGION 0x400000
-#define DEBUG_MIPTREE 0x800000
-
-#define DBG(...) do { \
- if (BRW_DEBUG & FILE_DEBUG_FLAG) \
- brw->pipe.winsys->printf(brw->pipe.winsys, __VA_ARGS__); \
-} while(0)
-
-#define PRINT(...) do { \
- brw->pipe.winsys->printf(brw->pipe.winsys, __VA_ARGS__); \
-} while(0)
-
-struct brw_state_flags {
- unsigned cache;
- unsigned brw;
-};
-
-
-struct brw_shader_info {
- int nr_regs[8]; /* TGSI_FILE_* */
-};
-
-
-
-struct brw_vertex_program {
- struct pipe_shader_state program;
- struct brw_shader_info info;
- int id;
-};
-
-
-
-struct brw_fragment_program {
- struct pipe_shader_state program;
- struct brw_shader_info info;
-
- boolean UsesDepth;
- boolean UsesKill;
- boolean ComputesDepth;
- int id;
-};
-
-
-
-
-struct pipe_setup_linkage {
- struct {
- unsigned vp_output:5;
- unsigned interp_mode:4;
- unsigned bf_vp_output:5;
- } fp_input[PIPE_MAX_SHADER_INPUTS];
-
- unsigned fp_input_count:5;
- unsigned max_vp_output:5;
-};
-
-
-
-struct brw_texture {
- struct pipe_texture base;
-
- /* Derived from the above:
- */
- unsigned pitch;
- unsigned depth_pitch; /* per-image on i945? */
- unsigned total_height;
-
- unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
-
- /* Explicitly store the offset of each image for each cube face or
- * depth value. Pretty much have to accept that hardware formats
- * are going to be so diverse that there is no unified way to
- * compute the offsets of depth/cube images within a mipmap level,
- * so have to store them as a lookup table:
- */
- unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */
-
- /* Includes image offset tables:
- */
- unsigned level_offset[PIPE_MAX_TEXTURE_LEVELS];
-
- /* The data is held here:
- */
- struct pipe_buffer *buffer;
-};
-
-/* Data about a particular attempt to compile a program. Note that
- * there can be many of these, each in a different GL state
- * corresponding to a different brw_wm_prog_key struct, with different
- * compiled programs:
- */
-/* Data about a particular attempt to compile a program. Note that
- * there can be many of these, each in a different GL state
- * corresponding to a different brw_wm_prog_key struct, with different
- * compiled programs:
- */
-
-struct brw_wm_prog_data {
- unsigned curb_read_length;
- unsigned urb_read_length;
-
- unsigned first_curbe_grf;
- unsigned total_grf;
- unsigned total_scratch;
-
- /* Internally generated constants for the CURBE. These are loaded
- * ahead of the data from the constant buffer.
- */
- const float internal_const[8];
- unsigned nr_internal_consts;
- unsigned max_const;
-
- boolean error;
-};
-
-struct brw_sf_prog_data {
- unsigned urb_read_length;
- unsigned total_grf;
-
- /* Each vertex may have upto 12 attributes, 4 components each,
- * except WPOS which requires only 2. (11*4 + 2) == 44 ==> 11
- * rows.
- *
- * Actually we use 4 for each, so call it 12 rows.
- */
- unsigned urb_entry_size;
-};
-
-struct brw_clip_prog_data {
- unsigned curb_read_length; /* user planes? */
- unsigned clip_mode;
- unsigned urb_read_length;
- unsigned total_grf;
-};
-
-struct brw_gs_prog_data {
- unsigned urb_read_length;
- unsigned total_grf;
-};
-
-struct brw_vs_prog_data {
- unsigned curb_read_length;
- unsigned urb_read_length;
- unsigned total_grf;
- unsigned outputs_written;
-
- unsigned inputs_read;
-
- unsigned max_const;
-
- float imm_buf[PIPE_MAX_CONSTANT][4];
- unsigned num_imm;
- unsigned num_consts;
-
- /* Used for calculating urb partitions:
- */
- unsigned urb_entry_size;
-};
-
-
-#define BRW_MAX_TEX_UNIT 8
-#define BRW_WM_MAX_SURF BRW_MAX_TEX_UNIT + 1
-
-/* Create a fixed sized struct for caching binding tables:
- */
-struct brw_surface_binding_table {
- unsigned surf_ss_offset[BRW_WM_MAX_SURF];
-};
-
-
-struct brw_cache;
-
-struct brw_mem_pool {
- struct pipe_buffer *buffer;
-
- unsigned size;
- unsigned offset; /* offset of first free byte */
-
- struct brw_context *brw;
-};
-
-struct brw_cache_item {
- unsigned hash;
- unsigned key_size; /* for variable-sized keys */
- const void *key;
-
- unsigned offset; /* offset within pool's buffer */
- unsigned data_size;
-
- struct brw_cache_item *next;
-};
-
-
-
-struct brw_cache {
- unsigned id;
-
- const char *name;
-
- struct brw_context *brw;
- struct brw_mem_pool *pool;
-
- struct brw_cache_item **items;
- unsigned size, n_items;
-
- unsigned key_size; /* for fixed-size keys */
- unsigned aux_size;
-
- unsigned last_addr; /* offset of active item */
-};
-
-
-
-
-/* Considered adding a member to this struct to document which flags
- * an update might raise so that ordering of the state atoms can be
- * checked or derived at runtime. Dropped the idea in favor of having
- * a debug mode where the state is monitored for flags which are
- * raised that have already been tested against.
- */
-struct brw_tracked_state {
- struct brw_state_flags dirty;
- void (*update)( struct brw_context *brw );
-};
-
-
-/* Flags for brw->state.cache.
- */
-#define CACHE_NEW_CC_VP (1<<BRW_CC_VP)
-#define CACHE_NEW_CC_UNIT (1<<BRW_CC_UNIT)
-#define CACHE_NEW_WM_PROG (1<<BRW_WM_PROG)
-#define CACHE_NEW_SAMPLER_DEFAULT_COLOR (1<<BRW_SAMPLER_DEFAULT_COLOR)
-#define CACHE_NEW_SAMPLER (1<<BRW_SAMPLER)
-#define CACHE_NEW_WM_UNIT (1<<BRW_WM_UNIT)
-#define CACHE_NEW_SF_PROG (1<<BRW_SF_PROG)
-#define CACHE_NEW_SF_VP (1<<BRW_SF_VP)
-#define CACHE_NEW_SF_UNIT (1<<BRW_SF_UNIT)
-#define CACHE_NEW_VS_UNIT (1<<BRW_VS_UNIT)
-#define CACHE_NEW_VS_PROG (1<<BRW_VS_PROG)
-#define CACHE_NEW_GS_UNIT (1<<BRW_GS_UNIT)
-#define CACHE_NEW_GS_PROG (1<<BRW_GS_PROG)
-#define CACHE_NEW_CLIP_VP (1<<BRW_CLIP_VP)
-#define CACHE_NEW_CLIP_UNIT (1<<BRW_CLIP_UNIT)
-#define CACHE_NEW_CLIP_PROG (1<<BRW_CLIP_PROG)
-#define CACHE_NEW_SURFACE (1<<BRW_SS_SURFACE)
-#define CACHE_NEW_SURF_BIND (1<<BRW_SS_SURF_BIND)
-
-
-
-
-enum brw_mempool_id {
- BRW_GS_POOL,
- BRW_SS_POOL,
- BRW_MAX_POOL
-};
-
-
-struct brw_cached_batch_item {
- struct header *header;
- unsigned sz;
- struct brw_cached_batch_item *next;
-};
-
-
-
-/* Protect against a future where PIPE_ATTRIB_MAX > 32. Wouldn't life
- * be easier if C allowed arrays of packed elements?
- */
-#define ATTRIB_BIT_DWORDS ((PIPE_ATTRIB_MAX+31)/32)
-
-
-
-
-struct brw_vertex_info {
- unsigned varying; /* varying:1[PIPE_ATTRIB_MAX] */
- unsigned sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[PIPE_ATTRIB_MAX] */
-};
-
-
-
-
-
-struct brw_context
-{
- struct pipe_context pipe;
- struct brw_winsys *winsys;
-
- unsigned primitive;
- unsigned reduced_primitive;
-
- boolean emit_state_always;
-
- struct {
- struct brw_state_flags dirty;
- } state;
-
-
- struct {
- const struct pipe_blend_state *Blend;
- const struct pipe_depth_stencil_alpha_state *DepthStencil;
- const struct pipe_poly_stipple *PolygonStipple;
- const struct pipe_rasterizer_state *Raster;
- const struct pipe_sampler_state *Samplers[PIPE_MAX_SAMPLERS];
- const struct brw_vertex_program *VertexProgram;
- const struct brw_fragment_program *FragmentProgram;
-
- struct pipe_clip_state Clip;
- struct pipe_blend_color BlendColor;
- struct pipe_scissor_state Scissor;
- struct pipe_viewport_state Viewport;
- struct pipe_framebuffer_state FrameBuffer;
-
- const struct pipe_constant_buffer *Constants[2];
- const struct brw_texture *Texture[PIPE_MAX_SAMPLERS];
- } attribs;
-
- struct brw_mem_pool pool[BRW_MAX_POOL];
- struct brw_cache cache[BRW_MAX_CACHE];
- struct brw_cached_batch_item *cached_batch_items;
-
- struct {
-
- /* Arrays with buffer objects to copy non-bufferobj arrays into
- * for upload:
- */
- struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX];
-
- struct brw_vertex_element_state inputs[PIPE_ATTRIB_MAX];
-
-#define BRW_NR_UPLOAD_BUFS 17
-#define BRW_UPLOAD_INIT_SIZE (128*1024)
-
- /* Summary of size and varying of active arrays, so we can check
- * for changes to this state:
- */
- struct brw_vertex_info info;
- } vb;
-
-
- unsigned hardware_dirty;
- unsigned dirty;
- unsigned pci_id;
- /* BRW_NEW_URB_ALLOCATIONS:
- */
- struct {
- unsigned vsize; /* vertex size plus header in urb registers */
- unsigned csize; /* constant buffer size in urb registers */
- unsigned sfsize; /* setup data size in urb registers */
-
- boolean constrained;
-
- unsigned nr_vs_entries;
- unsigned nr_gs_entries;
- unsigned nr_clip_entries;
- unsigned nr_sf_entries;
- unsigned nr_cs_entries;
-
-/* unsigned vs_size; */
-/* unsigned gs_size; */
-/* unsigned clip_size; */
-/* unsigned sf_size; */
-/* unsigned cs_size; */
-
- unsigned vs_start;
- unsigned gs_start;
- unsigned clip_start;
- unsigned sf_start;
- unsigned cs_start;
- } urb;
-
-
- /* BRW_NEW_CURBE_OFFSETS:
- */
- struct {
- unsigned wm_start;
- unsigned wm_size;
- unsigned clip_start;
- unsigned clip_size;
- unsigned vs_start;
- unsigned vs_size;
- unsigned total_size;
-
- unsigned gs_offset;
-
- float *last_buf;
- unsigned last_bufsz;
- } curbe;
-
- struct {
- struct brw_vs_prog_data *prog_data;
-
- unsigned prog_gs_offset;
- unsigned state_gs_offset;
- } vs;
-
- struct {
- struct brw_gs_prog_data *prog_data;
-
- boolean prog_active;
- unsigned prog_gs_offset;
- unsigned state_gs_offset;
- } gs;
-
- struct {
- struct brw_clip_prog_data *prog_data;
-
- unsigned prog_gs_offset;
- unsigned vp_gs_offset;
- unsigned state_gs_offset;
- } clip;
-
-
- struct {
- struct brw_sf_prog_data *prog_data;
-
- struct pipe_setup_linkage linkage;
-
- unsigned prog_gs_offset;
- unsigned vp_gs_offset;
- unsigned state_gs_offset;
- } sf;
-
- struct {
- struct brw_wm_prog_data *prog_data;
-
-// struct brw_wm_compiler *compile_data;
-
-
- /**
- * Array of sampler state uploaded at sampler_gs_offset of BRW_SAMPLER
- * cache
- */
- struct brw_sampler_state sampler[BRW_MAX_TEX_UNIT];
-
- unsigned render_surf;
- unsigned nr_surfaces;
-
- unsigned max_threads;
- struct pipe_buffer *scratch_buffer;
- unsigned scratch_buffer_size;
-
- unsigned sampler_count;
- unsigned sampler_gs_offset;
-
- struct brw_surface_binding_table bind;
- unsigned bind_ss_offset;
-
- unsigned prog_gs_offset;
- unsigned state_gs_offset;
- } wm;
-
-
- struct {
- unsigned vp_gs_offset;
- unsigned state_gs_offset;
- } cc;
-
-
- /* Used to give every program string a unique id
- */
- unsigned program_id;
-};
-
-
-#define BRW_PACKCOLOR8888(r,g,b,a) ((r<<24) | (g<<16) | (b<<8) | a)
-
-
-/*======================================================================
- * brw_vtbl.c
- */
-void brw_do_flush( struct brw_context *brw,
- unsigned flags );
-
-
-/*======================================================================
- * brw_state.c
- */
-void brw_validate_state(struct brw_context *brw);
-void brw_init_state(struct brw_context *brw);
-void brw_destroy_state(struct brw_context *brw);
-
-
-/*======================================================================
- * brw_tex.c
- */
-void brwUpdateTextureState( struct brw_context *brw );
-
-
-/* brw_urb.c
- */
-void brw_upload_urb_fence(struct brw_context *brw);
-
-void brw_upload_constant_buffer_state(struct brw_context *brw);
-
-void brw_init_surface_functions(struct brw_context *brw);
-void brw_init_state_functions(struct brw_context *brw);
-void brw_init_flush_functions(struct brw_context *brw);
-void brw_init_string_functions(struct brw_context *brw);
-
-/*======================================================================
- * Inline conversion functions. These are better-typed than the
- * macros used previously:
- */
-static inline struct brw_context *
-brw_context( struct pipe_context *ctx )
-{
- return (struct brw_context *)ctx;
-}
-
-#endif
-
diff --git a/src/mesa/pipe/i965simple/brw_curbe.c b/src/mesa/pipe/i965simple/brw_curbe.c
deleted file mode 100644
index 52bbd525c1..0000000000
--- a/src/mesa/pipe/i965simple/brw_curbe.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_state.h"
-#include "brw_batch.h"
-#include "brw_util.h"
-#include "brw_wm.h"
-#include "pipe/p_state.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-
-#define FILE_DEBUG_FLAG DEBUG_FALLBACKS
-
-/* Partition the CURBE between the various users of constant values:
- */
-static void calculate_curbe_offsets( struct brw_context *brw )
-{
- /* CACHE_NEW_WM_PROG */
- unsigned nr_fp_regs = align(brw->wm.prog_data->max_const, 16);
-
- /* BRW_NEW_VERTEX_PROGRAM */
- unsigned nr_vp_regs = align(brw->vs.prog_data->max_const, 16);
- unsigned nr_clip_regs = 0;
- unsigned total_regs;
-
-#if 0
- /* BRW_NEW_CLIP ? */
- if (brw->attribs.Transform->ClipPlanesEnabled) {
- unsigned nr_planes = 6 + brw_count_bits(brw->attribs.Transform->ClipPlanesEnabled);
- nr_clip_regs = align(nr_planes * 4, 16);
- }
-#endif
-
-
- total_regs = nr_fp_regs + nr_vp_regs + nr_clip_regs;
-
- /* This can happen - what to do? Probably rather than falling
- * back, the best thing to do is emit programs which code the
- * constants as immediate values. Could do this either as a static
- * cap on WM and VS, or adaptively.
- *
- * Unfortunately, this is currently dependent on the results of the
- * program generation process (in the case of wm), so this would
- * introduce the need to re-generate programs in the event of a
- * curbe allocation failure.
- */
- /* Max size is 32 - just large enough to
- * hold the 128 parameters allowed by
- * the fragment and vertex program
- * api's. It's not clear what happens
- * when both VP and FP want to use 128
- * parameters, though.
- */
- assert(total_regs <= 32);
-
- /* Lazy resize:
- */
- if (nr_fp_regs > brw->curbe.wm_size ||
- nr_vp_regs > brw->curbe.vs_size ||
- nr_clip_regs != brw->curbe.clip_size ||
- (total_regs < brw->curbe.total_size / 4 &&
- brw->curbe.total_size > 16)) {
-
- unsigned reg = 0;
-
- /* Calculate a new layout:
- */
- reg = 0;
- brw->curbe.wm_start = reg;
- brw->curbe.wm_size = nr_fp_regs; reg += nr_fp_regs;
- brw->curbe.clip_start = reg;
- brw->curbe.clip_size = nr_clip_regs; reg += nr_clip_regs;
- brw->curbe.vs_start = reg;
- brw->curbe.vs_size = nr_vp_regs; reg += nr_vp_regs;
- brw->curbe.total_size = reg;
-
-#if 0
- if (0)
- DBG("curbe wm %d+%d clip %d+%d vs %d+%d\n",
- brw->curbe.wm_start,
- brw->curbe.wm_size,
- brw->curbe.clip_start,
- brw->curbe.clip_size,
- brw->curbe.vs_start,
- brw->curbe.vs_size );
-#endif
-
- brw->state.dirty.brw |= BRW_NEW_CURBE_OFFSETS;
- }
-}
-
-
-const struct brw_tracked_state brw_curbe_offsets = {
- .dirty = {
- .brw = (BRW_NEW_CLIP |
- BRW_NEW_VS),
- .cache = CACHE_NEW_WM_PROG
- },
- .update = calculate_curbe_offsets
-};
-
-
-
-/* Define the number of curbes within CS's urb allocation. Multiple
- * urb entries -> multiple curbes. These will be used by
- * fixed-function hardware in a double-buffering scheme to avoid a
- * pipeline stall each time the contents of the curbe is changed.
- */
-void brw_upload_constant_buffer_state(struct brw_context *brw)
-{
- struct brw_constant_buffer_state cbs;
- memset(&cbs, 0, sizeof(cbs));
-
- /* It appears that this is the state packet for the CS unit, ie. the
- * urb entries detailed here are housed in the CS range from the
- * URB_FENCE command.
- */
- cbs.header.opcode = CMD_CONST_BUFFER_STATE;
- cbs.header.length = sizeof(cbs)/4 - 2;
-
- /* BRW_NEW_URB_FENCE */
- cbs.bits0.nr_urb_entries = brw->urb.nr_cs_entries;
- cbs.bits0.urb_entry_size = brw->urb.csize - 1;
-
- assert(brw->urb.nr_cs_entries);
- BRW_CACHED_BATCH_STRUCT(brw, &cbs);
-}
-
-
-static float fixed_plane[6][4] = {
- { 0, 0, -1, 1 },
- { 0, 0, 1, 1 },
- { 0, -1, 0, 1 },
- { 0, 1, 0, 1 },
- {-1, 0, 0, 1 },
- { 1, 0, 0, 1 }
-};
-
-/* Upload a new set of constants. Too much variability to go into the
- * cache mechanism, but maybe would benefit from a comparison against
- * the current uploaded set of constants.
- */
-static void upload_constant_buffer(struct brw_context *brw)
-{
- struct brw_mem_pool *pool = &brw->pool[BRW_GS_POOL];
- unsigned sz = brw->curbe.total_size;
- unsigned bufsz = sz * sizeof(float);
- float *buf;
- unsigned i;
-
-
- if (sz == 0) {
- struct brw_constant_buffer cb;
- cb.header.opcode = CMD_CONST_BUFFER;
- cb.header.length = sizeof(cb)/4 - 2;
- cb.header.valid = 0;
- cb.bits0.buffer_length = 0;
- cb.bits0.buffer_address = 0;
- BRW_BATCH_STRUCT(brw, &cb);
-
- if (brw->curbe.last_buf) {
- free(brw->curbe.last_buf);
- brw->curbe.last_buf = NULL;
- brw->curbe.last_bufsz = 0;
- }
-
- return;
- }
-
- buf = (float *)malloc(bufsz);
-
- memset(buf, 0, bufsz);
-
- if (brw->curbe.wm_size) {
- unsigned offset = brw->curbe.wm_start * 16;
-
- /* First the constant buffer constants:
- */
-
- /* Then any internally generated constants:
- */
- for (i = 0; i < brw->wm.prog_data->nr_internal_consts; i++)
- buf[offset + i] = brw->wm.prog_data->internal_const[i];
-
- assert(brw->wm.prog_data->max_const ==
- brw->wm.prog_data->nr_internal_consts);
- }
-
-
- /* The clipplanes are actually delivered to both CLIP and VS units.
- * VS uses them to calculate the outcode bitmasks.
- */
- if (brw->curbe.clip_size) {
- unsigned offset = brw->curbe.clip_start * 16;
- unsigned j;
-
- /* If any planes are going this way, send them all this way:
- */
- for (i = 0; i < 6; i++) {
- buf[offset + i * 4 + 0] = fixed_plane[i][0];
- buf[offset + i * 4 + 1] = fixed_plane[i][1];
- buf[offset + i * 4 + 2] = fixed_plane[i][2];
- buf[offset + i * 4 + 3] = fixed_plane[i][3];
- }
-
- /* Clip planes: BRW_NEW_CLIP:
- */
- for (j = 0; j < brw->attribs.Clip.nr; j++) {
- buf[offset + i * 4 + 0] = brw->attribs.Clip.ucp[j][0];
- buf[offset + i * 4 + 1] = brw->attribs.Clip.ucp[j][1];
- buf[offset + i * 4 + 2] = brw->attribs.Clip.ucp[j][2];
- buf[offset + i * 4 + 3] = brw->attribs.Clip.ucp[j][3];
- i++;
- }
- }
-
-
- if (brw->curbe.vs_size) {
- unsigned offset = brw->curbe.vs_start * 16;
- /*unsigned nr = vp->max_const;*/
- const struct pipe_constant_buffer *cbuffer = brw->attribs.Constants[0];
- struct pipe_winsys *ws = brw->pipe.winsys;
- /* FIXME: buffer size is num_consts + num_immediates */
- if (brw->vs.prog_data->num_consts) {
- /* map the vertex constant buffer and copy to curbe: */
- void *data = ws->buffer_map(ws, cbuffer->buffer, 0);
- /* FIXME: this is wrong. the cbuffer->size currently
- * represents size of consts + immediates. so if we'll
- * have both we'll copy over the end of the buffer
- * with the subsequent memcpy */
- memcpy(&buf[offset], data, cbuffer->size);
- ws->buffer_unmap(ws, cbuffer->buffer);
- offset += cbuffer->size;
- }
- /*immediates*/
- if (brw->vs.prog_data->num_imm) {
- memcpy(&buf[offset], brw->vs.prog_data->imm_buf,
- brw->vs.prog_data->num_imm * 4 * sizeof(float));
- }
- }
-
- if (1) {
- for (i = 0; i < sz; i+=4)
- debug_printf("curbe %d.%d: %f %f %f %f\n", i/8, i&4,
- buf[i+0], buf[i+1], buf[i+2], buf[i+3]);
-
- debug_printf("last_buf %p buf %p sz %d/%d cmp %d\n",
- brw->curbe.last_buf, buf,
- bufsz, brw->curbe.last_bufsz,
- brw->curbe.last_buf ? memcmp(buf, brw->curbe.last_buf, bufsz) : -1);
- }
-
- if (brw->curbe.last_buf &&
- bufsz == brw->curbe.last_bufsz &&
- memcmp(buf, brw->curbe.last_buf, bufsz) == 0) {
- free(buf);
-/* return; */
- }
- else {
- if (brw->curbe.last_buf)
- free(brw->curbe.last_buf);
- brw->curbe.last_buf = buf;
- brw->curbe.last_bufsz = bufsz;
-
-
- if (!brw_pool_alloc(pool,
- bufsz,
- 1 << 6,
- &brw->curbe.gs_offset)) {
- debug_printf("out of GS memory for curbe\n");
- assert(0);
- return;
- }
-
-
- /* Copy data to the buffer:
- */
- brw->winsys->buffer_subdata_typed(brw->winsys,
- pool->buffer,
- brw->curbe.gs_offset,
- bufsz,
- buf,
- BRW_CONSTANT_BUFFER );
- }
-
- /* TODO: only emit the constant_buffer packet when necessary, ie:
- - contents have changed
- - offset has changed
- - hw requirements due to other packets emitted.
- */
- {
- struct brw_constant_buffer cb;
-
- memset(&cb, 0, sizeof(cb));
-
- cb.header.opcode = CMD_CONST_BUFFER;
- cb.header.length = sizeof(cb)/4 - 2;
- cb.header.valid = 1;
- cb.bits0.buffer_length = sz - 1;
- cb.bits0.buffer_address = brw->curbe.gs_offset >> 6;
-
- /* Because this provokes an action (ie copy the constants into the
- * URB), it shouldn't be shortcircuited if identical to the
- * previous time - because eg. the urb destination may have
- * changed, or the urb contents different to last time.
- *
- * Note that the data referred to is actually copied internally,
- * not just used in place according to passed pointer.
- *
- * It appears that the CS unit takes care of using each available
- * URB entry (Const URB Entry == CURBE) in turn, and issuing
- * flushes as necessary when doublebuffering of CURBEs isn't
- * possible.
- */
- BRW_BATCH_STRUCT(brw, &cb);
- }
-}
-
-/* This tracked state is unique in that the state it monitors varies
- * dynamically depending on the parameters tracked by the fragment and
- * vertex programs. This is the template used as a starting point,
- * each context will maintain a copy of this internally and update as
- * required.
- */
-const struct brw_tracked_state brw_constant_buffer = {
- .dirty = {
- .brw = (BRW_NEW_CLIP |
- BRW_NEW_CONSTANTS |
- BRW_NEW_URB_FENCE | /* Implicit - hardware requires this, not used above */
- BRW_NEW_PSP | /* Implicit - hardware requires this, not used above */
- BRW_NEW_CURBE_OFFSETS),
- .cache = (CACHE_NEW_WM_PROG)
- },
- .update = upload_constant_buffer
-};
-
diff --git a/src/mesa/pipe/i965simple/brw_defines.h b/src/mesa/pipe/i965simple/brw_defines.h
deleted file mode 100644
index 9379a397f6..0000000000
--- a/src/mesa/pipe/i965simple/brw_defines.h
+++ /dev/null
@@ -1,852 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_DEFINES_H
-#define BRW_DEFINES_H
-
-/*
- */
-#define MI_NOOP 0x00
-#define MI_USER_INTERRUPT 0x02
-#define MI_WAIT_FOR_EVENT 0x03
-#define MI_FLUSH 0x04
-#define MI_REPORT_HEAD 0x07
-#define MI_ARB_ON_OFF 0x08
-#define MI_BATCH_BUFFER_END 0x0A
-#define MI_OVERLAY_FLIP 0x11
-#define MI_LOAD_SCAN_LINES_INCL 0x12
-#define MI_LOAD_SCAN_LINES_EXCL 0x13
-#define MI_DISPLAY_BUFFER_INFO 0x14
-#define MI_SET_CONTEXT 0x18
-#define MI_STORE_DATA_IMM 0x20
-#define MI_STORE_DATA_INDEX 0x21
-#define MI_LOAD_REGISTER_IMM 0x22
-#define MI_STORE_REGISTER_MEM 0x24
-#define MI_BATCH_BUFFER_START 0x31
-
-#define MI_SYNCHRONOUS_FLIP 0x0
-#define MI_ASYNCHRONOUS_FLIP 0x1
-
-#define MI_BUFFER_SECURE 0x0
-#define MI_BUFFER_NONSECURE 0x1
-
-#define MI_ARBITRATE_AT_CHAIN_POINTS 0x0
-#define MI_ARBITRATE_BETWEEN_INSTS 0x1
-#define MI_NO_ARBITRATION 0x3
-
-#define MI_CONDITION_CODE_WAIT_DISABLED 0x0
-#define MI_CONDITION_CODE_WAIT_0 0x1
-#define MI_CONDITION_CODE_WAIT_1 0x2
-#define MI_CONDITION_CODE_WAIT_2 0x3
-#define MI_CONDITION_CODE_WAIT_3 0x4
-#define MI_CONDITION_CODE_WAIT_4 0x5
-
-#define MI_DISPLAY_PIPE_A 0x0
-#define MI_DISPLAY_PIPE_B 0x1
-
-#define MI_DISPLAY_PLANE_A 0x0
-#define MI_DISPLAY_PLANE_B 0x1
-#define MI_DISPLAY_PLANE_C 0x2
-
-#define MI_STANDARD_FLIP 0x0
-#define MI_ENQUEUE_FLIP_PERFORM_BASE_FRAME_NUMBER_LOAD 0x1
-#define MI_ENQUEUE_FLIP_TARGET_FRAME_NUMBER_RELATIVE 0x2
-#define MI_ENQUEUE_FLIP_ABSOLUTE_TARGET_FRAME_NUMBER 0x3
-
-#define MI_PHYSICAL_ADDRESS 0x0
-#define MI_VIRTUAL_ADDRESS 0x1
-
-#define MI_BUFFER_MEMORY_MAIN 0x0
-#define MI_BUFFER_MEMORY_GTT 0x2
-#define MI_BUFFER_MEMORY_PER_PROCESS_GTT 0x3
-
-#define MI_FLIP_CONTINUE 0x0
-#define MI_FLIP_ON 0x1
-#define MI_FLIP_OFF 0x2
-
-#define MI_UNTRUSTED_REGISTER_SPACE 0x0
-#define MI_TRUSTED_REGISTER_SPACE 0x1
-
-/* 3D state:
- */
-#define _3DOP_3DSTATE_PIPELINED 0x0
-#define _3DOP_3DSTATE_NONPIPELINED 0x1
-#define _3DOP_3DCONTROL 0x2
-#define _3DOP_3DPRIMITIVE 0x3
-
-#define _3DSTATE_PIPELINED_POINTERS 0x00
-#define _3DSTATE_BINDING_TABLE_POINTERS 0x01
-#define _3DSTATE_VERTEX_BUFFERS 0x08
-#define _3DSTATE_VERTEX_ELEMENTS 0x09
-#define _3DSTATE_INDEX_BUFFER 0x0A
-#define _3DSTATE_VF_STATISTICS 0x0B
-#define _3DSTATE_DRAWING_RECTANGLE 0x00
-#define _3DSTATE_CONSTANT_COLOR 0x01
-#define _3DSTATE_SAMPLER_PALETTE_LOAD 0x02
-#define _3DSTATE_CHROMA_KEY 0x04
-#define _3DSTATE_DEPTH_BUFFER 0x05
-#define _3DSTATE_POLY_STIPPLE_OFFSET 0x06
-#define _3DSTATE_POLY_STIPPLE_PATTERN 0x07
-#define _3DSTATE_LINE_STIPPLE 0x08
-#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP 0x09
-#define _3DCONTROL 0x00
-#define _3DPRIMITIVE 0x00
-
-#define PIPE_CONTROL_NOWRITE 0x00
-#define PIPE_CONTROL_WRITEIMMEDIATE 0x01
-#define PIPE_CONTROL_WRITEDEPTH 0x02
-#define PIPE_CONTROL_WRITETIMESTAMP 0x03
-
-#define PIPE_CONTROL_GTTWRITE_PROCESS_LOCAL 0x00
-#define PIPE_CONTROL_GTTWRITE_GLOBAL 0x01
-
-#define _3DPRIM_POINTLIST 0x01
-#define _3DPRIM_LINELIST 0x02
-#define _3DPRIM_LINESTRIP 0x03
-#define _3DPRIM_TRILIST 0x04
-#define _3DPRIM_TRISTRIP 0x05
-#define _3DPRIM_TRIFAN 0x06
-#define _3DPRIM_QUADLIST 0x07
-#define _3DPRIM_QUADSTRIP 0x08
-#define _3DPRIM_LINELIST_ADJ 0x09
-#define _3DPRIM_LINESTRIP_ADJ 0x0A
-#define _3DPRIM_TRILIST_ADJ 0x0B
-#define _3DPRIM_TRISTRIP_ADJ 0x0C
-#define _3DPRIM_TRISTRIP_REVERSE 0x0D
-#define _3DPRIM_POLYGON 0x0E
-#define _3DPRIM_RECTLIST 0x0F
-#define _3DPRIM_LINELOOP 0x10
-#define _3DPRIM_POINTLIST_BF 0x11
-#define _3DPRIM_LINESTRIP_CONT 0x12
-#define _3DPRIM_LINESTRIP_BF 0x13
-#define _3DPRIM_LINESTRIP_CONT_BF 0x14
-#define _3DPRIM_TRIFAN_NOSTIPPLE 0x15
-
-#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
-#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM 1
-
-#define BRW_ANISORATIO_2 0
-#define BRW_ANISORATIO_4 1
-#define BRW_ANISORATIO_6 2
-#define BRW_ANISORATIO_8 3
-#define BRW_ANISORATIO_10 4
-#define BRW_ANISORATIO_12 5
-#define BRW_ANISORATIO_14 6
-#define BRW_ANISORATIO_16 7
-
-#define BRW_BLENDFACTOR_ONE 0x1
-#define BRW_BLENDFACTOR_SRC_COLOR 0x2
-#define BRW_BLENDFACTOR_SRC_ALPHA 0x3
-#define BRW_BLENDFACTOR_DST_ALPHA 0x4
-#define BRW_BLENDFACTOR_DST_COLOR 0x5
-#define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
-#define BRW_BLENDFACTOR_CONST_COLOR 0x7
-#define BRW_BLENDFACTOR_CONST_ALPHA 0x8
-#define BRW_BLENDFACTOR_SRC1_COLOR 0x9
-#define BRW_BLENDFACTOR_SRC1_ALPHA 0x0A
-#define BRW_BLENDFACTOR_ZERO 0x11
-#define BRW_BLENDFACTOR_INV_SRC_COLOR 0x12
-#define BRW_BLENDFACTOR_INV_SRC_ALPHA 0x13
-#define BRW_BLENDFACTOR_INV_DST_ALPHA 0x14
-#define BRW_BLENDFACTOR_INV_DST_COLOR 0x15
-#define BRW_BLENDFACTOR_INV_CONST_COLOR 0x17
-#define BRW_BLENDFACTOR_INV_CONST_ALPHA 0x18
-#define BRW_BLENDFACTOR_INV_SRC1_COLOR 0x19
-#define BRW_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
-
-#define BRW_BLENDFUNCTION_ADD 0
-#define BRW_BLENDFUNCTION_SUBTRACT 1
-#define BRW_BLENDFUNCTION_REVERSE_SUBTRACT 2
-#define BRW_BLENDFUNCTION_MIN 3
-#define BRW_BLENDFUNCTION_MAX 4
-
-#define BRW_ALPHATEST_FORMAT_UNORM8 0
-#define BRW_ALPHATEST_FORMAT_FLOAT32 1
-
-#define BRW_CHROMAKEY_KILL_ON_ANY_MATCH 0
-#define BRW_CHROMAKEY_REPLACE_BLACK 1
-
-#define BRW_CLIP_API_OGL 0
-#define BRW_CLIP_API_DX 1
-
-#define BRW_CLIPMODE_NORMAL 0
-#define BRW_CLIPMODE_CLIP_ALL 1
-#define BRW_CLIPMODE_CLIP_NON_REJECTED 2
-#define BRW_CLIPMODE_REJECT_ALL 3
-#define BRW_CLIPMODE_ACCEPT_ALL 4
-
-#define BRW_CLIP_NDCSPACE 0
-#define BRW_CLIP_SCREENSPACE 1
-
-#define BRW_COMPAREFUNCTION_ALWAYS 0
-#define BRW_COMPAREFUNCTION_NEVER 1
-#define BRW_COMPAREFUNCTION_LESS 2
-#define BRW_COMPAREFUNCTION_EQUAL 3
-#define BRW_COMPAREFUNCTION_LEQUAL 4
-#define BRW_COMPAREFUNCTION_GREATER 5
-#define BRW_COMPAREFUNCTION_NOTEQUAL 6
-#define BRW_COMPAREFUNCTION_GEQUAL 7
-
-#define BRW_COVERAGE_PIXELS_HALF 0
-#define BRW_COVERAGE_PIXELS_1 1
-#define BRW_COVERAGE_PIXELS_2 2
-#define BRW_COVERAGE_PIXELS_4 3
-
-#define BRW_CULLMODE_BOTH 0
-#define BRW_CULLMODE_NONE 1
-#define BRW_CULLMODE_FRONT 2
-#define BRW_CULLMODE_BACK 3
-
-#define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM 0
-#define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT 1
-
-#define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT 0
-#define BRW_DEPTHFORMAT_D32_FLOAT 1
-#define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT 2
-#define BRW_DEPTHFORMAT_D16_UNORM 5
-
-#define BRW_FLOATING_POINT_IEEE_754 0
-#define BRW_FLOATING_POINT_NON_IEEE_754 1
-
-#define BRW_FRONTWINDING_CW 0
-#define BRW_FRONTWINDING_CCW 1
-
-#define BRW_SPRITE_POINT_ENABLE 16
-
-#define BRW_INDEX_BYTE 0
-#define BRW_INDEX_WORD 1
-#define BRW_INDEX_DWORD 2
-
-#define BRW_LOGICOPFUNCTION_CLEAR 0
-#define BRW_LOGICOPFUNCTION_NOR 1
-#define BRW_LOGICOPFUNCTION_AND_INVERTED 2
-#define BRW_LOGICOPFUNCTION_COPY_INVERTED 3
-#define BRW_LOGICOPFUNCTION_AND_REVERSE 4
-#define BRW_LOGICOPFUNCTION_INVERT 5
-#define BRW_LOGICOPFUNCTION_XOR 6
-#define BRW_LOGICOPFUNCTION_NAND 7
-#define BRW_LOGICOPFUNCTION_AND 8
-#define BRW_LOGICOPFUNCTION_EQUIV 9
-#define BRW_LOGICOPFUNCTION_NOOP 10
-#define BRW_LOGICOPFUNCTION_OR_INVERTED 11
-#define BRW_LOGICOPFUNCTION_COPY 12
-#define BRW_LOGICOPFUNCTION_OR_REVERSE 13
-#define BRW_LOGICOPFUNCTION_OR 14
-#define BRW_LOGICOPFUNCTION_SET 15
-
-#define BRW_MAPFILTER_NEAREST 0x0
-#define BRW_MAPFILTER_LINEAR 0x1
-#define BRW_MAPFILTER_ANISOTROPIC 0x2
-
-#define BRW_MIPFILTER_NONE 0
-#define BRW_MIPFILTER_NEAREST 1
-#define BRW_MIPFILTER_LINEAR 3
-
-#define BRW_POLYGON_FRONT_FACING 0
-#define BRW_POLYGON_BACK_FACING 1
-
-#define BRW_PREFILTER_ALWAYS 0x0
-#define BRW_PREFILTER_NEVER 0x1
-#define BRW_PREFILTER_LESS 0x2
-#define BRW_PREFILTER_EQUAL 0x3
-#define BRW_PREFILTER_LEQUAL 0x4
-#define BRW_PREFILTER_GREATER 0x5
-#define BRW_PREFILTER_NOTEQUAL 0x6
-#define BRW_PREFILTER_GEQUAL 0x7
-
-#define BRW_PROVOKING_VERTEX_0 0
-#define BRW_PROVOKING_VERTEX_1 1
-#define BRW_PROVOKING_VERTEX_2 2
-
-#define BRW_RASTRULE_UPPER_LEFT 0
-#define BRW_RASTRULE_UPPER_RIGHT 1
-
-#define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0
-#define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1
-#define BRW_RENDERTARGET_CLAMPRANGE_FORMAT 2
-
-#define BRW_STENCILOP_KEEP 0
-#define BRW_STENCILOP_ZERO 1
-#define BRW_STENCILOP_REPLACE 2
-#define BRW_STENCILOP_INCRSAT 3
-#define BRW_STENCILOP_DECRSAT 4
-#define BRW_STENCILOP_INCR 5
-#define BRW_STENCILOP_DECR 6
-#define BRW_STENCILOP_INVERT 7
-
-#define BRW_SURFACE_MIPMAPLAYOUT_BELOW 0
-#define BRW_SURFACE_MIPMAPLAYOUT_RIGHT 1
-
-#define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT 0x000
-#define BRW_SURFACEFORMAT_R32G32B32A32_SINT 0x001
-#define BRW_SURFACEFORMAT_R32G32B32A32_UINT 0x002
-#define BRW_SURFACEFORMAT_R32G32B32A32_UNORM 0x003
-#define BRW_SURFACEFORMAT_R32G32B32A32_SNORM 0x004
-#define BRW_SURFACEFORMAT_R64G64_FLOAT 0x005
-#define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT 0x006
-#define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED 0x007
-#define BRW_SURFACEFORMAT_R32G32B32A32_USCALED 0x008
-#define BRW_SURFACEFORMAT_R32G32B32_FLOAT 0x040
-#define BRW_SURFACEFORMAT_R32G32B32_SINT 0x041
-#define BRW_SURFACEFORMAT_R32G32B32_UINT 0x042
-#define BRW_SURFACEFORMAT_R32G32B32_UNORM 0x043
-#define BRW_SURFACEFORMAT_R32G32B32_SNORM 0x044
-#define BRW_SURFACEFORMAT_R32G32B32_SSCALED 0x045
-#define BRW_SURFACEFORMAT_R32G32B32_USCALED 0x046
-#define BRW_SURFACEFORMAT_R16G16B16A16_UNORM 0x080
-#define BRW_SURFACEFORMAT_R16G16B16A16_SNORM 0x081
-#define BRW_SURFACEFORMAT_R16G16B16A16_SINT 0x082
-#define BRW_SURFACEFORMAT_R16G16B16A16_UINT 0x083
-#define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT 0x084
-#define BRW_SURFACEFORMAT_R32G32_FLOAT 0x085
-#define BRW_SURFACEFORMAT_R32G32_SINT 0x086
-#define BRW_SURFACEFORMAT_R32G32_UINT 0x087
-#define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS 0x088
-#define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT 0x089
-#define BRW_SURFACEFORMAT_L32A32_FLOAT 0x08A
-#define BRW_SURFACEFORMAT_R32G32_UNORM 0x08B
-#define BRW_SURFACEFORMAT_R32G32_SNORM 0x08C
-#define BRW_SURFACEFORMAT_R64_FLOAT 0x08D
-#define BRW_SURFACEFORMAT_R16G16B16X16_UNORM 0x08E
-#define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT 0x08F
-#define BRW_SURFACEFORMAT_A32X32_FLOAT 0x090
-#define BRW_SURFACEFORMAT_L32X32_FLOAT 0x091
-#define BRW_SURFACEFORMAT_I32X32_FLOAT 0x092
-#define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED 0x093
-#define BRW_SURFACEFORMAT_R16G16B16A16_USCALED 0x094
-#define BRW_SURFACEFORMAT_R32G32_SSCALED 0x095
-#define BRW_SURFACEFORMAT_R32G32_USCALED 0x096
-#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM 0x0C0
-#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB 0x0C1
-#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM 0x0C2
-#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB 0x0C3
-#define BRW_SURFACEFORMAT_R10G10B10A2_UINT 0x0C4
-#define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM 0x0C5
-#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM 0x0C7
-#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB 0x0C8
-#define BRW_SURFACEFORMAT_R8G8B8A8_SNORM 0x0C9
-#define BRW_SURFACEFORMAT_R8G8B8A8_SINT 0x0CA
-#define BRW_SURFACEFORMAT_R8G8B8A8_UINT 0x0CB
-#define BRW_SURFACEFORMAT_R16G16_UNORM 0x0CC
-#define BRW_SURFACEFORMAT_R16G16_SNORM 0x0CD
-#define BRW_SURFACEFORMAT_R16G16_SINT 0x0CE
-#define BRW_SURFACEFORMAT_R16G16_UINT 0x0CF
-#define BRW_SURFACEFORMAT_R16G16_FLOAT 0x0D0
-#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM 0x0D1
-#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB 0x0D2
-#define BRW_SURFACEFORMAT_R11G11B10_FLOAT 0x0D3
-#define BRW_SURFACEFORMAT_R32_SINT 0x0D6
-#define BRW_SURFACEFORMAT_R32_UINT 0x0D7
-#define BRW_SURFACEFORMAT_R32_FLOAT 0x0D8
-#define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS 0x0D9
-#define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT 0x0DA
-#define BRW_SURFACEFORMAT_L16A16_UNORM 0x0DF
-#define BRW_SURFACEFORMAT_I24X8_UNORM 0x0E0
-#define BRW_SURFACEFORMAT_L24X8_UNORM 0x0E1
-#define BRW_SURFACEFORMAT_A24X8_UNORM 0x0E2
-#define BRW_SURFACEFORMAT_I32_FLOAT 0x0E3
-#define BRW_SURFACEFORMAT_L32_FLOAT 0x0E4
-#define BRW_SURFACEFORMAT_A32_FLOAT 0x0E5
-#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM 0x0E9
-#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB 0x0EA
-#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM 0x0EB
-#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB 0x0EC
-#define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP 0x0ED
-#define BRW_SURFACEFORMAT_B10G10R10X2_UNORM 0x0EE
-#define BRW_SURFACEFORMAT_L16A16_FLOAT 0x0F0
-#define BRW_SURFACEFORMAT_R32_UNORM 0x0F1
-#define BRW_SURFACEFORMAT_R32_SNORM 0x0F2
-#define BRW_SURFACEFORMAT_R10G10B10X2_USCALED 0x0F3
-#define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED 0x0F4
-#define BRW_SURFACEFORMAT_R8G8B8A8_USCALED 0x0F5
-#define BRW_SURFACEFORMAT_R16G16_SSCALED 0x0F6
-#define BRW_SURFACEFORMAT_R16G16_USCALED 0x0F7
-#define BRW_SURFACEFORMAT_R32_SSCALED 0x0F8
-#define BRW_SURFACEFORMAT_R32_USCALED 0x0F9
-#define BRW_SURFACEFORMAT_B5G6R5_UNORM 0x100
-#define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB 0x101
-#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM 0x102
-#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB 0x103
-#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM 0x104
-#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB 0x105
-#define BRW_SURFACEFORMAT_R8G8_UNORM 0x106
-#define BRW_SURFACEFORMAT_R8G8_SNORM 0x107
-#define BRW_SURFACEFORMAT_R8G8_SINT 0x108
-#define BRW_SURFACEFORMAT_R8G8_UINT 0x109
-#define BRW_SURFACEFORMAT_R16_UNORM 0x10A
-#define BRW_SURFACEFORMAT_R16_SNORM 0x10B
-#define BRW_SURFACEFORMAT_R16_SINT 0x10C
-#define BRW_SURFACEFORMAT_R16_UINT 0x10D
-#define BRW_SURFACEFORMAT_R16_FLOAT 0x10E
-#define BRW_SURFACEFORMAT_I16_UNORM 0x111
-#define BRW_SURFACEFORMAT_L16_UNORM 0x112
-#define BRW_SURFACEFORMAT_A16_UNORM 0x113
-#define BRW_SURFACEFORMAT_L8A8_UNORM 0x114
-#define BRW_SURFACEFORMAT_I16_FLOAT 0x115
-#define BRW_SURFACEFORMAT_L16_FLOAT 0x116
-#define BRW_SURFACEFORMAT_A16_FLOAT 0x117
-#define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM 0x119
-#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM 0x11A
-#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB 0x11B
-#define BRW_SURFACEFORMAT_R8G8_SSCALED 0x11C
-#define BRW_SURFACEFORMAT_R8G8_USCALED 0x11D
-#define BRW_SURFACEFORMAT_R16_SSCALED 0x11E
-#define BRW_SURFACEFORMAT_R16_USCALED 0x11F
-#define BRW_SURFACEFORMAT_R8_UNORM 0x140
-#define BRW_SURFACEFORMAT_R8_SNORM 0x141
-#define BRW_SURFACEFORMAT_R8_SINT 0x142
-#define BRW_SURFACEFORMAT_R8_UINT 0x143
-#define BRW_SURFACEFORMAT_A8_UNORM 0x144
-#define BRW_SURFACEFORMAT_I8_UNORM 0x145
-#define BRW_SURFACEFORMAT_L8_UNORM 0x146
-#define BRW_SURFACEFORMAT_P4A4_UNORM 0x147
-#define BRW_SURFACEFORMAT_A4P4_UNORM 0x148
-#define BRW_SURFACEFORMAT_R8_SSCALED 0x149
-#define BRW_SURFACEFORMAT_R8_USCALED 0x14A
-#define BRW_SURFACEFORMAT_R1_UINT 0x181
-#define BRW_SURFACEFORMAT_YCRCB_NORMAL 0x182
-#define BRW_SURFACEFORMAT_YCRCB_SWAPUVY 0x183
-#define BRW_SURFACEFORMAT_BC1_UNORM 0x186
-#define BRW_SURFACEFORMAT_BC2_UNORM 0x187
-#define BRW_SURFACEFORMAT_BC3_UNORM 0x188
-#define BRW_SURFACEFORMAT_BC4_UNORM 0x189
-#define BRW_SURFACEFORMAT_BC5_UNORM 0x18A
-#define BRW_SURFACEFORMAT_BC1_UNORM_SRGB 0x18B
-#define BRW_SURFACEFORMAT_BC2_UNORM_SRGB 0x18C
-#define BRW_SURFACEFORMAT_BC3_UNORM_SRGB 0x18D
-#define BRW_SURFACEFORMAT_MONO8 0x18E
-#define BRW_SURFACEFORMAT_YCRCB_SWAPUV 0x18F
-#define BRW_SURFACEFORMAT_YCRCB_SWAPY 0x190
-#define BRW_SURFACEFORMAT_DXT1_RGB 0x191
-#define BRW_SURFACEFORMAT_FXT1 0x192
-#define BRW_SURFACEFORMAT_R8G8B8_UNORM 0x193
-#define BRW_SURFACEFORMAT_R8G8B8_SNORM 0x194
-#define BRW_SURFACEFORMAT_R8G8B8_SSCALED 0x195
-#define BRW_SURFACEFORMAT_R8G8B8_USCALED 0x196
-#define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT 0x197
-#define BRW_SURFACEFORMAT_R64G64B64_FLOAT 0x198
-#define BRW_SURFACEFORMAT_BC4_SNORM 0x199
-#define BRW_SURFACEFORMAT_BC5_SNORM 0x19A
-#define BRW_SURFACEFORMAT_R16G16B16_UNORM 0x19C
-#define BRW_SURFACEFORMAT_R16G16B16_SNORM 0x19D
-#define BRW_SURFACEFORMAT_R16G16B16_SSCALED 0x19E
-#define BRW_SURFACEFORMAT_R16G16B16_USCALED 0x19F
-
-#define BRW_SURFACERETURNFORMAT_FLOAT32 0
-#define BRW_SURFACERETURNFORMAT_S1 1
-
-#define BRW_SURFACE_1D 0
-#define BRW_SURFACE_2D 1
-#define BRW_SURFACE_3D 2
-#define BRW_SURFACE_CUBE 3
-#define BRW_SURFACE_BUFFER 4
-#define BRW_SURFACE_NULL 7
-
-#define BRW_TEXCOORDMODE_WRAP 0
-#define BRW_TEXCOORDMODE_MIRROR 1
-#define BRW_TEXCOORDMODE_CLAMP 2
-#define BRW_TEXCOORDMODE_CUBE 3
-#define BRW_TEXCOORDMODE_CLAMP_BORDER 4
-#define BRW_TEXCOORDMODE_MIRROR_ONCE 5
-
-#define BRW_THREAD_PRIORITY_NORMAL 0
-#define BRW_THREAD_PRIORITY_HIGH 1
-
-#define BRW_TILEWALK_XMAJOR 0
-#define BRW_TILEWALK_YMAJOR 1
-
-#define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS 0
-#define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS 1
-
-#define BRW_VERTEXBUFFER_ACCESS_VERTEXDATA 0
-#define BRW_VERTEXBUFFER_ACCESS_INSTANCEDATA 1
-
-#define BRW_VFCOMPONENT_NOSTORE 0
-#define BRW_VFCOMPONENT_STORE_SRC 1
-#define BRW_VFCOMPONENT_STORE_0 2
-#define BRW_VFCOMPONENT_STORE_1_FLT 3
-#define BRW_VFCOMPONENT_STORE_1_INT 4
-#define BRW_VFCOMPONENT_STORE_VID 5
-#define BRW_VFCOMPONENT_STORE_IID 6
-#define BRW_VFCOMPONENT_STORE_PID 7
-
-
-
-/* Execution Unit (EU) defines
- */
-
-#define BRW_ALIGN_1 0
-#define BRW_ALIGN_16 1
-
-#define BRW_ADDRESS_DIRECT 0
-#define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER 1
-
-#define BRW_CHANNEL_X 0
-#define BRW_CHANNEL_Y 1
-#define BRW_CHANNEL_Z 2
-#define BRW_CHANNEL_W 3
-
-#define BRW_COMPRESSION_NONE 0
-#define BRW_COMPRESSION_2NDHALF 1
-#define BRW_COMPRESSION_COMPRESSED 2
-
-#define BRW_CONDITIONAL_NONE 0
-#define BRW_CONDITIONAL_Z 1
-#define BRW_CONDITIONAL_NZ 2
-#define BRW_CONDITIONAL_EQ 1 /* Z */
-#define BRW_CONDITIONAL_NEQ 2 /* NZ */
-#define BRW_CONDITIONAL_G 3
-#define BRW_CONDITIONAL_GE 4
-#define BRW_CONDITIONAL_L 5
-#define BRW_CONDITIONAL_LE 6
-#define BRW_CONDITIONAL_C 7
-#define BRW_CONDITIONAL_O 8
-
-#define BRW_DEBUG_NONE 0
-#define BRW_DEBUG_BREAKPOINT 1
-
-#define BRW_DEPENDENCY_NORMAL 0
-#define BRW_DEPENDENCY_NOTCLEARED 1
-#define BRW_DEPENDENCY_NOTCHECKED 2
-#define BRW_DEPENDENCY_DISABLE 3
-
-#define BRW_EXECUTE_1 0
-#define BRW_EXECUTE_2 1
-#define BRW_EXECUTE_4 2
-#define BRW_EXECUTE_8 3
-#define BRW_EXECUTE_16 4
-#define BRW_EXECUTE_32 5
-
-#define BRW_HORIZONTAL_STRIDE_0 0
-#define BRW_HORIZONTAL_STRIDE_1 1
-#define BRW_HORIZONTAL_STRIDE_2 2
-#define BRW_HORIZONTAL_STRIDE_4 3
-
-#define BRW_INSTRUCTION_NORMAL 0
-#define BRW_INSTRUCTION_SATURATE 1
-
-#define BRW_MASK_ENABLE 0
-#define BRW_MASK_DISABLE 1
-
-#define BRW_OPCODE_MOV 1
-#define BRW_OPCODE_SEL 2
-#define BRW_OPCODE_NOT 4
-#define BRW_OPCODE_AND 5
-#define BRW_OPCODE_OR 6
-#define BRW_OPCODE_XOR 7
-#define BRW_OPCODE_SHR 8
-#define BRW_OPCODE_SHL 9
-#define BRW_OPCODE_RSR 10
-#define BRW_OPCODE_RSL 11
-#define BRW_OPCODE_ASR 12
-#define BRW_OPCODE_CMP 16
-#define BRW_OPCODE_JMPI 32
-#define BRW_OPCODE_IF 34
-#define BRW_OPCODE_IFF 35
-#define BRW_OPCODE_ELSE 36
-#define BRW_OPCODE_ENDIF 37
-#define BRW_OPCODE_DO 38
-#define BRW_OPCODE_WHILE 39
-#define BRW_OPCODE_BREAK 40
-#define BRW_OPCODE_CONTINUE 41
-#define BRW_OPCODE_HALT 42
-#define BRW_OPCODE_MSAVE 44
-#define BRW_OPCODE_MRESTORE 45
-#define BRW_OPCODE_PUSH 46
-#define BRW_OPCODE_POP 47
-#define BRW_OPCODE_WAIT 48
-#define BRW_OPCODE_SEND 49
-#define BRW_OPCODE_ADD 64
-#define BRW_OPCODE_MUL 65
-#define BRW_OPCODE_AVG 66
-#define BRW_OPCODE_FRC 67
-#define BRW_OPCODE_RNDU 68
-#define BRW_OPCODE_RNDD 69
-#define BRW_OPCODE_RNDE 70
-#define BRW_OPCODE_RNDZ 71
-#define BRW_OPCODE_MAC 72
-#define BRW_OPCODE_MACH 73
-#define BRW_OPCODE_LZD 74
-#define BRW_OPCODE_SAD2 80
-#define BRW_OPCODE_SADA2 81
-#define BRW_OPCODE_DP4 84
-#define BRW_OPCODE_DPH 85
-#define BRW_OPCODE_DP3 86
-#define BRW_OPCODE_DP2 87
-#define BRW_OPCODE_DPA2 88
-#define BRW_OPCODE_LINE 89
-#define BRW_OPCODE_NOP 126
-
-#define BRW_PREDICATE_NONE 0
-#define BRW_PREDICATE_NORMAL 1
-#define BRW_PREDICATE_ALIGN1_ANYV 2
-#define BRW_PREDICATE_ALIGN1_ALLV 3
-#define BRW_PREDICATE_ALIGN1_ANY2H 4
-#define BRW_PREDICATE_ALIGN1_ALL2H 5
-#define BRW_PREDICATE_ALIGN1_ANY4H 6
-#define BRW_PREDICATE_ALIGN1_ALL4H 7
-#define BRW_PREDICATE_ALIGN1_ANY8H 8
-#define BRW_PREDICATE_ALIGN1_ALL8H 9
-#define BRW_PREDICATE_ALIGN1_ANY16H 10
-#define BRW_PREDICATE_ALIGN1_ALL16H 11
-#define BRW_PREDICATE_ALIGN16_REPLICATE_X 2
-#define BRW_PREDICATE_ALIGN16_REPLICATE_Y 3
-#define BRW_PREDICATE_ALIGN16_REPLICATE_Z 4
-#define BRW_PREDICATE_ALIGN16_REPLICATE_W 5
-#define BRW_PREDICATE_ALIGN16_ANY4H 6
-#define BRW_PREDICATE_ALIGN16_ALL4H 7
-
-#define BRW_ARCHITECTURE_REGISTER_FILE 0
-#define BRW_GENERAL_REGISTER_FILE 1
-#define BRW_MESSAGE_REGISTER_FILE 2
-#define BRW_IMMEDIATE_VALUE 3
-
-#define BRW_REGISTER_TYPE_UD 0
-#define BRW_REGISTER_TYPE_D 1
-#define BRW_REGISTER_TYPE_UW 2
-#define BRW_REGISTER_TYPE_W 3
-#define BRW_REGISTER_TYPE_UB 4
-#define BRW_REGISTER_TYPE_B 5
-#define BRW_REGISTER_TYPE_VF 5 /* packed float vector, immediates only? */
-#define BRW_REGISTER_TYPE_HF 6
-#define BRW_REGISTER_TYPE_V 6 /* packed int vector, immediates only, uword dest only */
-#define BRW_REGISTER_TYPE_F 7
-
-#define BRW_ARF_NULL 0x00
-#define BRW_ARF_ADDRESS 0x10
-#define BRW_ARF_ACCUMULATOR 0x20
-#define BRW_ARF_FLAG 0x30
-#define BRW_ARF_MASK 0x40
-#define BRW_ARF_MASK_STACK 0x50
-#define BRW_ARF_MASK_STACK_DEPTH 0x60
-#define BRW_ARF_STATE 0x70
-#define BRW_ARF_CONTROL 0x80
-#define BRW_ARF_NOTIFICATION_COUNT 0x90
-#define BRW_ARF_IP 0xA0
-
-#define BRW_AMASK 0
-#define BRW_IMASK 1
-#define BRW_LMASK 2
-#define BRW_CMASK 3
-
-
-
-#define BRW_THREAD_NORMAL 0
-#define BRW_THREAD_ATOMIC 1
-#define BRW_THREAD_SWITCH 2
-
-#define BRW_VERTICAL_STRIDE_0 0
-#define BRW_VERTICAL_STRIDE_1 1
-#define BRW_VERTICAL_STRIDE_2 2
-#define BRW_VERTICAL_STRIDE_4 3
-#define BRW_VERTICAL_STRIDE_8 4
-#define BRW_VERTICAL_STRIDE_16 5
-#define BRW_VERTICAL_STRIDE_32 6
-#define BRW_VERTICAL_STRIDE_64 7
-#define BRW_VERTICAL_STRIDE_128 8
-#define BRW_VERTICAL_STRIDE_256 9
-#define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL 0xF
-
-#define BRW_WIDTH_1 0
-#define BRW_WIDTH_2 1
-#define BRW_WIDTH_4 2
-#define BRW_WIDTH_8 3
-#define BRW_WIDTH_16 4
-
-#define BRW_STATELESS_BUFFER_BOUNDARY_1K 0
-#define BRW_STATELESS_BUFFER_BOUNDARY_2K 1
-#define BRW_STATELESS_BUFFER_BOUNDARY_4K 2
-#define BRW_STATELESS_BUFFER_BOUNDARY_8K 3
-#define BRW_STATELESS_BUFFER_BOUNDARY_16K 4
-#define BRW_STATELESS_BUFFER_BOUNDARY_32K 5
-#define BRW_STATELESS_BUFFER_BOUNDARY_64K 6
-#define BRW_STATELESS_BUFFER_BOUNDARY_128K 7
-#define BRW_STATELESS_BUFFER_BOUNDARY_256K 8
-#define BRW_STATELESS_BUFFER_BOUNDARY_512K 9
-#define BRW_STATELESS_BUFFER_BOUNDARY_1M 10
-#define BRW_STATELESS_BUFFER_BOUNDARY_2M 11
-
-#define BRW_POLYGON_FACING_FRONT 0
-#define BRW_POLYGON_FACING_BACK 1
-
-#define BRW_MESSAGE_TARGET_NULL 0
-#define BRW_MESSAGE_TARGET_MATH 1
-#define BRW_MESSAGE_TARGET_SAMPLER 2
-#define BRW_MESSAGE_TARGET_GATEWAY 3
-#define BRW_MESSAGE_TARGET_DATAPORT_READ 4
-#define BRW_MESSAGE_TARGET_DATAPORT_WRITE 5
-#define BRW_MESSAGE_TARGET_URB 6
-#define BRW_MESSAGE_TARGET_THREAD_SPAWNER 7
-
-#define BRW_SAMPLER_RETURN_FORMAT_FLOAT32 0
-#define BRW_SAMPLER_RETURN_FORMAT_UINT32 2
-#define BRW_SAMPLER_RETURN_FORMAT_SINT32 3
-
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE 0
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE 0
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS 0
-#define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX 1
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD 1
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD 1
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS 2
-#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS 2
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE 0
-#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE 2
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO 2
-#define BRW_SAMPLER_MESSAGE_SIMD8_RESINFO 2
-#define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO 2
-#define BRW_SAMPLER_MESSAGE_SIMD4X2_LD 3
-#define BRW_SAMPLER_MESSAGE_SIMD8_LD 3
-#define BRW_SAMPLER_MESSAGE_SIMD16_LD 3
-
-#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW 0
-#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH 1
-#define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS 2
-#define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS 3
-#define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS 4
-
-#define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD 0
-#define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS 2
-
-#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS 2
-#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS 3
-
-#define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ 0
-#define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 1
-#define BRW_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ 2
-#define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 3
-
-#define BRW_DATAPORT_READ_TARGET_DATA_CACHE 0
-#define BRW_DATAPORT_READ_TARGET_RENDER_CACHE 1
-#define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE 2
-
-#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE 0
-#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED 1
-#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01 2
-#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23 3
-#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01 4
-
-#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 0
-#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 1
-#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE 2
-#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 3
-#define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 4
-#define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE 5
-#define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE 7
-
-#define BRW_MATH_FUNCTION_INV 1
-#define BRW_MATH_FUNCTION_LOG 2
-#define BRW_MATH_FUNCTION_EXP 3
-#define BRW_MATH_FUNCTION_SQRT 4
-#define BRW_MATH_FUNCTION_RSQ 5
-#define BRW_MATH_FUNCTION_SIN 6 /* was 7 */
-#define BRW_MATH_FUNCTION_COS 7 /* was 8 */
-#define BRW_MATH_FUNCTION_SINCOS 8 /* was 6 */
-#define BRW_MATH_FUNCTION_TAN 9
-#define BRW_MATH_FUNCTION_POW 10
-#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER 11
-#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT 12
-#define BRW_MATH_FUNCTION_INT_DIV_REMAINDER 13
-
-#define BRW_MATH_INTEGER_UNSIGNED 0
-#define BRW_MATH_INTEGER_SIGNED 1
-
-#define BRW_MATH_PRECISION_FULL 0
-#define BRW_MATH_PRECISION_PARTIAL 1
-
-#define BRW_MATH_SATURATE_NONE 0
-#define BRW_MATH_SATURATE_SATURATE 1
-
-#define BRW_MATH_DATA_VECTOR 0
-#define BRW_MATH_DATA_SCALAR 1
-
-#define BRW_URB_OPCODE_WRITE 0
-
-#define BRW_URB_SWIZZLE_NONE 0
-#define BRW_URB_SWIZZLE_INTERLEAVE 1
-#define BRW_URB_SWIZZLE_TRANSPOSE 2
-
-#define BRW_SCRATCH_SPACE_SIZE_1K 0
-#define BRW_SCRATCH_SPACE_SIZE_2K 1
-#define BRW_SCRATCH_SPACE_SIZE_4K 2
-#define BRW_SCRATCH_SPACE_SIZE_8K 3
-#define BRW_SCRATCH_SPACE_SIZE_16K 4
-#define BRW_SCRATCH_SPACE_SIZE_32K 5
-#define BRW_SCRATCH_SPACE_SIZE_64K 6
-#define BRW_SCRATCH_SPACE_SIZE_128K 7
-#define BRW_SCRATCH_SPACE_SIZE_256K 8
-#define BRW_SCRATCH_SPACE_SIZE_512K 9
-#define BRW_SCRATCH_SPACE_SIZE_1M 10
-#define BRW_SCRATCH_SPACE_SIZE_2M 11
-
-
-
-
-#define CMD_URB_FENCE 0x6000
-#define CMD_CONST_BUFFER_STATE 0x6001
-#define CMD_CONST_BUFFER 0x6002
-
-#define CMD_STATE_BASE_ADDRESS 0x6101
-#define CMD_STATE_INSN_POINTER 0x6102
-#define CMD_PIPELINE_SELECT 0x6104
-
-#define CMD_PIPELINED_STATE_POINTERS 0x7800
-#define CMD_BINDING_TABLE_PTRS 0x7801
-#define CMD_VERTEX_BUFFER 0x7808
-#define CMD_VERTEX_ELEMENT 0x7809
-#define CMD_INDEX_BUFFER 0x780a
-#define CMD_VF_STATISTICS 0x780b
-
-#define CMD_DRAW_RECT 0x7900
-#define CMD_BLEND_CONSTANT_COLOR 0x7901
-#define CMD_CHROMA_KEY 0x7904
-#define CMD_DEPTH_BUFFER 0x7905
-#define CMD_POLY_STIPPLE_OFFSET 0x7906
-#define CMD_POLY_STIPPLE_PATTERN 0x7907
-#define CMD_LINE_STIPPLE_PATTERN 0x7908
-#define CMD_GLOBAL_DEPTH_OFFSET_CLAMP 0x7909
-
-#define CMD_PIPE_CONTROL 0x7a00
-
-#define CMD_3D_PRIM 0x7b00
-
-#define CMD_MI_FLUSH 0x0200
-
-
-/* Various values from the R0 vertex header:
- */
-#define R02_PRIM_END 0x1
-#define R02_PRIM_START 0x2
-
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_draw.c b/src/mesa/pipe/i965simple/brw_draw.c
deleted file mode 100644
index 7598e3dc8a..0000000000
--- a/src/mesa/pipe/i965simple/brw_draw.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <stdlib.h>
-
-#include "brw_batch.h"
-#include "brw_draw.h"
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_state.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_winsys.h"
-
-static unsigned hw_prim[PIPE_PRIM_POLYGON+1] = {
- _3DPRIM_POINTLIST,
- _3DPRIM_LINELIST,
- _3DPRIM_LINELOOP,
- _3DPRIM_LINESTRIP,
- _3DPRIM_TRILIST,
- _3DPRIM_TRISTRIP,
- _3DPRIM_TRIFAN,
- _3DPRIM_QUADLIST,
- _3DPRIM_QUADSTRIP,
- _3DPRIM_POLYGON
-};
-
-
-static const int reduced_prim[PIPE_PRIM_POLYGON+1] = {
- PIPE_PRIM_POINTS,
- PIPE_PRIM_LINES,
- PIPE_PRIM_LINES,
- PIPE_PRIM_LINES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES
-};
-
-
-/* When the primitive changes, set a state bit and re-validate. Not
- * the nicest and would rather deal with this by having all the
- * programs be immune to the active primitive (ie. cope with all
- * possibilities). That may not be realistic however.
- */
-static void brw_set_prim(struct brw_context *brw, int prim)
-{
- PRINT("PRIM: %d\n", prim);
-
- /* Slight optimization to avoid the GS program when not needed:
- */
- if (prim == PIPE_PRIM_QUAD_STRIP &&
- brw->attribs.Raster->flatshade &&
- brw->attribs.Raster->fill_cw == PIPE_POLYGON_MODE_FILL &&
- brw->attribs.Raster->fill_ccw == PIPE_POLYGON_MODE_FILL)
- prim = PIPE_PRIM_TRIANGLE_STRIP;
-
- if (prim != brw->primitive) {
- brw->primitive = prim;
- brw->state.dirty.brw |= BRW_NEW_PRIMITIVE;
-
- if (reduced_prim[prim] != brw->reduced_primitive) {
- brw->reduced_primitive = reduced_prim[prim];
- brw->state.dirty.brw |= BRW_NEW_REDUCED_PRIMITIVE;
- }
-
- brw_validate_state(brw);
- }
-
-}
-
-
-static unsigned trim(int prim, unsigned length)
-{
- if (prim == PIPE_PRIM_QUAD_STRIP)
- return length > 3 ? (length - length % 2) : 0;
- else if (prim == PIPE_PRIM_QUADS)
- return length - length % 4;
- else
- return length;
-}
-
-
-
-static boolean brw_emit_prim( struct brw_context *brw,
- boolean indexed,
- unsigned start,
- unsigned count )
-
-{
- struct brw_3d_primitive prim_packet;
-
- if (BRW_DEBUG & DEBUG_PRIMS)
- PRINT("PRIM: %d %d %d\n", brw->primitive, start, count);
-
- prim_packet.header.opcode = CMD_3D_PRIM;
- prim_packet.header.length = sizeof(prim_packet)/4 - 2;
- prim_packet.header.pad = 0;
- prim_packet.header.topology = hw_prim[brw->primitive];
- prim_packet.header.indexed = indexed;
-
- prim_packet.verts_per_instance = trim(brw->primitive, count);
- prim_packet.start_vert_location = start;
- prim_packet.instance_count = 1;
- prim_packet.start_instance_location = 0;
- prim_packet.base_vert_location = 0;
-
- if (prim_packet.verts_per_instance == 0)
- return TRUE;
-
- return brw_batchbuffer_data( brw->winsys,
- &prim_packet,
- sizeof(prim_packet) );
-}
-
-
-/* May fail if out of video memory for texture or vbo upload, or on
- * fallback conditions.
- */
-static boolean brw_try_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
- unsigned index_size,
- unsigned mode,
- unsigned start,
- unsigned count )
-{
- struct brw_context *brw = brw_context(pipe);
-
- /* Set the first primitive ahead of validate_state:
- */
- brw_set_prim(brw, mode);
-
- /* Upload index, vertex data:
- */
- if (index_buffer &&
- !brw_upload_indices( brw, index_buffer, index_size, start, count ))
- return FALSE;
-
- if (!brw_upload_vertex_buffers(brw))
- return FALSE;
-
- if (!brw_upload_vertex_elements( brw ))
- return FALSE;
-
- /* XXX: Need to separate validate and upload of state.
- */
- if (brw->state.dirty.brw)
- brw_validate_state( brw );
-
- if (!brw_emit_prim(brw, index_buffer != NULL,
- start, count))
- return FALSE;
-
- return TRUE;
-}
-
-
-
-static boolean brw_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode,
- unsigned start,
- unsigned count )
-{
- if (!brw_try_draw_elements( pipe,
- indexBuffer,
- indexSize,
- mode, start, count ))
- {
- /* flush ? */
-
- if (!brw_try_draw_elements( pipe,
- indexBuffer,
- indexSize,
- mode, start,
- count )) {
- assert(0);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-
-
-static boolean brw_draw_arrays( struct pipe_context *pipe,
- unsigned mode,
- unsigned start,
- unsigned count )
-{
- if (!brw_try_draw_elements( pipe, NULL, 0, mode, start, count )) {
- /* flush ? */
-
- if (!brw_try_draw_elements( pipe, NULL, 0, mode, start, count )) {
- assert(0);
- return FALSE;
- }
- }
-
- return TRUE;
-}
-
-
-
-void brw_init_draw_functions( struct brw_context *brw )
-{
- brw->pipe.draw_arrays = brw_draw_arrays;
- brw->pipe.draw_elements = brw_draw_elements;
-}
-
-
diff --git a/src/mesa/pipe/i965simple/brw_draw.h b/src/mesa/pipe/i965simple/brw_draw.h
deleted file mode 100644
index 62fe0d5d0e..0000000000
--- a/src/mesa/pipe/i965simple/brw_draw.h
+++ /dev/null
@@ -1,55 +0,0 @@
- /**************************************************************************
- *
- * Copyright 2005 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 BRW_DRAW_H
-#define BRW_DRAW_H
-
-#include "pipe/p_context.h"
-
-struct brw_context;
-
-
-
-void brw_init_draw_functions( struct brw_context *brw );
-
-
-boolean brw_upload_vertices( struct brw_context *brw,
- unsigned min_index,
- unsigned max_index );
-
-boolean brw_upload_indices(struct brw_context *brw,
- const struct pipe_buffer *index_buffer,
- int ib_size, int start, int count);
-
-boolean brw_upload_vertex_buffers( struct brw_context *brw );
-boolean brw_upload_vertex_elements( struct brw_context *brw );
-
-unsigned brw_translate_surface_format( unsigned id );
-
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_draw_upload.c b/src/mesa/pipe/i965simple/brw_draw_upload.c
deleted file mode 100644
index aa85d93866..0000000000
--- a/src/mesa/pipe/i965simple/brw_draw_upload.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <stdlib.h>
-
-#include "brw_batch.h"
-#include "brw_draw.h"
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_state.h"
-
-struct brw_array_state {
- union header_union header;
-
- struct {
- union {
- struct {
- unsigned pitch:11;
- unsigned pad:15;
- unsigned access_type:1;
- unsigned vb_index:5;
- } bits;
- unsigned dword;
- } vb0;
-
- struct pipe_buffer *buffer;
- unsigned offset;
-
- unsigned max_index;
- unsigned instance_data_step_rate;
-
- } vb[BRW_VBP_MAX];
-};
-
-
-
-unsigned brw_translate_surface_format( unsigned id )
-{
- switch (id) {
- case PIPE_FORMAT_R64_FLOAT:
- return BRW_SURFACEFORMAT_R64_FLOAT;
- case PIPE_FORMAT_R64G64_FLOAT:
- return BRW_SURFACEFORMAT_R64G64_FLOAT;
- case PIPE_FORMAT_R64G64B64_FLOAT:
- return BRW_SURFACEFORMAT_R64G64B64_FLOAT;
- case PIPE_FORMAT_R64G64B64A64_FLOAT:
- return BRW_SURFACEFORMAT_R64G64B64A64_FLOAT;
-
- case PIPE_FORMAT_R32_FLOAT:
- return BRW_SURFACEFORMAT_R32_FLOAT;
- case PIPE_FORMAT_R32G32_FLOAT:
- return BRW_SURFACEFORMAT_R32G32_FLOAT;
- case PIPE_FORMAT_R32G32B32_FLOAT:
- return BRW_SURFACEFORMAT_R32G32B32_FLOAT;
- case PIPE_FORMAT_R32G32B32A32_FLOAT:
- return BRW_SURFACEFORMAT_R32G32B32A32_FLOAT;
-
- case PIPE_FORMAT_R32_UNORM:
- return BRW_SURFACEFORMAT_R32_UNORM;
- case PIPE_FORMAT_R32G32_UNORM:
- return BRW_SURFACEFORMAT_R32G32_UNORM;
- case PIPE_FORMAT_R32G32B32_UNORM:
- return BRW_SURFACEFORMAT_R32G32B32_UNORM;
- case PIPE_FORMAT_R32G32B32A32_UNORM:
- return BRW_SURFACEFORMAT_R32G32B32A32_UNORM;
-
- case PIPE_FORMAT_R32_USCALED:
- return BRW_SURFACEFORMAT_R32_USCALED;
- case PIPE_FORMAT_R32G32_USCALED:
- return BRW_SURFACEFORMAT_R32G32_USCALED;
- case PIPE_FORMAT_R32G32B32_USCALED:
- return BRW_SURFACEFORMAT_R32G32B32_USCALED;
- case PIPE_FORMAT_R32G32B32A32_USCALED:
- return BRW_SURFACEFORMAT_R32G32B32A32_USCALED;
-
- case PIPE_FORMAT_R32_SNORM:
- return BRW_SURFACEFORMAT_R32_SNORM;
- case PIPE_FORMAT_R32G32_SNORM:
- return BRW_SURFACEFORMAT_R32G32_SNORM;
- case PIPE_FORMAT_R32G32B32_SNORM:
- return BRW_SURFACEFORMAT_R32G32B32_SNORM;
- case PIPE_FORMAT_R32G32B32A32_SNORM:
- return BRW_SURFACEFORMAT_R32G32B32A32_SNORM;
-
- case PIPE_FORMAT_R32_SSCALED:
- return BRW_SURFACEFORMAT_R32_SSCALED;
- case PIPE_FORMAT_R32G32_SSCALED:
- return BRW_SURFACEFORMAT_R32G32_SSCALED;
- case PIPE_FORMAT_R32G32B32_SSCALED:
- return BRW_SURFACEFORMAT_R32G32B32_SSCALED;
- case PIPE_FORMAT_R32G32B32A32_SSCALED:
- return BRW_SURFACEFORMAT_R32G32B32A32_SSCALED;
-
- case PIPE_FORMAT_R16_UNORM:
- return BRW_SURFACEFORMAT_R16_UNORM;
- case PIPE_FORMAT_R16G16_UNORM:
- return BRW_SURFACEFORMAT_R16G16_UNORM;
- case PIPE_FORMAT_R16G16B16_UNORM:
- return BRW_SURFACEFORMAT_R16G16B16_UNORM;
- case PIPE_FORMAT_R16G16B16A16_UNORM:
- return BRW_SURFACEFORMAT_R16G16B16A16_UNORM;
-
- case PIPE_FORMAT_R16_USCALED:
- return BRW_SURFACEFORMAT_R16_USCALED;
- case PIPE_FORMAT_R16G16_USCALED:
- return BRW_SURFACEFORMAT_R16G16_USCALED;
- case PIPE_FORMAT_R16G16B16_USCALED:
- return BRW_SURFACEFORMAT_R16G16B16_USCALED;
- case PIPE_FORMAT_R16G16B16A16_USCALED:
- return BRW_SURFACEFORMAT_R16G16B16A16_USCALED;
-
- case PIPE_FORMAT_R16_SNORM:
- return BRW_SURFACEFORMAT_R16_SNORM;
- case PIPE_FORMAT_R16G16_SNORM:
- return BRW_SURFACEFORMAT_R16G16_SNORM;
- case PIPE_FORMAT_R16G16B16_SNORM:
- return BRW_SURFACEFORMAT_R16G16B16_SNORM;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- return BRW_SURFACEFORMAT_R16G16B16A16_SNORM;
-
- case PIPE_FORMAT_R16_SSCALED:
- return BRW_SURFACEFORMAT_R16_SSCALED;
- case PIPE_FORMAT_R16G16_SSCALED:
- return BRW_SURFACEFORMAT_R16G16_SSCALED;
- case PIPE_FORMAT_R16G16B16_SSCALED:
- return BRW_SURFACEFORMAT_R16G16B16_SSCALED;
- case PIPE_FORMAT_R16G16B16A16_SSCALED:
- return BRW_SURFACEFORMAT_R16G16B16A16_SSCALED;
-
- case PIPE_FORMAT_R8_UNORM:
- return BRW_SURFACEFORMAT_R8_UNORM;
- case PIPE_FORMAT_R8G8_UNORM:
- return BRW_SURFACEFORMAT_R8G8_UNORM;
- case PIPE_FORMAT_R8G8B8_UNORM:
- return BRW_SURFACEFORMAT_R8G8B8_UNORM;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
-
- case PIPE_FORMAT_R8_USCALED:
- return BRW_SURFACEFORMAT_R8_USCALED;
- case PIPE_FORMAT_R8G8_USCALED:
- return BRW_SURFACEFORMAT_R8G8_USCALED;
- case PIPE_FORMAT_R8G8B8_USCALED:
- return BRW_SURFACEFORMAT_R8G8B8_USCALED;
- case PIPE_FORMAT_R8G8B8A8_USCALED:
- return BRW_SURFACEFORMAT_R8G8B8A8_USCALED;
-
- case PIPE_FORMAT_R8_SNORM:
- return BRW_SURFACEFORMAT_R8_SNORM;
- case PIPE_FORMAT_R8G8_SNORM:
- return BRW_SURFACEFORMAT_R8G8_SNORM;
- case PIPE_FORMAT_R8G8B8_SNORM:
- return BRW_SURFACEFORMAT_R8G8B8_SNORM;
- case PIPE_FORMAT_R8G8B8A8_SNORM:
- return BRW_SURFACEFORMAT_R8G8B8A8_SNORM;
-
- case PIPE_FORMAT_R8_SSCALED:
- return BRW_SURFACEFORMAT_R8_SSCALED;
- case PIPE_FORMAT_R8G8_SSCALED:
- return BRW_SURFACEFORMAT_R8G8_SSCALED;
- case PIPE_FORMAT_R8G8B8_SSCALED:
- return BRW_SURFACEFORMAT_R8G8B8_SSCALED;
- case PIPE_FORMAT_R8G8B8A8_SSCALED:
- return BRW_SURFACEFORMAT_R8G8B8A8_SSCALED;
-
- default:
- assert(0);
- return 0;
- }
-}
-
-static unsigned get_index_type(int type)
-{
- switch (type) {
- case 1: return BRW_INDEX_BYTE;
- case 2: return BRW_INDEX_WORD;
- case 4: return BRW_INDEX_DWORD;
- default: assert(0); return 0;
- }
-}
-
-
-boolean brw_upload_vertex_buffers( struct brw_context *brw )
-{
- struct brw_array_state vbp;
- unsigned nr_enabled = 0;
- unsigned i;
-
- memset(&vbp, 0, sizeof(vbp));
-
- /* This is a hardware limit:
- */
-
- for (i = 0; i < BRW_VEP_MAX; i++)
- {
- if (brw->vb.vbo_array[i] == NULL) {
- nr_enabled = i;
- break;
- }
-
- vbp.vb[i].vb0.bits.pitch = brw->vb.vbo_array[i]->pitch;
- vbp.vb[i].vb0.bits.pad = 0;
- vbp.vb[i].vb0.bits.access_type = BRW_VERTEXBUFFER_ACCESS_VERTEXDATA;
- vbp.vb[i].vb0.bits.vb_index = i;
- vbp.vb[i].offset = brw->vb.vbo_array[i]->buffer_offset;
- vbp.vb[i].buffer = brw->vb.vbo_array[i]->buffer;
- vbp.vb[i].max_index = brw->vb.vbo_array[i]->max_index;
- }
-
-
- vbp.header.bits.length = (1 + nr_enabled * 4) - 2;
- vbp.header.bits.opcode = CMD_VERTEX_BUFFER;
-
- BEGIN_BATCH(vbp.header.bits.length+2, 0);
- OUT_BATCH( vbp.header.dword );
-
- for (i = 0; i < nr_enabled; i++) {
- OUT_BATCH( vbp.vb[i].vb0.dword );
- OUT_RELOC( vbp.vb[i].buffer, PIPE_BUFFER_USAGE_GPU_READ,
- vbp.vb[i].offset);
- OUT_BATCH( vbp.vb[i].max_index );
- OUT_BATCH( vbp.vb[i].instance_data_step_rate );
- }
- ADVANCE_BATCH();
- return TRUE;
-}
-
-
-
-boolean brw_upload_vertex_elements( struct brw_context *brw )
-{
- struct brw_vertex_element_packet vep;
-
- unsigned i;
- unsigned nr_enabled = brw->attribs.VertexProgram->program.num_inputs;
-
- memset(&vep, 0, sizeof(vep));
-
- for (i = 0; i < nr_enabled; i++)
- vep.ve[i] = brw->vb.inputs[i];
-
-
- vep.header.length = (1 + nr_enabled * sizeof(vep.ve[0])/4) - 2;
- vep.header.opcode = CMD_VERTEX_ELEMENT;
- brw_cached_batch_struct(brw, &vep, 4 + nr_enabled * sizeof(vep.ve[0]));
-
- return TRUE;
-}
-
-boolean brw_upload_indices( struct brw_context *brw,
- const struct pipe_buffer *index_buffer,
- int ib_size, int start, int count)
-{
- /* Emit the indexbuffer packet:
- */
- {
- struct brw_indexbuffer ib;
-
- memset(&ib, 0, sizeof(ib));
-
- ib.header.bits.opcode = CMD_INDEX_BUFFER;
- ib.header.bits.length = sizeof(ib)/4 - 2;
- ib.header.bits.index_format = get_index_type(ib_size);
- ib.header.bits.cut_index_enable = 0;
-
-
- BEGIN_BATCH(4, 0);
- OUT_BATCH( ib.header.dword );
- OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start);
- OUT_RELOC( index_buffer, PIPE_BUFFER_USAGE_GPU_READ, start + count);
- OUT_BATCH( 0 );
- ADVANCE_BATCH();
- }
- return TRUE;
-}
diff --git a/src/mesa/pipe/i965simple/brw_eu.c b/src/mesa/pipe/i965simple/brw_eu.c
deleted file mode 100644
index e2002d1821..0000000000
--- a/src/mesa/pipe/i965simple/brw_eu.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_eu.h"
-
-
-
-/* How does predicate control work when execution_size != 8? Do I
- * need to test/set for 0xffff when execution_size is 16?
- */
-void brw_set_predicate_control_flag_value( struct brw_compile *p, unsigned value )
-{
- p->current->header.predicate_control = BRW_PREDICATE_NONE;
-
- if (value != 0xff) {
- if (value != p->flag_value) {
- brw_push_insn_state(p);
- brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
- p->flag_value = value;
- brw_pop_insn_state(p);
- }
-
- p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
- }
-}
-
-void brw_set_predicate_control( struct brw_compile *p, unsigned pc )
-{
- p->current->header.predicate_control = pc;
-}
-
-void brw_set_conditionalmod( struct brw_compile *p, unsigned conditional )
-{
- p->current->header.destreg__conditonalmod = conditional;
-}
-
-void brw_set_access_mode( struct brw_compile *p, unsigned access_mode )
-{
- p->current->header.access_mode = access_mode;
-}
-
-void brw_set_compression_control( struct brw_compile *p, boolean compression_control )
-{
- p->current->header.compression_control = compression_control;
-}
-
-void brw_set_mask_control( struct brw_compile *p, unsigned value )
-{
- p->current->header.mask_control = value;
-}
-
-void brw_set_saturate( struct brw_compile *p, unsigned value )
-{
- p->current->header.saturate = value;
-}
-
-void brw_push_insn_state( struct brw_compile *p )
-{
- assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
- memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
- p->current++;
-}
-
-void brw_pop_insn_state( struct brw_compile *p )
-{
- assert(p->current != p->stack);
- p->current--;
-}
-
-
-/***********************************************************************
- */
-void brw_init_compile( struct brw_compile *p )
-{
- p->nr_insn = 0;
- p->current = p->stack;
- memset(p->current, 0, sizeof(p->current[0]));
-
- /* Some defaults?
- */
- brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
- brw_set_saturate(p, 0);
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
- brw_set_predicate_control_flag_value(p, 0xff);
-}
-
-
-const unsigned *brw_get_program( struct brw_compile *p,
- unsigned *sz )
-{
- unsigned i;
-
- for (i = 0; i < 8; i++)
- brw_NOP(p);
-
- *sz = p->nr_insn * sizeof(struct brw_instruction);
- return (const unsigned *)p->store;
-}
-
diff --git a/src/mesa/pipe/i965simple/brw_eu.h b/src/mesa/pipe/i965simple/brw_eu.h
deleted file mode 100644
index 23151ae9ed..0000000000
--- a/src/mesa/pipe/i965simple/brw_eu.h
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_EU_H
-#define BRW_EU_H
-
-#include "brw_structs.h"
-#include "brw_defines.h"
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_shader_tokens.h"
-
-#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
-#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
-
-#define BRW_SWIZZLE_NOOP BRW_SWIZZLE4(0,1,2,3)
-#define BRW_SWIZZLE_XYZW BRW_SWIZZLE4(0,1,2,3)
-#define BRW_SWIZZLE_XXXX BRW_SWIZZLE4(0,0,0,0)
-#define BRW_SWIZZLE_XYXY BRW_SWIZZLE4(0,1,0,1)
-
-
-#define REG_SIZE (8*4)
-
-
-/* These aren't hardware structs, just something useful for us to pass around:
- *
- * Align1 operation has a lot of control over input ranges. Used in
- * WM programs to implement shaders decomposed into "channel serial"
- * or "structure of array" form:
- */
-struct brw_reg
-{
- unsigned type:4;
- unsigned file:2;
- unsigned nr:8;
- unsigned subnr:5; /* :1 in align16 */
- unsigned negate:1; /* source only */
- unsigned abs:1; /* source only */
- unsigned vstride:4; /* source only */
- unsigned width:3; /* src only, align1 only */
- unsigned hstride:2; /* src only, align1 only */
- unsigned address_mode:1; /* relative addressing, hopefully! */
- unsigned pad0:1;
-
- union {
- struct {
- unsigned swizzle:8; /* src only, align16 only */
- unsigned writemask:4; /* dest only, align16 only */
- int indirect_offset:10; /* relative addressing offset */
- unsigned pad1:10; /* two dwords total */
- } bits;
-
- float f;
- int d;
- unsigned ud;
- } dw1;
-};
-
-
-struct brw_indirect {
- unsigned addr_subnr:4;
- int addr_offset:10;
- unsigned pad:18;
-};
-
-
-#define BRW_EU_MAX_INSN_STACK 5
-#define BRW_EU_MAX_INSN 1200
-
-struct brw_compile {
- struct brw_instruction store[BRW_EU_MAX_INSN];
- unsigned nr_insn;
-
- /* Allow clients to push/pop instruction state:
- */
- struct brw_instruction stack[BRW_EU_MAX_INSN_STACK];
- struct brw_instruction *current;
-
- unsigned flag_value;
- boolean single_program_flow;
-};
-
-
-
-static __inline int type_sz( unsigned type )
-{
- switch( type ) {
- case BRW_REGISTER_TYPE_UD:
- case BRW_REGISTER_TYPE_D:
- case BRW_REGISTER_TYPE_F:
- return 4;
- case BRW_REGISTER_TYPE_HF:
- case BRW_REGISTER_TYPE_UW:
- case BRW_REGISTER_TYPE_W:
- return 2;
- case BRW_REGISTER_TYPE_UB:
- case BRW_REGISTER_TYPE_B:
- return 1;
- default:
- return 0;
- }
-}
-
-static __inline struct brw_reg brw_reg( unsigned file,
- unsigned nr,
- unsigned subnr,
- unsigned type,
- unsigned vstride,
- unsigned width,
- unsigned hstride,
- unsigned swizzle,
- unsigned writemask)
-{
-
- struct brw_reg reg;
- reg.type = type;
- reg.file = file;
- reg.nr = nr;
- reg.subnr = subnr * type_sz(type);
- reg.negate = 0;
- reg.abs = 0;
- reg.vstride = vstride;
- reg.width = width;
- reg.hstride = hstride;
- reg.address_mode = BRW_ADDRESS_DIRECT;
- reg.pad0 = 0;
-
- /* Could do better: If the reg is r5.3<0;1,0>, we probably want to
- * set swizzle and writemask to W, as the lower bits of subnr will
- * be lost when converted to align16. This is probably too much to
- * keep track of as you'd want it adjusted by suboffset(), etc.
- * Perhaps fix up when converting to align16?
- */
- reg.dw1.bits.swizzle = swizzle;
- reg.dw1.bits.writemask = writemask;
- reg.dw1.bits.indirect_offset = 0;
- reg.dw1.bits.pad1 = 0;
- return reg;
-}
-
-static __inline struct brw_reg brw_vec16_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return brw_reg(file,
- nr,
- subnr,
- BRW_REGISTER_TYPE_F,
- BRW_VERTICAL_STRIDE_16,
- BRW_WIDTH_16,
- BRW_HORIZONTAL_STRIDE_1,
- BRW_SWIZZLE_XYZW,
- TGSI_WRITEMASK_XYZW);
-}
-
-static __inline struct brw_reg brw_vec8_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return brw_reg(file,
- nr,
- subnr,
- BRW_REGISTER_TYPE_F,
- BRW_VERTICAL_STRIDE_8,
- BRW_WIDTH_8,
- BRW_HORIZONTAL_STRIDE_1,
- BRW_SWIZZLE_XYZW,
- TGSI_WRITEMASK_XYZW);
-}
-
-
-static __inline struct brw_reg brw_vec4_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return brw_reg(file,
- nr,
- subnr,
- BRW_REGISTER_TYPE_F,
- BRW_VERTICAL_STRIDE_4,
- BRW_WIDTH_4,
- BRW_HORIZONTAL_STRIDE_1,
- BRW_SWIZZLE_XYZW,
- TGSI_WRITEMASK_XYZW);
-}
-
-
-static __inline struct brw_reg brw_vec2_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return brw_reg(file,
- nr,
- subnr,
- BRW_REGISTER_TYPE_F,
- BRW_VERTICAL_STRIDE_2,
- BRW_WIDTH_2,
- BRW_HORIZONTAL_STRIDE_1,
- BRW_SWIZZLE_XYXY,
- TGSI_WRITEMASK_XY);
-}
-
-static __inline struct brw_reg brw_vec1_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return brw_reg(file,
- nr,
- subnr,
- BRW_REGISTER_TYPE_F,
- BRW_VERTICAL_STRIDE_0,
- BRW_WIDTH_1,
- BRW_HORIZONTAL_STRIDE_0,
- BRW_SWIZZLE_XXXX,
- TGSI_WRITEMASK_X);
-}
-
-
-static __inline struct brw_reg retype( struct brw_reg reg,
- unsigned type )
-{
- reg.type = type;
- return reg;
-}
-
-static __inline struct brw_reg suboffset( struct brw_reg reg,
- unsigned delta )
-{
- reg.subnr += delta * type_sz(reg.type);
- return reg;
-}
-
-
-static __inline struct brw_reg offset( struct brw_reg reg,
- unsigned delta )
-{
- reg.nr += delta;
- return reg;
-}
-
-
-static __inline struct brw_reg byte_offset( struct brw_reg reg,
- unsigned bytes )
-{
- unsigned newoffset = reg.nr * REG_SIZE + reg.subnr + bytes;
- reg.nr = newoffset / REG_SIZE;
- reg.subnr = newoffset % REG_SIZE;
- return reg;
-}
-
-
-static __inline struct brw_reg brw_uw16_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return suboffset(retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
-}
-
-static __inline struct brw_reg brw_uw8_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return suboffset(retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
-}
-
-static __inline struct brw_reg brw_uw1_reg( unsigned file,
- unsigned nr,
- unsigned subnr )
-{
- return suboffset(retype(brw_vec1_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
-}
-
-static __inline struct brw_reg brw_imm_reg( unsigned type )
-{
- return brw_reg( BRW_IMMEDIATE_VALUE,
- 0,
- 0,
- type,
- BRW_VERTICAL_STRIDE_0,
- BRW_WIDTH_1,
- BRW_HORIZONTAL_STRIDE_0,
- 0,
- 0);
-}
-
-static __inline struct brw_reg brw_imm_f( float f )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
- imm.dw1.f = f;
- return imm;
-}
-
-static __inline struct brw_reg brw_imm_d( int d )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D);
- imm.dw1.d = d;
- return imm;
-}
-
-static __inline struct brw_reg brw_imm_ud( unsigned ud )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD);
- imm.dw1.ud = ud;
- return imm;
-}
-
-static __inline struct brw_reg brw_imm_uw( ushort uw )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW);
- imm.dw1.ud = uw;
- return imm;
-}
-
-static __inline struct brw_reg brw_imm_w( short w )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
- imm.dw1.d = w;
- return imm;
-}
-
-/* brw_imm_b and brw_imm_ub aren't supported by hardware - the type
- * numbers alias with _V and _VF below:
- */
-
-/* Vector of eight signed half-byte values:
- */
-static __inline struct brw_reg brw_imm_v( unsigned v )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V);
- imm.vstride = BRW_VERTICAL_STRIDE_0;
- imm.width = BRW_WIDTH_8;
- imm.hstride = BRW_HORIZONTAL_STRIDE_1;
- imm.dw1.ud = v;
- return imm;
-}
-
-/* Vector of four 8-bit float values:
- */
-static __inline struct brw_reg brw_imm_vf( unsigned v )
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
- imm.vstride = BRW_VERTICAL_STRIDE_0;
- imm.width = BRW_WIDTH_4;
- imm.hstride = BRW_HORIZONTAL_STRIDE_1;
- imm.dw1.ud = v;
- return imm;
-}
-
-#define VF_ZERO 0x0
-#define VF_ONE 0x30
-#define VF_NEG (1<<7)
-
-static __inline struct brw_reg brw_imm_vf4( unsigned v0,
- unsigned v1,
- unsigned v2,
- unsigned v3)
-{
- struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
- imm.vstride = BRW_VERTICAL_STRIDE_0;
- imm.width = BRW_WIDTH_4;
- imm.hstride = BRW_HORIZONTAL_STRIDE_1;
- imm.dw1.ud = ((v0 << 0) |
- (v1 << 8) |
- (v2 << 16) |
- (v3 << 24));
- return imm;
-}
-
-
-static __inline struct brw_reg brw_address( struct brw_reg reg )
-{
- return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr);
-}
-
-
-static __inline struct brw_reg brw_vec1_grf( unsigned nr,
- unsigned subnr )
-{
- return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
-}
-
-static __inline struct brw_reg brw_vec8_grf( unsigned nr,
- unsigned subnr )
-{
- return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
-}
-
-static __inline struct brw_reg brw_vec4_grf( unsigned nr,
- unsigned subnr )
-{
- return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
-}
-
-
-static __inline struct brw_reg brw_vec2_grf( unsigned nr,
- unsigned subnr )
-{
- return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
-}
-
-static __inline struct brw_reg brw_uw8_grf( unsigned nr,
- unsigned subnr )
-{
- return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
-}
-
-static __inline struct brw_reg brw_null_reg( void )
-{
- return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_NULL,
- 0);
-}
-
-static __inline struct brw_reg brw_address_reg( unsigned subnr )
-{
- return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_ADDRESS,
- subnr);
-}
-
-/* If/else instructions break in align16 mode if writemask & swizzle
- * aren't xyzw. This goes against the convention for other scalar
- * regs:
- */
-static __inline struct brw_reg brw_ip_reg( void )
-{
- return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_IP,
- 0,
- BRW_REGISTER_TYPE_UD,
- BRW_VERTICAL_STRIDE_4, /* ? */
- BRW_WIDTH_1,
- BRW_HORIZONTAL_STRIDE_0,
- BRW_SWIZZLE_XYZW, /* NOTE! */
- TGSI_WRITEMASK_XYZW); /* NOTE! */
-}
-
-static __inline struct brw_reg brw_acc_reg( void )
-{
- return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_ACCUMULATOR,
- 0);
-}
-
-
-static __inline struct brw_reg brw_flag_reg( void )
-{
- return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_FLAG,
- 0);
-}
-
-
-static __inline struct brw_reg brw_mask_reg( unsigned subnr )
-{
- return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
- BRW_ARF_MASK,
- subnr);
-}
-
-static __inline struct brw_reg brw_message_reg( unsigned nr )
-{
- return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE,
- nr,
- 0);
-}
-
-
-
-
-/* This is almost always called with a numeric constant argument, so
- * make things easy to evaluate at compile time:
- */
-static __inline unsigned cvt( unsigned val )
-{
- switch (val) {
- case 0: return 0;
- case 1: return 1;
- case 2: return 2;
- case 4: return 3;
- case 8: return 4;
- case 16: return 5;
- case 32: return 6;
- }
- return 0;
-}
-
-static __inline struct brw_reg stride( struct brw_reg reg,
- unsigned vstride,
- unsigned width,
- unsigned hstride )
-{
-
- reg.vstride = cvt(vstride);
- reg.width = cvt(width) - 1;
- reg.hstride = cvt(hstride);
- return reg;
-}
-
-static __inline struct brw_reg vec16( struct brw_reg reg )
-{
- return stride(reg, 16,16,1);
-}
-
-static __inline struct brw_reg vec8( struct brw_reg reg )
-{
- return stride(reg, 8,8,1);
-}
-
-static __inline struct brw_reg vec4( struct brw_reg reg )
-{
- return stride(reg, 4,4,1);
-}
-
-static __inline struct brw_reg vec2( struct brw_reg reg )
-{
- return stride(reg, 2,2,1);
-}
-
-static __inline struct brw_reg vec1( struct brw_reg reg )
-{
- return stride(reg, 0,1,0);
-}
-
-static __inline struct brw_reg get_element( struct brw_reg reg, unsigned elt )
-{
- return vec1(suboffset(reg, elt));
-}
-
-static __inline struct brw_reg get_element_ud( struct brw_reg reg, unsigned elt )
-{
- return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_UD), elt));
-}
-
-
-static __inline struct brw_reg brw_swizzle( struct brw_reg reg,
- unsigned x,
- unsigned y,
- unsigned z,
- unsigned w)
-{
- reg.dw1.bits.swizzle = BRW_SWIZZLE4(BRW_GET_SWZ(reg.dw1.bits.swizzle, x),
- BRW_GET_SWZ(reg.dw1.bits.swizzle, y),
- BRW_GET_SWZ(reg.dw1.bits.swizzle, z),
- BRW_GET_SWZ(reg.dw1.bits.swizzle, w));
- return reg;
-}
-
-
-static __inline struct brw_reg brw_swizzle1( struct brw_reg reg,
- unsigned x )
-{
- return brw_swizzle(reg, x, x, x, x);
-}
-
-static __inline struct brw_reg brw_writemask( struct brw_reg reg,
- unsigned mask )
-{
- reg.dw1.bits.writemask &= mask;
- return reg;
-}
-
-static __inline struct brw_reg brw_set_writemask( struct brw_reg reg,
- unsigned mask )
-{
- reg.dw1.bits.writemask = mask;
- return reg;
-}
-
-static __inline struct brw_reg negate( struct brw_reg reg )
-{
- reg.negate ^= 1;
- return reg;
-}
-
-static __inline struct brw_reg brw_abs( struct brw_reg reg )
-{
- reg.abs = 1;
- return reg;
-}
-
-/***********************************************************************
- */
-static __inline struct brw_reg brw_vec4_indirect( unsigned subnr,
- int offset )
-{
- struct brw_reg reg = brw_vec4_grf(0, 0);
- reg.subnr = subnr;
- reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
- reg.dw1.bits.indirect_offset = offset;
- return reg;
-}
-
-static __inline struct brw_reg brw_vec1_indirect( unsigned subnr,
- int offset )
-{
- struct brw_reg reg = brw_vec1_grf(0, 0);
- reg.subnr = subnr;
- reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
- reg.dw1.bits.indirect_offset = offset;
- return reg;
-}
-
-static __inline struct brw_reg deref_4f(struct brw_indirect ptr, int offset)
-{
- return brw_vec4_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
-}
-
-static __inline struct brw_reg deref_1f(struct brw_indirect ptr, int offset)
-{
- return brw_vec1_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
-}
-
-static __inline struct brw_reg deref_4b(struct brw_indirect ptr, int offset)
-{
- return retype(deref_4f(ptr, offset), BRW_REGISTER_TYPE_B);
-}
-
-static __inline struct brw_reg deref_1uw(struct brw_indirect ptr, int offset)
-{
- return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW);
-}
-
-static __inline struct brw_reg deref_1ud(struct brw_indirect ptr, int offset)
-{
- return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD);
-}
-
-static __inline struct brw_reg get_addr_reg(struct brw_indirect ptr)
-{
- return brw_address_reg(ptr.addr_subnr);
-}
-
-static __inline struct brw_indirect brw_indirect_offset( struct brw_indirect ptr, int offset )
-{
- ptr.addr_offset += offset;
- return ptr;
-}
-
-static __inline struct brw_indirect brw_indirect( unsigned addr_subnr, int offset )
-{
- struct brw_indirect ptr;
- ptr.addr_subnr = addr_subnr;
- ptr.addr_offset = offset;
- ptr.pad = 0;
- return ptr;
-}
-
-static __inline struct brw_instruction *current_insn( struct brw_compile *p)
-{
- return &p->store[p->nr_insn];
-}
-
-void brw_pop_insn_state( struct brw_compile *p );
-void brw_push_insn_state( struct brw_compile *p );
-void brw_set_mask_control( struct brw_compile *p, unsigned value );
-void brw_set_saturate( struct brw_compile *p, unsigned value );
-void brw_set_access_mode( struct brw_compile *p, unsigned access_mode );
-void brw_set_compression_control( struct brw_compile *p, boolean control );
-void brw_set_predicate_control_flag_value( struct brw_compile *p, unsigned value );
-void brw_set_predicate_control( struct brw_compile *p, unsigned pc );
-void brw_set_conditionalmod( struct brw_compile *p, unsigned conditional );
-
-void brw_init_compile( struct brw_compile *p );
-const unsigned *brw_get_program( struct brw_compile *p, unsigned *sz );
-
-
-struct brw_instruction *brw_alu1( struct brw_compile *p,
- unsigned opcode,
- struct brw_reg dest,
- struct brw_reg src );
-
-struct brw_instruction *brw_alu2(struct brw_compile *p,
- unsigned opcode,
- struct brw_reg dest,
- struct brw_reg src0,
- struct brw_reg src1 );
-
-/* Helpers for regular instructions:
- */
-#define ALU1(OP) \
-struct brw_instruction *brw_##OP(struct brw_compile *p, \
- struct brw_reg dest, \
- struct brw_reg src0);
-
-#define ALU2(OP) \
-struct brw_instruction *brw_##OP(struct brw_compile *p, \
- struct brw_reg dest, \
- struct brw_reg src0, \
- struct brw_reg src1);
-
-ALU1(MOV)
-ALU2(SEL)
-ALU1(NOT)
-ALU2(AND)
-ALU2(OR)
-ALU2(XOR)
-ALU2(SHR)
-ALU2(SHL)
-ALU2(RSR)
-ALU2(RSL)
-ALU2(ASR)
-ALU2(JMPI)
-ALU2(ADD)
-ALU2(MUL)
-ALU1(FRC)
-ALU1(RNDD)
-ALU2(MAC)
-ALU2(MACH)
-ALU1(LZD)
-ALU2(DP4)
-ALU2(DPH)
-ALU2(DP3)
-ALU2(DP2)
-ALU2(LINE)
-
-#undef ALU1
-#undef ALU2
-
-
-
-/* Helpers for SEND instruction:
- */
-void brw_urb_WRITE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- boolean allocate,
- boolean used,
- unsigned msg_length,
- unsigned response_length,
- boolean eot,
- boolean writes_complete,
- unsigned offset,
- unsigned swizzle);
-
-void brw_fb_WRITE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- unsigned binding_table_index,
- unsigned msg_length,
- unsigned response_length,
- boolean eot);
-
-void brw_SAMPLE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- unsigned binding_table_index,
- unsigned sampler,
- unsigned writemask,
- unsigned msg_type,
- unsigned response_length,
- unsigned msg_length,
- boolean eot);
-
-void brw_math_16( struct brw_compile *p,
- struct brw_reg dest,
- unsigned function,
- unsigned saturate,
- unsigned msg_reg_nr,
- struct brw_reg src,
- unsigned precision );
-
-void brw_math( struct brw_compile *p,
- struct brw_reg dest,
- unsigned function,
- unsigned saturate,
- unsigned msg_reg_nr,
- struct brw_reg src,
- unsigned data_type,
- unsigned precision );
-
-void brw_dp_READ_16( struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- unsigned scratch_offset );
-
-void brw_dp_WRITE_16( struct brw_compile *p,
- struct brw_reg src,
- unsigned msg_reg_nr,
- unsigned scratch_offset );
-
-/* If/else/endif. Works by manipulating the execution flags on each
- * channel.
- */
-struct brw_instruction *brw_IF(struct brw_compile *p,
- unsigned execute_size);
-
-struct brw_instruction *brw_ELSE(struct brw_compile *p,
- struct brw_instruction *if_insn);
-
-void brw_ENDIF(struct brw_compile *p,
- struct brw_instruction *if_or_else_insn);
-
-
-/* DO/WHILE loops:
- */
-struct brw_instruction *brw_DO(struct brw_compile *p,
- unsigned execute_size);
-
-struct brw_instruction *brw_WHILE(struct brw_compile *p,
- struct brw_instruction *patch_insn);
-
-struct brw_instruction *brw_BREAK(struct brw_compile *p);
-struct brw_instruction *brw_CONT(struct brw_compile *p);
-/* Forward jumps:
- */
-void brw_land_fwd_jump(struct brw_compile *p,
- struct brw_instruction *jmp_insn);
-
-
-
-void brw_NOP(struct brw_compile *p);
-
-/* Special case: there is never a destination, execution size will be
- * taken from src0:
- */
-void brw_CMP(struct brw_compile *p,
- struct brw_reg dest,
- unsigned conditional,
- struct brw_reg src0,
- struct brw_reg src1);
-
-void brw_print_reg( struct brw_reg reg );
-
-
-/***********************************************************************
- * brw_eu_util.c:
- */
-
-void brw_copy_indirect_to_indirect(struct brw_compile *p,
- struct brw_indirect dst_ptr,
- struct brw_indirect src_ptr,
- unsigned count);
-
-void brw_copy_from_indirect(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_indirect ptr,
- unsigned count);
-
-void brw_copy4(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src,
- unsigned count);
-
-void brw_copy8(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src,
- unsigned count);
-
-void brw_math_invert( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src);
-
-void brw_set_src1( struct brw_instruction *insn,
- struct brw_reg reg );
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_eu_debug.c b/src/mesa/pipe/i965simple/brw_eu_debug.c
deleted file mode 100644
index 4a94ddefa6..0000000000
--- a/src/mesa/pipe/i965simple/brw_eu_debug.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_debug.h"
-
-#include "brw_eu.h"
-
-void brw_print_reg( struct brw_reg hwreg )
-{
- static const char *file[] = {
- "arf",
- "grf",
- "msg",
- "imm"
- };
-
- static const char *type[] = {
- "ud",
- "d",
- "uw",
- "w",
- "ub",
- "vf",
- "hf",
- "f"
- };
-
- debug_printf("%s%s",
- hwreg.abs ? "abs/" : "",
- hwreg.negate ? "-" : "");
-
- if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
- hwreg.nr % 2 == 0 &&
- hwreg.subnr == 0 &&
- hwreg.vstride == BRW_VERTICAL_STRIDE_8 &&
- hwreg.width == BRW_WIDTH_8 &&
- hwreg.hstride == BRW_HORIZONTAL_STRIDE_1 &&
- hwreg.type == BRW_REGISTER_TYPE_F) {
- debug_printf("vec%d", hwreg.nr);
- }
- else if (hwreg.file == BRW_GENERAL_REGISTER_FILE &&
- hwreg.vstride == BRW_VERTICAL_STRIDE_0 &&
- hwreg.width == BRW_WIDTH_1 &&
- hwreg.hstride == BRW_HORIZONTAL_STRIDE_0 &&
- hwreg.type == BRW_REGISTER_TYPE_F) {
- debug_printf("scl%d.%d", hwreg.nr, hwreg.subnr / 4);
- }
- else {
- debug_printf("%s%d.%d<%d;%d,%d>:%s",
- file[hwreg.file],
- hwreg.nr,
- hwreg.subnr / type_sz(hwreg.type),
- hwreg.vstride ? (1<<(hwreg.vstride-1)) : 0,
- 1<<hwreg.width,
- hwreg.hstride ? (1<<(hwreg.hstride-1)) : 0,
- type[hwreg.type]);
- }
-}
-
-
-
diff --git a/src/mesa/pipe/i965simple/brw_eu_emit.c b/src/mesa/pipe/i965simple/brw_eu_emit.c
deleted file mode 100644
index 400a80b6fb..0000000000
--- a/src/mesa/pipe/i965simple/brw_eu_emit.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_eu.h"
-
-
-
-
-/***********************************************************************
- * Internal helper for constructing instructions
- */
-
-static void guess_execution_size( struct brw_instruction *insn,
- struct brw_reg reg )
-{
- if (reg.width == BRW_WIDTH_8 &&
- insn->header.compression_control == BRW_COMPRESSION_COMPRESSED)
- insn->header.execution_size = BRW_EXECUTE_16;
- else
- insn->header.execution_size = reg.width; /* note - definitions are compatible */
-}
-
-
-static void brw_set_dest( struct brw_instruction *insn,
- struct brw_reg dest )
-{
- insn->bits1.da1.dest_reg_file = dest.file;
- insn->bits1.da1.dest_reg_type = dest.type;
- insn->bits1.da1.dest_address_mode = dest.address_mode;
-
- if (dest.address_mode == BRW_ADDRESS_DIRECT) {
- insn->bits1.da1.dest_reg_nr = dest.nr;
-
- if (insn->header.access_mode == BRW_ALIGN_1) {
- insn->bits1.da1.dest_subreg_nr = dest.subnr;
- insn->bits1.da1.dest_horiz_stride = BRW_HORIZONTAL_STRIDE_1;
- }
- else {
- insn->bits1.da16.dest_subreg_nr = dest.subnr / 16;
- insn->bits1.da16.dest_writemask = dest.dw1.bits.writemask;
- }
- }
- else {
- insn->bits1.ia1.dest_subreg_nr = dest.subnr;
-
- /* These are different sizes in align1 vs align16:
- */
- if (insn->header.access_mode == BRW_ALIGN_1) {
- insn->bits1.ia1.dest_indirect_offset = dest.dw1.bits.indirect_offset;
- insn->bits1.ia1.dest_horiz_stride = BRW_HORIZONTAL_STRIDE_1;
- }
- else {
- insn->bits1.ia16.dest_indirect_offset = dest.dw1.bits.indirect_offset;
- }
- }
-
- /* NEW: Set the execution size based on dest.width and
- * insn->compression_control:
- */
- guess_execution_size(insn, dest);
-}
-
-static void brw_set_src0( struct brw_instruction *insn,
- struct brw_reg reg )
-{
- assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
-
- insn->bits1.da1.src0_reg_file = reg.file;
- insn->bits1.da1.src0_reg_type = reg.type;
- insn->bits2.da1.src0_abs = reg.abs;
- insn->bits2.da1.src0_negate = reg.negate;
- insn->bits2.da1.src0_address_mode = reg.address_mode;
-
- if (reg.file == BRW_IMMEDIATE_VALUE) {
- insn->bits3.ud = reg.dw1.ud;
-
- /* Required to set some fields in src1 as well:
- */
- insn->bits1.da1.src1_reg_file = 0; /* arf */
- insn->bits1.da1.src1_reg_type = reg.type;
- }
- else
- {
- if (reg.address_mode == BRW_ADDRESS_DIRECT) {
- if (insn->header.access_mode == BRW_ALIGN_1) {
- insn->bits2.da1.src0_subreg_nr = reg.subnr;
- insn->bits2.da1.src0_reg_nr = reg.nr;
- }
- else {
- insn->bits2.da16.src0_subreg_nr = reg.subnr / 16;
- insn->bits2.da16.src0_reg_nr = reg.nr;
- }
- }
- else {
- insn->bits2.ia1.src0_subreg_nr = reg.subnr;
-
- if (insn->header.access_mode == BRW_ALIGN_1) {
- insn->bits2.ia1.src0_indirect_offset = reg.dw1.bits.indirect_offset;
- }
- else {
- insn->bits2.ia16.src0_subreg_nr = reg.dw1.bits.indirect_offset;
- }
- }
-
- if (insn->header.access_mode == BRW_ALIGN_1) {
- if (reg.width == BRW_WIDTH_1 &&
- insn->header.execution_size == BRW_EXECUTE_1) {
- insn->bits2.da1.src0_horiz_stride = BRW_HORIZONTAL_STRIDE_0;
- insn->bits2.da1.src0_width = BRW_WIDTH_1;
- insn->bits2.da1.src0_vert_stride = BRW_VERTICAL_STRIDE_0;
- }
- else {
- insn->bits2.da1.src0_horiz_stride = reg.hstride;
- insn->bits2.da1.src0_width = reg.width;
- insn->bits2.da1.src0_vert_stride = reg.vstride;
- }
- }
- else {
- insn->bits2.da16.src0_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);
- insn->bits2.da16.src0_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);
- insn->bits2.da16.src0_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);
- insn->bits2.da16.src0_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);
-
- /* This is an oddity of the fact we're using the same
- * descriptions for registers in align_16 as align_1:
- */
- if (reg.vstride == BRW_VERTICAL_STRIDE_8)
- insn->bits2.da16.src0_vert_stride = BRW_VERTICAL_STRIDE_4;
- else
- insn->bits2.da16.src0_vert_stride = reg.vstride;
- }
- }
-}
-
-
-void brw_set_src1( struct brw_instruction *insn,
- struct brw_reg reg )
-{
- assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
-
- insn->bits1.da1.src1_reg_file = reg.file;
- insn->bits1.da1.src1_reg_type = reg.type;
- insn->bits3.da1.src1_abs = reg.abs;
- insn->bits3.da1.src1_negate = reg.negate;
-
- /* Only src1 can be immediate in two-argument instructions.
- */
- assert(insn->bits1.da1.src0_reg_file != BRW_IMMEDIATE_VALUE);
-
- if (reg.file == BRW_IMMEDIATE_VALUE) {
- insn->bits3.ud = reg.dw1.ud;
- }
- else {
- /* This is a hardware restriction, which may or may not be lifted
- * in the future:
- */
- assert (reg.address_mode == BRW_ADDRESS_DIRECT);
- //assert (reg.file == BRW_GENERAL_REGISTER_FILE);
-
- if (insn->header.access_mode == BRW_ALIGN_1) {
- insn->bits3.da1.src1_subreg_nr = reg.subnr;
- insn->bits3.da1.src1_reg_nr = reg.nr;
- }
- else {
- insn->bits3.da16.src1_subreg_nr = reg.subnr / 16;
- insn->bits3.da16.src1_reg_nr = reg.nr;
- }
-
- if (insn->header.access_mode == BRW_ALIGN_1) {
- if (reg.width == BRW_WIDTH_1 &&
- insn->header.execution_size == BRW_EXECUTE_1) {
- insn->bits3.da1.src1_horiz_stride = BRW_HORIZONTAL_STRIDE_0;
- insn->bits3.da1.src1_width = BRW_WIDTH_1;
- insn->bits3.da1.src1_vert_stride = BRW_VERTICAL_STRIDE_0;
- }
- else {
- insn->bits3.da1.src1_horiz_stride = reg.hstride;
- insn->bits3.da1.src1_width = reg.width;
- insn->bits3.da1.src1_vert_stride = reg.vstride;
- }
- }
- else {
- insn->bits3.da16.src1_swz_x = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_X);
- insn->bits3.da16.src1_swz_y = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Y);
- insn->bits3.da16.src1_swz_z = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_Z);
- insn->bits3.da16.src1_swz_w = BRW_GET_SWZ(reg.dw1.bits.swizzle, BRW_CHANNEL_W);
-
- /* This is an oddity of the fact we're using the same
- * descriptions for registers in align_16 as align_1:
- */
- if (reg.vstride == BRW_VERTICAL_STRIDE_8)
- insn->bits3.da16.src1_vert_stride = BRW_VERTICAL_STRIDE_4;
- else
- insn->bits3.da16.src1_vert_stride = reg.vstride;
- }
- }
-}
-
-
-
-static void brw_set_math_message( struct brw_instruction *insn,
- unsigned msg_length,
- unsigned response_length,
- unsigned function,
- unsigned integer_type,
- boolean low_precision,
- boolean saturate,
- unsigned dataType )
-{
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->bits3.math.function = function;
- insn->bits3.math.int_type = integer_type;
- insn->bits3.math.precision = low_precision;
- insn->bits3.math.saturate = saturate;
- insn->bits3.math.data_type = dataType;
- insn->bits3.math.response_length = response_length;
- insn->bits3.math.msg_length = msg_length;
- insn->bits3.math.msg_target = BRW_MESSAGE_TARGET_MATH;
- insn->bits3.math.end_of_thread = 0;
-}
-
-static void brw_set_urb_message( struct brw_instruction *insn,
- boolean allocate,
- boolean used,
- unsigned msg_length,
- unsigned response_length,
- boolean end_of_thread,
- boolean complete,
- unsigned offset,
- unsigned swizzle_control )
-{
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->bits3.urb.opcode = 0; /* ? */
- insn->bits3.urb.offset = offset;
- insn->bits3.urb.swizzle_control = swizzle_control;
- insn->bits3.urb.allocate = allocate;
- insn->bits3.urb.used = used; /* ? */
- insn->bits3.urb.complete = complete;
- insn->bits3.urb.response_length = response_length;
- insn->bits3.urb.msg_length = msg_length;
- insn->bits3.urb.msg_target = BRW_MESSAGE_TARGET_URB;
- insn->bits3.urb.end_of_thread = end_of_thread;
-}
-
-static void brw_set_dp_write_message( struct brw_instruction *insn,
- unsigned binding_table_index,
- unsigned msg_control,
- unsigned msg_type,
- unsigned msg_length,
- unsigned pixel_scoreboard_clear,
- unsigned response_length,
- unsigned end_of_thread )
-{
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->bits3.dp_write.binding_table_index = binding_table_index;
- insn->bits3.dp_write.msg_control = msg_control;
- insn->bits3.dp_write.pixel_scoreboard_clear = pixel_scoreboard_clear;
- insn->bits3.dp_write.msg_type = msg_type;
- insn->bits3.dp_write.send_commit_msg = 0;
- insn->bits3.dp_write.response_length = response_length;
- insn->bits3.dp_write.msg_length = msg_length;
- insn->bits3.dp_write.msg_target = BRW_MESSAGE_TARGET_DATAPORT_WRITE;
- insn->bits3.urb.end_of_thread = end_of_thread;
-}
-
-static void brw_set_dp_read_message( struct brw_instruction *insn,
- unsigned binding_table_index,
- unsigned msg_control,
- unsigned msg_type,
- unsigned target_cache,
- unsigned msg_length,
- unsigned response_length,
- unsigned end_of_thread )
-{
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->bits3.dp_read.binding_table_index = binding_table_index;
- insn->bits3.dp_read.msg_control = msg_control;
- insn->bits3.dp_read.msg_type = msg_type;
- insn->bits3.dp_read.target_cache = target_cache;
- insn->bits3.dp_read.response_length = response_length;
- insn->bits3.dp_read.msg_length = msg_length;
- insn->bits3.dp_read.msg_target = BRW_MESSAGE_TARGET_DATAPORT_READ;
- insn->bits3.dp_read.end_of_thread = end_of_thread;
-}
-
-static void brw_set_sampler_message( struct brw_instruction *insn,
- unsigned binding_table_index,
- unsigned sampler,
- unsigned msg_type,
- unsigned response_length,
- unsigned msg_length,
- boolean eot)
-{
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->bits3.sampler.binding_table_index = binding_table_index;
- insn->bits3.sampler.sampler = sampler;
- insn->bits3.sampler.msg_type = msg_type;
- insn->bits3.sampler.return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
- insn->bits3.sampler.response_length = response_length;
- insn->bits3.sampler.msg_length = msg_length;
- insn->bits3.sampler.end_of_thread = eot;
- insn->bits3.sampler.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
-}
-
-
-
-static struct brw_instruction *next_insn( struct brw_compile *p,
- unsigned opcode )
-{
- struct brw_instruction *insn;
-
- assert(p->nr_insn + 1 < BRW_EU_MAX_INSN);
-
- insn = &p->store[p->nr_insn++];
- memcpy(insn, p->current, sizeof(*insn));
-
- /* Reset this one-shot flag:
- */
-
- if (p->current->header.destreg__conditonalmod) {
- p->current->header.destreg__conditonalmod = 0;
- p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
- }
-
- insn->header.opcode = opcode;
- return insn;
-}
-
-
-struct brw_instruction *brw_alu1( struct brw_compile *p,
- unsigned opcode,
- struct brw_reg dest,
- struct brw_reg src )
-{
- struct brw_instruction *insn = next_insn(p, opcode);
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src);
- return insn;
-}
-
-struct brw_instruction *brw_alu2(struct brw_compile *p,
- unsigned opcode,
- struct brw_reg dest,
- struct brw_reg src0,
- struct brw_reg src1 )
-{
- struct brw_instruction *insn = next_insn(p, opcode);
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src0);
- brw_set_src1(insn, src1);
- return insn;
-}
-
-
-/***********************************************************************
- * Convenience routines.
- */
-#define ALU1(OP) \
-struct brw_instruction *brw_##OP(struct brw_compile *p, \
- struct brw_reg dest, \
- struct brw_reg src0) \
-{ \
- return brw_alu1(p, BRW_OPCODE_##OP, dest, src0); \
-}
-
-#define ALU2(OP) \
-struct brw_instruction *brw_##OP(struct brw_compile *p, \
- struct brw_reg dest, \
- struct brw_reg src0, \
- struct brw_reg src1) \
-{ \
- return brw_alu2(p, BRW_OPCODE_##OP, dest, src0, src1); \
-}
-
-
-ALU1(MOV)
-ALU2(SEL)
-ALU1(NOT)
-ALU2(AND)
-ALU2(OR)
-ALU2(XOR)
-ALU2(SHR)
-ALU2(SHL)
-ALU2(RSR)
-ALU2(RSL)
-ALU2(ASR)
-ALU2(ADD)
-ALU2(MUL)
-ALU1(FRC)
-ALU1(RNDD)
-ALU2(MAC)
-ALU2(MACH)
-ALU1(LZD)
-ALU2(DP4)
-ALU2(DPH)
-ALU2(DP3)
-ALU2(DP2)
-ALU2(LINE)
-
-
-
-
-void brw_NOP(struct brw_compile *p)
-{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_NOP);
- brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src1(insn, brw_imm_ud(0x0));
-}
-
-
-
-
-
-/***********************************************************************
- * Comparisons, if/else/endif
- */
-
-struct brw_instruction *brw_JMPI(struct brw_compile *p,
- struct brw_reg dest,
- struct brw_reg src0,
- struct brw_reg src1)
-{
- struct brw_instruction *insn = brw_alu2(p, BRW_OPCODE_JMPI, dest, src0, src1);
-
- p->current->header.predicate_control = BRW_PREDICATE_NONE;
-
- return insn;
-}
-
-/* EU takes the value from the flag register and pushes it onto some
- * sort of a stack (presumably merging with any flag value already on
- * the stack). Within an if block, the flags at the top of the stack
- * control execution on each channel of the unit, eg. on each of the
- * 16 pixel values in our wm programs.
- *
- * When the matching 'else' instruction is reached (presumably by
- * countdown of the instruction count patched in by our ELSE/ENDIF
- * functions), the relevent flags are inverted.
- *
- * When the matching 'endif' instruction is reached, the flags are
- * popped off. If the stack is now empty, normal execution resumes.
- *
- * No attempt is made to deal with stack overflow (14 elements?).
- */
-struct brw_instruction *brw_IF(struct brw_compile *p, unsigned execute_size)
-{
- struct brw_instruction *insn;
-
- if (p->single_program_flow) {
- assert(execute_size == BRW_EXECUTE_1);
-
- insn = next_insn(p, BRW_OPCODE_ADD);
- insn->header.predicate_inverse = 1;
- } else {
- insn = next_insn(p, BRW_OPCODE_IF);
- }
-
- /* Override the defaults for this instruction:
- */
- brw_set_dest(insn, brw_ip_reg());
- brw_set_src0(insn, brw_ip_reg());
- brw_set_src1(insn, brw_imm_d(0x0));
-
- insn->header.execution_size = execute_size;
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.predicate_control = BRW_PREDICATE_NORMAL;
- insn->header.mask_control = BRW_MASK_ENABLE;
-
- p->current->header.predicate_control = BRW_PREDICATE_NONE;
-
- return insn;
-}
-
-
-struct brw_instruction *brw_ELSE(struct brw_compile *p,
- struct brw_instruction *if_insn)
-{
- struct brw_instruction *insn;
-
- if (p->single_program_flow) {
- insn = next_insn(p, BRW_OPCODE_ADD);
- } else {
- insn = next_insn(p, BRW_OPCODE_ELSE);
- }
-
- brw_set_dest(insn, brw_ip_reg());
- brw_set_src0(insn, brw_ip_reg());
- brw_set_src1(insn, brw_imm_d(0x0));
-
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = if_insn->header.execution_size;
- insn->header.mask_control = BRW_MASK_ENABLE;
-
- /* Patch the if instruction to point at this instruction.
- */
- if (p->single_program_flow) {
- assert(if_insn->header.opcode == BRW_OPCODE_ADD);
-
- if_insn->bits3.ud = (insn - if_insn + 1) * 16;
- } else {
- assert(if_insn->header.opcode == BRW_OPCODE_IF);
-
- if_insn->bits3.if_else.jump_count = insn - if_insn;
- if_insn->bits3.if_else.pop_count = 1;
- if_insn->bits3.if_else.pad0 = 0;
- }
-
- return insn;
-}
-
-void brw_ENDIF(struct brw_compile *p,
- struct brw_instruction *patch_insn)
-{
- if (p->single_program_flow) {
- /* In single program flow mode, there's no need to execute an ENDIF,
- * since we don't need to do any stack operations, and if we're executing
- * currently, we want to just continue executing.
- */
- struct brw_instruction *next = &p->store[p->nr_insn];
-
- assert(patch_insn->header.opcode == BRW_OPCODE_ADD);
-
- patch_insn->bits3.ud = (next - patch_insn) * 16;
- } else {
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_ENDIF);
-
- brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src1(insn, brw_imm_d(0x0));
-
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = patch_insn->header.execution_size;
- insn->header.mask_control = BRW_MASK_ENABLE;
-
- assert(patch_insn->bits3.if_else.jump_count == 0);
-
- /* Patch the if or else instructions to point at this or the next
- * instruction respectively.
- */
- if (patch_insn->header.opcode == BRW_OPCODE_IF) {
- /* Automagically turn it into an IFF:
- */
- patch_insn->header.opcode = BRW_OPCODE_IFF;
- patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
- patch_insn->bits3.if_else.pop_count = 0;
- patch_insn->bits3.if_else.pad0 = 0;
- } else if (patch_insn->header.opcode == BRW_OPCODE_ELSE) {
- patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
- patch_insn->bits3.if_else.pop_count = 1;
- patch_insn->bits3.if_else.pad0 = 0;
- } else {
- assert(0);
- }
-
- /* Also pop item off the stack in the endif instruction:
- */
- insn->bits3.if_else.jump_count = 0;
- insn->bits3.if_else.pop_count = 1;
- insn->bits3.if_else.pad0 = 0;
- }
-}
-
-struct brw_instruction *brw_BREAK(struct brw_compile *p)
-{
- struct brw_instruction *insn;
- insn = next_insn(p, BRW_OPCODE_BREAK);
- brw_set_dest(insn, brw_ip_reg());
- brw_set_src0(insn, brw_ip_reg());
- brw_set_src1(insn, brw_imm_d(0x0));
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = BRW_EXECUTE_8;
- insn->header.mask_control = BRW_MASK_DISABLE;
- insn->bits3.if_else.pad0 = 0;
- return insn;
-}
-
-struct brw_instruction *brw_CONT(struct brw_compile *p)
-{
- struct brw_instruction *insn;
- insn = next_insn(p, BRW_OPCODE_CONTINUE);
- brw_set_dest(insn, brw_ip_reg());
- brw_set_src0(insn, brw_ip_reg());
- brw_set_src1(insn, brw_imm_d(0x0));
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = BRW_EXECUTE_8;
- insn->header.mask_control = BRW_MASK_DISABLE;
- insn->bits3.if_else.pad0 = 0;
- return insn;
-}
-
-/* DO/WHILE loop:
- */
-struct brw_instruction *brw_DO(struct brw_compile *p, unsigned execute_size)
-{
- if (p->single_program_flow) {
- return &p->store[p->nr_insn];
- } else {
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_DO);
-
- /* Override the defaults for this instruction:
- */
- brw_set_dest(insn, brw_null_reg());
- brw_set_src0(insn, brw_null_reg());
- brw_set_src1(insn, brw_null_reg());
-
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = execute_size;
- insn->header.predicate_control = BRW_PREDICATE_NONE;
- /* insn->header.mask_control = BRW_MASK_ENABLE; */
- insn->header.mask_control = BRW_MASK_DISABLE;
-
- return insn;
- }
-}
-
-
-
-struct brw_instruction *brw_WHILE(struct brw_compile *p,
- struct brw_instruction *do_insn)
-{
- struct brw_instruction *insn;
-
- if (p->single_program_flow)
- insn = next_insn(p, BRW_OPCODE_ADD);
- else
- insn = next_insn(p, BRW_OPCODE_WHILE);
-
- brw_set_dest(insn, brw_ip_reg());
- brw_set_src0(insn, brw_ip_reg());
- brw_set_src1(insn, brw_imm_d(0x0));
-
- insn->header.compression_control = BRW_COMPRESSION_NONE;
-
- if (p->single_program_flow) {
- insn->header.execution_size = BRW_EXECUTE_1;
-
- insn->bits3.d = (do_insn - insn) * 16;
- } else {
- insn->header.execution_size = do_insn->header.execution_size;
-
- assert(do_insn->header.opcode == BRW_OPCODE_DO);
- insn->bits3.if_else.jump_count = do_insn - insn;
- insn->bits3.if_else.pop_count = 0;
- insn->bits3.if_else.pad0 = 0;
- }
-
-/* insn->header.mask_control = BRW_MASK_ENABLE; */
-
- insn->header.mask_control = BRW_MASK_DISABLE;
- p->current->header.predicate_control = BRW_PREDICATE_NONE;
- return insn;
-}
-
-
-/* FORWARD JUMPS:
- */
-void brw_land_fwd_jump(struct brw_compile *p,
- struct brw_instruction *jmp_insn)
-{
- struct brw_instruction *landing = &p->store[p->nr_insn];
-
- assert(jmp_insn->header.opcode == BRW_OPCODE_JMPI);
- assert(jmp_insn->bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE);
-
- jmp_insn->bits3.ud = (landing - jmp_insn) - 1;
-}
-
-
-
-/* To integrate with the above, it makes sense that the comparison
- * instruction should populate the flag register. It might be simpler
- * just to use the flag reg for most WM tasks?
- */
-void brw_CMP(struct brw_compile *p,
- struct brw_reg dest,
- unsigned conditional,
- struct brw_reg src0,
- struct brw_reg src1)
-{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_CMP);
-
- insn->header.destreg__conditonalmod = conditional;
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src0);
- brw_set_src1(insn, src1);
-
-/* guess_execution_size(insn, src0); */
-
-
- /* Make it so that future instructions will use the computed flag
- * value until brw_set_predicate_control_flag_value() is called
- * again.
- */
- if (dest.file == BRW_ARCHITECTURE_REGISTER_FILE &&
- dest.nr == 0) {
- p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
- p->flag_value = 0xff;
- }
-}
-
-
-
-/***********************************************************************
- * Helpers for the various SEND message types:
- */
-
-/* Invert 8 values
- */
-void brw_math( struct brw_compile *p,
- struct brw_reg dest,
- unsigned function,
- unsigned saturate,
- unsigned msg_reg_nr,
- struct brw_reg src,
- unsigned data_type,
- unsigned precision )
-{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
- unsigned msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1;
- unsigned response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1;
-
- /* Example code doesn't set predicate_control for send
- * instructions.
- */
- insn->header.predicate_control = 0;
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src);
- brw_set_math_message(insn,
- msg_length, response_length,
- function,
- BRW_MATH_INTEGER_UNSIGNED,
- precision,
- saturate,
- data_type);
-}
-
-/* Use 2 send instructions to invert 16 elements
- */
-void brw_math_16( struct brw_compile *p,
- struct brw_reg dest,
- unsigned function,
- unsigned saturate,
- unsigned msg_reg_nr,
- struct brw_reg src,
- unsigned precision )
-{
- struct brw_instruction *insn;
- unsigned msg_length = (function == BRW_MATH_FUNCTION_POW) ? 2 : 1;
- unsigned response_length = (function == BRW_MATH_FUNCTION_SINCOS) ? 2 : 1;
-
- /* First instruction:
- */
- brw_push_insn_state(p);
- brw_set_predicate_control_flag_value(p, 0xff);
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-
- insn = next_insn(p, BRW_OPCODE_SEND);
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src);
- brw_set_math_message(insn,
- msg_length, response_length,
- function,
- BRW_MATH_INTEGER_UNSIGNED,
- precision,
- saturate,
- BRW_MATH_DATA_VECTOR);
-
- /* Second instruction:
- */
- insn = next_insn(p, BRW_OPCODE_SEND);
- insn->header.compression_control = BRW_COMPRESSION_2NDHALF;
- insn->header.destreg__conditonalmod = msg_reg_nr+1;
-
- brw_set_dest(insn, offset(dest,1));
- brw_set_src0(insn, src);
- brw_set_math_message(insn,
- msg_length, response_length,
- function,
- BRW_MATH_INTEGER_UNSIGNED,
- precision,
- saturate,
- BRW_MATH_DATA_VECTOR);
-
- brw_pop_insn_state(p);
-}
-
-
-
-
-void brw_dp_WRITE_16( struct brw_compile *p,
- struct brw_reg src,
- unsigned msg_reg_nr,
- unsigned scratch_offset )
-{
- {
- brw_push_insn_state(p);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-
- brw_MOV(p,
- retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
- brw_imm_d(scratch_offset));
-
- brw_pop_insn_state(p);
- }
-
- {
- unsigned msg_length = 3;
- struct brw_reg dest = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW);
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-
- insn->header.predicate_control = 0; /* XXX */
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src);
-
- brw_set_dp_write_message(insn,
- 255, /* bti */
- BRW_DATAPORT_OWORD_BLOCK_4_OWORDS, /* msg_control */
- BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE, /* msg_type */
- msg_length,
- 0, /* pixel scoreboard */
- 0, /* response_length */
- 0); /* eot */
- }
-
-}
-
-
-void brw_dp_READ_16( struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- unsigned scratch_offset )
-{
- {
- brw_push_insn_state(p);
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
-
- brw_MOV(p,
- retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
- brw_imm_d(scratch_offset));
-
- brw_pop_insn_state(p);
- }
-
- {
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-
- insn->header.predicate_control = 0; /* XXX */
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest); /* UW? */
- brw_set_src0(insn, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW));
-
- brw_set_dp_read_message(insn,
- 255, /* bti */
- 3, /* msg_control */
- BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ, /* msg_type */
- 1, /* target cache */
- 1, /* msg_length */
- 2, /* response_length */
- 0); /* eot */
- }
-}
-
-
-void brw_fb_WRITE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- unsigned binding_table_index,
- unsigned msg_length,
- unsigned response_length,
- boolean eot)
-{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-
- insn->header.predicate_control = 0; /* XXX */
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src0);
- brw_set_dp_write_message(insn,
- binding_table_index,
- BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE, /* msg_control */
- BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE, /* msg_type */
- msg_length,
- 1, /* pixel scoreboard */
- response_length,
- eot);
-}
-
-
-
-void brw_SAMPLE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- unsigned binding_table_index,
- unsigned sampler,
- unsigned writemask,
- unsigned msg_type,
- unsigned response_length,
- unsigned msg_length,
- boolean eot)
-{
- boolean need_stall = 0;
-
- if(writemask == 0) {
-/* debug_printf("%s: zero writemask??\n", __FUNCTION__); */
- return;
- }
-
- /* Hardware doesn't do destination dependency checking on send
- * instructions properly. Add a workaround which generates the
- * dependency by other means. In practice it seems like this bug
- * only crops up for texture samples, and only where registers are
- * written by the send and then written again later without being
- * read in between. Luckily for us, we already track that
- * information and use it to modify the writemask for the
- * instruction, so that is a guide for whether a workaround is
- * needed.
- */
- if (writemask != TGSI_WRITEMASK_XYZW) {
- unsigned dst_offset = 0;
- unsigned i, newmask = 0, len = 0;
-
- for (i = 0; i < 4; i++) {
- if (writemask & (1<<i))
- break;
- dst_offset += 2;
- }
- for (; i < 4; i++) {
- if (!(writemask & (1<<i)))
- break;
- newmask |= 1<<i;
- len++;
- }
-
- if (newmask != writemask) {
- need_stall = 1;
-/* debug_printf("need stall %x %x\n", newmask , writemask); */
- }
- else {
- struct brw_reg m1 = brw_message_reg(msg_reg_nr);
-
- newmask = ~newmask & TGSI_WRITEMASK_XYZW;
-
- brw_push_insn_state(p);
-
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
-
- brw_MOV(p, m1, brw_vec8_grf(0,0));
- brw_MOV(p, get_element_ud(m1, 2), brw_imm_ud(newmask << 12));
-
- brw_pop_insn_state(p);
-
- src0 = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW);
- dest = offset(dest, dst_offset);
- response_length = len * 2;
- }
- }
-
- {
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-
- insn->header.predicate_control = 0; /* XXX */
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src0);
- brw_set_sampler_message(insn,
- binding_table_index,
- sampler,
- msg_type,
- response_length,
- msg_length,
- eot);
- }
-
- if (need_stall)
- {
- struct brw_reg reg = vec8(offset(dest, response_length-1));
-
- /* mov (8) r9.0<1>:f r9.0<8;8,1>:f { Align1 }
- */
- brw_push_insn_state(p);
- brw_set_compression_control(p, FALSE);
- brw_MOV(p, reg, reg);
- brw_pop_insn_state(p);
- }
-
-}
-
-/* All these variables are pretty confusing - we might be better off
- * using bitmasks and macros for this, in the old style. Or perhaps
- * just having the caller instantiate the fields in dword3 itself.
- */
-void brw_urb_WRITE(struct brw_compile *p,
- struct brw_reg dest,
- unsigned msg_reg_nr,
- struct brw_reg src0,
- boolean allocate,
- boolean used,
- unsigned msg_length,
- unsigned response_length,
- boolean eot,
- boolean writes_complete,
- unsigned offset,
- unsigned swizzle)
-{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_SEND);
-
- assert(msg_length < 16);
-
- brw_set_dest(insn, dest);
- brw_set_src0(insn, src0);
- brw_set_src1(insn, brw_imm_d(0));
-
- insn->header.destreg__conditonalmod = msg_reg_nr;
-
- brw_set_urb_message(insn,
- allocate,
- used,
- msg_length,
- response_length,
- eot,
- writes_complete,
- offset,
- swizzle);
-}
-
diff --git a/src/mesa/pipe/i965simple/brw_eu_util.c b/src/mesa/pipe/i965simple/brw_eu_util.c
deleted file mode 100644
index 3a65b141f0..0000000000
--- a/src/mesa/pipe/i965simple/brw_eu_util.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_eu.h"
-
-
-void brw_math_invert( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src)
-{
- brw_math( p,
- dst,
- BRW_MATH_FUNCTION_INV,
- BRW_MATH_SATURATE_NONE,
- 0,
- src,
- BRW_MATH_PRECISION_FULL,
- BRW_MATH_DATA_VECTOR );
-}
-
-
-
-void brw_copy4(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src,
- unsigned count)
-{
- unsigned i;
-
- dst = vec4(dst);
- src = vec4(src);
-
- for (i = 0; i < count; i++)
- {
- unsigned delta = i*32;
- brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
- brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
- }
-}
-
-
-void brw_copy8(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg src,
- unsigned count)
-{
- unsigned i;
-
- dst = vec8(dst);
- src = vec8(src);
-
- for (i = 0; i < count; i++)
- {
- unsigned delta = i*32;
- brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
- }
-}
-
-
-void brw_copy_indirect_to_indirect(struct brw_compile *p,
- struct brw_indirect dst_ptr,
- struct brw_indirect src_ptr,
- unsigned count)
-{
- unsigned i;
-
- for (i = 0; i < count; i++)
- {
- unsigned delta = i*32;
- brw_MOV(p, deref_4f(dst_ptr, delta), deref_4f(src_ptr, delta));
- brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
- }
-}
-
-
-void brw_copy_from_indirect(struct brw_compile *p,
- struct brw_reg dst,
- struct brw_indirect ptr,
- unsigned count)
-{
- unsigned i;
-
- dst = vec4(dst);
-
- for (i = 0; i < count; i++)
- {
- unsigned delta = i*32;
- brw_MOV(p, byte_offset(dst, delta), deref_4f(ptr, delta));
- brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
- }
-}
-
-
-
-
diff --git a/src/mesa/pipe/i965simple/brw_flush.c b/src/mesa/pipe/i965simple/brw_flush.c
deleted file mode 100644
index 5216c680cf..0000000000
--- a/src/mesa/pipe/i965simple/brw_flush.c
+++ /dev/null
@@ -1,80 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_defines.h"
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_batch.h"
-
-
-/**
- * In future we may want a fence-like interface instead of finish.
- */
-static void brw_flush( struct pipe_context *pipe,
- unsigned flags )
-{
- struct brw_context *brw = brw_context(pipe);
- struct pipe_fence_handle *fence;
-
- /* Do we need to emit an MI_FLUSH command to flush the hardware
- * caches?
- */
- if (flags & (PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE)) {
- struct brw_mi_flush flush;
-
- memset(&flush, 0, sizeof(flush));
- flush.opcode = CMD_MI_FLUSH;
-
- if (!(flags & PIPE_FLUSH_RENDER_CACHE))
- flush.flags |= BRW_INHIBIT_FLUSH_RENDER_CACHE;
-
- if (flags & PIPE_FLUSH_TEXTURE_CACHE)
- flush.flags |= BRW_FLUSH_READ_CACHE;
-
- BRW_BATCH_STRUCT(brw, &flush);
- }
-
- /* If there are no flags, just flush pending commands to hardware:
- */
- FLUSH_BATCH( &fence );
-
- if (flags & PIPE_FLUSH_WAIT) {
-// brw->winsys->wait_fence(brw->winsys, fence);
- }
-}
-
-
-
-void brw_init_flush_functions( struct brw_context *brw )
-{
- brw->pipe.flush = brw_flush;
-}
diff --git a/src/mesa/pipe/i965simple/brw_gs.c b/src/mesa/pipe/i965simple/brw_gs.c
deleted file mode 100644
index de60868ccc..0000000000
--- a/src/mesa/pipe/i965simple/brw_gs.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_state.h"
-#include "brw_gs.h"
-
-
-
-static void compile_gs_prog( struct brw_context *brw,
- struct brw_gs_prog_key *key )
-{
- struct brw_gs_compile c;
- const unsigned *program;
- unsigned program_size;
-
- memset(&c, 0, sizeof(c));
-
- c.key = *key;
-
- /* Need to locate the two positions present in vertex + header.
- * These are currently hardcoded:
- */
- c.nr_attrs = brw_count_bits(c.key.attrs);
- c.nr_regs = (c.nr_attrs + 1) / 2 + 1; /* are vertices packed, or reg-aligned? */
- c.nr_bytes = c.nr_regs * REG_SIZE;
-
-
- /* Begin the compilation:
- */
- brw_init_compile(&c.func);
-
- c.func.single_program_flow = 1;
-
- /* For some reason the thread is spawned with only 4 channels
- * unmasked.
- */
- brw_set_mask_control(&c.func, BRW_MASK_DISABLE);
-
-
- /* Note that primitives which don't require a GS program have
- * already been weeded out by this stage:
- */
- switch (key->primitive) {
- case PIPE_PRIM_QUADS:
- brw_gs_quads( &c );
- break;
- case PIPE_PRIM_QUAD_STRIP:
- brw_gs_quad_strip( &c );
- break;
- case PIPE_PRIM_LINE_LOOP:
- brw_gs_lines( &c );
- break;
- case PIPE_PRIM_LINES:
- if (key->hint_gs_always)
- brw_gs_lines( &c );
- else {
- return;
- }
- break;
- case PIPE_PRIM_TRIANGLES:
- if (key->hint_gs_always)
- brw_gs_tris( &c );
- else {
- return;
- }
- break;
- case PIPE_PRIM_POINTS:
- if (key->hint_gs_always)
- brw_gs_points( &c );
- else {
- return;
- }
- break;
- default:
- return;
- }
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- /* Upload
- */
- brw->gs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_GS_PROG],
- &c.key,
- sizeof(c.key),
- program,
- program_size,
- &c.prog_data,
- &brw->gs.prog_data );
-}
-
-
-static boolean search_cache( struct brw_context *brw,
- struct brw_gs_prog_key *key )
-{
- return brw_search_cache(&brw->cache[BRW_GS_PROG],
- key, sizeof(*key),
- &brw->gs.prog_data,
- &brw->gs.prog_gs_offset);
-}
-
-
-static const int gs_prim[PIPE_PRIM_POLYGON+1] = {
- PIPE_PRIM_POINTS,
- PIPE_PRIM_LINES,
- PIPE_PRIM_LINE_LOOP,
- PIPE_PRIM_LINES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_TRIANGLES,
- PIPE_PRIM_QUADS,
- PIPE_PRIM_QUAD_STRIP,
- PIPE_PRIM_TRIANGLES
-};
-
-static void populate_key( struct brw_context *brw,
- struct brw_gs_prog_key *key )
-{
- memset(key, 0, sizeof(*key));
-
- /* CACHE_NEW_VS_PROG */
- key->attrs = brw->vs.prog_data->outputs_written;
-
- /* BRW_NEW_PRIMITIVE */
- key->primitive = gs_prim[brw->primitive];
-
- key->hint_gs_always = 0; /* debug code? */
-
- key->need_gs_prog = (key->hint_gs_always ||
- brw->primitive == PIPE_PRIM_QUADS ||
- brw->primitive == PIPE_PRIM_QUAD_STRIP ||
- brw->primitive == PIPE_PRIM_LINE_LOOP);
-}
-
-/* Calculate interpolants for triangle and line rasterization.
- */
-static void upload_gs_prog( struct brw_context *brw )
-{
- struct brw_gs_prog_key key;
-
- /* Populate the key:
- */
- populate_key(brw, &key);
-
- if (brw->gs.prog_active != key.need_gs_prog) {
- brw->state.dirty.cache |= CACHE_NEW_GS_PROG;
- brw->gs.prog_active = key.need_gs_prog;
- }
-
- if (brw->gs.prog_active) {
- if (!search_cache(brw, &key))
- compile_gs_prog( brw, &key );
- }
-}
-
-
-const struct brw_tracked_state brw_gs_prog = {
- .dirty = {
- .brw = BRW_NEW_PRIMITIVE,
- .cache = CACHE_NEW_VS_PROG
- },
- .update = upload_gs_prog
-};
diff --git a/src/mesa/pipe/i965simple/brw_gs.h b/src/mesa/pipe/i965simple/brw_gs.h
deleted file mode 100644
index f09141c6aa..0000000000
--- a/src/mesa/pipe/i965simple/brw_gs.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_GS_H
-#define BRW_GS_H
-
-
-#include "brw_context.h"
-#include "brw_eu.h"
-
-#define MAX_GS_VERTS (4)
-
-struct brw_gs_prog_key {
- unsigned attrs:32;
- unsigned primitive:4;
- unsigned hint_gs_always:1;
- unsigned need_gs_prog:1;
- unsigned pad:26;
-};
-
-struct brw_gs_compile {
- struct brw_compile func;
- struct brw_gs_prog_key key;
- struct brw_gs_prog_data prog_data;
-
- struct {
- struct brw_reg R0;
- struct brw_reg vertex[MAX_GS_VERTS];
- } reg;
-
- /* 3 different ways of expressing vertex size:
- */
- unsigned nr_attrs;
- unsigned nr_regs;
- unsigned nr_bytes;
-};
-
-#define ATTR_SIZE (4*4)
-
-void brw_gs_quads( struct brw_gs_compile *c );
-void brw_gs_quad_strip( struct brw_gs_compile *c );
-void brw_gs_tris( struct brw_gs_compile *c );
-void brw_gs_lines( struct brw_gs_compile *c );
-void brw_gs_points( struct brw_gs_compile *c );
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_gs_emit.c b/src/mesa/pipe/i965simple/brw_gs_emit.c
deleted file mode 100644
index c3cc90b10f..0000000000
--- a/src/mesa/pipe/i965simple/brw_gs_emit.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_gs.h"
-
-static void brw_gs_alloc_regs( struct brw_gs_compile *c,
- unsigned nr_verts )
-{
- unsigned i = 0,j;
-
- /* Register usage is static, precompute here:
- */
- c->reg.R0 = retype(brw_vec8_grf(i, 0), BRW_REGISTER_TYPE_UD); i++;
-
- /* Payload vertices plus space for more generated vertices:
- */
- for (j = 0; j < nr_verts; j++) {
- c->reg.vertex[j] = brw_vec4_grf(i, 0);
- i += c->nr_regs;
- }
-
- c->prog_data.urb_read_length = c->nr_regs;
- c->prog_data.total_grf = i;
-}
-
-
-static void brw_gs_emit_vue(struct brw_gs_compile *c,
- struct brw_reg vert,
- boolean last,
- unsigned header)
-{
- struct brw_compile *p = &c->func;
- boolean allocate = !last;
-
- /* Overwrite PrimType and PrimStart in the message header, for
- * each vertex in turn:
- */
- brw_MOV(p, get_element_ud(c->reg.R0, 2), brw_imm_ud(header));
-
- /* Copy the vertex from vertn into m1..mN+1:
- */
- brw_copy8(p, brw_message_reg(1), vert, c->nr_regs);
-
- /* Send each vertex as a seperate write to the urb. This is
- * different to the concept in brw_sf_emit.c, where subsequent
- * writes are used to build up a single urb entry. Each of these
- * writes instantiates a seperate urb entry, and a new one must be
- * allocated each time.
- */
- brw_urb_WRITE(p,
- allocate ? c->reg.R0 : retype(brw_null_reg(), BRW_REGISTER_TYPE_UD),
- 0,
- c->reg.R0,
- allocate,
- 1, /* used */
- c->nr_regs + 1, /* msg length */
- allocate ? 1 : 0, /* response length */
- allocate ? 0 : 1, /* eot */
- 1, /* writes_complete */
- 0, /* urb offset */
- BRW_URB_SWIZZLE_NONE);
-}
-
-
-
-void brw_gs_quads( struct brw_gs_compile *c )
-{
- brw_gs_alloc_regs(c, 4);
-
- /* Use polygons for correct edgeflag behaviour. Note that vertex 3
- * is the PV for quads, but vertex 0 for polygons:
- */
- brw_gs_emit_vue(c, c->reg.vertex[3], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
- brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
- brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_POLYGON << 2));
- brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
-}
-
-void brw_gs_quad_strip( struct brw_gs_compile *c )
-{
- brw_gs_alloc_regs(c, 4);
-
- brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
- brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
- brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
- brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
-}
-
-void brw_gs_tris( struct brw_gs_compile *c )
-{
- brw_gs_alloc_regs(c, 3);
- brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_TRILIST << 2) | R02_PRIM_START));
- brw_gs_emit_vue(c, c->reg.vertex[1], 0, (_3DPRIM_TRILIST << 2));
- brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_TRILIST << 2) | R02_PRIM_END));
-}
-
-void brw_gs_lines( struct brw_gs_compile *c )
-{
- brw_gs_alloc_regs(c, 2);
- brw_gs_emit_vue(c, c->reg.vertex[0], 0, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_START));
- brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_LINESTRIP << 2) | R02_PRIM_END));
-}
-
-void brw_gs_points( struct brw_gs_compile *c )
-{
- brw_gs_alloc_regs(c, 1);
- brw_gs_emit_vue(c, c->reg.vertex[0], 1, ((_3DPRIM_POINTLIST << 2) | R02_PRIM_START | R02_PRIM_END));
-}
-
-
-
-
-
-
-
-
diff --git a/src/mesa/pipe/i965simple/brw_gs_state.c b/src/mesa/pipe/i965simple/brw_gs_state.c
deleted file mode 100644
index 3932e9e939..0000000000
--- a/src/mesa/pipe/i965simple/brw_gs_state.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "pipe/p_util.h"
-
-
-
-static void upload_gs_unit( struct brw_context *brw )
-{
- struct brw_gs_unit_state gs;
-
- memset(&gs, 0, sizeof(gs));
-
- /* CACHE_NEW_GS_PROG */
- if (brw->gs.prog_active) {
- gs.thread0.grf_reg_count =
- align(brw->gs.prog_data->total_grf, 16) / 16 - 1;
- gs.thread0.kernel_start_pointer = brw->gs.prog_gs_offset >> 6;
- gs.thread3.urb_entry_read_length = brw->gs.prog_data->urb_read_length;
- }
- else {
- gs.thread0.grf_reg_count = 0;
- gs.thread0.kernel_start_pointer = 0;
- gs.thread3.urb_entry_read_length = 1;
- }
-
- /* BRW_NEW_URB_FENCE */
- gs.thread4.nr_urb_entries = brw->urb.nr_gs_entries;
- gs.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
-
- gs.thread4.max_threads = 0; /* Hardware requirement */
-
- if (BRW_DEBUG & DEBUG_STATS)
- gs.thread4.stats_enable = 1;
-
- /* CONSTANT */
- gs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
- gs.thread1.single_program_flow = 1;
- gs.thread3.dispatch_grf_start_reg = 1;
- gs.thread3.const_urb_entry_read_offset = 0;
- gs.thread3.const_urb_entry_read_length = 0;
- gs.thread3.urb_entry_read_offset = 0;
-
-
- brw->gs.state_gs_offset = brw_cache_data( &brw->cache[BRW_GS_UNIT], &gs );
-}
-
-
-const struct brw_tracked_state brw_gs_unit = {
- .dirty = {
- .brw = (BRW_NEW_CURBE_OFFSETS |
- BRW_NEW_URB_FENCE),
- .cache = CACHE_NEW_GS_PROG
- },
- .update = upload_gs_unit
-};
diff --git a/src/mesa/pipe/i965simple/brw_misc_state.c b/src/mesa/pipe/i965simple/brw_misc_state.c
deleted file mode 100644
index 925049ecc1..0000000000
--- a/src/mesa/pipe/i965simple/brw_misc_state.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_batch.h"
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-
-
-
-
-
-/***********************************************************************
- * Blend color
- */
-
-static void upload_blend_constant_color(struct brw_context *brw)
-{
- struct brw_blend_constant_color bcc;
-
- memset(&bcc, 0, sizeof(bcc));
- bcc.header.opcode = CMD_BLEND_CONSTANT_COLOR;
- bcc.header.length = sizeof(bcc)/4-2;
- bcc.blend_constant_color[0] = brw->attribs.BlendColor.color[0];
- bcc.blend_constant_color[1] = brw->attribs.BlendColor.color[1];
- bcc.blend_constant_color[2] = brw->attribs.BlendColor.color[2];
- bcc.blend_constant_color[3] = brw->attribs.BlendColor.color[3];
-
- BRW_CACHED_BATCH_STRUCT(brw, &bcc);
-}
-
-
-const struct brw_tracked_state brw_blend_constant_color = {
- .dirty = {
- .brw = BRW_NEW_BLEND,
- .cache = 0
- },
- .update = upload_blend_constant_color
-};
-
-
-/***********************************************************************
- * Drawing rectangle
- */
-static void upload_drawing_rect(struct brw_context *brw)
-{
- struct brw_drawrect bdr;
-
- memset(&bdr, 0, sizeof(bdr));
- bdr.header.opcode = CMD_DRAW_RECT;
- bdr.header.length = sizeof(bdr)/4 - 2;
- bdr.xmin = 0;
- bdr.ymin = 0;
- bdr.xmax = brw->attribs.FrameBuffer.cbufs[0]->width;
- bdr.ymax = brw->attribs.FrameBuffer.cbufs[0]->height;
- bdr.xorg = 0;
- bdr.yorg = 0;
-
- /* Can't use BRW_CACHED_BATCH_STRUCT because this is also emitted
- * uncached in brw_draw.c:
- */
- BRW_BATCH_STRUCT(brw, &bdr);
-}
-
-const struct brw_tracked_state brw_drawing_rect = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_drawing_rect
-};
-
-/**
- * Upload the binding table pointers, which point each stage's array of surface
- * state pointers.
- *
- * The binding table pointers are relative to the surface state base address,
- * which is the BRW_SS_POOL cache buffer.
- */
-static void upload_binding_table_pointers(struct brw_context *brw)
-{
- struct brw_binding_table_pointers btp;
- memset(&btp, 0, sizeof(btp));
-
- btp.header.opcode = CMD_BINDING_TABLE_PTRS;
- btp.header.length = sizeof(btp)/4 - 2;
- btp.vs = 0;
- btp.gs = 0;
- btp.clp = 0;
- btp.sf = 0;
- btp.wm = brw->wm.bind_ss_offset;
-
- BRW_CACHED_BATCH_STRUCT(brw, &btp);
-}
-
-const struct brw_tracked_state brw_binding_table_pointers = {
- .dirty = {
- .brw = 0,
- .cache = CACHE_NEW_SURF_BIND
- },
- .update = upload_binding_table_pointers,
-};
-
-
-/**
- * Upload pointers to the per-stage state.
- *
- * The state pointers in this packet are all relative to the general state
- * base address set by CMD_STATE_BASE_ADDRESS, which is the BRW_GS_POOL buffer.
- */
-static void upload_pipelined_state_pointers(struct brw_context *brw )
-{
- struct brw_pipelined_state_pointers psp;
- memset(&psp, 0, sizeof(psp));
-
- psp.header.opcode = CMD_PIPELINED_STATE_POINTERS;
- psp.header.length = sizeof(psp)/4 - 2;
-
- psp.vs.offset = brw->vs.state_gs_offset >> 5;
- psp.sf.offset = brw->sf.state_gs_offset >> 5;
- psp.wm.offset = brw->wm.state_gs_offset >> 5;
- psp.cc.offset = brw->cc.state_gs_offset >> 5;
-
- /* GS gets turned on and off regularly. Need to re-emit URB fence
- * after this occurs.
- */
- if (brw->gs.prog_active) {
- psp.gs.offset = brw->gs.state_gs_offset >> 5;
- psp.gs.enable = 1;
- }
-
- if (0) {
- psp.clp.offset = brw->clip.state_gs_offset >> 5;
- psp.clp.enable = 1;
- }
-
-
- if (BRW_CACHED_BATCH_STRUCT(brw, &psp))
- brw->state.dirty.brw |= BRW_NEW_PSP;
-}
-
-const struct brw_tracked_state brw_pipelined_state_pointers = {
- .dirty = {
- .brw = 0,
- .cache = (CACHE_NEW_VS_UNIT |
- CACHE_NEW_GS_UNIT |
- CACHE_NEW_GS_PROG |
- CACHE_NEW_CLIP_UNIT |
- CACHE_NEW_SF_UNIT |
- CACHE_NEW_WM_UNIT |
- CACHE_NEW_CC_UNIT)
- },
- .update = upload_pipelined_state_pointers
-};
-
-static void upload_psp_urb_cbs(struct brw_context *brw )
-{
- upload_pipelined_state_pointers(brw);
- brw_upload_urb_fence(brw);
- brw_upload_constant_buffer_state(brw);
-}
-
-
-const struct brw_tracked_state brw_psp_urb_cbs = {
- .dirty = {
- .brw = BRW_NEW_URB_FENCE,
- .cache = (CACHE_NEW_VS_UNIT |
- CACHE_NEW_GS_UNIT |
- CACHE_NEW_GS_PROG |
- CACHE_NEW_CLIP_UNIT |
- CACHE_NEW_SF_UNIT |
- CACHE_NEW_WM_UNIT |
- CACHE_NEW_CC_UNIT)
- },
- .update = upload_psp_urb_cbs
-};
-
-/**
- * Upload the depthbuffer offset and format.
- *
- * We have to do this per state validation as we need to emit the relocation
- * in the batch buffer.
- */
-static void upload_depthbuffer(struct brw_context *brw)
-{
- struct pipe_surface *depth_surface = brw->attribs.FrameBuffer.zsbuf;
-
- BEGIN_BATCH(5, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (5 - 2));
- if (depth_surface == NULL) {
- OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) |
- (BRW_SURFACE_NULL << 29));
- OUT_BATCH(0);
- OUT_BATCH(0);
- OUT_BATCH(0);
- } else {
- unsigned int format;
-
- switch (depth_surface->cpp) {
- case 2:
- format = BRW_DEPTHFORMAT_D16_UNORM;
- break;
- case 4:
- if (depth_surface->format == PIPE_FORMAT_Z32_FLOAT)
- format = BRW_DEPTHFORMAT_D32_FLOAT;
- else
- format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
- break;
- default:
- assert(0);
- return;
- }
-
- OUT_BATCH(((depth_surface->pitch * depth_surface->cpp) - 1) |
- (format << 18) |
- (BRW_TILEWALK_YMAJOR << 26) |
-// (depth_surface->region->tiled << 27) |
- (BRW_SURFACE_2D << 29));
- OUT_RELOC(depth_surface->buffer,
- PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE, 0);
- OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) |
- ((depth_surface->pitch - 1) << 6) |
- ((depth_surface->height - 1) << 19));
- OUT_BATCH(0);
- }
- ADVANCE_BATCH();
-}
-
-const struct brw_tracked_state brw_depthbuffer = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_depthbuffer,
-};
-
-
-
-
-/***********************************************************************
- * Polygon stipple packet
- */
-
-static void upload_polygon_stipple(struct brw_context *brw)
-{
- struct brw_polygon_stipple bps;
- unsigned i;
-
- memset(&bps, 0, sizeof(bps));
- bps.header.opcode = CMD_POLY_STIPPLE_PATTERN;
- bps.header.length = sizeof(bps)/4-2;
-
- /* XXX: state tracker should send *all* state down initially!
- */
- if (brw->attribs.PolygonStipple)
- for (i = 0; i < 32; i++)
- bps.stipple[i] = brw->attribs.PolygonStipple->stipple[31 - i]; /* invert */
-
- BRW_CACHED_BATCH_STRUCT(brw, &bps);
-}
-
-const struct brw_tracked_state brw_polygon_stipple = {
- .dirty = {
- .brw = BRW_NEW_STIPPLE,
- .cache = 0
- },
- .update = upload_polygon_stipple
-};
-
-
-/***********************************************************************
- * Line stipple packet
- */
-
-static void upload_line_stipple(struct brw_context *brw)
-{
- struct brw_line_stipple bls;
- float tmp;
- int tmpi;
-
- memset(&bls, 0, sizeof(bls));
- bls.header.opcode = CMD_LINE_STIPPLE_PATTERN;
- bls.header.length = sizeof(bls)/4 - 2;
-
- bls.bits0.pattern = brw->attribs.Raster->line_stipple_pattern;
- bls.bits1.repeat_count = brw->attribs.Raster->line_stipple_factor;
-
- tmp = 1.0 / (float) brw->attribs.Raster->line_stipple_factor;
- tmpi = tmp * (1<<13);
-
-
- bls.bits1.inverse_repeat_count = tmpi;
-
- BRW_CACHED_BATCH_STRUCT(brw, &bls);
-}
-
-const struct brw_tracked_state brw_line_stipple = {
- .dirty = {
- .brw = BRW_NEW_STIPPLE,
- .cache = 0
- },
- .update = upload_line_stipple
-};
-
-
-/***********************************************************************
- * Misc constant state packets
- */
-
-static void upload_pipe_control(struct brw_context *brw)
-{
- struct brw_pipe_control pc;
-
- return;
-
- memset(&pc, 0, sizeof(pc));
-
- pc.header.opcode = CMD_PIPE_CONTROL;
- pc.header.length = sizeof(pc)/4 - 2;
- pc.header.post_sync_operation = PIPE_CONTROL_NOWRITE;
-
- pc.header.instruction_state_cache_flush_enable = 1;
-
- pc.bits1.dest_addr_type = PIPE_CONTROL_GTTWRITE_GLOBAL;
-
- BRW_BATCH_STRUCT(brw, &pc);
-}
-
-const struct brw_tracked_state brw_pipe_control = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_pipe_control
-};
-
-
-/***********************************************************************
- * Misc invarient state packets
- */
-
-static void upload_invarient_state( struct brw_context *brw )
-{
- {
- struct brw_mi_flush flush;
-
- memset(&flush, 0, sizeof(flush));
- flush.opcode = CMD_MI_FLUSH;
- flush.flags = BRW_FLUSH_STATE_CACHE | BRW_FLUSH_READ_CACHE;
- BRW_BATCH_STRUCT(brw, &flush);
- }
-
- {
- /* 0x61040000 Pipeline Select */
- /* PipelineSelect : 0 */
- struct brw_pipeline_select ps;
-
- memset(&ps, 0, sizeof(ps));
- ps.header.opcode = CMD_PIPELINE_SELECT;
- ps.header.pipeline_select = 0;
- BRW_BATCH_STRUCT(brw, &ps);
- }
-
- {
- struct brw_global_depth_offset_clamp gdo;
- memset(&gdo, 0, sizeof(gdo));
-
- /* Disable depth offset clamping.
- */
- gdo.header.opcode = CMD_GLOBAL_DEPTH_OFFSET_CLAMP;
- gdo.header.length = sizeof(gdo)/4 - 2;
- gdo.depth_offset_clamp = 0.0;
-
- BRW_BATCH_STRUCT(brw, &gdo);
- }
-
-
- /* 0x61020000 State Instruction Pointer */
- {
- struct brw_system_instruction_pointer sip;
- memset(&sip, 0, sizeof(sip));
-
- sip.header.opcode = CMD_STATE_INSN_POINTER;
- sip.header.length = 0;
- sip.bits0.pad = 0;
- sip.bits0.system_instruction_pointer = 0;
- BRW_BATCH_STRUCT(brw, &sip);
- }
-
-
- {
- struct brw_vf_statistics vfs;
- memset(&vfs, 0, sizeof(vfs));
-
- vfs.opcode = CMD_VF_STATISTICS;
- if (BRW_DEBUG & DEBUG_STATS)
- vfs.statistics_enable = 1;
-
- BRW_BATCH_STRUCT(brw, &vfs);
- }
-
-
- {
- struct brw_polygon_stipple_offset bpso;
-
- memset(&bpso, 0, sizeof(bpso));
- bpso.header.opcode = CMD_POLY_STIPPLE_OFFSET;
- bpso.header.length = sizeof(bpso)/4-2;
- bpso.bits0.x_offset = 0;
- bpso.bits0.y_offset = 0;
-
- BRW_BATCH_STRUCT(brw, &bpso);
- }
-}
-
-const struct brw_tracked_state brw_invarient_state = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_invarient_state
-};
-
-/**
- * Define the base addresses which some state is referenced from.
- *
- * This allows us to avoid having to emit relocations in many places for
- * cached state, and instead emit pointers inside of large, mostly-static
- * state pools. This comes at the expense of memory, and more expensive cache
- * misses.
- */
-static void upload_state_base_address( struct brw_context *brw )
-{
- /* Output the structure (brw_state_base_address) directly to the
- * batchbuffer, so we can emit relocations inline.
- */
- BEGIN_BATCH(6, INTEL_BATCH_NO_CLIPRECTS);
- OUT_BATCH(CMD_STATE_BASE_ADDRESS << 16 | (6 - 2));
- OUT_RELOC(brw->pool[BRW_GS_POOL].buffer,
- PIPE_BUFFER_USAGE_GPU_READ,
- 1); /* General state base address */
- OUT_RELOC(brw->pool[BRW_SS_POOL].buffer,
- PIPE_BUFFER_USAGE_GPU_READ,
- 1); /* Surface state base address */
- OUT_BATCH(1); /* Indirect object base address */
- OUT_BATCH(1); /* General state upper bound */
- OUT_BATCH(1); /* Indirect object upper bound */
- ADVANCE_BATCH();
-}
-
-
-const struct brw_tracked_state brw_state_base_address = {
- .dirty = {
- .brw = BRW_NEW_SCENE,
- .cache = 0
- },
- .update = upload_state_base_address
-};
diff --git a/src/mesa/pipe/i965simple/brw_reg.h b/src/mesa/pipe/i965simple/brw_reg.h
deleted file mode 100644
index 9e885c3b3b..0000000000
--- a/src/mesa/pipe/i965simple/brw_reg.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#define CMD_MI (0x0 << 29)
-#define CMD_2D (0x2 << 29)
-#define CMD_3D (0x3 << 29)
-
-#define MI_BATCH_BUFFER_END (CMD_MI | 0xA << 23)
-
-/* Stalls command execution waiting for the given events to have occurred. */
-#define MI_WAIT_FOR_EVENT (CMD_MI | (0x3 << 23))
-#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
-#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
-
-/* Primitive dispatch on 830-945 */
-#define _3DPRIMITIVE (CMD_3D | (0x1f << 24))
-#define PRIM_INDIRECT (1<<23)
-#define PRIM_INLINE (0<<23)
-#define PRIM_INDIRECT_SEQUENTIAL (0<<17)
-#define PRIM_INDIRECT_ELTS (1<<17)
-
-#define PRIM3D_TRILIST (0x0<<18)
-#define PRIM3D_TRISTRIP (0x1<<18)
-#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
-#define PRIM3D_TRIFAN (0x3<<18)
-#define PRIM3D_POLY (0x4<<18)
-#define PRIM3D_LINELIST (0x5<<18)
-#define PRIM3D_LINESTRIP (0x6<<18)
-#define PRIM3D_RECTLIST (0x7<<18)
-#define PRIM3D_POINTLIST (0x8<<18)
-#define PRIM3D_DIB (0x9<<18)
-#define PRIM3D_MASK (0x1f<<18)
-
-#define XY_SETUP_BLT_CMD (CMD_2D | (0x01 << 22) | 6)
-
-#define XY_COLOR_BLT_CMD (CMD_2D | (0x50 << 22) | 4)
-
-#define XY_SRC_COPY_BLT_CMD (CMD_2D | (0x53 << 22) | 6)
-
-/* BR00 */
-#define XY_BLT_WRITE_ALPHA (1 << 21)
-#define XY_BLT_WRITE_RGB (1 << 20)
-#define XY_SRC_TILED (1 << 15)
-#define XY_DST_TILED (1 << 11)
-
-/* BR13 */
-#define BR13_565 (0x1 << 24)
-#define BR13_8888 (0x3 << 24)
-
-#define FENCE_LINEAR 0
-#define FENCE_XMAJOR 1
-#define FENCE_YMAJOR 2
diff --git a/src/mesa/pipe/i965simple/brw_sf.c b/src/mesa/pipe/i965simple/brw_sf.c
deleted file mode 100644
index 7c83b81c85..0000000000
--- a/src/mesa/pipe/i965simple/brw_sf.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_sf.h"
-#include "brw_state.h"
-#include "tgsi/util/tgsi_parse.h"
-
-
-static void compile_sf_prog( struct brw_context *brw,
- struct brw_sf_prog_key *key )
-{
- struct brw_sf_compile c;
- const unsigned *program;
- unsigned program_size;
-
- memset(&c, 0, sizeof(c));
-
- /* Begin the compilation:
- */
- brw_init_compile(&c.func);
-
- c.key = *key;
-
-
- c.nr_attrs = c.key.vp_output_count;
- c.nr_attr_regs = (c.nr_attrs+1)/2;
-
- c.nr_setup_attrs = c.key.fp_input_count + 1; /* +1 for position */
- c.nr_setup_regs = (c.nr_setup_attrs+1)/2;
-
- c.prog_data.urb_read_length = c.nr_attr_regs;
- c.prog_data.urb_entry_size = c.nr_setup_regs * 2;
-
-
- /* Which primitive? Or all three?
- */
- switch (key->primitive) {
- case SF_TRIANGLES:
- c.nr_verts = 3;
- brw_emit_tri_setup( &c );
- break;
- case SF_LINES:
- c.nr_verts = 2;
- brw_emit_line_setup( &c );
- break;
- case SF_POINTS:
- c.nr_verts = 1;
- brw_emit_point_setup( &c );
- break;
-
- case SF_UNFILLED_TRIS:
- default:
- assert(0);
- return;
- }
-
-
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- /* Upload
- */
- brw->sf.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_SF_PROG],
- &c.key,
- sizeof(c.key),
- program,
- program_size,
- &c.prog_data,
- &brw->sf.prog_data );
-}
-
-
-static boolean search_cache( struct brw_context *brw,
- struct brw_sf_prog_key *key )
-{
- return brw_search_cache(&brw->cache[BRW_SF_PROG],
- key, sizeof(*key),
- &brw->sf.prog_data,
- &brw->sf.prog_gs_offset);
-}
-
-
-/* Calculate interpolants for triangle and line rasterization.
- */
-static void upload_sf_prog( struct brw_context *brw )
-{
- const struct brw_fragment_program *fs = brw->attribs.FragmentProgram;
- struct brw_sf_prog_key key;
- struct tgsi_parse_context parse;
- int i, done = 0;
-
-
- memset(&key, 0, sizeof(key));
-
- /* Populate the key, noting state dependencies:
- */
- /* CACHE_NEW_VS_PROG */
- key.vp_output_count = brw->vs.prog_data->outputs_written;
-
- /* BRW_NEW_FS */
- key.fp_input_count = brw->attribs.FragmentProgram->info.nr_regs[TGSI_FILE_INPUT];
-
-
- /* BRW_NEW_REDUCED_PRIMITIVE */
- switch (brw->reduced_primitive) {
- case PIPE_PRIM_TRIANGLES:
-// if (key.attrs & (1<<VERT_RESULT_EDGE))
-// key.primitive = SF_UNFILLED_TRIS;
-// else
- key.primitive = SF_TRIANGLES;
- break;
- case PIPE_PRIM_LINES:
- key.primitive = SF_LINES;
- break;
- case PIPE_PRIM_POINTS:
- key.primitive = SF_POINTS;
- break;
- }
-
-
-
- /* Scan fp inputs to figure out what interpolation modes are
- * required for each incoming vp output. There is an assumption
- * that the state tracker makes sure there is a 1:1 linkage between
- * these sets of attributes (XXX: position??)
- */
- tgsi_parse_init( &parse, fs->program.tokens );
- while( !done &&
- !tgsi_parse_end_of_tokens( &parse ) )
- {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT)
- {
- int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
- int interp_mode = parse.FullToken.FullDeclaration.Interpolation.Interpolate;
- //int semantic = parse.FullToken.FullDeclaration.Semantic.SemanticName;
- //int semantic_index = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
-
- debug_printf("fs input %d..%d interp mode %d\n", first, last, interp_mode);
-
- switch (interp_mode) {
- case TGSI_INTERPOLATE_CONSTANT:
- for (i = first; i <= last; i++)
- key.const_mask |= (1 << i);
- break;
- case TGSI_INTERPOLATE_LINEAR:
- for (i = first; i <= last; i++)
- key.linear_mask |= (1 << i);
- break;
- case TGSI_INTERPOLATE_PERSPECTIVE:
- for (i = first; i <= last; i++)
- key.persp_mask |= (1 << i);
- break;
- default:
- break;
- }
-
- /* Also need stuff for flat shading, twosided color.
- */
-
- }
- break;
- default:
- done = 1;
- break;
- }
- }
-
- /* Hack: Adjust for position. Optimize away when not required (ie
- * for perspective interpolation).
- */
- key.persp_mask <<= 1;
- key.linear_mask <<= 1;
- key.linear_mask |= 1;
- key.const_mask <<= 1;
-
- debug_printf("key.persp_mask: %x\n", key.persp_mask);
- debug_printf("key.linear_mask: %x\n", key.linear_mask);
- debug_printf("key.const_mask: %x\n", key.const_mask);
-
-
-// key.do_point_sprite = brw->attribs.Point->PointSprite;
-// key.SpriteOrigin = brw->attribs.Point->SpriteOrigin;
-
-// key.do_flat_shading = (brw->attribs.Raster->flatshade);
-// key.do_twoside_color = (brw->attribs.Light->Enabled && brw->attribs.Light->Model.TwoSide);
-
-// if (key.do_twoside_color)
-// key.frontface_ccw = (brw->attribs.Polygon->FrontFace == GL_CCW);
-
-
- if (!search_cache(brw, &key))
- compile_sf_prog( brw, &key );
-}
-
-
-const struct brw_tracked_state brw_sf_prog = {
- .dirty = {
- .brw = (BRW_NEW_RASTERIZER |
- BRW_NEW_REDUCED_PRIMITIVE |
- BRW_NEW_VS |
- BRW_NEW_FS),
- .cache = 0,
- },
- .update = upload_sf_prog
-};
-
-
-
-#if 0
-/* Build a struct like the one we'd like the state tracker to pass to
- * us.
- */
-static void update_sf_linkage( struct brw_context *brw )
-{
- const struct brw_vertex_program *vs = brw->attribs.VertexProgram;
- const struct brw_fragment_program *fs = brw->attribs.FragmentProgram;
- struct pipe_setup_linkage state;
- struct tgsi_parse_context parse;
-
- int i, j;
- int nr_vp_outputs = 0;
- int done = 0;
-
- struct {
- unsigned semantic:8;
- unsigned semantic_index:16;
- } fp_semantic[32], vp_semantic[32];
-
- memset(&state, 0, sizeof(state));
-
- state.fp_input_count = 0;
-
-
-
-
-
-
- assert(state.fp_input_count == fs->program.num_inputs);
-
-
- /* Then scan vp outputs
- */
- done = 0;
- tgsi_parse_init( &parse, vs->program.tokens );
- while( !done &&
- !tgsi_parse_end_of_tokens( &parse ) )
- {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_INPUT)
- {
- int first = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- int last = parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
-
- for (i = first; i < last; i++) {
- vp_semantic[i].semantic =
- parse.FullToken.FullDeclaration.Semantic.SemanticName;
- vp_semantic[i].semantic_index =
- parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
- }
-
- assert(last > nr_vp_outputs);
- nr_vp_outputs = last;
- }
- break;
- default:
- done = 1;
- break;
- }
- }
-
-
- /* Now match based on semantic information.
- */
- for (i = 0; i< state.fp_input_count; i++) {
- for (j = 0; j < nr_vp_outputs; j++) {
- if (fp_semantic[i].semantic == vp_semantic[j].semantic &&
- fp_semantic[i].semantic_index == vp_semantic[j].semantic_index) {
- state.fp_input[i].vp_output = j;
- }
- }
- if (fp_semantic[i].semantic == TGSI_SEMANTIC_COLOR) {
- for (j = 0; j < nr_vp_outputs; j++) {
- if (TGSI_SEMANTIC_BCOLOR == vp_semantic[j].semantic &&
- fp_semantic[i].semantic_index == vp_semantic[j].semantic_index) {
- state.fp_input[i].bf_vp_output = j;
- }
- }
- }
- }
-
- if (memcmp(&brw->sf.linkage, &state, sizeof(state)) != 0) {
- brw->sf.linkage = state;
- brw->state.dirty.brw |= BRW_NEW_SF_LINKAGE;
- }
-}
-
-
-const struct brw_tracked_state brw_sf_linkage = {
- .dirty = {
- .brw = (BRW_NEW_VS |
- BRW_NEW_FS),
- .cache = 0,
- },
- .update = update_sf_linkage
-};
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_sf.h b/src/mesa/pipe/i965simple/brw_sf.h
deleted file mode 100644
index b7ada47560..0000000000
--- a/src/mesa/pipe/i965simple/brw_sf.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_SF_H
-#define BRW_SF_H
-
-#include "brw_context.h"
-#include "brw_eu.h"
-
-
-#define SF_POINTS 0
-#define SF_LINES 1
-#define SF_TRIANGLES 2
-#define SF_UNFILLED_TRIS 3
-
-
-
-struct brw_sf_prog_key {
- unsigned vp_output_count:5;
- unsigned fp_input_count:5;
-
- unsigned primitive:2;
- unsigned do_twoside_color:1;
- unsigned do_flat_shading:1;
- unsigned frontface_ccw:1;
- unsigned do_point_sprite:1;
-
- /* Interpolation masks;
- */
- unsigned linear_mask;
- unsigned persp_mask;
- unsigned const_mask;
-
-
-// int SpriteOrigin;
-};
-
-struct brw_sf_point_tex {
- boolean CoordReplace;
-};
-
-struct brw_sf_compile {
- struct brw_compile func;
- struct brw_sf_prog_key key;
- struct brw_sf_prog_data prog_data;
-
- struct brw_reg pv;
- struct brw_reg det;
- struct brw_reg dx0;
- struct brw_reg dx2;
- struct brw_reg dy0;
- struct brw_reg dy2;
-
- /* z and 1/w passed in seperately:
- */
- struct brw_reg z[3];
- struct brw_reg inv_w[3];
-
- /* The vertices:
- */
- struct brw_reg vert[3];
-
- /* Temporaries, allocated after last vertex reg.
- */
- struct brw_reg inv_det;
- struct brw_reg a1_sub_a0;
- struct brw_reg a2_sub_a0;
- struct brw_reg tmp;
-
- struct brw_reg m1Cx;
- struct brw_reg m2Cy;
- struct brw_reg m3C0;
-
- unsigned nr_verts;
- unsigned nr_attrs;
- unsigned nr_attr_regs;
- unsigned nr_setup_attrs;
- unsigned nr_setup_regs;
-#if 0
- ubyte attr_to_idx[VERT_RESULT_MAX];
- ubyte idx_to_attr[VERT_RESULT_MAX];
- struct brw_sf_point_tex point_attrs[VERT_RESULT_MAX];
-#endif
-};
-
-
-void brw_emit_tri_setup( struct brw_sf_compile *c );
-void brw_emit_line_setup( struct brw_sf_compile *c );
-void brw_emit_point_setup( struct brw_sf_compile *c );
-void brw_emit_point_sprite_setup( struct brw_sf_compile *c );
-void brw_emit_anyprim_setup( struct brw_sf_compile *c );
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_sf_emit.c b/src/mesa/pipe/i965simple/brw_sf_emit.c
deleted file mode 100644
index 78d6fa5e9e..0000000000
--- a/src/mesa/pipe/i965simple/brw_sf_emit.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_defines.h"
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_util.h"
-#include "brw_sf.h"
-
-
-
-/***********************************************************************
- * Triangle setup.
- */
-
-
-static void alloc_regs( struct brw_sf_compile *c )
-{
- unsigned reg, i;
-
- /* Values computed by fixed function unit:
- */
- c->pv = retype(brw_vec1_grf(1, 1), BRW_REGISTER_TYPE_UD);
- c->det = brw_vec1_grf(1, 2);
- c->dx0 = brw_vec1_grf(1, 3);
- c->dx2 = brw_vec1_grf(1, 4);
- c->dy0 = brw_vec1_grf(1, 5);
- c->dy2 = brw_vec1_grf(1, 6);
-
- /* z and 1/w passed in seperately:
- */
- c->z[0] = brw_vec1_grf(2, 0);
- c->inv_w[0] = brw_vec1_grf(2, 1);
- c->z[1] = brw_vec1_grf(2, 2);
- c->inv_w[1] = brw_vec1_grf(2, 3);
- c->z[2] = brw_vec1_grf(2, 4);
- c->inv_w[2] = brw_vec1_grf(2, 5);
-
- /* The vertices:
- */
- reg = 3;
- for (i = 0; i < c->nr_verts; i++) {
- c->vert[i] = brw_vec8_grf(reg, 0);
- reg += c->nr_attr_regs;
- }
-
- /* Temporaries, allocated after last vertex reg.
- */
- c->inv_det = brw_vec1_grf(reg, 0); reg++;
- c->a1_sub_a0 = brw_vec8_grf(reg, 0); reg++;
- c->a2_sub_a0 = brw_vec8_grf(reg, 0); reg++;
- c->tmp = brw_vec8_grf(reg, 0); reg++;
-
- /* Note grf allocation:
- */
- c->prog_data.total_grf = reg;
-
-
- /* Outputs of this program - interpolation coefficients for
- * rasterization:
- */
- c->m1Cx = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 1, 0);
- c->m2Cy = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 2, 0);
- c->m3C0 = brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, 3, 0);
-}
-
-
-static void copy_z_inv_w( struct brw_sf_compile *c )
-{
- struct brw_compile *p = &c->func;
- unsigned i;
-
- brw_push_insn_state(p);
-
- /* Copy both scalars with a single MOV:
- */
- for (i = 0; i < c->nr_verts; i++)
- brw_MOV(p, vec2(suboffset(c->vert[i], 2)), vec2(c->z[i]));
-
- brw_pop_insn_state(p);
-}
-
-
-static void invert_det( struct brw_sf_compile *c)
-{
- brw_math(&c->func,
- c->inv_det,
- BRW_MATH_FUNCTION_INV,
- BRW_MATH_SATURATE_NONE,
- 0,
- c->det,
- BRW_MATH_DATA_SCALAR,
- BRW_MATH_PRECISION_FULL);
-
-}
-
-#define NON_PERPECTIVE_ATTRS (FRAG_BIT_WPOS | \
- FRAG_BIT_COL0 | \
- FRAG_BIT_COL1)
-
-static boolean calculate_masks( struct brw_sf_compile *c,
- unsigned reg,
- ushort *pc,
- ushort *pc_persp,
- ushort *pc_linear)
-{
- boolean is_last_attr = (reg == c->nr_setup_regs - 1);
- unsigned persp_mask = c->key.persp_mask;
- unsigned linear_mask = c->key.linear_mask;
-
- debug_printf("persp_mask: %x\n", persp_mask);
- debug_printf("linear_mask: %x\n", linear_mask);
-
- *pc_persp = 0;
- *pc_linear = 0;
- *pc = 0xf;
-
- if (persp_mask & (1 << (reg*2)))
- *pc_persp = 0xf;
-
- if (linear_mask & (1 << (reg*2)))
- *pc_linear = 0xf;
-
- /* Maybe only processs one attribute on the final round:
- */
- if (reg*2+1 < c->nr_setup_attrs) {
- *pc |= 0xf0;
-
- if (persp_mask & (1 << (reg*2+1)))
- *pc_persp |= 0xf0;
-
- if (linear_mask & (1 << (reg*2+1)))
- *pc_linear |= 0xf0;
- }
-
- debug_printf("pc: %x\n", *pc);
- debug_printf("pc_persp: %x\n", *pc_persp);
- debug_printf("pc_linear: %x\n", *pc_linear);
-
-
- return is_last_attr;
-}
-
-
-
-void brw_emit_tri_setup( struct brw_sf_compile *c )
-{
- struct brw_compile *p = &c->func;
- unsigned i;
-
- debug_printf("%s START ==============\n", __FUNCTION__);
-
- c->nr_verts = 3;
- alloc_regs(c);
- invert_det(c);
- copy_z_inv_w(c);
-
-
- for (i = 0; i < c->nr_setup_regs; i++)
- {
- /* Pair of incoming attributes:
- */
- struct brw_reg a0 = offset(c->vert[0], i);
- struct brw_reg a1 = offset(c->vert[1], i);
- struct brw_reg a2 = offset(c->vert[2], i);
- ushort pc = 0, pc_persp = 0, pc_linear = 0;
- boolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
-
- if (pc_persp)
- {
- brw_set_predicate_control_flag_value(p, pc_persp);
- brw_MUL(p, a0, a0, c->inv_w[0]);
- brw_MUL(p, a1, a1, c->inv_w[1]);
- brw_MUL(p, a2, a2, c->inv_w[2]);
- }
-
-
- /* Calculate coefficients for interpolated values:
- */
- if (pc_linear)
- {
- brw_set_predicate_control_flag_value(p, pc_linear);
-
- brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
- brw_ADD(p, c->a2_sub_a0, a2, negate(a0));
-
- /* calculate dA/dx
- */
- brw_MUL(p, brw_null_reg(), c->a1_sub_a0, c->dy2);
- brw_MAC(p, c->tmp, c->a2_sub_a0, negate(c->dy0));
- brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
-
- /* calculate dA/dy
- */
- brw_MUL(p, brw_null_reg(), c->a2_sub_a0, c->dx0);
- brw_MAC(p, c->tmp, c->a1_sub_a0, negate(c->dx2));
- brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
- }
-
- {
- brw_set_predicate_control_flag_value(p, pc);
- /* start point for interpolation
- */
- brw_MOV(p, c->m3C0, a0);
-
- /* Copy m0..m3 to URB. m0 is implicitly copied from r0 in
- * the send instruction:
- */
- brw_urb_WRITE(p,
- brw_null_reg(),
- 0,
- brw_vec8_grf(0, 0), /* r0, will be copied to m0 */
- 0, /* allocate */
- 1, /* used */
- 4, /* msg len */
- 0, /* response len */
- last, /* eot */
- last, /* writes complete */
- i*4, /* offset */
- BRW_URB_SWIZZLE_TRANSPOSE); /* XXX: Swizzle control "SF to windower" */
- }
- }
-
- debug_printf("%s DONE ==============\n", __FUNCTION__);
-
-}
-
-
-
-void brw_emit_line_setup( struct brw_sf_compile *c )
-{
- struct brw_compile *p = &c->func;
- unsigned i;
-
-
- c->nr_verts = 2;
- alloc_regs(c);
- invert_det(c);
- copy_z_inv_w(c);
-
- for (i = 0; i < c->nr_setup_regs; i++)
- {
- /* Pair of incoming attributes:
- */
- struct brw_reg a0 = offset(c->vert[0], i);
- struct brw_reg a1 = offset(c->vert[1], i);
- ushort pc, pc_persp, pc_linear;
- boolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
-
- if (pc_persp)
- {
- brw_set_predicate_control_flag_value(p, pc_persp);
- brw_MUL(p, a0, a0, c->inv_w[0]);
- brw_MUL(p, a1, a1, c->inv_w[1]);
- }
-
- /* Calculate coefficients for position, color:
- */
- if (pc_linear) {
- brw_set_predicate_control_flag_value(p, pc_linear);
-
- brw_ADD(p, c->a1_sub_a0, a1, negate(a0));
-
- brw_MUL(p, c->tmp, c->a1_sub_a0, c->dx0);
- brw_MUL(p, c->m1Cx, c->tmp, c->inv_det);
-
- brw_MUL(p, c->tmp, c->a1_sub_a0, c->dy0);
- brw_MUL(p, c->m2Cy, c->tmp, c->inv_det);
- }
-
- {
- brw_set_predicate_control_flag_value(p, pc);
-
- /* start point for interpolation
- */
- brw_MOV(p, c->m3C0, a0);
-
- /* Copy m0..m3 to URB.
- */
- brw_urb_WRITE(p,
- brw_null_reg(),
- 0,
- brw_vec8_grf(0, 0),
- 0, /* allocate */
- 1, /* used */
- 4, /* msg len */
- 0, /* response len */
- last, /* eot */
- last, /* writes complete */
- i*4, /* urb destination offset */
- BRW_URB_SWIZZLE_TRANSPOSE);
- }
- }
-}
-
-
-/* Points setup - several simplifications as all attributes are
- * constant across the face of the point (point sprites excluded!)
- */
-void brw_emit_point_setup( struct brw_sf_compile *c )
-{
- struct brw_compile *p = &c->func;
- unsigned i;
-
- c->nr_verts = 1;
- alloc_regs(c);
- copy_z_inv_w(c);
-
- brw_MOV(p, c->m1Cx, brw_imm_ud(0)); /* zero - move out of loop */
- brw_MOV(p, c->m2Cy, brw_imm_ud(0)); /* zero - move out of loop */
-
- for (i = 0; i < c->nr_setup_regs; i++)
- {
- struct brw_reg a0 = offset(c->vert[0], i);
- ushort pc, pc_persp, pc_linear;
- boolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear);
-
- if (pc_persp)
- {
- /* This seems odd as the values are all constant, but the
- * fragment shader will be expecting it:
- */
- brw_set_predicate_control_flag_value(p, pc_persp);
- brw_MUL(p, a0, a0, c->inv_w[0]);
- }
-
-
- /* The delta values are always zero, just send the starting
- * coordinate. Again, this is to fit in with the interpolation
- * code in the fragment shader.
- */
- {
- brw_set_predicate_control_flag_value(p, pc);
-
- brw_MOV(p, c->m3C0, a0); /* constant value */
-
- /* Copy m0..m3 to URB.
- */
- brw_urb_WRITE(p,
- brw_null_reg(),
- 0,
- brw_vec8_grf(0, 0),
- 0, /* allocate */
- 1, /* used */
- 4, /* msg len */
- 0, /* response len */
- last, /* eot */
- last, /* writes complete */
- i*4, /* urb destination offset */
- BRW_URB_SWIZZLE_TRANSPOSE);
- }
- }
-}
diff --git a/src/mesa/pipe/i965simple/brw_sf_state.c b/src/mesa/pipe/i965simple/brw_sf_state.c
deleted file mode 100644
index 9acd3ea61b..0000000000
--- a/src/mesa/pipe/i965simple/brw_sf_state.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "pipe/p_util.h"
-
-static void upload_sf_vp(struct brw_context *brw)
-{
- struct brw_sf_viewport sfv;
-
- memset(&sfv, 0, sizeof(sfv));
-
-
- /* BRW_NEW_VIEWPORT */
- {
- const float *scale = brw->attribs.Viewport.scale;
- const float *trans = brw->attribs.Viewport.translate;
-
- sfv.viewport.m00 = scale[0];
- sfv.viewport.m11 = scale[1];
- sfv.viewport.m22 = scale[2];
- sfv.viewport.m30 = trans[0];
- sfv.viewport.m31 = trans[1];
- sfv.viewport.m32 = trans[2];
- }
-
- /* _NEW_SCISSOR */
- sfv.scissor.xmin = brw->attribs.Scissor.minx;
- sfv.scissor.xmax = brw->attribs.Scissor.maxx - 1;
- sfv.scissor.ymin = brw->attribs.Scissor.miny;
- sfv.scissor.ymax = brw->attribs.Scissor.maxy - 1;
-
- brw->sf.vp_gs_offset = brw_cache_data( &brw->cache[BRW_SF_VP], &sfv );
-}
-
-const struct brw_tracked_state brw_sf_vp = {
- .dirty = {
- .brw = (BRW_NEW_SCISSOR |
- BRW_NEW_VIEWPORT),
- .cache = 0
- },
- .update = upload_sf_vp
-};
-
-static void upload_sf_unit( struct brw_context *brw )
-{
- struct brw_sf_unit_state sf;
- memset(&sf, 0, sizeof(sf));
-
- /* CACHE_NEW_SF_PROG */
- sf.thread0.grf_reg_count = align(brw->sf.prog_data->total_grf, 16) / 16 - 1;
- sf.thread0.kernel_start_pointer = brw->sf.prog_gs_offset >> 6;
- sf.thread3.urb_entry_read_length = brw->sf.prog_data->urb_read_length;
-
- sf.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
- sf.thread3.dispatch_grf_start_reg = 3;
- sf.thread3.urb_entry_read_offset = 1;
-
- /* BRW_NEW_URB_FENCE */
- sf.thread4.nr_urb_entries = brw->urb.nr_sf_entries;
- sf.thread4.urb_entry_allocation_size = brw->urb.sfsize - 1;
- sf.thread4.max_threads = MIN2(12, brw->urb.nr_sf_entries / 2) - 1;
-
- if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
- sf.thread4.max_threads = 0;
-
- if (BRW_DEBUG & DEBUG_STATS)
- sf.thread4.stats_enable = 1;
-
- /* CACHE_NEW_SF_VP */
- sf.sf5.sf_viewport_state_offset = brw->sf.vp_gs_offset >> 5;
- sf.sf5.viewport_transform = 1;
-
- /* BRW_NEW_RASTER */
- if (brw->attribs.Raster->scissor)
- sf.sf6.scissor = 1;
-
-#if 0
- if (brw->attribs.Polygon->FrontFace == GL_CCW)
- sf.sf5.front_winding = BRW_FRONTWINDING_CCW;
- else
- sf.sf5.front_winding = BRW_FRONTWINDING_CW;
-
-
- if (brw->attribs.Polygon->CullFlag) {
- switch (brw->attribs.Polygon->CullFaceMode) {
- case GL_FRONT:
- sf.sf6.cull_mode = BRW_CULLMODE_FRONT;
- break;
- case GL_BACK:
- sf.sf6.cull_mode = BRW_CULLMODE_BACK;
- break;
- case GL_FRONT_AND_BACK:
- sf.sf6.cull_mode = BRW_CULLMODE_BOTH;
- break;
- default:
- assert(0);
- break;
- }
- }
- else
- sf.sf6.cull_mode = BRW_CULLMODE_NONE;
-#else
- sf.sf5.front_winding = BRW_FRONTWINDING_CCW;
- sf.sf6.cull_mode = BRW_CULLMODE_NONE;
-#endif
-
- sf.sf6.line_width = CLAMP(brw->attribs.Raster->line_width, 1.0, 5.0) * (1<<1);
-
- sf.sf6.line_endcap_aa_region_width = 1;
- if (brw->attribs.Raster->line_smooth)
- sf.sf6.aa_enable = 1;
- else if (sf.sf6.line_width <= 0x2)
- sf.sf6.line_width = 0;
-
- sf.sf6.point_rast_rule = 1; /* opengl conventions */
-
- sf.sf7.sprite_point = brw->attribs.Raster->point_sprite;
- sf.sf7.point_size = CLAMP(brw->attribs.Raster->line_width, 1.0, 255.0) * (1<<3);
- sf.sf7.use_point_size_state = !brw->attribs.Raster->point_size_per_vertex;
-
- /* might be BRW_NEW_PRIMITIVE if we have to adjust pv for polygons:
- */
- sf.sf7.trifan_pv = 2;
- sf.sf7.linestrip_pv = 1;
- sf.sf7.tristrip_pv = 2;
- sf.sf7.line_last_pixel_enable = 0;
-
- /* Set bias for OpenGL rasterization rules:
- */
- sf.sf6.dest_org_vbias = 0x8;
- sf.sf6.dest_org_hbias = 0x8;
-
- brw->sf.state_gs_offset = brw_cache_data( &brw->cache[BRW_SF_UNIT], &sf );
-}
-
-
-const struct brw_tracked_state brw_sf_unit = {
- .dirty = {
- .brw = (BRW_NEW_RASTERIZER |
- BRW_NEW_URB_FENCE),
- .cache = (CACHE_NEW_SF_VP |
- CACHE_NEW_SF_PROG)
- },
- .update = upload_sf_unit
-};
-
-
diff --git a/src/mesa/pipe/i965simple/brw_shader_info.c b/src/mesa/pipe/i965simple/brw_shader_info.c
deleted file mode 100644
index 431b45466a..0000000000
--- a/src/mesa/pipe/i965simple/brw_shader_info.c
+++ /dev/null
@@ -1,49 +0,0 @@
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-
-
-
-
-void brw_shader_info(const struct tgsi_token *tokens,
- struct brw_shader_info *info )
-{
- struct tgsi_parse_context parse;
- int done = 0;
-
- tgsi_parse_init( &parse, tokens );
-
- while( !done &&
- !tgsi_parse_end_of_tokens( &parse ) )
- {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- {
- const struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
- unsigned last = decl->u.DeclarationRange.Last;
-
- assert( decl->Declaration.Declare == TGSI_DECLARE_RANGE );
-
- // Broken by crazy wpos init:
- //assert( info->nr_regs[decl->Declaration.File] <= last);
-
- info->nr_regs[decl->Declaration.File] = MAX2(info->nr_regs[decl->Declaration.File],
- last+1);
- break;
- }
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- default:
- done = 1;
- break;
- }
- }
-
- tgsi_parse_free (&parse);
-
-}
diff --git a/src/mesa/pipe/i965simple/brw_state.c b/src/mesa/pipe/i965simple/brw_state.c
deleted file mode 100644
index 95dfce88e4..0000000000
--- a/src/mesa/pipe/i965simple/brw_state.c
+++ /dev/null
@@ -1,424 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Zack Rusin <zack@tungstengraphics.com>
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-
-#include "brw_context.h"
-#include "brw_defines.h"
-#include "brw_state.h"
-#include "brw_draw.h"
-
-
-#define DUP( TYPE, VAL ) \
-do { \
- struct TYPE *x = malloc(sizeof(*x)); \
- memcpy(x, VAL, sizeof(*x) ); \
- return x; \
-} while (0)
-
-/************************************************************************
- * Blend
- */
-static void *
-brw_create_blend_state(struct pipe_context *pipe,
- const struct pipe_blend_state *blend)
-{
- DUP( pipe_blend_state, blend );
-}
-
-static void brw_bind_blend_state(struct pipe_context *pipe,
- void *blend)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Blend = (struct pipe_blend_state*)blend;
- brw->state.dirty.brw |= BRW_NEW_BLEND;
-}
-
-
-static void brw_delete_blend_state(struct pipe_context *pipe, void *blend)
-{
- free(blend);
-}
-
-static void brw_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color )
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.BlendColor = *blend_color;
-
- brw->state.dirty.brw |= BRW_NEW_BLEND;
-}
-
-/************************************************************************
- * Sampler
- */
-
-static void *
-brw_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
-{
- DUP( pipe_sampler_state, sampler );
-}
-
-static void brw_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Samplers[unit] = sampler;
- brw->state.dirty.brw |= BRW_NEW_SAMPLER;
-}
-
-static void brw_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
-{
- free(sampler);
-}
-
-
-/************************************************************************
- * Depth stencil
- */
-
-static void *
-brw_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
-{
- DUP( pipe_depth_stencil_alpha_state, depth_stencil );
-}
-
-static void brw_bind_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.DepthStencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
-
- brw->state.dirty.brw |= BRW_NEW_DEPTH_STENCIL;
-}
-
-static void brw_delete_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- free(depth_stencil);
-}
-
-/************************************************************************
- * Scissor
- */
-static void brw_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct brw_context *brw = brw_context(pipe);
-
- memcpy( &brw->attribs.Scissor, scissor, sizeof(*scissor) );
- brw->state.dirty.brw |= BRW_NEW_SCISSOR;
-}
-
-
-/************************************************************************
- * Stipple
- */
-
-static void brw_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
-}
-
-
-/************************************************************************
- * Fragment shader
- */
-
-static void * brw_create_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *shader)
-{
- struct brw_fragment_program *brw_fp = CALLOC_STRUCT(brw_fragment_program);
-
- /* XXX: Do I have to duplicate the tokens as well??
- */
- brw_fp->program = *shader;
- brw_fp->id = brw_context(pipe)->program_id++;
-
- brw_shader_info(shader->tokens,
- &brw_fp->info);
-
- tgsi_dump(shader->tokens, 0);
-
-
- return (void *)brw_fp;
-}
-
-static void brw_bind_fs_state(struct pipe_context *pipe, void *shader)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.FragmentProgram = (struct brw_fragment_program *)shader;
- brw->state.dirty.brw |= BRW_NEW_FS;
-}
-
-static void brw_delete_fs_state(struct pipe_context *pipe, void *shader)
-{
- FREE(shader);
-}
-
-
-/************************************************************************
- * Vertex shader and other TNL state
- */
-
-static void *brw_create_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *shader)
-{
- struct brw_vertex_program *brw_vp = CALLOC_STRUCT(brw_vertex_program);
-
- /* XXX: Do I have to duplicate the tokens as well??
- */
- brw_vp->program = *shader;
- brw_vp->id = brw_context(pipe)->program_id++;
- brw_shader_info(shader->tokens,
- &brw_vp->info);
-
- tgsi_dump(shader->tokens, 0);
-
- return (void *)brw_vp;
-}
-
-static void brw_bind_vs_state(struct pipe_context *pipe, void *vs)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.VertexProgram = (struct brw_vertex_program *)vs;
- brw->state.dirty.brw |= BRW_NEW_VS;
-
- debug_printf("YYYYYYYYYYYYY BINDING VERTEX SHADER\n");
-}
-
-static void brw_delete_vs_state(struct pipe_context *pipe, void *shader)
-{
- FREE(shader);
-}
-
-
-static void brw_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Clip = *clip;
-}
-
-
-static void brw_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Viewport = *viewport; /* struct copy */
- brw->state.dirty.brw |= BRW_NEW_VIEWPORT;
-
- /* pass the viewport info to the draw module */
- //draw_set_viewport_state(brw->draw, viewport);
-}
-
-
-static void brw_set_vertex_buffer( struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_buffer *buffer )
-{
- struct brw_context *brw = brw_context(pipe);
- brw->vb.vbo_array[index] = buffer;
-}
-
-static void brw_set_vertex_element(struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_element *element)
-{
- /* flush ? */
- struct brw_context *brw = brw_context(pipe);
-
- assert(index < PIPE_ATTRIB_MAX);
- struct brw_vertex_element_state el;
- memset(&el, 0, sizeof(el));
-
- el.ve0.src_offset = element->src_offset;
- el.ve0.src_format = brw_translate_surface_format(element->src_format);
- el.ve0.valid = 1;
- el.ve0.vertex_buffer_index = element->vertex_buffer_index;
-
- el.ve1.dst_offset = index * 4;
-
- el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_SRC;
- el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_SRC;
- el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_SRC;
- el.ve1.vfcomponent0 = BRW_VFCOMPONENT_STORE_SRC;
-
- switch (element->nr_components) {
- case 1: el.ve1.vfcomponent1 = BRW_VFCOMPONENT_STORE_0;
- case 2: el.ve1.vfcomponent2 = BRW_VFCOMPONENT_STORE_0;
- case 3: el.ve1.vfcomponent3 = BRW_VFCOMPONENT_STORE_1_FLT;
- break;
- }
-
- brw->vb.inputs[index] = el;
-}
-
-
-
-/************************************************************************
- * Constant buffers
- */
-
-static void brw_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf)
-{
- struct brw_context *brw = brw_context(pipe);
-
- assert(buf == 0 || index == 0);
-
- brw->attribs.Constants[shader] = buf;
- brw->state.dirty.brw |= BRW_NEW_CONSTANTS;
-}
-
-
-/************************************************************************
- * Texture surfaces
- */
-
-
-static void brw_set_sampler_texture(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Texture[unit] = (struct brw_texture*)texture; /* ptr, not struct */
-
- brw->state.dirty.brw |= BRW_NEW_TEXTURE;
-}
-
-
-/************************************************************************
- * Render targets, etc
- */
-
-static void brw_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.FrameBuffer = *fb; /* struct copy */
-
- brw->state.dirty.brw |= BRW_NEW_FRAMEBUFFER;
-}
-
-
-
-/************************************************************************
- * Rasterizer state
- */
-
-static void *
-brw_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *rasterizer)
-{
- DUP(pipe_rasterizer_state, rasterizer);
-}
-
-static void brw_bind_rasterizer_state( struct pipe_context *pipe,
- void *setup )
-{
- struct brw_context *brw = brw_context(pipe);
-
- brw->attribs.Raster = (struct pipe_rasterizer_state *)setup;
-
- /* Also pass-through to draw module:
- */
- //draw_set_rasterizer_state(brw->draw, setup);
-
- brw->state.dirty.brw |= BRW_NEW_RASTERIZER;
-}
-
-static void brw_delete_rasterizer_state(struct pipe_context *pipe,
- void *setup)
-{
- free(setup);
-}
-
-
-
-void
-brw_init_state_functions( struct brw_context *brw )
-{
- brw->pipe.create_blend_state = brw_create_blend_state;
- brw->pipe.bind_blend_state = brw_bind_blend_state;
- brw->pipe.delete_blend_state = brw_delete_blend_state;
-
- brw->pipe.create_sampler_state = brw_create_sampler_state;
- brw->pipe.bind_sampler_state = brw_bind_sampler_state;
- brw->pipe.delete_sampler_state = brw_delete_sampler_state;
-
- brw->pipe.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
- brw->pipe.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
- brw->pipe.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
-
- brw->pipe.create_rasterizer_state = brw_create_rasterizer_state;
- brw->pipe.bind_rasterizer_state = brw_bind_rasterizer_state;
- brw->pipe.delete_rasterizer_state = brw_delete_rasterizer_state;
- brw->pipe.create_fs_state = brw_create_fs_state;
- brw->pipe.bind_fs_state = brw_bind_fs_state;
- brw->pipe.delete_fs_state = brw_delete_fs_state;
- brw->pipe.create_vs_state = brw_create_vs_state;
- brw->pipe.bind_vs_state = brw_bind_vs_state;
- brw->pipe.delete_vs_state = brw_delete_vs_state;
-
- brw->pipe.set_blend_color = brw_set_blend_color;
- brw->pipe.set_clip_state = brw_set_clip_state;
- brw->pipe.set_constant_buffer = brw_set_constant_buffer;
- brw->pipe.set_framebuffer_state = brw_set_framebuffer_state;
-
-// brw->pipe.set_feedback_state = brw_set_feedback_state;
-// brw->pipe.set_feedback_buffer = brw_set_feedback_buffer;
-
- brw->pipe.set_polygon_stipple = brw_set_polygon_stipple;
- brw->pipe.set_scissor_state = brw_set_scissor_state;
- brw->pipe.set_sampler_texture = brw_set_sampler_texture;
- brw->pipe.set_viewport_state = brw_set_viewport_state;
- brw->pipe.set_vertex_buffer = brw_set_vertex_buffer;
- brw->pipe.set_vertex_element = brw_set_vertex_element;
-}
diff --git a/src/mesa/pipe/i965simple/brw_state.h b/src/mesa/pipe/i965simple/brw_state.h
deleted file mode 100644
index 258e9a556e..0000000000
--- a/src/mesa/pipe/i965simple/brw_state.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_STATE_H
-#define BRW_STATE_H
-
-#include "brw_context.h"
-#include "brw_winsys.h"
-
-
-const struct brw_tracked_state brw_blend_constant_color;
-const struct brw_tracked_state brw_cc_unit;
-const struct brw_tracked_state brw_cc_vp;
-const struct brw_tracked_state brw_clip_prog;
-const struct brw_tracked_state brw_clip_unit;
-const struct brw_tracked_state brw_constant_buffer_state;
-const struct brw_tracked_state brw_constant_buffer;
-const struct brw_tracked_state brw_curbe_offsets;
-const struct brw_tracked_state brw_invarient_state;
-const struct brw_tracked_state brw_gs_prog;
-const struct brw_tracked_state brw_gs_unit;
-const struct brw_tracked_state brw_drawing_rect;
-const struct brw_tracked_state brw_line_stipple;
-const struct brw_tracked_state brw_pipelined_state_pointers;
-const struct brw_tracked_state brw_binding_table_pointers;
-const struct brw_tracked_state brw_depthbuffer;
-const struct brw_tracked_state brw_polygon_stipple_offset;
-const struct brw_tracked_state brw_polygon_stipple;
-const struct brw_tracked_state brw_program_parameters;
-const struct brw_tracked_state brw_recalculate_urb_fence;
-const struct brw_tracked_state brw_sf_prog;
-const struct brw_tracked_state brw_sf_unit;
-const struct brw_tracked_state brw_sf_vp;
-const struct brw_tracked_state brw_state_base_address;
-const struct brw_tracked_state brw_urb_fence;
-const struct brw_tracked_state brw_vertex_state;
-const struct brw_tracked_state brw_vs_prog;
-const struct brw_tracked_state brw_vs_unit;
-const struct brw_tracked_state brw_wm_prog;
-const struct brw_tracked_state brw_wm_samplers;
-const struct brw_tracked_state brw_wm_surfaces;
-const struct brw_tracked_state brw_wm_unit;
-
-const struct brw_tracked_state brw_psp_urb_cbs;
-
-const struct brw_tracked_state brw_active_vertprog;
-const struct brw_tracked_state brw_tnl_vertprog;
-const struct brw_tracked_state brw_pipe_control;
-
-const struct brw_tracked_state brw_clear_surface_cache;
-const struct brw_tracked_state brw_clear_batch_cache;
-
-/***********************************************************************
- * brw_state_cache.c
- */
-unsigned brw_cache_data(struct brw_cache *cache,
- const void *data );
-
-unsigned brw_cache_data_sz(struct brw_cache *cache,
- const void *data,
- unsigned data_sz);
-
-unsigned brw_upload_cache( struct brw_cache *cache,
- const void *key,
- unsigned key_sz,
- const void *data,
- unsigned data_sz,
- const void *aux,
- void *aux_return );
-
-boolean brw_search_cache( struct brw_cache *cache,
- const void *key,
- unsigned key_size,
- void *aux_return,
- unsigned *offset_return);
-
-void brw_init_caches( struct brw_context *brw );
-void brw_destroy_caches( struct brw_context *brw );
-
-static inline struct pipe_buffer *brw_cache_buffer(struct brw_context *brw,
- enum brw_cache_id id)
-{
- return brw->cache[id].pool->buffer;
-}
-
-/***********************************************************************
- * brw_state_batch.c
- */
-#define BRW_CACHED_BATCH_STRUCT(brw, s) brw_cached_batch_struct( brw, (s), sizeof(*(s)) )
-
-boolean brw_cached_batch_struct( struct brw_context *brw,
- const void *data,
- unsigned sz );
-
-void brw_destroy_batch_cache( struct brw_context *brw );
-
-
-/***********************************************************************
- * brw_state_pool.c
- */
-void brw_init_pools( struct brw_context *brw );
-void brw_destroy_pools( struct brw_context *brw );
-
-boolean brw_pool_alloc( struct brw_mem_pool *pool,
- unsigned size,
- unsigned alignment,
- unsigned *offset_return);
-
-void brw_pool_fence( struct brw_context *brw,
- struct brw_mem_pool *pool,
- unsigned fence );
-
-
-void brw_pool_check_wrap( struct brw_context *brw,
- struct brw_mem_pool *pool );
-
-void brw_clear_all_caches( struct brw_context *brw );
-void brw_invalidate_pools( struct brw_context *brw );
-void brw_clear_batch_cache_flush( struct brw_context *brw );
-
-
-/* brw_shader_info.c
- */
-
-void brw_shader_info(const struct tgsi_token *tokens,
- struct brw_shader_info *info );
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_state_batch.c b/src/mesa/pipe/i965simple/brw_state_batch.c
deleted file mode 100644
index 35db76b594..0000000000
--- a/src/mesa/pipe/i965simple/brw_state_batch.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_state.h"
-#include "brw_winsys.h"
-
-#include "pipe/p_util.h"
-
-/* A facility similar to the data caching code above, which aims to
- * prevent identical commands being issued repeatedly.
- */
-boolean brw_cached_batch_struct( struct brw_context *brw,
- const void *data,
- unsigned sz )
-{
- struct brw_cached_batch_item *item = brw->cached_batch_items;
- struct header *newheader = (struct header *)data;
-
- if (brw->emit_state_always) {
- brw_batchbuffer_data(brw->winsys, data, sz);
- return TRUE;
- }
-
- while (item) {
- if (item->header->opcode == newheader->opcode) {
- if (item->sz == sz && memcmp(item->header, newheader, sz) == 0)
- return FALSE;
- if (item->sz != sz) {
- FREE(item->header);
- item->header = MALLOC(sz);
- item->sz = sz;
- }
- goto emit;
- }
- item = item->next;
- }
-
- assert(!item);
- item = CALLOC_STRUCT(brw_cached_batch_item);
- item->header = MALLOC(sz);
- item->sz = sz;
- item->next = brw->cached_batch_items;
- brw->cached_batch_items = item;
-
-emit:
- memcpy(item->header, newheader, sz);
- brw_batchbuffer_data(brw->winsys, data, sz);
- return TRUE;
-}
-
-static void clear_batch_cache( struct brw_context *brw )
-{
- struct brw_cached_batch_item *item = brw->cached_batch_items;
-
- while (item) {
- struct brw_cached_batch_item *next = item->next;
- free((void *)item->header);
- free(item);
- item = next;
- }
-
- brw->cached_batch_items = NULL;
-
-
- brw_clear_all_caches(brw);
-
- brw_invalidate_pools(brw);
-}
-
-void brw_clear_batch_cache_flush( struct brw_context *brw )
-{
- clear_batch_cache(brw);
-
-/* brw_do_flush(brw, BRW_FLUSH_STATE_CACHE|BRW_FLUSH_READ_CACHE); */
-
- brw->state.dirty.brw |= ~0;
- brw->state.dirty.cache |= ~0;
-}
-
-
-
-void brw_destroy_batch_cache( struct brw_context *brw )
-{
- clear_batch_cache(brw);
-}
diff --git a/src/mesa/pipe/i965simple/brw_state_cache.c b/src/mesa/pipe/i965simple/brw_state_cache.c
deleted file mode 100644
index b3a5124461..0000000000
--- a/src/mesa/pipe/i965simple/brw_state_cache.c
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_state.h"
-
-#include "brw_wm.h"
-#include "brw_vs.h"
-#include "brw_clip.h"
-#include "brw_sf.h"
-#include "brw_gs.h"
-
-#include "pipe/p_util.h"
-
-
-
-/***********************************************************************
- * Check cache for uploaded version of struct, else upload new one.
- * Fail when memory is exhausted.
- *
- * XXX: FIXME: Currently search is so slow it would be quicker to
- * regenerate the data every time...
- */
-
-static unsigned hash_key( const void *key, unsigned key_size )
-{
- unsigned *ikey = (unsigned *)key;
- unsigned hash = 0, i;
-
- assert(key_size % 4 == 0);
-
- /* I'm sure this can be improved on:
- */
- for (i = 0; i < key_size/4; i++)
- hash ^= ikey[i];
-
- return hash;
-}
-
-static struct brw_cache_item *search_cache( struct brw_cache *cache,
- unsigned hash,
- const void *key,
- unsigned key_size)
-{
- struct brw_cache_item *c;
-
- for (c = cache->items[hash % cache->size]; c; c = c->next) {
- if (c->hash == hash &&
- c->key_size == key_size &&
- memcmp(c->key, key, key_size) == 0)
- return c;
- }
-
- return NULL;
-}
-
-
-static void rehash( struct brw_cache *cache )
-{
- struct brw_cache_item **items;
- struct brw_cache_item *c, *next;
- unsigned size, i;
-
- size = cache->size * 3;
- items = (struct brw_cache_item**) MALLOC(size * sizeof(*items));
- memset(items, 0, size * sizeof(*items));
-
- for (i = 0; i < cache->size; i++)
- for (c = cache->items[i]; c; c = next) {
- next = c->next;
- c->next = items[c->hash % size];
- items[c->hash % size] = c;
- }
-
- FREE(cache->items);
- cache->items = items;
- cache->size = size;
-}
-
-
-boolean brw_search_cache( struct brw_cache *cache,
- const void *key,
- unsigned key_size,
- void *aux_return,
- unsigned *offset_return)
-{
- struct brw_cache_item *item;
- unsigned addr = 0;
- unsigned hash = hash_key(key, key_size);
-
- item = search_cache(cache, hash, key, key_size);
-
- if (item) {
- if (aux_return)
- *(void **)aux_return = (void *)((char *)item->key + item->key_size);
-
- *offset_return = addr = item->offset;
- }
-
- if (item == NULL || addr != cache->last_addr) {
- cache->brw->state.dirty.cache |= 1<<cache->id;
- cache->last_addr = addr;
- }
-
- return item != NULL;
-}
-
-unsigned brw_upload_cache( struct brw_cache *cache,
- const void *key,
- unsigned key_size,
- const void *data,
- unsigned data_size,
- const void *aux,
- void *aux_return )
-{
- unsigned offset;
- struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
- unsigned hash = hash_key(key, key_size);
- void *tmp = MALLOC(key_size + cache->aux_size);
-
- if (!brw_pool_alloc(cache->pool, data_size, 1 << 6, &offset)) {
- /* Should not be possible:
- */
- debug_printf("brw_pool_alloc failed\n");
- exit(1);
- }
-
- memcpy(tmp, key, key_size);
-
- if (cache->aux_size)
- memcpy(tmp+key_size, aux, cache->aux_size);
-
- item->key = tmp;
- item->hash = hash;
- item->key_size = key_size;
- item->offset = offset;
- item->data_size = data_size;
-
- if (++cache->n_items > cache->size * 1.5)
- rehash(cache);
-
- hash %= cache->size;
- item->next = cache->items[hash];
- cache->items[hash] = item;
-
- if (aux_return) {
- assert(cache->aux_size);
- *(void **)aux_return = (void *)((char *)item->key + item->key_size);
- }
-
- if (BRW_DEBUG & DEBUG_STATE)
- debug_printf("upload %s: %d bytes to pool buffer %p offset %x\n",
- cache->name,
- data_size,
- (void*)cache->pool->buffer,
- offset);
-
- /* Copy data to the buffer:
- */
- cache->brw->winsys->buffer_subdata_typed(cache->brw->winsys,
- cache->pool->buffer,
- offset,
- data_size,
- data,
- cache->id);
-
- cache->brw->state.dirty.cache |= 1<<cache->id;
- cache->last_addr = offset;
-
- return offset;
-}
-
-/* This doesn't really work with aux data. Use search/upload instead
- */
-unsigned brw_cache_data_sz(struct brw_cache *cache,
- const void *data,
- unsigned data_size)
-{
- unsigned addr;
-
- if (!brw_search_cache(cache, data, data_size, NULL, &addr)) {
- addr = brw_upload_cache(cache,
- data, data_size,
- data, data_size,
- NULL, NULL);
- }
-
- return addr;
-}
-
-unsigned brw_cache_data(struct brw_cache *cache,
- const void *data)
-{
- return brw_cache_data_sz(cache, data, cache->key_size);
-}
-
-enum pool_type {
- DW_SURFACE_STATE,
- DW_GENERAL_STATE
-};
-
-static void brw_init_cache( struct brw_context *brw,
- const char *name,
- unsigned id,
- unsigned key_size,
- unsigned aux_size,
- enum pool_type pool_type)
-{
- struct brw_cache *cache = &brw->cache[id];
- cache->brw = brw;
- cache->id = id;
- cache->name = name;
- cache->items = NULL;
-
- cache->size = 7;
- cache->n_items = 0;
- cache->items = (struct brw_cache_item **)
- CALLOC(cache->size, sizeof(struct brw_cache_item));
-
-
- cache->key_size = key_size;
- cache->aux_size = aux_size;
- switch (pool_type) {
- case DW_GENERAL_STATE: cache->pool = &brw->pool[BRW_GS_POOL]; break;
- case DW_SURFACE_STATE: cache->pool = &brw->pool[BRW_SS_POOL]; break;
- default: assert(0); break;
- }
-}
-
-void brw_init_caches( struct brw_context *brw )
-{
-
- brw_init_cache(brw,
- "CC_VP",
- BRW_CC_VP,
- sizeof(struct brw_cc_viewport),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "CC_UNIT",
- BRW_CC_UNIT,
- sizeof(struct brw_cc_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "WM_PROG",
- BRW_WM_PROG,
- sizeof(struct brw_wm_prog_key),
- sizeof(struct brw_wm_prog_data),
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SAMPLER_DEFAULT_COLOR",
- BRW_SAMPLER_DEFAULT_COLOR,
- sizeof(struct brw_sampler_default_color),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SAMPLER",
- BRW_SAMPLER,
- 0, /* variable key/data size */
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "WM_UNIT",
- BRW_WM_UNIT,
- sizeof(struct brw_wm_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SF_PROG",
- BRW_SF_PROG,
- sizeof(struct brw_sf_prog_key),
- sizeof(struct brw_sf_prog_data),
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SF_VP",
- BRW_SF_VP,
- sizeof(struct brw_sf_viewport),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SF_UNIT",
- BRW_SF_UNIT,
- sizeof(struct brw_sf_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "VS_UNIT",
- BRW_VS_UNIT,
- sizeof(struct brw_vs_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "VS_PROG",
- BRW_VS_PROG,
- sizeof(struct brw_vs_prog_key),
- sizeof(struct brw_vs_prog_data),
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "CLIP_UNIT",
- BRW_CLIP_UNIT,
- sizeof(struct brw_clip_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "CLIP_PROG",
- BRW_CLIP_PROG,
- sizeof(struct brw_clip_prog_key),
- sizeof(struct brw_clip_prog_data),
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "GS_UNIT",
- BRW_GS_UNIT,
- sizeof(struct brw_gs_unit_state),
- 0,
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "GS_PROG",
- BRW_GS_PROG,
- sizeof(struct brw_gs_prog_key),
- sizeof(struct brw_gs_prog_data),
- DW_GENERAL_STATE);
-
- brw_init_cache(brw,
- "SS_SURFACE",
- BRW_SS_SURFACE,
- sizeof(struct brw_surface_state),
- 0,
- DW_SURFACE_STATE);
-
- brw_init_cache(brw,
- "SS_SURF_BIND",
- BRW_SS_SURF_BIND,
- sizeof(struct brw_surface_binding_table),
- 0,
- DW_SURFACE_STATE);
-}
-
-
-/* When we lose hardware context, need to invalidate the surface cache
- * as these structs must be explicitly re-uploaded. They are subject
- * to fixup by the memory manager as they contain absolute agp
- * offsets, so we need to ensure there is a fresh version of the
- * struct available to receive the fixup.
- *
- * XXX: Need to ensure that there aren't two versions of a surface or
- * bufferobj with different backing data active in the same buffer at
- * once? Otherwise the cache could confuse them. Maybe better not to
- * cache at all?
- *
- * --> Isn't this the same as saying need to ensure batch is flushed
- * before new data is uploaded to an existing buffer? We
- * already try to make sure of that.
- */
-static void clear_cache( struct brw_cache *cache )
-{
- struct brw_cache_item *c, *next;
- unsigned i;
-
- for (i = 0; i < cache->size; i++) {
- for (c = cache->items[i]; c; c = next) {
- next = c->next;
- free((void *)c->key);
- free(c);
- }
- cache->items[i] = NULL;
- }
-
- cache->n_items = 0;
-}
-
-void brw_clear_all_caches( struct brw_context *brw )
-{
- int i;
-
- if (BRW_DEBUG & DEBUG_STATE)
- debug_printf("%s\n", __FUNCTION__);
-
- for (i = 0; i < BRW_MAX_CACHE; i++)
- clear_cache(&brw->cache[i]);
-
- if (brw->curbe.last_buf) {
- FREE(brw->curbe.last_buf);
- brw->curbe.last_buf = NULL;
- }
-
- brw->state.dirty.brw |= ~0;
- brw->state.dirty.cache |= ~0;
-}
-
-
-
-
-
-void brw_destroy_caches( struct brw_context *brw )
-{
- unsigned i;
-
- for (i = 0; i < BRW_MAX_CACHE; i++)
- clear_cache(&brw->cache[i]);
-}
diff --git a/src/mesa/pipe/i965simple/brw_state_pool.c b/src/mesa/pipe/i965simple/brw_state_pool.c
deleted file mode 100644
index f3174bfe0a..0000000000
--- a/src/mesa/pipe/i965simple/brw_state_pool.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-/** @file brw_state_pool.c
- * Implements the state pool allocator.
- *
- * For the 965, we create two state pools for state cache entries. Objects
- * will be allocated into the pools depending on which state base address
- * their pointer is relative to in other 965 state.
- *
- * The state pools are relatively simple: As objects are allocated, increment
- * the offset to allocate space. When the pool is "full" (rather, close to
- * full), we reset the pool and reset the state cache entries that point into
- * the pool.
- */
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "brw_context.h"
-#include "brw_state.h"
-
-boolean brw_pool_alloc( struct brw_mem_pool *pool,
- unsigned size,
- unsigned alignment,
- unsigned *offset_return)
-{
- unsigned fixup = align(pool->offset, alignment) - pool->offset;
-
- size = align(size, 4);
-
- if (pool->offset + fixup + size >= pool->size) {
- debug_printf("%s failed\n", __FUNCTION__);
- assert(0);
- exit(0);
- }
-
- pool->offset += fixup;
- *offset_return = pool->offset;
- pool->offset += size;
-
- return TRUE;
-}
-
-static
-void brw_invalidate_pool( struct brw_mem_pool *pool )
-{
- if (BRW_DEBUG & DEBUG_STATE)
- debug_printf("\n\n\n %s \n\n\n", __FUNCTION__);
-
- pool->offset = 0;
-
- brw_clear_all_caches(pool->brw);
-}
-
-
-static void brw_init_pool( struct brw_context *brw,
- unsigned pool_id,
- unsigned size )
-{
- struct brw_mem_pool *pool = &brw->pool[pool_id];
-
- pool->size = size;
- pool->brw = brw;
-
- pool->buffer = brw->pipe.winsys->buffer_create(brw->pipe.winsys,
- 4096,
- 0 /* DRM_BO_FLAG_MEM_TT */,
- size);
-}
-
-static void brw_destroy_pool( struct brw_context *brw,
- unsigned pool_id )
-{
- struct brw_mem_pool *pool = &brw->pool[pool_id];
-
- pipe_buffer_reference( pool->brw->pipe.winsys,
- &pool->buffer,
- NULL );
-}
-
-
-void brw_pool_check_wrap( struct brw_context *brw,
- struct brw_mem_pool *pool )
-{
- if (pool->offset > (pool->size * 3) / 4) {
- brw->state.dirty.brw |= BRW_NEW_SCENE;
- }
-
-}
-
-void brw_init_pools( struct brw_context *brw )
-{
- brw_init_pool(brw, BRW_GS_POOL, 0x80000);
- brw_init_pool(brw, BRW_SS_POOL, 0x80000);
-}
-
-void brw_destroy_pools( struct brw_context *brw )
-{
- brw_destroy_pool(brw, BRW_GS_POOL);
- brw_destroy_pool(brw, BRW_SS_POOL);
-}
-
-
-void brw_invalidate_pools( struct brw_context *brw )
-{
- brw_invalidate_pool(&brw->pool[BRW_GS_POOL]);
- brw_invalidate_pool(&brw->pool[BRW_SS_POOL]);
-}
diff --git a/src/mesa/pipe/i965simple/brw_state_upload.c b/src/mesa/pipe/i965simple/brw_state_upload.c
deleted file mode 100644
index e727601e1e..0000000000
--- a/src/mesa/pipe/i965simple/brw_state_upload.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-
-#include "pipe/p_util.h"
-
-/* This is used to initialize brw->state.atoms[]. We could use this
- * list directly except for a single atom, brw_constant_buffer, which
- * has a .dirty value which changes according to the parameters of the
- * current fragment and vertex programs, and so cannot be a static
- * value.
- */
-const struct brw_tracked_state *atoms[] =
-{
- &brw_vs_prog,
- &brw_gs_prog,
- &brw_clip_prog,
- &brw_sf_prog,
- &brw_wm_prog,
-
- /* Once all the programs are done, we know how large urb entry
- * sizes need to be and can decide if we need to change the urb
- * layout.
- */
- &brw_curbe_offsets,
- &brw_recalculate_urb_fence,
-
-
- &brw_cc_vp,
- &brw_cc_unit,
-
- &brw_wm_surfaces, /* must do before samplers */
- &brw_wm_samplers,
-
- &brw_wm_unit,
- &brw_sf_vp,
- &brw_sf_unit,
- &brw_vs_unit, /* always required, enabled or not */
- &brw_clip_unit,
- &brw_gs_unit,
-
- /* Command packets:
- */
- &brw_invarient_state,
- &brw_state_base_address,
- &brw_pipe_control,
-
- &brw_binding_table_pointers,
- &brw_blend_constant_color,
-
- &brw_drawing_rect,
- &brw_depthbuffer,
-
- &brw_polygon_stipple,
- &brw_line_stipple,
-
- &brw_psp_urb_cbs,
-
- &brw_constant_buffer
-};
-
-
-void brw_init_state( struct brw_context *brw )
-{
- brw_init_pools(brw);
- brw_init_caches(brw);
-
- brw->state.dirty.brw = ~0;
- brw->emit_state_always = 0;
-}
-
-
-void brw_destroy_state( struct brw_context *brw )
-{
- brw_destroy_caches(brw);
- brw_destroy_batch_cache(brw);
- brw_destroy_pools(brw);
-}
-
-/***********************************************************************
- */
-
-static boolean check_state( const struct brw_state_flags *a,
- const struct brw_state_flags *b )
-{
- return ((a->brw & b->brw) ||
- (a->cache & b->cache));
-}
-
-static void accumulate_state( struct brw_state_flags *a,
- const struct brw_state_flags *b )
-{
- a->brw |= b->brw;
- a->cache |= b->cache;
-}
-
-
-static void xor_states( struct brw_state_flags *result,
- const struct brw_state_flags *a,
- const struct brw_state_flags *b )
-{
- result->brw = a->brw ^ b->brw;
- result->cache = a->cache ^ b->cache;
-}
-
-
-/***********************************************************************
- * Emit all state:
- */
-void brw_validate_state( struct brw_context *brw )
-{
- struct brw_state_flags *state = &brw->state.dirty;
- unsigned i;
-
- if (brw->emit_state_always)
- state->brw |= ~0;
-
- if (state->cache == 0 &&
- state->brw == 0)
- return;
-
- if (brw->state.dirty.brw & BRW_NEW_SCENE)
- brw_clear_batch_cache_flush(brw);
-
- if (BRW_DEBUG) {
- /* Debug version which enforces various sanity checks on the
- * state flags which are generated and checked to help ensure
- * state atoms are ordered correctly in the list.
- */
- struct brw_state_flags examined, prev;
- memset(&examined, 0, sizeof(examined));
- prev = *state;
-
- for (i = 0; i < Elements(atoms); i++) {
- const struct brw_tracked_state *atom = atoms[i];
- struct brw_state_flags generated;
-
- assert(atom->dirty.brw ||
- atom->dirty.cache);
- assert(atom->update);
-
- if (check_state(state, &atom->dirty)) {
- atom->update( brw );
- }
-
- accumulate_state(&examined, &atom->dirty);
-
- /* generated = (prev ^ state)
- * if (examined & generated)
- * fail;
- */
- xor_states(&generated, &prev, state);
- assert(!check_state(&examined, &generated));
- prev = *state;
- }
- }
- else {
- for (i = 0; i < Elements(atoms); i++) {
- const struct brw_tracked_state *atom = atoms[i];
-
- assert(atom->dirty.brw ||
- atom->dirty.cache);
- assert(atom->update);
-
- if (check_state(state, &atom->dirty))
- atom->update( brw );
- }
- }
-
- memset(state, 0, sizeof(*state));
-}
diff --git a/src/mesa/pipe/i965simple/brw_strings.c b/src/mesa/pipe/i965simple/brw_strings.c
deleted file mode 100644
index 29a41ed1e9..0000000000
--- a/src/mesa/pipe/i965simple/brw_strings.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "brw_context.h"
-#include "brw_reg.h"
-
-
-static const char *brw_get_vendor( struct pipe_context *pipe )
-{
- return "Tungsten Graphics, Inc.";
-}
-
-
-static const char *brw_get_name( struct pipe_context *pipe )
-{
- static char buffer[128];
- const char *chipset;
-
- switch (brw_context(pipe)->pci_id) {
- case PCI_CHIP_I965_Q:
- chipset = "Intel(R) 965Q";
- break;
- case PCI_CHIP_I965_G:
- case PCI_CHIP_I965_G_1:
- chipset = "Intel(R) 965G";
- break;
- case PCI_CHIP_I965_GM:
- chipset = "Intel(R) 965GM";
- break;
- case PCI_CHIP_I965_GME:
- chipset = "Intel(R) 965GME/GLE";
- break;
- default:
- chipset = "unknown";
- break;
- }
-
- sprintf(buffer, "pipe/i965 (chipset: %s)", chipset);
- return buffer;
-}
-
-
-void
-brw_init_string_functions(struct brw_context *brw)
-{
- brw->pipe.get_name = brw_get_name;
- brw->pipe.get_vendor = brw_get_vendor;
-}
diff --git a/src/mesa/pipe/i965simple/brw_structs.h b/src/mesa/pipe/i965simple/brw_structs.h
deleted file mode 100644
index bbb087e95d..0000000000
--- a/src/mesa/pipe/i965simple/brw_structs.h
+++ /dev/null
@@ -1,1348 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_STRUCTS_H
-#define BRW_STRUCTS_H
-
-#include "pipe/p_compiler.h"
-
-/* Command packets:
- */
-struct header
-{
- unsigned length:16;
- unsigned opcode:16;
-};
-
-
-union header_union
-{
- struct header bits;
- unsigned dword;
-};
-
-struct brw_3d_control
-{
- struct
- {
- unsigned length:8;
- unsigned notify_enable:1;
- unsigned pad:3;
- unsigned wc_flush_enable:1;
- unsigned depth_stall_enable:1;
- unsigned operation:2;
- unsigned opcode:16;
- } header;
-
- struct
- {
- unsigned pad:2;
- unsigned dest_addr_type:1;
- unsigned dest_addr:29;
- } dest;
-
- unsigned dword2;
- unsigned dword3;
-};
-
-
-struct brw_3d_primitive
-{
- struct
- {
- unsigned length:8;
- unsigned pad:2;
- unsigned topology:5;
- unsigned indexed:1;
- unsigned opcode:16;
- } header;
-
- unsigned verts_per_instance;
- unsigned start_vert_location;
- unsigned instance_count;
- unsigned start_instance_location;
- unsigned base_vert_location;
-};
-
-/* These seem to be passed around as function args, so it works out
- * better to keep them as #defines:
- */
-#define BRW_FLUSH_READ_CACHE 0x1
-#define BRW_FLUSH_STATE_CACHE 0x2
-#define BRW_INHIBIT_FLUSH_RENDER_CACHE 0x4
-#define BRW_FLUSH_SNAPSHOT_COUNTERS 0x8
-
-struct brw_mi_flush
-{
- unsigned flags:4;
- unsigned pad:12;
- unsigned opcode:16;
-};
-
-struct brw_vf_statistics
-{
- unsigned statistics_enable:1;
- unsigned pad:15;
- unsigned opcode:16;
-};
-
-
-
-struct brw_binding_table_pointers
-{
- struct header header;
- unsigned vs;
- unsigned gs;
- unsigned clp;
- unsigned sf;
- unsigned wm;
-};
-
-
-struct brw_blend_constant_color
-{
- struct header header;
- float blend_constant_color[4];
-};
-
-
-struct brw_depthbuffer
-{
- union header_union header;
-
- union {
- struct {
- unsigned pitch:18;
- unsigned format:3;
- unsigned pad:4;
- unsigned depth_offset_disable:1;
- unsigned tile_walk:1;
- unsigned tiled_surface:1;
- unsigned pad2:1;
- unsigned surface_type:3;
- } bits;
- unsigned dword;
- } dword1;
-
- unsigned dword2_base_addr;
-
- union {
- struct {
- unsigned pad:1;
- unsigned mipmap_layout:1;
- unsigned lod:4;
- unsigned width:13;
- unsigned height:13;
- } bits;
- unsigned dword;
- } dword3;
-
- union {
- struct {
- unsigned pad:12;
- unsigned min_array_element:9;
- unsigned depth:11;
- } bits;
- unsigned dword;
- } dword4;
-};
-
-struct brw_drawrect
-{
- struct header header;
- unsigned xmin:16;
- unsigned ymin:16;
- unsigned xmax:16;
- unsigned ymax:16;
- unsigned xorg:16;
- unsigned yorg:16;
-};
-
-
-
-
-struct brw_global_depth_offset_clamp
-{
- struct header header;
- float depth_offset_clamp;
-};
-
-struct brw_indexbuffer
-{
- union {
- struct
- {
- unsigned length:8;
- unsigned index_format:2;
- unsigned cut_index_enable:1;
- unsigned pad:5;
- unsigned opcode:16;
- } bits;
- unsigned dword;
-
- } header;
-
- unsigned buffer_start;
- unsigned buffer_end;
-};
-
-
-struct brw_line_stipple
-{
- struct header header;
-
- struct
- {
- unsigned pattern:16;
- unsigned pad:16;
- } bits0;
-
- struct
- {
- unsigned repeat_count:9;
- unsigned pad:7;
- unsigned inverse_repeat_count:16;
- } bits1;
-};
-
-
-struct brw_pipelined_state_pointers
-{
- struct header header;
-
- struct {
- unsigned pad:5;
- unsigned offset:27;
- } vs;
-
- struct
- {
- unsigned enable:1;
- unsigned pad:4;
- unsigned offset:27;
- } gs;
-
- struct
- {
- unsigned enable:1;
- unsigned pad:4;
- unsigned offset:27;
- } clp;
-
- struct
- {
- unsigned pad:5;
- unsigned offset:27;
- } sf;
-
- struct
- {
- unsigned pad:5;
- unsigned offset:27;
- } wm;
-
- struct
- {
- unsigned pad:5;
- unsigned offset:27; /* KW: check me! */
- } cc;
-};
-
-
-struct brw_polygon_stipple_offset
-{
- struct header header;
-
- struct {
- unsigned y_offset:5;
- unsigned pad:3;
- unsigned x_offset:5;
- unsigned pad0:19;
- } bits0;
-};
-
-
-
-struct brw_polygon_stipple
-{
- struct header header;
- unsigned stipple[32];
-};
-
-
-
-struct brw_pipeline_select
-{
- struct
- {
- unsigned pipeline_select:1;
- unsigned pad:15;
- unsigned opcode:16;
- } header;
-};
-
-
-struct brw_pipe_control
-{
- struct
- {
- unsigned length:8;
- unsigned notify_enable:1;
- unsigned pad:2;
- unsigned instruction_state_cache_flush_enable:1;
- unsigned write_cache_flush_enable:1;
- unsigned depth_stall_enable:1;
- unsigned post_sync_operation:2;
-
- unsigned opcode:16;
- } header;
-
- struct
- {
- unsigned pad:2;
- unsigned dest_addr_type:1;
- unsigned dest_addr:29;
- } bits1;
-
- unsigned data0;
- unsigned data1;
-};
-
-
-struct brw_urb_fence
-{
- struct
- {
- unsigned length:8;
- unsigned vs_realloc:1;
- unsigned gs_realloc:1;
- unsigned clp_realloc:1;
- unsigned sf_realloc:1;
- unsigned vfe_realloc:1;
- unsigned cs_realloc:1;
- unsigned pad:2;
- unsigned opcode:16;
- } header;
-
- struct
- {
- unsigned vs_fence:10;
- unsigned gs_fence:10;
- unsigned clp_fence:10;
- unsigned pad:2;
- } bits0;
-
- struct
- {
- unsigned sf_fence:10;
- unsigned vf_fence:10;
- unsigned cs_fence:10;
- unsigned pad:2;
- } bits1;
-};
-
-struct brw_constant_buffer_state /* previously brw_command_streamer */
-{
- struct header header;
-
- struct
- {
- unsigned nr_urb_entries:3;
- unsigned pad:1;
- unsigned urb_entry_size:5;
- unsigned pad0:23;
- } bits0;
-};
-
-struct brw_constant_buffer
-{
- struct
- {
- unsigned length:8;
- unsigned valid:1;
- unsigned pad:7;
- unsigned opcode:16;
- } header;
-
- struct
- {
- unsigned buffer_length:6;
- unsigned buffer_address:26;
- } bits0;
-};
-
-struct brw_state_base_address
-{
- struct header header;
-
- struct
- {
- unsigned modify_enable:1;
- unsigned pad:4;
- unsigned general_state_address:27;
- } bits0;
-
- struct
- {
- unsigned modify_enable:1;
- unsigned pad:4;
- unsigned surface_state_address:27;
- } bits1;
-
- struct
- {
- unsigned modify_enable:1;
- unsigned pad:4;
- unsigned indirect_object_state_address:27;
- } bits2;
-
- struct
- {
- unsigned modify_enable:1;
- unsigned pad:11;
- unsigned general_state_upper_bound:20;
- } bits3;
-
- struct
- {
- unsigned modify_enable:1;
- unsigned pad:11;
- unsigned indirect_object_state_upper_bound:20;
- } bits4;
-};
-
-struct brw_state_prefetch
-{
- struct header header;
-
- struct
- {
- unsigned prefetch_count:3;
- unsigned pad:3;
- unsigned prefetch_pointer:26;
- } bits0;
-};
-
-struct brw_system_instruction_pointer
-{
- struct header header;
-
- struct
- {
- unsigned pad:4;
- unsigned system_instruction_pointer:28;
- } bits0;
-};
-
-
-
-
-/* State structs for the various fixed function units:
- */
-
-
-struct thread0
-{
- unsigned pad0:1;
- unsigned grf_reg_count:3;
- unsigned pad1:2;
- unsigned kernel_start_pointer:26;
-};
-
-struct thread1
-{
- unsigned ext_halt_exception_enable:1;
- unsigned sw_exception_enable:1;
- unsigned mask_stack_exception_enable:1;
- unsigned timeout_exception_enable:1;
- unsigned illegal_op_exception_enable:1;
- unsigned pad0:3;
- unsigned depth_coef_urb_read_offset:6; /* WM only */
- unsigned pad1:2;
- unsigned floating_point_mode:1;
- unsigned thread_priority:1;
- unsigned binding_table_entry_count:8;
- unsigned pad3:5;
- unsigned single_program_flow:1;
-};
-
-struct thread2
-{
- unsigned per_thread_scratch_space:4;
- unsigned pad0:6;
- unsigned scratch_space_base_pointer:22;
-};
-
-
-struct thread3
-{
- unsigned dispatch_grf_start_reg:4;
- unsigned urb_entry_read_offset:6;
- unsigned pad0:1;
- unsigned urb_entry_read_length:6;
- unsigned pad1:1;
- unsigned const_urb_entry_read_offset:6;
- unsigned pad2:1;
- unsigned const_urb_entry_read_length:6;
- unsigned pad3:1;
-};
-
-
-
-struct brw_clip_unit_state
-{
- struct thread0 thread0;
- struct
- {
- unsigned pad0:7;
- unsigned sw_exception_enable:1;
- unsigned pad1:3;
- unsigned mask_stack_exception_enable:1;
- unsigned pad2:1;
- unsigned illegal_op_exception_enable:1;
- unsigned pad3:2;
- unsigned floating_point_mode:1;
- unsigned thread_priority:1;
- unsigned binding_table_entry_count:8;
- unsigned pad4:5;
- unsigned single_program_flow:1;
- } thread1;
-
- struct thread2 thread2;
- struct thread3 thread3;
-
- struct
- {
- unsigned pad0:9;
- unsigned gs_output_stats:1; /* not always */
- unsigned stats_enable:1;
- unsigned nr_urb_entries:7;
- unsigned pad1:1;
- unsigned urb_entry_allocation_size:5;
- unsigned pad2:1;
- unsigned max_threads:1; /* may be less */
- unsigned pad3:6;
- } thread4;
-
- struct
- {
- unsigned pad0:13;
- unsigned clip_mode:3;
- unsigned userclip_enable_flags:8;
- unsigned userclip_must_clip:1;
- unsigned pad1:1;
- unsigned guard_band_enable:1;
- unsigned viewport_z_clip_enable:1;
- unsigned viewport_xy_clip_enable:1;
- unsigned vertex_position_space:1;
- unsigned api_mode:1;
- unsigned pad2:1;
- } clip5;
-
- struct
- {
- unsigned pad0:5;
- unsigned clipper_viewport_state_ptr:27;
- } clip6;
-
-
- float viewport_xmin;
- float viewport_xmax;
- float viewport_ymin;
- float viewport_ymax;
-};
-
-
-
-struct brw_cc_unit_state
-{
- struct
- {
- unsigned pad0:3;
- unsigned bf_stencil_pass_depth_pass_op:3;
- unsigned bf_stencil_pass_depth_fail_op:3;
- unsigned bf_stencil_fail_op:3;
- unsigned bf_stencil_func:3;
- unsigned bf_stencil_enable:1;
- unsigned pad1:2;
- unsigned stencil_write_enable:1;
- unsigned stencil_pass_depth_pass_op:3;
- unsigned stencil_pass_depth_fail_op:3;
- unsigned stencil_fail_op:3;
- unsigned stencil_func:3;
- unsigned stencil_enable:1;
- } cc0;
-
-
- struct
- {
- unsigned bf_stencil_ref:8;
- unsigned stencil_write_mask:8;
- unsigned stencil_test_mask:8;
- unsigned stencil_ref:8;
- } cc1;
-
-
- struct
- {
- unsigned logicop_enable:1;
- unsigned pad0:10;
- unsigned depth_write_enable:1;
- unsigned depth_test_function:3;
- unsigned depth_test:1;
- unsigned bf_stencil_write_mask:8;
- unsigned bf_stencil_test_mask:8;
- } cc2;
-
-
- struct
- {
- unsigned pad0:8;
- unsigned alpha_test_func:3;
- unsigned alpha_test:1;
- unsigned blend_enable:1;
- unsigned ia_blend_enable:1;
- unsigned pad1:1;
- unsigned alpha_test_format:1;
- unsigned pad2:16;
- } cc3;
-
- struct
- {
- unsigned pad0:5;
- unsigned cc_viewport_state_offset:27;
- } cc4;
-
- struct
- {
- unsigned pad0:2;
- unsigned ia_dest_blend_factor:5;
- unsigned ia_src_blend_factor:5;
- unsigned ia_blend_function:3;
- unsigned statistics_enable:1;
- unsigned logicop_func:4;
- unsigned pad1:11;
- unsigned dither_enable:1;
- } cc5;
-
- struct
- {
- unsigned clamp_post_alpha_blend:1;
- unsigned clamp_pre_alpha_blend:1;
- unsigned clamp_range:2;
- unsigned pad0:11;
- unsigned y_dither_offset:2;
- unsigned x_dither_offset:2;
- unsigned dest_blend_factor:5;
- unsigned src_blend_factor:5;
- unsigned blend_function:3;
- } cc6;
-
- struct {
- union {
- float f;
- ubyte ub[4];
- } alpha_ref;
- } cc7;
-};
-
-
-
-struct brw_sf_unit_state
-{
- struct thread0 thread0;
- struct thread1 thread1;
- struct thread2 thread2;
- struct thread3 thread3;
-
- struct
- {
- unsigned pad0:10;
- unsigned stats_enable:1;
- unsigned nr_urb_entries:7;
- unsigned pad1:1;
- unsigned urb_entry_allocation_size:5;
- unsigned pad2:1;
- unsigned max_threads:6;
- unsigned pad3:1;
- } thread4;
-
- struct
- {
- unsigned front_winding:1;
- unsigned viewport_transform:1;
- unsigned pad0:3;
- unsigned sf_viewport_state_offset:27;
- } sf5;
-
- struct
- {
- unsigned pad0:9;
- unsigned dest_org_vbias:4;
- unsigned dest_org_hbias:4;
- unsigned scissor:1;
- unsigned disable_2x2_trifilter:1;
- unsigned disable_zero_pix_trifilter:1;
- unsigned point_rast_rule:2;
- unsigned line_endcap_aa_region_width:2;
- unsigned line_width:4;
- unsigned fast_scissor_disable:1;
- unsigned cull_mode:2;
- unsigned aa_enable:1;
- } sf6;
-
- struct
- {
- unsigned point_size:11;
- unsigned use_point_size_state:1;
- unsigned subpixel_precision:1;
- unsigned sprite_point:1;
- unsigned pad0:11;
- unsigned trifan_pv:2;
- unsigned linestrip_pv:2;
- unsigned tristrip_pv:2;
- unsigned line_last_pixel_enable:1;
- } sf7;
-
-};
-
-
-struct brw_gs_unit_state
-{
- struct thread0 thread0;
- struct thread1 thread1;
- struct thread2 thread2;
- struct thread3 thread3;
-
- struct
- {
- unsigned pad0:10;
- unsigned stats_enable:1;
- unsigned nr_urb_entries:7;
- unsigned pad1:1;
- unsigned urb_entry_allocation_size:5;
- unsigned pad2:1;
- unsigned max_threads:1;
- unsigned pad3:6;
- } thread4;
-
- struct
- {
- unsigned sampler_count:3;
- unsigned pad0:2;
- unsigned sampler_state_pointer:27;
- } gs5;
-
-
- struct
- {
- unsigned max_vp_index:4;
- unsigned pad0:26;
- unsigned reorder_enable:1;
- unsigned pad1:1;
- } gs6;
-};
-
-
-struct brw_vs_unit_state
-{
- struct thread0 thread0;
- struct thread1 thread1;
- struct thread2 thread2;
- struct thread3 thread3;
-
- struct
- {
- unsigned pad0:10;
- unsigned stats_enable:1;
- unsigned nr_urb_entries:7;
- unsigned pad1:1;
- unsigned urb_entry_allocation_size:5;
- unsigned pad2:1;
- unsigned max_threads:4;
- unsigned pad3:3;
- } thread4;
-
- struct
- {
- unsigned sampler_count:3;
- unsigned pad0:2;
- unsigned sampler_state_pointer:27;
- } vs5;
-
- struct
- {
- unsigned vs_enable:1;
- unsigned vert_cache_disable:1;
- unsigned pad0:30;
- } vs6;
-};
-
-
-struct brw_wm_unit_state
-{
- struct thread0 thread0;
- struct thread1 thread1;
- struct thread2 thread2;
- struct thread3 thread3;
-
- struct {
- unsigned stats_enable:1;
- unsigned pad0:1;
- unsigned sampler_count:3;
- unsigned sampler_state_pointer:27;
- } wm4;
-
- struct
- {
- unsigned enable_8_pix:1;
- unsigned enable_16_pix:1;
- unsigned enable_32_pix:1;
- unsigned pad0:7;
- unsigned legacy_global_depth_bias:1;
- unsigned line_stipple:1;
- unsigned depth_offset:1;
- unsigned polygon_stipple:1;
- unsigned line_aa_region_width:2;
- unsigned line_endcap_aa_region_width:2;
- unsigned early_depth_test:1;
- unsigned thread_dispatch_enable:1;
- unsigned program_uses_depth:1;
- unsigned program_computes_depth:1;
- unsigned program_uses_killpixel:1;
- unsigned legacy_line_rast: 1;
- unsigned pad1:1;
- unsigned max_threads:6;
- unsigned pad2:1;
- } wm5;
-
- float global_depth_offset_constant;
- float global_depth_offset_scale;
-};
-
-struct brw_sampler_default_color {
- float color[4];
-};
-
-struct brw_sampler_state
-{
-
- struct
- {
- unsigned shadow_function:3;
- unsigned lod_bias:11;
- unsigned min_filter:3;
- unsigned mag_filter:3;
- unsigned mip_filter:2;
- unsigned base_level:5;
- unsigned pad:1;
- unsigned lod_preclamp:1;
- unsigned default_color_mode:1;
- unsigned pad0:1;
- unsigned disable:1;
- } ss0;
-
- struct
- {
- unsigned r_wrap_mode:3;
- unsigned t_wrap_mode:3;
- unsigned s_wrap_mode:3;
- unsigned pad:3;
- unsigned max_lod:10;
- unsigned min_lod:10;
- } ss1;
-
-
- struct
- {
- unsigned pad:5;
- unsigned default_color_pointer:27;
- } ss2;
-
- struct
- {
- unsigned pad:19;
- unsigned max_aniso:3;
- unsigned chroma_key_mode:1;
- unsigned chroma_key_index:2;
- unsigned chroma_key_enable:1;
- unsigned monochrome_filter_width:3;
- unsigned monochrome_filter_height:3;
- } ss3;
-};
-
-
-struct brw_clipper_viewport
-{
- float xmin;
- float xmax;
- float ymin;
- float ymax;
-};
-
-struct brw_cc_viewport
-{
- float min_depth;
- float max_depth;
-};
-
-struct brw_sf_viewport
-{
- struct {
- float m00;
- float m11;
- float m22;
- float m30;
- float m31;
- float m32;
- } viewport;
-
- struct {
- short xmin;
- short ymin;
- short xmax;
- short ymax;
- } scissor;
-};
-
-/* Documented in the subsystem/shared-functions/sampler chapter...
- */
-struct brw_surface_state
-{
- struct {
- unsigned cube_pos_z:1;
- unsigned cube_neg_z:1;
- unsigned cube_pos_y:1;
- unsigned cube_neg_y:1;
- unsigned cube_pos_x:1;
- unsigned cube_neg_x:1;
- unsigned pad:4;
- unsigned mipmap_layout_mode:1;
- unsigned vert_line_stride_ofs:1;
- unsigned vert_line_stride:1;
- unsigned color_blend:1;
- unsigned writedisable_blue:1;
- unsigned writedisable_green:1;
- unsigned writedisable_red:1;
- unsigned writedisable_alpha:1;
- unsigned surface_format:9;
- unsigned data_return_format:1;
- unsigned pad0:1;
- unsigned surface_type:3;
- } ss0;
-
- struct {
- unsigned base_addr;
- } ss1;
-
- struct {
- unsigned pad:2;
- unsigned mip_count:4;
- unsigned width:13;
- unsigned height:13;
- } ss2;
-
- struct {
- unsigned tile_walk:1;
- unsigned tiled_surface:1;
- unsigned pad:1;
- unsigned pitch:18;
- unsigned depth:11;
- } ss3;
-
- struct {
- unsigned pad:19;
- unsigned min_array_elt:9;
- unsigned min_lod:4;
- } ss4;
-};
-
-
-
-struct brw_vertex_buffer_state
-{
- struct {
- unsigned pitch:11;
- unsigned pad:15;
- unsigned access_type:1;
- unsigned vb_index:5;
- } vb0;
-
- unsigned start_addr;
- unsigned max_index;
-#if 1
- unsigned instance_data_step_rate; /* not included for sequential/random vertices? */
-#endif
-};
-
-#define BRW_VBP_MAX 17
-
-struct brw_vb_array_state {
- struct header header;
- struct brw_vertex_buffer_state vb[BRW_VBP_MAX];
-};
-
-
-struct brw_vertex_element_state
-{
- struct
- {
- unsigned src_offset:11;
- unsigned pad:5;
- unsigned src_format:9;
- unsigned pad0:1;
- unsigned valid:1;
- unsigned vertex_buffer_index:5;
- } ve0;
-
- struct
- {
- unsigned dst_offset:8;
- unsigned pad:8;
- unsigned vfcomponent3:4;
- unsigned vfcomponent2:4;
- unsigned vfcomponent1:4;
- unsigned vfcomponent0:4;
- } ve1;
-};
-
-#define BRW_VEP_MAX 18
-
-struct brw_vertex_element_packet {
- struct header header;
- struct brw_vertex_element_state ve[BRW_VEP_MAX]; /* note: less than _TNL_ATTRIB_MAX */
-};
-
-
-struct brw_urb_immediate {
- unsigned opcode:4;
- unsigned offset:6;
- unsigned swizzle_control:2;
- unsigned pad:1;
- unsigned allocate:1;
- unsigned used:1;
- unsigned complete:1;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
-};
-
-/* Instruction format for the execution units:
- */
-
-struct brw_instruction
-{
- struct
- {
- unsigned opcode:7;
- unsigned pad:1;
- unsigned access_mode:1;
- unsigned mask_control:1;
- unsigned dependency_control:2;
- unsigned compression_control:2;
- unsigned thread_control:2;
- unsigned predicate_control:4;
- unsigned predicate_inverse:1;
- unsigned execution_size:3;
- unsigned destreg__conditonalmod:4; /* destreg - send, conditionalmod - others */
- unsigned pad0:2;
- unsigned debug_control:1;
- unsigned saturate:1;
- } header;
-
- union {
- struct
- {
- unsigned dest_reg_file:2;
- unsigned dest_reg_type:3;
- unsigned src0_reg_file:2;
- unsigned src0_reg_type:3;
- unsigned src1_reg_file:2;
- unsigned src1_reg_type:3;
- unsigned pad:1;
- unsigned dest_subreg_nr:5;
- unsigned dest_reg_nr:8;
- unsigned dest_horiz_stride:2;
- unsigned dest_address_mode:1;
- } da1;
-
- struct
- {
- unsigned dest_reg_file:2;
- unsigned dest_reg_type:3;
- unsigned src0_reg_file:2;
- unsigned src0_reg_type:3;
- unsigned pad:6;
- int dest_indirect_offset:10; /* offset against the deref'd address reg */
- unsigned dest_subreg_nr:3; /* subnr for the address reg a0.x */
- unsigned dest_horiz_stride:2;
- unsigned dest_address_mode:1;
- } ia1;
-
- struct
- {
- unsigned dest_reg_file:2;
- unsigned dest_reg_type:3;
- unsigned src0_reg_file:2;
- unsigned src0_reg_type:3;
- unsigned src1_reg_file:2;
- unsigned src1_reg_type:3;
- unsigned pad0:1;
- unsigned dest_writemask:4;
- unsigned dest_subreg_nr:1;
- unsigned dest_reg_nr:8;
- unsigned pad1:2;
- unsigned dest_address_mode:1;
- } da16;
-
- struct
- {
- unsigned dest_reg_file:2;
- unsigned dest_reg_type:3;
- unsigned src0_reg_file:2;
- unsigned src0_reg_type:3;
- unsigned pad0:6;
- unsigned dest_writemask:4;
- int dest_indirect_offset:6;
- unsigned dest_subreg_nr:3;
- unsigned pad1:2;
- unsigned dest_address_mode:1;
- } ia16;
- } bits1;
-
-
- union {
- struct
- {
- unsigned src0_subreg_nr:5;
- unsigned src0_reg_nr:8;
- unsigned src0_abs:1;
- unsigned src0_negate:1;
- unsigned src0_address_mode:1;
- unsigned src0_horiz_stride:2;
- unsigned src0_width:3;
- unsigned src0_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad:6;
- } da1;
-
- struct
- {
- int src0_indirect_offset:10;
- unsigned src0_subreg_nr:3;
- unsigned src0_abs:1;
- unsigned src0_negate:1;
- unsigned src0_address_mode:1;
- unsigned src0_horiz_stride:2;
- unsigned src0_width:3;
- unsigned src0_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad:6;
- } ia1;
-
- struct
- {
- unsigned src0_swz_x:2;
- unsigned src0_swz_y:2;
- unsigned src0_subreg_nr:1;
- unsigned src0_reg_nr:8;
- unsigned src0_abs:1;
- unsigned src0_negate:1;
- unsigned src0_address_mode:1;
- unsigned src0_swz_z:2;
- unsigned src0_swz_w:2;
- unsigned pad0:1;
- unsigned src0_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad1:6;
- } da16;
-
- struct
- {
- unsigned src0_swz_x:2;
- unsigned src0_swz_y:2;
- int src0_indirect_offset:6;
- unsigned src0_subreg_nr:3;
- unsigned src0_abs:1;
- unsigned src0_negate:1;
- unsigned src0_address_mode:1;
- unsigned src0_swz_z:2;
- unsigned src0_swz_w:2;
- unsigned pad0:1;
- unsigned src0_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad1:6;
- } ia16;
-
- } bits2;
-
- union
- {
- struct
- {
- unsigned src1_subreg_nr:5;
- unsigned src1_reg_nr:8;
- unsigned src1_abs:1;
- unsigned src1_negate:1;
- unsigned pad:1;
- unsigned src1_horiz_stride:2;
- unsigned src1_width:3;
- unsigned src1_vert_stride:4;
- unsigned pad0:7;
- } da1;
-
- struct
- {
- unsigned src1_swz_x:2;
- unsigned src1_swz_y:2;
- unsigned src1_subreg_nr:1;
- unsigned src1_reg_nr:8;
- unsigned src1_abs:1;
- unsigned src1_negate:1;
- unsigned pad0:1;
- unsigned src1_swz_z:2;
- unsigned src1_swz_w:2;
- unsigned pad1:1;
- unsigned src1_vert_stride:4;
- unsigned pad2:7;
- } da16;
-
- struct
- {
- int src1_indirect_offset:10;
- unsigned src1_subreg_nr:3;
- unsigned src1_abs:1;
- unsigned src1_negate:1;
- unsigned pad0:1;
- unsigned src1_horiz_stride:2;
- unsigned src1_width:3;
- unsigned src1_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad1:6;
- } ia1;
-
- struct
- {
- unsigned src1_swz_x:2;
- unsigned src1_swz_y:2;
- int src1_indirect_offset:6;
- unsigned src1_subreg_nr:3;
- unsigned src1_abs:1;
- unsigned src1_negate:1;
- unsigned pad0:1;
- unsigned src1_swz_z:2;
- unsigned src1_swz_w:2;
- unsigned pad1:1;
- unsigned src1_vert_stride:4;
- unsigned flag_reg_nr:1;
- unsigned pad2:6;
- } ia16;
-
-
- struct
- {
- int jump_count:16; /* note: signed */
- unsigned pop_count:4;
- unsigned pad0:12;
- } if_else;
-
- struct {
- unsigned function:4;
- unsigned int_type:1;
- unsigned precision:1;
- unsigned saturate:1;
- unsigned data_type:1;
- unsigned pad0:8;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
- } math;
-
- struct {
- unsigned binding_table_index:8;
- unsigned sampler:4;
- unsigned return_format:2;
- unsigned msg_type:2;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
- } sampler;
-
- struct brw_urb_immediate urb;
-
- struct {
- unsigned binding_table_index:8;
- unsigned msg_control:4;
- unsigned msg_type:2;
- unsigned target_cache:2;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
- } dp_read;
-
- struct {
- unsigned binding_table_index:8;
- unsigned msg_control:3;
- unsigned pixel_scoreboard_clear:1;
- unsigned msg_type:3;
- unsigned send_commit_msg:1;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
- } dp_write;
-
- struct {
- unsigned pad:16;
- unsigned response_length:4;
- unsigned msg_length:4;
- unsigned msg_target:4;
- unsigned pad1:3;
- unsigned end_of_thread:1;
- } generic;
-
- int d;
- unsigned ud;
- } bits3;
-};
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_surface.c b/src/mesa/pipe/i965simple/brw_surface.c
deleted file mode 100644
index 518845e4b2..0000000000
--- a/src/mesa/pipe/i965simple/brw_surface.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "brw_blit.h"
-#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 "pipe/util/p_tile.h"
-
-
-/*
- * XXX note: same as code in sp_surface.c
- */
-static struct pipe_surface *
-brw_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
-{
- struct brw_texture *tex = (struct brw_texture *)pt;
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
-
- offset = tex->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset += tex->image_offset[level][face] * pt->cpp;
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset += tex->image_offset[level][zslice] * pt->cpp;
- }
- else {
- assert(face == 0);
- assert(zslice == 0);
- }
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->format);
- assert(ps->refcount);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = tex->pitch;
- ps->offset = offset;
- }
- return ps;
-}
-
-
-/* Upload data to a rectangular sub-region. Lots of choices how to do this:
- *
- * - memcpy by span to current destination
- * - upload data as new buffer and blit
- *
- * Currently always memcpy.
- */
-static void
-brw_surface_data(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- const void *src, unsigned src_pitch,
- unsigned srcx, unsigned srcy, unsigned width, unsigned height)
-{
- pipe_copy_rect(pipe_surface_map(dst) + dst->offset,
- dst->cpp, dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
-
- pipe_surface_unmap(dst);
-}
-
-
-/* Assumes all values are within bounds -- no checking at this level -
- * do it higher up if required.
- */
-static void
-brw_surface_copy(struct pipe_context *pipe,
- unsigned do_flip,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy, unsigned width, unsigned height)
-{
- assert(dst != src);
- assert(dst->cpp == src->cpp);
-
- if (0) {
- pipe_copy_rect(pipe_surface_map(dst) + dst->offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src) + src->offset,
- do_flip ? -src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : srcy);
-
- pipe_surface_unmap(src);
- pipe_surface_unmap(dst);
- }
- else {
- brw_copy_blit(brw_context(pipe),
- do_flip,
- dst->cpp,
- (short) src->pitch, src->buffer, src->offset, FALSE,
- (short) dst->pitch, dst->buffer, dst->offset, FALSE,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty,
- (short) width, (short) height, PIPE_LOGICOP_COPY);
- }
-}
-
-/* Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map + (y * dst->pitch + x) * dst->cpp;
-}
-
-
-static void
-brw_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- if (0) {
- unsigned i, j;
- void *dst_map = pipe_surface_map(dst);
-
- switch (dst->cpp) {
- case 1: {
- ubyte *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
- case 2: {
- ushort *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
- case 4: {
- unsigned *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe_surface_unmap( dst );
- }
- else {
- brw_fill_blit(brw_context(pipe),
- dst->cpp,
- (short) dst->pitch,
- dst->buffer, dst->offset, FALSE,
- (short) dstx, (short) dsty,
- (short) width, (short) height,
- value);
- }
-}
-
-void
-brw_init_surface_functions(struct brw_context *brw)
-{
- brw->pipe.get_tex_surface = brw_get_tex_surface;
- brw->pipe.surface_copy = brw_surface_copy;
- brw->pipe.surface_fill = brw_surface_fill;
-}
diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.c b/src/mesa/pipe/i965simple/brw_tex_layout.c
deleted file mode 100644
index 90561f1307..0000000000
--- a/src/mesa/pipe/i965simple/brw_tex_layout.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-/* 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 "brw_context.h"
-
-#define FILE_DEBUG_FLAG DEBUG_TEXTURE
-
-#if 0
-unsigned intel_compressed_alignment(unsigned internalFormat)
-{
- unsigned alignment = 4;
-
- switch (internalFormat) {
- case GL_COMPRESSED_RGB_FXT1_3DFX:
- case GL_COMPRESSED_RGBA_FXT1_3DFX:
- alignment = 8;
- break;
-
- default:
- break;
- }
-
- return alignment;
-}
-#endif
-
-static unsigned minify( unsigned d )
-{
- return MAX2(1, d>>1);
-}
-
-
-static boolean brw_miptree_layout(struct pipe_context *, struct brw_texture *);
-
-static void intel_miptree_set_image_offset(struct brw_texture *tex,
- unsigned level,
- unsigned img,
- unsigned x, unsigned y)
-{
- struct pipe_texture *pt = &tex->base;
- if (img == 0 && level == 0)
- assert(x == 0 && y == 0);
- assert(img < tex->nr_images[level]);
-
- tex->image_offset[level][img] = (x + y * tex->pitch) * pt->cpp;
-}
-
-static void intel_miptree_set_level_info(struct brw_texture *tex,
- unsigned level,
- unsigned nr_images,
- unsigned x, unsigned y,
- unsigned w, unsigned h, unsigned d)
-{
- struct pipe_texture *pt = &tex->base;
-
- assert(level < PIPE_MAX_TEXTURE_LEVELS);
-
- pt->width[level] = w;
- pt->height[level] = h;
- pt->depth[level] = d;
-
- tex->level_offset[level] = (x + y * tex->pitch) * pt->cpp;
- tex->nr_images[level] = nr_images;
-
- /*
- DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
- level, w, h, d, x, y, tex->level_offset[level]);
- */
-
- /* Not sure when this would happen, but anyway:
- */
- if (tex->image_offset[level]) {
- FREE(tex->image_offset[level]);
- tex->image_offset[level] = NULL;
- }
-
- assert(nr_images);
- assert(!tex->image_offset[level]);
-
- tex->image_offset[level] = (unsigned *) MALLOC(nr_images * sizeof(unsigned));
- tex->image_offset[level][0] = 0;
-}
-
-static void i945_miptree_layout_2d(struct brw_texture *tex)
-{
- struct pipe_texture *pt = &tex->base;
- unsigned align_h = 2, align_w = 4;
- unsigned level;
- unsigned x = 0;
- unsigned y = 0;
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
-
- tex->pitch = pt->width[0];
-
-#if 0
- if (pt->compressed) {
- align_w = intel_compressed_alignment(pt->internal_format);
- tex->pitch = ALIGN(pt->width[0], align_w);
- }
-#endif
-
- /* May need to adjust pitch to accomodate the placement of
- * the 2nd mipmap. This occurs when the alignment
- * constraints of mipmap placement push the right edge of the
- * 2nd mipmap out past the width of its parent.
- */
- if (pt->last_level > 0) {
- unsigned mip1_width;
-
- if (pt->compressed) {
- mip1_width = align(minify(pt->width[0]), align_w)
- + align(minify(minify(pt->width[0])), align_w);
- } else {
- mip1_width = align(minify(pt->width[0]), align_w)
- + minify(minify(pt->width[0]));
- }
-
- if (mip1_width > tex->pitch) {
- tex->pitch = mip1_width;
- }
- }
-
- /* Pitch must be a whole number of dwords, even though we
- * express it in texels.
- */
- tex->pitch = align(tex->pitch * pt->cpp, 4) / pt->cpp;
- tex->total_height = 0;
-
- for (level = 0; level <= pt->last_level; level++) {
- unsigned img_height;
-
- intel_miptree_set_level_info(tex, level, 1, x, y, width,
- height, 1);
-
- if (pt->compressed)
- img_height = MAX2(1, height/4);
- else
- img_height = align(height, align_h);
-
-
- /* Because the images are packed better, the final offset
- * might not be the maximal one:
- */
- tex->total_height = MAX2(tex->total_height, y + img_height);
-
- /* Layout_below: step right after second mipmap.
- */
- if (level == 1) {
- x += align(width, align_w);
- }
- else {
- y += img_height;
- }
-
- width = minify(width);
- height = minify(height);
- }
-}
-
-static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture *tex)
-{
- struct pipe_texture *pt = &tex->base;
- /* XXX: these vary depending on image format:
- */
-/* int align_w = 4; */
-
- switch (pt->target) {
- case PIPE_TEXTURE_CUBE:
- case PIPE_TEXTURE_3D: {
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned depth = pt->depth[0];
- unsigned pack_x_pitch, pack_x_nr;
- unsigned pack_y_pitch;
- unsigned level;
- unsigned align_h = 2;
- unsigned align_w = 4;
-
- tex->total_height = 0;
-#if 0
- if (pt->compressed) {
- align_w = intel_compressed_alignment(pt->internal_format);
- pt->pitch = align(width, align_w);
- pack_y_pitch = (height + 3) / 4;
- } else
-#endif
- {
- tex->pitch = align(pt->width[0] * pt->cpp, 4) / pt->cpp;
- pack_y_pitch = align(pt->height[0], align_h);
- }
-
- pack_x_pitch = tex->pitch;
- pack_x_nr = 1;
-
- for (level = 0; level <= pt->last_level; level++) {
- unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6;
- int x = 0;
- int y = 0;
- uint q, j;
-
- intel_miptree_set_level_info(tex, level, nr_images,
- 0, tex->total_height,
- width, height, depth);
-
- for (q = 0; q < nr_images;) {
- for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) {
- intel_miptree_set_image_offset(tex, level, q, x, y);
- x += pack_x_pitch;
- }
-
- x = 0;
- y += pack_y_pitch;
- }
-
-
- tex->total_height += y;
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
-
- if (pt->compressed) {
- pack_y_pitch = (height + 3) / 4;
-
- if (pack_x_pitch > align(width, align_w)) {
- pack_x_pitch = align(width, align_w);
- pack_x_nr <<= 1;
- }
- } else {
- if (pack_x_pitch > 4) {
- pack_x_pitch >>= 1;
- pack_x_nr <<= 1;
- assert(pack_x_pitch * pack_x_nr <= tex->pitch);
- }
-
- if (pack_y_pitch > 2) {
- pack_y_pitch >>= 1;
- pack_y_pitch = align(pack_y_pitch, align_h);
- }
- }
-
- }
- break;
- }
-
- default:
- i945_miptree_layout_2d(tex);
- break;
- }
-#if 0
- PRINT("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
- pt->pitch,
- pt->total_height,
- pt->cpp,
- pt->pitch * pt->total_height * pt->cpp );
-#endif
-
- return TRUE;
-}
-
-
-struct pipe_texture *
-brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
-{
- struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
-
- if (tex) {
- tex->base = *templat;
-
- if (brw_miptree_layout(pipe, tex))
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
- PIPE_BUFFER_USAGE_PIXEL,
- tex->pitch * tex->base.cpp *
- tex->total_height);
-
- if (!tex->buffer) {
- FREE(tex);
- return NULL;
- }
- }
-
- return &tex->base;
-}
-
-void
-brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
-{
- if (!*pt)
- return;
-
- /*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
- */
- if (--(*pt)->refcount <= 0) {
- struct brw_texture *tex = (struct brw_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
-
- pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
-
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- free(tex->image_offset[i]);
-
- free(tex);
- }
- *pt = NULL;
-}
diff --git a/src/mesa/pipe/i965simple/brw_tex_layout.h b/src/mesa/pipe/i965simple/brw_tex_layout.h
deleted file mode 100644
index cfd6b1ef3a..0000000000
--- a/src/mesa/pipe/i965simple/brw_tex_layout.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef BRW_TEX_LAYOUT_H
-#define BRW_TEX_LAYOUT_H
-
-#include "pipe/p_compiler.h"
-
-struct pipe_context;
-struct pipe_texture;
-
-extern struct pipe_texture *
-brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat);
-
-extern void
-brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_urb.c b/src/mesa/pipe/i965simple/brw_urb.c
deleted file mode 100644
index 101a4367b9..0000000000
--- a/src/mesa/pipe/i965simple/brw_urb.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-//#include "brw_state.h"
-#include "brw_batch.h"
-#include "brw_defines.h"
-
-#define VS 0
-#define GS 1
-#define CLP 2
-#define SF 3
-#define CS 4
-
-/* XXX: Are the min_entry_size numbers useful?
- * XXX: Verify min_nr_entries, esp for VS.
- * XXX: Verify SF min_entry_size.
- */
-static const struct {
- unsigned min_nr_entries;
- unsigned preferred_nr_entries;
- unsigned min_entry_size;
- unsigned max_entry_size;
-} limits[CS+1] = {
- { 8, 32, 1, 5 }, /* vs */
- { 4, 8, 1, 5 }, /* gs */
- { 6, 8, 1, 5 }, /* clp */
- { 1, 8, 1, 12 }, /* sf */
- { 1, 4, 1, 32 } /* cs */
-};
-
-
-static boolean check_urb_layout( struct brw_context *brw )
-{
- brw->urb.vs_start = 0;
- brw->urb.gs_start = brw->urb.nr_vs_entries * brw->urb.vsize;
- brw->urb.clip_start = brw->urb.gs_start + brw->urb.nr_gs_entries * brw->urb.vsize;
- brw->urb.sf_start = brw->urb.clip_start + brw->urb.nr_clip_entries * brw->urb.vsize;
- brw->urb.cs_start = brw->urb.sf_start + brw->urb.nr_sf_entries * brw->urb.sfsize;
-
- return brw->urb.cs_start + brw->urb.nr_cs_entries * brw->urb.csize <= 256;
-}
-
-/* Most minimal update, forces re-emit of URB fence packet after GS
- * unit turned on/off.
- */
-static void recalculate_urb_fence( struct brw_context *brw )
-{
- unsigned csize = brw->curbe.total_size;
- unsigned vsize = brw->vs.prog_data->urb_entry_size;
- unsigned sfsize = brw->sf.prog_data->urb_entry_size;
-
- if (csize < limits[CS].min_entry_size)
- csize = limits[CS].min_entry_size;
-
- if (vsize < limits[VS].min_entry_size)
- vsize = limits[VS].min_entry_size;
-
- if (sfsize < limits[SF].min_entry_size)
- sfsize = limits[SF].min_entry_size;
-
- if (brw->urb.vsize < vsize ||
- brw->urb.sfsize < sfsize ||
- brw->urb.csize < csize ||
- (brw->urb.constrained && (brw->urb.vsize > brw->urb.vsize ||
- brw->urb.sfsize > brw->urb.sfsize ||
- brw->urb.csize > brw->urb.csize))) {
-
-
- brw->urb.csize = csize;
- brw->urb.sfsize = sfsize;
- brw->urb.vsize = vsize;
-
- brw->urb.nr_vs_entries = limits[VS].preferred_nr_entries;
- brw->urb.nr_gs_entries = limits[GS].preferred_nr_entries;
- brw->urb.nr_clip_entries = limits[CLP].preferred_nr_entries;
- brw->urb.nr_sf_entries = limits[SF].preferred_nr_entries;
- brw->urb.nr_cs_entries = limits[CS].preferred_nr_entries;
-
- if (!check_urb_layout(brw)) {
- brw->urb.nr_vs_entries = limits[VS].min_nr_entries;
- brw->urb.nr_gs_entries = limits[GS].min_nr_entries;
- brw->urb.nr_clip_entries = limits[CLP].min_nr_entries;
- brw->urb.nr_sf_entries = limits[SF].min_nr_entries;
- brw->urb.nr_cs_entries = limits[CS].min_nr_entries;
-
- brw->urb.constrained = 1;
-
- if (!check_urb_layout(brw)) {
- /* This is impossible, given the maximal sizes of urb
- * entries and the values for minimum nr of entries
- * provided above.
- */
- debug_printf("couldn't calculate URB layout!\n");
- exit(1);
- }
-
- if (BRW_DEBUG & (DEBUG_URB|DEBUG_FALLBACKS))
- debug_printf("URB CONSTRAINED\n");
- }
- else
- brw->urb.constrained = 0;
-
- if (BRW_DEBUG & DEBUG_URB)
- debug_printf("URB fence: %d ..VS.. %d ..GS.. %d ..CLP.. %d ..SF.. %d ..CS.. %d\n",
- brw->urb.vs_start,
- brw->urb.gs_start,
- brw->urb.clip_start,
- brw->urb.sf_start,
- brw->urb.cs_start,
- 256);
-
- brw->state.dirty.brw |= BRW_NEW_URB_FENCE;
- }
-}
-
-
-const struct brw_tracked_state brw_recalculate_urb_fence = {
- .dirty = {
- .brw = BRW_NEW_CURBE_OFFSETS,
- .cache = (CACHE_NEW_VS_PROG |
- CACHE_NEW_SF_PROG)
- },
- .update = recalculate_urb_fence
-};
-
-
-
-
-
-void brw_upload_urb_fence(struct brw_context *brw)
-{
- struct brw_urb_fence uf;
- memset(&uf, 0, sizeof(uf));
-
- uf.header.opcode = CMD_URB_FENCE;
- uf.header.length = sizeof(uf)/4-2;
- uf.header.vs_realloc = 1;
- uf.header.gs_realloc = 1;
- uf.header.clp_realloc = 1;
- uf.header.sf_realloc = 1;
- uf.header.vfe_realloc = 1;
- uf.header.cs_realloc = 1;
-
- /* The ordering below is correct, not the layout in the
- * instruction.
- *
- * There are 256 urb reg pairs in total.
- */
- uf.bits0.vs_fence = brw->urb.gs_start;
- uf.bits0.gs_fence = brw->urb.clip_start;
- uf.bits0.clp_fence = brw->urb.sf_start;
- uf.bits1.sf_fence = brw->urb.cs_start;
- uf.bits1.cs_fence = 256;
-
- BRW_BATCH_STRUCT(brw, &uf);
-}
diff --git a/src/mesa/pipe/i965simple/brw_util.c b/src/mesa/pipe/i965simple/brw_util.c
deleted file mode 100644
index 42391d7c8c..0000000000
--- a/src/mesa/pipe/i965simple/brw_util.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_util.h"
-#include "brw_defines.h"
-
-#include "pipe/p_defines.h"
-
-unsigned brw_count_bits( unsigned val )
-{
- unsigned i;
- for (i = 0; val ; val >>= 1)
- if (val & 1)
- i++;
- return i;
-}
-
-
-unsigned brw_translate_blend_equation( int mode )
-{
- switch (mode) {
- case PIPE_BLEND_ADD:
- return BRW_BLENDFUNCTION_ADD;
- case PIPE_BLEND_MIN:
- return BRW_BLENDFUNCTION_MIN;
- case PIPE_BLEND_MAX:
- return BRW_BLENDFUNCTION_MAX;
- case PIPE_BLEND_SUBTRACT:
- return BRW_BLENDFUNCTION_SUBTRACT;
- case PIPE_BLEND_REVERSE_SUBTRACT:
- return BRW_BLENDFUNCTION_REVERSE_SUBTRACT;
- default:
- assert(0);
- return BRW_BLENDFUNCTION_ADD;
- }
-}
-
-unsigned brw_translate_blend_factor( int factor )
-{
- switch(factor) {
- case PIPE_BLENDFACTOR_ZERO:
- return BRW_BLENDFACTOR_ZERO;
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- return BRW_BLENDFACTOR_SRC_ALPHA;
- case PIPE_BLENDFACTOR_ONE:
- return BRW_BLENDFACTOR_ONE;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- return BRW_BLENDFACTOR_SRC_COLOR;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- return BRW_BLENDFACTOR_INV_SRC_COLOR;
- case PIPE_BLENDFACTOR_DST_COLOR:
- return BRW_BLENDFACTOR_DST_COLOR;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- return BRW_BLENDFACTOR_INV_DST_COLOR;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- return BRW_BLENDFACTOR_INV_SRC_ALPHA;
- case PIPE_BLENDFACTOR_DST_ALPHA:
- return BRW_BLENDFACTOR_DST_ALPHA;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- return BRW_BLENDFACTOR_INV_DST_ALPHA;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- return BRW_BLENDFACTOR_SRC_ALPHA_SATURATE;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- return BRW_BLENDFACTOR_CONST_COLOR;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- return BRW_BLENDFACTOR_INV_CONST_COLOR;
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- return BRW_BLENDFACTOR_CONST_ALPHA;
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- return BRW_BLENDFACTOR_INV_CONST_ALPHA;
- default:
- assert(0);
- return BRW_BLENDFACTOR_ZERO;
- }
-}
diff --git a/src/mesa/pipe/i965simple/brw_util.h b/src/mesa/pipe/i965simple/brw_util.h
deleted file mode 100644
index d60e5934db..0000000000
--- a/src/mesa/pipe/i965simple/brw_util.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_UTIL_H
-#define BRW_UTIL_H
-
-#include "pipe/p_state.h"
-
-extern unsigned brw_count_bits( unsigned val );
-extern unsigned brw_translate_blend_factor( int factor );
-extern unsigned brw_translate_blend_equation( int mode );
-
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_vs.c b/src/mesa/pipe/i965simple/brw_vs.c
deleted file mode 100644
index 738c6346d5..0000000000
--- a/src/mesa/pipe/i965simple/brw_vs.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_vs.h"
-#include "brw_util.h"
-#include "brw_state.h"
-
-
-static void do_vs_prog( struct brw_context *brw,
- const struct brw_vertex_program *vp,
- struct brw_vs_prog_key *key )
-{
- unsigned program_size;
- const unsigned *program;
- struct brw_vs_compile c;
-
- memset(&c, 0, sizeof(c));
- memcpy(&c.key, key, sizeof(*key));
-
- brw_init_compile(&c.func);
- c.vp = vp;
-
- c.prog_data.outputs_written = vp->program.num_outputs;
- c.prog_data.inputs_read = vp->program.num_inputs;
-
-#if 0
- if (c.key.copy_edgeflag) {
- c.prog_data.outputs_written |= 1<<VERT_RESULT_EDGE;
- c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
- }
-#endif
-
- /* Emit GEN4 code.
- */
- brw_vs_emit(&c);
-
- /* get the program
- */
- program = brw_get_program(&c.func, &program_size);
-
- /*
- */
- brw->vs.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_VS_PROG],
- &c.key,
- sizeof(c.key),
- program,
- program_size,
- &c.prog_data,
- &brw->vs.prog_data);
-}
-
-
-static void brw_upload_vs_prog( struct brw_context *brw )
-{
- struct brw_vs_prog_key key;
- const struct brw_vertex_program *vp = brw->attribs.VertexProgram;
-
- assert(vp);
-
- memset(&key, 0, sizeof(key));
-
- /* Just upload the program verbatim for now. Always send it all
- * the inputs it asks for, whether they are varying or not.
- */
- key.program_string_id = vp->id;
- key.nr_userclip = brw->attribs.Clip.nr;
- key.copy_edgeflag = (brw->attribs.Raster->fill_cw != PIPE_POLYGON_MODE_FILL ||
- brw->attribs.Raster->fill_ccw != PIPE_POLYGON_MODE_FILL);
-
- /* Make an early check for the key.
- */
- if (brw_search_cache(&brw->cache[BRW_VS_PROG],
- &key, sizeof(key),
- &brw->vs.prog_data,
- &brw->vs.prog_gs_offset))
- return;
-
- do_vs_prog(brw, vp, &key);
-}
-
-
-/* See brw_vs.c:
- */
-const struct brw_tracked_state brw_vs_prog = {
- .dirty = {
- .brw = BRW_NEW_VS,
- .cache = 0
- },
- .update = brw_upload_vs_prog
-};
diff --git a/src/mesa/pipe/i965simple/brw_vs.h b/src/mesa/pipe/i965simple/brw_vs.h
deleted file mode 100644
index 0e58f043b0..0000000000
--- a/src/mesa/pipe/i965simple/brw_vs.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_VS_H
-#define BRW_VS_H
-
-
-#include "brw_context.h"
-#include "brw_eu.h"
-
-
-struct brw_vs_prog_key {
- unsigned program_string_id;
- unsigned nr_userclip:4;
- unsigned copy_edgeflag:1;
- unsigned know_w_is_one:1;
- unsigned pad:26;
-};
-
-
-struct brw_vs_compile {
- struct brw_compile func;
- struct brw_vs_prog_key key;
- struct brw_vs_prog_data prog_data;
-
- struct brw_vertex_program *vp;
-
- unsigned nr_inputs;
-
- unsigned first_output;
- unsigned nr_outputs;
-
- unsigned first_tmp;
- unsigned last_tmp;
-
- struct brw_reg r0;
- struct brw_reg r1;
- struct brw_reg regs[12][128];
- struct brw_reg tmp;
- struct brw_reg stack;
-
- struct {
- boolean used_in_src;
- struct brw_reg reg;
- } output_regs[128];
-
- struct brw_reg userplane[6];
-
-};
-
-void brw_vs_emit( struct brw_vs_compile *c );
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_vs_emit.c b/src/mesa/pipe/i965simple/brw_vs_emit.c
deleted file mode 100644
index 98915ba101..0000000000
--- a/src/mesa/pipe/i965simple/brw_vs_emit.c
+++ /dev/null
@@ -1,1332 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_context.h"
-#include "brw_vs.h"
-
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-
-struct brw_prog_info {
- unsigned num_temps;
- unsigned num_addrs;
- unsigned num_consts;
-
- unsigned writes_psize;
-
- unsigned pos_idx;
- unsigned result_edge_idx;
- unsigned edge_flag_idx;
- unsigned psize_idx;
-};
-
-/* Do things as simply as possible. Allocate and populate all regs
- * ahead of time.
- */
-static void brw_vs_alloc_regs( struct brw_vs_compile *c,
- struct brw_prog_info *info )
-{
- unsigned i, reg = 0, mrf;
- unsigned nr_params;
-
- /* r0 -- reserved as usual
- */
- c->r0 = brw_vec8_grf(reg, 0); reg++;
-
- /* User clip planes from curbe:
- */
- if (c->key.nr_userclip) {
- for (i = 0; i < c->key.nr_userclip; i++) {
- c->userplane[i] = stride( brw_vec4_grf(reg+3+i/2, (i%2) * 4), 0, 4, 1);
- }
-
- /* Deal with curbe alignment:
- */
- reg += ((6+c->key.nr_userclip+3)/4)*2;
- }
-
- /* Vertex program parameters from curbe:
- */
- nr_params = c->prog_data.max_const;
- for (i = 0; i < nr_params; i++) {
- c->regs[TGSI_FILE_CONSTANT][i] = stride(brw_vec4_grf(reg+i/2, (i%2) * 4), 0, 4, 1);
- }
- reg += (nr_params+1)/2;
- c->prog_data.curb_read_length = reg - 1;
-
-
-
- /* Allocate input regs:
- */
- c->nr_inputs = c->vp->program.num_inputs;
- for (i = 0; i < c->nr_inputs; i++) {
- c->regs[TGSI_FILE_INPUT][i] = brw_vec8_grf(reg, 0);
- reg++;
- }
-
-
- /* Allocate outputs: TODO: could organize the non-position outputs
- * to go straight into message regs.
- */
- c->nr_outputs = 0;
- c->first_output = reg;
- mrf = 4;
- for (i = 0; i < c->vp->program.num_outputs; i++) {
- c->nr_outputs++;
-#if 0
- if (i == VERT_RESULT_HPOS) {
- c->regs[TGSI_FILE_OUTPUT][i] = brw_vec8_grf(reg, 0);
- reg++;
- }
- else if (i == VERT_RESULT_PSIZ) {
- c->regs[TGSI_FILE_OUTPUT][i] = brw_vec8_grf(reg, 0);
- reg++;
- mrf++; /* just a placeholder? XXX fix later stages & remove this */
- }
- else {
- c->regs[TGSI_FILE_OUTPUT][i] = brw_message_reg(mrf);
- mrf++;
- }
-#else
- /*treat pos differently for now */
- if (i == info->pos_idx) {
- c->regs[TGSI_FILE_OUTPUT][i] = brw_vec8_grf(reg, 0);
- reg++;
- } else {
- c->regs[TGSI_FILE_OUTPUT][i] = brw_message_reg(mrf);
- mrf++;
- }
-#endif
- }
-
- /* Allocate program temporaries:
- */
- for (i = 0; i < info->num_temps; i++) {
- c->regs[TGSI_FILE_TEMPORARY][i] = brw_vec8_grf(reg, 0);
- reg++;
- }
-
- /* Address reg(s). Don't try to use the internal address reg until
- * deref time.
- */
- for (i = 0; i < info->num_addrs; i++) {
- c->regs[TGSI_FILE_ADDRESS][i] = brw_reg(BRW_GENERAL_REGISTER_FILE,
- reg,
- 0,
- BRW_REGISTER_TYPE_D,
- BRW_VERTICAL_STRIDE_8,
- BRW_WIDTH_8,
- BRW_HORIZONTAL_STRIDE_1,
- BRW_SWIZZLE_XXXX,
- TGSI_WRITEMASK_X);
- reg++;
- }
-
- for (i = 0; i < 128; i++) {
- if (c->output_regs[i].used_in_src) {
- c->output_regs[i].reg = brw_vec8_grf(reg, 0);
- reg++;
- }
- }
-
- c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
- reg += 2;
-
-
- /* Some opcodes need an internal temporary:
- */
- c->first_tmp = reg;
- c->last_tmp = reg; /* for allocation purposes */
-
- /* Each input reg holds data from two vertices. The
- * urb_read_length is the number of registers read from *each*
- * vertex urb, so is half the amount:
- */
- c->prog_data.urb_read_length = (c->nr_inputs+1)/2;
-
- c->prog_data.urb_entry_size = (c->nr_outputs+2+3)/4;
- c->prog_data.total_grf = reg;
-}
-
-
-static struct brw_reg get_tmp( struct brw_vs_compile *c )
-{
- struct brw_reg tmp = brw_vec8_grf(c->last_tmp, 0);
-
- if (++c->last_tmp > c->prog_data.total_grf)
- c->prog_data.total_grf = c->last_tmp;
-
- return tmp;
-}
-
-static void release_tmp( struct brw_vs_compile *c, struct brw_reg tmp )
-{
- if (tmp.nr == c->last_tmp-1)
- c->last_tmp--;
-}
-
-static void release_tmps( struct brw_vs_compile *c )
-{
- c->last_tmp = c->first_tmp;
-}
-
-
-static void unalias1( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0,
- void (*func)( struct brw_vs_compile *,
- struct brw_reg,
- struct brw_reg ))
-{
- if (dst.file == arg0.file && dst.nr == arg0.nr) {
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
- func(c, tmp, arg0);
- brw_MOV(p, dst, tmp);
- }
- else {
- func(c, dst, arg0);
- }
-}
-
-static void unalias2( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1,
- void (*func)( struct brw_vs_compile *,
- struct brw_reg,
- struct brw_reg,
- struct brw_reg ))
-{
- if ((dst.file == arg0.file && dst.nr == arg0.nr) ||
- (dst.file == arg1.file && dst.nr == arg1.nr)) {
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = brw_writemask(get_tmp(c), dst.dw1.bits.writemask);
- func(c, tmp, arg0, arg1);
- brw_MOV(p, dst, tmp);
- }
- else {
- func(c, dst, arg0, arg1);
- }
-}
-
-static void emit_sop( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1,
- unsigned cond)
-{
- brw_push_insn_state(p);
- brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_MOV(p, dst, brw_imm_f(1.0f));
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- brw_MOV(p, dst, brw_imm_f(0.0f));
- brw_pop_insn_state(p);
-}
-
-static void emit_seq( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
-}
-
-static void emit_sne( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
-}
-static void emit_slt( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_L);
-}
-
-static void emit_sle( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_LE);
-}
-
-static void emit_sgt( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_G);
-}
-
-static void emit_sge( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_GE);
-}
-
-static void emit_max( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, arg1);
- brw_SEL(p, dst, arg1, arg0);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-}
-
-static void emit_min( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1 )
-{
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0, arg1);
- brw_SEL(p, dst, arg0, arg1);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-}
-
-
-static void emit_math1( struct brw_vs_compile *c,
- unsigned function,
- struct brw_reg dst,
- struct brw_reg arg0,
- unsigned precision)
-{
- /* There are various odd behaviours with SEND on the simulator. In
- * addition there are documented issues with the fact that the GEN4
- * processor doesn't do dependency control properly on SEND
- * results. So, on balance, this kludge to get around failures
- * with writemasked math results looks like it might be necessary
- * whether that turns out to be a simulator bug or not:
- */
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = dst;
- boolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
- dst.file != BRW_GENERAL_REGISTER_FILE);
-
- if (need_tmp)
- tmp = get_tmp(c);
-
- brw_math(p,
- tmp,
- function,
- BRW_MATH_SATURATE_NONE,
- 2,
- arg0,
- BRW_MATH_DATA_SCALAR,
- precision);
-
- if (need_tmp) {
- brw_MOV(p, dst, tmp);
- release_tmp(c, tmp);
- }
-}
-
-static void emit_math2( struct brw_vs_compile *c,
- unsigned function,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1,
- unsigned precision)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = dst;
- boolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
- dst.file != BRW_GENERAL_REGISTER_FILE);
-
- if (need_tmp)
- tmp = get_tmp(c);
-
- brw_MOV(p, brw_message_reg(3), arg1);
-
- brw_math(p,
- tmp,
- function,
- BRW_MATH_SATURATE_NONE,
- 2,
- arg0,
- BRW_MATH_DATA_SCALAR,
- precision);
-
- if (need_tmp) {
- brw_MOV(p, dst, tmp);
- release_tmp(c, tmp);
- }
-}
-
-
-
-static void emit_exp_noalias( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0 )
-{
- struct brw_compile *p = &c->func;
-
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_X) {
- struct brw_reg tmp = get_tmp(c);
- struct brw_reg tmp_d = retype(tmp, BRW_REGISTER_TYPE_D);
-
- /* tmp_d = floor(arg0.x) */
- brw_RNDD(p, tmp_d, brw_swizzle1(arg0, 0));
-
- /* result[0] = 2.0 ^ tmp */
-
- /* Adjust exponent for floating point:
- * exp += 127
- */
- brw_ADD(p, brw_writemask(tmp_d, TGSI_WRITEMASK_X), tmp_d, brw_imm_d(127));
-
- /* Install exponent and sign.
- * Excess drops off the edge:
- */
- brw_SHL(p, brw_writemask(retype(dst, BRW_REGISTER_TYPE_D), TGSI_WRITEMASK_X),
- tmp_d, brw_imm_d(23));
-
- release_tmp(c, tmp);
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_Y) {
- /* result[1] = arg0.x - floor(arg0.x) */
- brw_FRC(p, brw_writemask(dst, TGSI_WRITEMASK_Y), brw_swizzle1(arg0, 0));
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_Z) {
- /* As with the LOG instruction, we might be better off just
- * doing a taylor expansion here, seeing as we have to do all
- * the prep work.
- *
- * If mathbox partial precision is too low, consider also:
- * result[3] = result[0] * EXP(result[1])
- */
- emit_math1(c,
- BRW_MATH_FUNCTION_EXP,
- brw_writemask(dst, TGSI_WRITEMASK_Z),
- brw_swizzle1(arg0, 0),
- BRW_MATH_PRECISION_PARTIAL);
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_W) {
- /* result[3] = 1.0; */
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_W), brw_imm_f(1));
- }
-}
-
-
-static void emit_log_noalias( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0 )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = dst;
- struct brw_reg tmp_ud = retype(tmp, BRW_REGISTER_TYPE_UD);
- struct brw_reg arg0_ud = retype(arg0, BRW_REGISTER_TYPE_UD);
- boolean need_tmp = (dst.dw1.bits.writemask != 0xf ||
- dst.file != BRW_GENERAL_REGISTER_FILE);
-
- if (need_tmp) {
- tmp = get_tmp(c);
- tmp_ud = retype(tmp, BRW_REGISTER_TYPE_UD);
- }
-
- /* Perform mant = frexpf(fabsf(x), &exp), adjust exp and mnt
- * according to spec:
- *
- * These almost look likey they could be joined up, but not really
- * practical:
- *
- * result[0].f = (x.i & ((1<<31)-1) >> 23) - 127
- * result[1].i = (x.i & ((1<<23)-1) + (127<<23)
- */
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_XZ) {
- brw_AND(p,
- brw_writemask(tmp_ud, TGSI_WRITEMASK_X),
- brw_swizzle1(arg0_ud, 0),
- brw_imm_ud((1U<<31)-1));
-
- brw_SHR(p,
- brw_writemask(tmp_ud, TGSI_WRITEMASK_X),
- tmp_ud,
- brw_imm_ud(23));
-
- brw_ADD(p,
- brw_writemask(tmp, TGSI_WRITEMASK_X),
- retype(tmp_ud, BRW_REGISTER_TYPE_D), /* does it matter? */
- brw_imm_d(-127));
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_YZ) {
- brw_AND(p,
- brw_writemask(tmp_ud, TGSI_WRITEMASK_Y),
- brw_swizzle1(arg0_ud, 0),
- brw_imm_ud((1<<23)-1));
-
- brw_OR(p,
- brw_writemask(tmp_ud, TGSI_WRITEMASK_Y),
- tmp_ud,
- brw_imm_ud(127<<23));
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_Z) {
- /* result[2] = result[0] + LOG2(result[1]); */
-
- /* Why bother? The above is just a hint how to do this with a
- * taylor series. Maybe we *should* use a taylor series as by
- * the time all the above has been done it's almost certainly
- * quicker than calling the mathbox, even with low precision.
- *
- * Options are:
- * - result[0] + mathbox.LOG2(result[1])
- * - mathbox.LOG2(arg0.x)
- * - result[0] + inline_taylor_approx(result[1])
- */
- emit_math1(c,
- BRW_MATH_FUNCTION_LOG,
- brw_writemask(tmp, TGSI_WRITEMASK_Z),
- brw_swizzle1(tmp, 1),
- BRW_MATH_PRECISION_FULL);
-
- brw_ADD(p,
- brw_writemask(tmp, TGSI_WRITEMASK_Z),
- brw_swizzle1(tmp, 2),
- brw_swizzle1(tmp, 0));
- }
-
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_W) {
- /* result[3] = 1.0; */
- brw_MOV(p, brw_writemask(tmp, TGSI_WRITEMASK_W), brw_imm_f(1));
- }
-
- if (need_tmp) {
- brw_MOV(p, dst, tmp);
- release_tmp(c, tmp);
- }
-}
-
-
-
-
-/* Need to unalias - consider swizzles: r0 = DST r0.xxxx r1
- */
-static void emit_dst_noalias( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0,
- struct brw_reg arg1)
-{
- struct brw_compile *p = &c->func;
-
- /* There must be a better way to do this:
- */
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_X)
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_X), brw_imm_f(1.0));
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_Y)
- brw_MUL(p, brw_writemask(dst, TGSI_WRITEMASK_Y), arg0, arg1);
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_Z)
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_Z), arg0);
- if (dst.dw1.bits.writemask & TGSI_WRITEMASK_W)
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_W), arg1);
-}
-
-static void emit_xpd( struct brw_compile *p,
- struct brw_reg dst,
- struct brw_reg t,
- struct brw_reg u)
-{
- brw_MUL(p, brw_null_reg(), brw_swizzle(t, 1,2,0,3), brw_swizzle(u,2,0,1,3));
- brw_MAC(p, dst, negate(brw_swizzle(t, 2,0,1,3)), brw_swizzle(u,1,2,0,3));
-}
-
-
-
-static void emit_lit_noalias( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0 )
-{
- struct brw_compile *p = &c->func;
- struct brw_instruction *if_insn;
- struct brw_reg tmp = dst;
- boolean need_tmp = (dst.file != BRW_GENERAL_REGISTER_FILE);
-
- if (need_tmp)
- tmp = get_tmp(c);
-
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_YZ), brw_imm_f(0));
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_XW), brw_imm_f(1));
-
- /* Need to use BRW_EXECUTE_8 and also do an 8-wide compare in order
- * to get all channels active inside the IF. In the clipping code
- * we run with NoMask, so it's not an option and we can use
- * BRW_EXECUTE_1 for all comparisions.
- */
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, brw_swizzle1(arg0,0), brw_imm_f(0));
- if_insn = brw_IF(p, BRW_EXECUTE_8);
- {
- brw_MOV(p, brw_writemask(dst, TGSI_WRITEMASK_Y), brw_swizzle1(arg0,0));
-
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_G, brw_swizzle1(arg0,1), brw_imm_f(0));
- brw_MOV(p, brw_writemask(tmp, TGSI_WRITEMASK_Z), brw_swizzle1(arg0,1));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-
- emit_math2(c,
- BRW_MATH_FUNCTION_POW,
- brw_writemask(dst, TGSI_WRITEMASK_Z),
- brw_swizzle1(tmp, 2),
- brw_swizzle1(arg0, 3),
- BRW_MATH_PRECISION_PARTIAL);
- }
-
- brw_ENDIF(p, if_insn);
-}
-
-
-
-
-
-/* TODO: relative addressing!
- */
-static struct brw_reg get_reg( struct brw_vs_compile *c,
- unsigned file,
- unsigned index )
-{
- switch (file) {
- case TGSI_FILE_TEMPORARY:
- case TGSI_FILE_INPUT:
- case TGSI_FILE_OUTPUT:
- assert(c->regs[file][index].nr != 0);
- return c->regs[file][index];
- case TGSI_FILE_CONSTANT:
- assert(c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_imm].nr != 0);
- return c->regs[TGSI_FILE_CONSTANT][index + c->prog_data.num_imm];
- case TGSI_FILE_IMMEDIATE:
- assert(c->regs[TGSI_FILE_CONSTANT][index].nr != 0);
- return c->regs[TGSI_FILE_CONSTANT][index];
- case TGSI_FILE_ADDRESS:
- assert(index == 0);
- return c->regs[file][index];
-
- case TGSI_FILE_NULL: /* undef values */
- return brw_null_reg();
-
- default:
- assert(0);
- return brw_null_reg();
- }
-}
-
-
-
-static struct brw_reg deref( struct brw_vs_compile *c,
- struct brw_reg arg,
- int offset)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = vec4(get_tmp(c));
- struct brw_reg vp_address = retype(vec1(get_reg(c, TGSI_FILE_ADDRESS, 0)), BRW_REGISTER_TYPE_UW);
- unsigned byte_offset = arg.nr * 32 + arg.subnr + offset * 16;
- struct brw_reg indirect = brw_vec4_indirect(0,0);
-
- {
- brw_push_insn_state(p);
- brw_set_access_mode(p, BRW_ALIGN_1);
-
- /* This is pretty clunky - load the address register twice and
- * fetch each 4-dword value in turn. There must be a way to do
- * this in a single pass, but I couldn't get it to work.
- */
- brw_ADD(p, brw_address_reg(0), vp_address, brw_imm_d(byte_offset));
- brw_MOV(p, tmp, indirect);
-
- brw_ADD(p, brw_address_reg(0), suboffset(vp_address, 8), brw_imm_d(byte_offset));
- brw_MOV(p, suboffset(tmp, 4), indirect);
-
- brw_pop_insn_state(p);
- }
-
- return vec8(tmp);
-}
-
-
-static void emit_arl( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct brw_reg arg0 )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg tmp = dst;
- boolean need_tmp = (dst.file != BRW_GENERAL_REGISTER_FILE);
-
- if (need_tmp)
- tmp = get_tmp(c);
-
- brw_RNDD(p, tmp, arg0);
- brw_MUL(p, dst, tmp, brw_imm_d(16));
-
- if (need_tmp)
- release_tmp(c, tmp);
-}
-
-
-/* Will return mangled results for SWZ op. The emit_swz() function
- * ignores this result and recalculates taking extended swizzles into
- * account.
- */
-static struct brw_reg get_arg( struct brw_vs_compile *c,
- struct tgsi_src_register *src )
-{
- struct brw_reg reg;
-
- if (src->File == TGSI_FILE_NULL)
- return brw_null_reg();
-
-#if 0
- if (src->RelAddr)
- reg = deref(c, c->regs[PROGRAM_STATE_VAR][0], src->Index);
- else
-#endif
- reg = get_reg(c, src->File, src->Index);
-
- /* Convert 3-bit swizzle to 2-bit.
- */
- reg.dw1.bits.swizzle = BRW_SWIZZLE4(src->SwizzleX,
- src->SwizzleY,
- src->SwizzleZ,
- src->SwizzleW);
-
- /* Note this is ok for non-swizzle instructions:
- */
- reg.negate = src->Negate ? 1 : 0;
-
- return reg;
-}
-
-
-static struct brw_reg get_dst( struct brw_vs_compile *c,
- const struct tgsi_dst_register *dst )
-{
- struct brw_reg reg = get_reg(c, dst->File, dst->Index);
-
- reg.dw1.bits.writemask = dst->WriteMask;
-
- return reg;
-}
-
-
-
-
-static void emit_swz( struct brw_vs_compile *c,
- struct brw_reg dst,
- struct tgsi_src_register src )
-{
- struct brw_compile *p = &c->func;
- unsigned zeros_mask = 0;
- unsigned ones_mask = 0;
- unsigned src_mask = 0;
- ubyte src_swz[4];
- boolean need_tmp = (src.Negate &&
- dst.file != BRW_GENERAL_REGISTER_FILE);
- struct brw_reg tmp = dst;
- unsigned i;
-
- if (need_tmp)
- tmp = get_tmp(c);
-
- for (i = 0; i < 4; i++) {
- if (dst.dw1.bits.writemask & (1<<i)) {
- ubyte s = 0;
- switch(i) {
- case 0:
- s = src.SwizzleX;
- break;
- s = src.SwizzleY;
- case 1:
- break;
- s = src.SwizzleZ;
- case 2:
- break;
- s = src.SwizzleW;
- case 3:
- break;
- }
- switch (s) {
- case TGSI_SWIZZLE_X:
- case TGSI_SWIZZLE_Y:
- case TGSI_SWIZZLE_Z:
- case TGSI_SWIZZLE_W:
- src_mask |= 1<<i;
- src_swz[i] = s;
- break;
- case TGSI_EXTSWIZZLE_ZERO:
- zeros_mask |= 1<<i;
- break;
- case TGSI_EXTSWIZZLE_ONE:
- ones_mask |= 1<<i;
- break;
- }
- }
- }
-
- /* Do src first, in case dst aliases src:
- */
- if (src_mask) {
- struct brw_reg arg0;
-
-#if 0
- if (src.RelAddr)
- arg0 = deref(c, c->regs[PROGRAM_STATE_VAR][0], src.Index);
- else
-#endif
- arg0 = get_reg(c, src.File, src.Index);
-
- arg0 = brw_swizzle(arg0,
- src_swz[0], src_swz[1],
- src_swz[2], src_swz[3]);
-
- brw_MOV(p, brw_writemask(tmp, src_mask), arg0);
- }
-
- if (zeros_mask)
- brw_MOV(p, brw_writemask(tmp, zeros_mask), brw_imm_f(0));
-
- if (ones_mask)
- brw_MOV(p, brw_writemask(tmp, ones_mask), brw_imm_f(1));
-
- if (src.Negate)
- brw_MOV(p, brw_writemask(tmp, src.Negate), negate(tmp));
-
- if (need_tmp) {
- brw_MOV(p, dst, tmp);
- release_tmp(c, tmp);
- }
-}
-
-
-
-/* Post-vertex-program processing. Send the results to the URB.
- */
-static void emit_vertex_write( struct brw_vs_compile *c, struct brw_prog_info *info)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg m0 = brw_message_reg(0);
- struct brw_reg pos = c->regs[TGSI_FILE_OUTPUT][info->pos_idx];
- struct brw_reg ndc;
-
- if (c->key.copy_edgeflag) {
- brw_MOV(p,
- get_reg(c, TGSI_FILE_OUTPUT, info->result_edge_idx),
- get_reg(c, TGSI_FILE_INPUT, info->edge_flag_idx));
- }
-
-
- /* Build ndc coords? TODO: Shortcircuit when w is known to be one.
- */
- if (!c->key.know_w_is_one) {
- ndc = get_tmp(c);
- emit_math1(c, BRW_MATH_FUNCTION_INV, ndc, brw_swizzle1(pos, 3), BRW_MATH_PRECISION_FULL);
- brw_MUL(p, brw_writemask(ndc, TGSI_WRITEMASK_XYZ), pos, ndc);
- }
- else {
- ndc = pos;
- }
-
- /* This includes the workaround for -ve rhw, so is no longer an
- * optional step:
- */
- if (info->writes_psize ||
- c->key.nr_userclip ||
- !c->key.know_w_is_one)
- {
- struct brw_reg header1 = retype(get_tmp(c), BRW_REGISTER_TYPE_UD);
- unsigned i;
-
- brw_MOV(p, header1, brw_imm_ud(0));
-
- brw_set_access_mode(p, BRW_ALIGN_16);
-
- if (info->writes_psize) {
- struct brw_reg psiz = c->regs[TGSI_FILE_OUTPUT][info->psize_idx];
- brw_MUL(p, brw_writemask(header1, TGSI_WRITEMASK_W),
- brw_swizzle1(psiz, 0), brw_imm_f(1<<11));
- brw_AND(p, brw_writemask(header1, TGSI_WRITEMASK_W), header1,
- brw_imm_ud(0x7ff<<8));
- }
-
-
- for (i = 0; i < c->key.nr_userclip; i++) {
- brw_set_conditionalmod(p, BRW_CONDITIONAL_L);
- brw_DP4(p, brw_null_reg(), pos, c->userplane[i]);
- brw_OR(p, brw_writemask(header1, TGSI_WRITEMASK_W), header1, brw_imm_ud(1<<i));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- }
-
-
- /* i965 clipping workaround:
- * 1) Test for -ve rhw
- * 2) If set,
- * set ndc = (0,0,0,0)
- * set ucp[6] = 1
- *
- * Later, clipping will detect ucp[6] and ensure the primitive is
- * clipped against all fixed planes.
- */
- if (!c->key.know_w_is_one) {
- brw_CMP(p,
- vec8(brw_null_reg()),
- BRW_CONDITIONAL_L,
- brw_swizzle1(ndc, 3),
- brw_imm_f(0));
-
- brw_OR(p, brw_writemask(header1, TGSI_WRITEMASK_W), header1, brw_imm_ud(1<<6));
- brw_MOV(p, ndc, brw_imm_f(0));
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- }
-
- brw_set_access_mode(p, BRW_ALIGN_1); /* why? */
- brw_MOV(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD), header1);
- brw_set_access_mode(p, BRW_ALIGN_16);
-
- release_tmp(c, header1);
- }
- else {
- brw_MOV(p, retype(brw_message_reg(1), BRW_REGISTER_TYPE_UD), brw_imm_ud(0));
- }
-
-
- /* Emit the (interleaved) headers for the two vertices - an 8-reg
- * of zeros followed by two sets of NDC coordinates:
- */
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_MOV(p, offset(m0, 2), ndc);
- brw_MOV(p, offset(m0, 3), pos);
-
-
- brw_urb_WRITE(p,
- brw_null_reg(), /* dest */
- 0, /* starting mrf reg nr */
- c->r0, /* src */
- 0, /* allocate */
- 1, /* used */
- c->nr_outputs + 3, /* msg len */
- 0, /* response len */
- 1, /* eot */
- 1, /* writes complete */
- 0, /* urb destination offset */
- BRW_URB_SWIZZLE_INTERLEAVE);
-
-}
-
-static void
-post_vs_emit( struct brw_vs_compile *c, struct brw_instruction *end_inst )
-{
- struct tgsi_parse_context parse;
- const struct tgsi_token *tokens = c->vp->program.tokens;
- tgsi_parse_init(&parse, tokens);
- while (!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
- if (parse.FullToken.Token.Type == TGSI_TOKEN_TYPE_INSTRUCTION) {
-#if 0
- struct brw_instruction *brw_inst1, *brw_inst2;
- const struct tgsi_full_instruction *inst1, *inst2;
- int offset;
- inst1 = &parse.FullToken.FullInstruction;
- brw_inst1 = inst1->Data;
- switch (inst1->Opcode) {
- case TGSI_OPCODE_CAL:
- case TGSI_OPCODE_BRA:
- target_insn = inst1->BranchTarget;
- inst2 = &c->vp->program.Base.Instructions[target_insn];
- brw_inst2 = inst2->Data;
- offset = brw_inst2 - brw_inst1;
- brw_set_src1(brw_inst1, brw_imm_d(offset*16));
- break;
- case TGSI_OPCODE_END:
- offset = end_inst - brw_inst1;
- brw_set_src1(brw_inst1, brw_imm_d(offset*16));
- break;
- default:
- break;
- }
-#endif
- }
- }
- tgsi_parse_free(&parse);
-}
-
-static void process_declaration(const struct tgsi_full_declaration *decl,
- struct brw_prog_info *info)
-{
- int first = decl->u.DeclarationRange.First;
- int last = decl->u.DeclarationRange.Last;
-
- assert (decl->Declaration.Declare != TGSI_DECLARE_MASK);
-
- switch(decl->Declaration.File) {
- case TGSI_FILE_CONSTANT:
- info->num_consts += last - first + 1;
- break;
- case TGSI_FILE_INPUT: {
- }
- break;
- case TGSI_FILE_OUTPUT: {
- assert(last == first); /* for now */
- if (decl->Declaration.Semantic) {
- switch (decl->Semantic.SemanticName) {
- case TGSI_SEMANTIC_POSITION: {
- info->pos_idx = first;
- }
- break;
- case TGSI_SEMANTIC_COLOR:
- break;
- case TGSI_SEMANTIC_BCOLOR:
- break;
- case TGSI_SEMANTIC_FOG:
- break;
- case TGSI_SEMANTIC_PSIZE: {
- info->writes_psize = TRUE;
- info->psize_idx = first;
- }
- break;
- case TGSI_SEMANTIC_GENERIC:
- break;
- }
- }
- }
- break;
- case TGSI_FILE_TEMPORARY: {
- info->num_temps += (last - first) + 1;
- }
- break;
- case TGSI_FILE_SAMPLER: {
- }
- break;
- case TGSI_FILE_ADDRESS: {
- info->num_addrs += (last - first) + 1;
- }
- break;
- case TGSI_FILE_IMMEDIATE: {
- }
- break;
- case TGSI_FILE_NULL: {
- }
- break;
- }
-}
-
-static void process_instruction(struct brw_vs_compile *c,
- struct tgsi_full_instruction *inst,
- struct brw_prog_info *info)
-{
- struct brw_reg args[3], dst;
- struct brw_compile *p = &c->func;
- struct brw_indirect stack_index = brw_indirect(0, 0);
- unsigned i;
- unsigned index;
- unsigned file;
- /*FIXME: might not be the only one*/
- const struct tgsi_dst_register *dst_reg = &inst->FullDstRegisters[0].DstRegister;
- /*
- struct brw_instruction *if_inst[MAX_IFSN];
- unsigned insn, if_insn = 0;
- */
-
- for (i = 0; i < 3; i++) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
- index = src->SrcRegister.Index;
- file = src->SrcRegister.File;
- if (file == TGSI_FILE_OUTPUT && c->output_regs[index].used_in_src)
- args[i] = c->output_regs[index].reg;
- else
- args[i] = get_arg(c, &src->SrcRegister);
- }
-
- /* Get dest regs. Note that it is possible for a reg to be both
- * dst and arg, given the static allocation of registers. So
- * care needs to be taken emitting multi-operation instructions.
- */
- index = dst_reg->Index;
- file = dst_reg->File;
- if (file == TGSI_FILE_OUTPUT && c->output_regs[index].used_in_src)
- dst = c->output_regs[index].reg;
- else
- dst = get_dst(c, dst_reg);
-
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ABS:
- brw_MOV(p, dst, brw_abs(args[0]));
- break;
- case TGSI_OPCODE_ADD:
- brw_ADD(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_DP3:
- brw_DP3(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_DP4:
- brw_DP4(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_DPH:
- brw_DPH(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_DST:
- unalias2(c, dst, args[0], args[1], emit_dst_noalias);
- break;
- case TGSI_OPCODE_EXP:
- unalias1(c, dst, args[0], emit_exp_noalias);
- break;
- case TGSI_OPCODE_EX2:
- emit_math1(c, BRW_MATH_FUNCTION_EXP, dst, args[0], BRW_MATH_PRECISION_FULL);
- break;
- case TGSI_OPCODE_ARL:
- emit_arl(c, dst, args[0]);
- break;
- case TGSI_OPCODE_FLR:
- brw_RNDD(p, dst, args[0]);
- break;
- case TGSI_OPCODE_FRC:
- brw_FRC(p, dst, args[0]);
- break;
- case TGSI_OPCODE_LOG:
- unalias1(c, dst, args[0], emit_log_noalias);
- break;
- case TGSI_OPCODE_LG2:
- emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, args[0], BRW_MATH_PRECISION_FULL);
- break;
- case TGSI_OPCODE_LIT:
- unalias1(c, dst, args[0], emit_lit_noalias);
- break;
- case TGSI_OPCODE_MAD:
- brw_MOV(p, brw_acc_reg(), args[2]);
- brw_MAC(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_MAX:
- emit_max(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_MIN:
- emit_min(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_MOV:
-#if 0
- case TGSI_OPCODE_SWZ:
- /* The args[0] value can't be used here as it won't have
- * correctly encoded the full swizzle:
- */
- emit_swz(c, dst, inst->SrcReg[0] );
-#endif
- brw_MOV(p, dst, args[0]);
- break;
- case TGSI_OPCODE_MUL:
- brw_MUL(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_POW:
- emit_math2(c, BRW_MATH_FUNCTION_POW, dst, args[0], args[1], BRW_MATH_PRECISION_FULL);
- break;
- case TGSI_OPCODE_RCP:
- emit_math1(c, BRW_MATH_FUNCTION_INV, dst, args[0], BRW_MATH_PRECISION_FULL);
- break;
- case TGSI_OPCODE_RSQ:
- emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, args[0], BRW_MATH_PRECISION_FULL);
- break;
-
- case TGSI_OPCODE_SEQ:
- emit_seq(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SNE:
- emit_sne(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SGE:
- emit_sge(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SGT:
- emit_sgt(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SLT:
- emit_slt(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SLE:
- emit_sle(p, dst, args[0], args[1]);
- break;
- case TGSI_OPCODE_SUB:
- brw_ADD(p, dst, args[0], negate(args[1]));
- break;
- case TGSI_OPCODE_XPD:
- emit_xpd(p, dst, args[0], args[1]);
- break;
-#if 0
- case TGSI_OPCODE_IF:
- assert(if_insn < MAX_IFSN);
- if_inst[if_insn++] = brw_IF(p, BRW_EXECUTE_8);
- break;
- case TGSI_OPCODE_ELSE:
- if_inst[if_insn-1] = brw_ELSE(p, if_inst[if_insn-1]);
- break;
- case TGSI_OPCODE_ENDIF:
- assert(if_insn > 0);
- brw_ENDIF(p, if_inst[--if_insn]);
- break;
- case TGSI_OPCODE_BRA:
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
- brw_set_predicate_control_flag_value(p, 0xff);
- break;
- case TGSI_OPCODE_CAL:
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_ADD(p, deref_1uw(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
- brw_set_access_mode(p, BRW_ALIGN_16);
- brw_ADD(p, get_addr_reg(stack_index),
- get_addr_reg(stack_index), brw_imm_d(4));
- inst->Data = &p->store[p->nr_insn];
- brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
- break;
-#endif
- case TGSI_OPCODE_RET:
-#if 0
- brw_ADD(p, get_addr_reg(stack_index),
- get_addr_reg(stack_index), brw_imm_d(-4));
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_MOV(p, brw_ip_reg(), deref_1uw(stack_index, 0));
- brw_set_access_mode(p, BRW_ALIGN_16);
-#else
- /*brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));*/
-#endif
- break;
- case TGSI_OPCODE_END:
- brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
- break;
- case TGSI_OPCODE_BGNSUB:
- case TGSI_OPCODE_ENDSUB:
- break;
- default:
- debug_printf("Unsupport opcode %d in vertex shader\n", inst->Instruction.Opcode);
- break;
- }
-
- if (dst_reg->File == TGSI_FILE_OUTPUT
- && dst_reg->Index != info->pos_idx
- && c->output_regs[dst_reg->Index].used_in_src)
- brw_MOV(p, get_dst(c, dst_reg), dst);
-
- release_tmps(c);
-}
-
-/* Emit the fragment program instructions here.
- */
-void brw_vs_emit(struct brw_vs_compile *c)
-{
-#define MAX_IFSN 32
- struct brw_compile *p = &c->func;
- struct brw_instruction *end_inst;
- struct tgsi_parse_context parse;
- struct brw_indirect stack_index = brw_indirect(0, 0);
- const struct tgsi_token *tokens = c->vp->program.tokens;
- struct brw_prog_info prog_info;
- unsigned allocated_registers = 0;
- memset(&prog_info, 0, sizeof(struct brw_prog_info));
-
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
- brw_set_access_mode(p, BRW_ALIGN_16);
-
- tgsi_parse_init(&parse, tokens);
- /* Message registers can't be read, so copy the output into GRF register
- if they are used in source registers */
- while (!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
- unsigned i;
- switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_INSTRUCTION: {
- const struct tgsi_full_instruction *inst = &parse.FullToken.FullInstruction;
- for (i = 0; i < 3; ++i) {
- const struct tgsi_src_register *src = &inst->FullSrcRegisters[i].SrcRegister;
- unsigned index = src->Index;
- unsigned file = src->File;
- if (file == TGSI_FILE_OUTPUT)
- c->output_regs[index].used_in_src = TRUE;
- }
- }
- break;
- default:
- /* nothing */
- break;
- }
- }
- tgsi_parse_free(&parse);
-
- tgsi_parse_init(&parse, tokens);
-
- while (!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
-
- switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION: {
- struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
- process_declaration(decl, &prog_info);
- }
- break;
- case TGSI_TOKEN_TYPE_IMMEDIATE: {
- struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
- /*assert(imm->Immediate.Size == 4);*/
- c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
- c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
- c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;
- c->prog_data.imm_buf[c->prog_data.num_imm][3] = imm->u.ImmediateFloat32[3].Float;
- c->prog_data.num_imm++;
- }
- break;
- case TGSI_TOKEN_TYPE_INSTRUCTION: {
- struct tgsi_full_instruction *inst = &parse.FullToken.FullInstruction;
- if (!allocated_registers) {
- /* first instruction (declerations finished).
- * now that we know what vars are being used allocate
- * registers for them.*/
- c->prog_data.num_consts = prog_info.num_consts;
- c->prog_data.max_const = prog_info.num_consts + c->prog_data.num_imm;
- brw_vs_alloc_regs(c, &prog_info);
-
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
- brw_set_access_mode(p, BRW_ALIGN_16);
- allocated_registers = 1;
- }
- process_instruction(c, inst, &prog_info);
- }
- break;
- }
- }
-
- end_inst = &p->store[p->nr_insn];
- emit_vertex_write(c, &prog_info);
- post_vs_emit(c, end_inst);
- tgsi_parse_free(&parse);
-
-}
diff --git a/src/mesa/pipe/i965simple/brw_vs_state.c b/src/mesa/pipe/i965simple/brw_vs_state.c
deleted file mode 100644
index c73469929c..0000000000
--- a/src/mesa/pipe/i965simple/brw_vs_state.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-
-#include "pipe/p_util.h"
-
-static void upload_vs_unit( struct brw_context *brw )
-{
- struct brw_vs_unit_state vs;
-
- memset(&vs, 0, sizeof(vs));
-
- /* CACHE_NEW_VS_PROG */
- vs.thread0.kernel_start_pointer = brw->vs.prog_gs_offset >> 6;
- vs.thread0.grf_reg_count = align(brw->vs.prog_data->total_grf, 16) / 16 - 1;
- vs.thread3.urb_entry_read_length = brw->vs.prog_data->urb_read_length;
- vs.thread3.const_urb_entry_read_length = brw->vs.prog_data->curb_read_length;
- vs.thread3.dispatch_grf_start_reg = 1;
-
-
- /* BRW_NEW_URB_FENCE */
- vs.thread4.nr_urb_entries = brw->urb.nr_vs_entries;
- vs.thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
- vs.thread4.max_threads = MIN2(
- MAX2(0, (brw->urb.nr_vs_entries - 6) / 2 - 1),
- 15);
-
-
-
- if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
- vs.thread4.max_threads = 0;
-
- /* BRW_NEW_CURBE_OFFSETS, _NEW_TRANSFORM */
- if (0 /*brw->attribs.Clip->ClipPlanesEnabled*/) {
- /* Note that we read in the userclip planes as well, hence
- * clip_start:
- */
- vs.thread3.const_urb_entry_read_offset = brw->curbe.clip_start * 2;
- }
- else {
- vs.thread3.const_urb_entry_read_offset = brw->curbe.vs_start * 2;
- }
-
- vs.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
- vs.thread3.urb_entry_read_offset = 0;
-
- /* No samplers for ARB_vp programs:
- */
- vs.vs5.sampler_count = 0;
-
- if (BRW_DEBUG & DEBUG_STATS)
- vs.thread4.stats_enable = 1;
-
- /* Vertex program always enabled:
- */
- vs.vs6.vs_enable = 1;
-
- brw->vs.state_gs_offset = brw_cache_data( &brw->cache[BRW_VS_UNIT], &vs );
-}
-
-
-const struct brw_tracked_state brw_vs_unit = {
- .dirty = {
- .brw = (BRW_NEW_CLIP |
- BRW_NEW_CURBE_OFFSETS |
- BRW_NEW_URB_FENCE),
- .cache = CACHE_NEW_VS_PROG
- },
- .update = upload_vs_unit
-};
diff --git a/src/mesa/pipe/i965simple/brw_winsys.h b/src/mesa/pipe/i965simple/brw_winsys.h
deleted file mode 100644
index 3523a58614..0000000000
--- a/src/mesa/pipe/i965simple/brw_winsys.h
+++ /dev/null
@@ -1,205 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * This is the interface that i965simple requires any window system
- * hosting it to implement. This is the only include file in i965simple
- * which is public.
- *
- */
-
-#ifndef BRW_WINSYS_H
-#define BRW_WINSYS_H
-
-
-#include "pipe/p_defines.h"
-
-
-/* Pipe drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-
-struct pipe_buffer;
-struct pipe_fence_handle;
-struct pipe_winsys;
-
-/* The pipe driver currently understands the following chipsets:
- */
-#define PCI_CHIP_I965_G 0x29A2
-#define PCI_CHIP_I965_Q 0x2992
-#define PCI_CHIP_I965_G_1 0x2982
-#define PCI_CHIP_I965_GM 0x2A02
-#define PCI_CHIP_I965_GME 0x2A12
-
-
-/* These are the names of all the state caches managed by the driver.
- *
- * When data is uploaded to a buffer with buffer_subdata, we use the
- * special version of that function below so that information about
- * what type of data this is can be passed to the winsys backend.
- * That in turn allows the correct flags to be set in the aub file
- * dump to allow human-readable file dumps later on.
- */
-
-enum brw_cache_id {
- BRW_CC_VP,
- BRW_CC_UNIT,
- BRW_WM_PROG,
- BRW_SAMPLER_DEFAULT_COLOR,
- BRW_SAMPLER,
- BRW_WM_UNIT,
- BRW_SF_PROG,
- BRW_SF_VP,
- BRW_SF_UNIT,
- BRW_VS_UNIT,
- BRW_VS_PROG,
- BRW_GS_UNIT,
- BRW_GS_PROG,
- BRW_CLIP_VP,
- BRW_CLIP_UNIT,
- BRW_CLIP_PROG,
- BRW_SS_SURFACE,
- BRW_SS_SURF_BIND,
-
- BRW_MAX_CACHE
-};
-
-#define BRW_CONSTANT_BUFFER BRW_MAX_CACHE
-
-/**
- * Additional winsys interface for i965simple.
- *
- * It is an over-simple batchbuffer mechanism. Will want to improve the
- * performance of this, perhaps based on the cmdstream stuff. It
- * would be pretty impossible to implement swz on top of this
- * interface.
- *
- * Will also need additions/changes to implement static/dynamic
- * indirect state.
- */
-struct brw_winsys {
-
- /**
- * Reserve space on batch buffer.
- *
- * Returns a null pointer if there is insufficient space in the batch buffer
- * to hold the requested number of dwords and relocations.
- *
- * The number of dwords should also include the number of relocations.
- */
- unsigned *(*batch_start)(struct brw_winsys *sws,
- unsigned dwords,
- unsigned relocs);
-
- void (*batch_dword)(struct brw_winsys *sws,
- unsigned dword);
-
- /**
- * Emit a relocation to a buffer.
- *
- * Used not only when the buffer addresses are not pinned, but also to
- * ensure refered buffers will not be destroyed until the current batch
- * buffer execution is finished.
- *
- * The access flags is a combination of I915_BUFFER_ACCESS_WRITE and
- * I915_BUFFER_ACCESS_READ macros.
- */
- void (*batch_reloc)(struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta);
-
-
- /* Not used yet, but really want this:
- */
- void (*batch_end)( struct brw_winsys *sws );
-
- /**
- * Flush the batch buffer.
- *
- * Fence argument must point to NULL or to a previous fence, and the caller
- * must call fence_reference when done with the fence.
- */
- void (*batch_flush)(struct brw_winsys *sws,
- struct pipe_fence_handle **fence);
-
-
- /* A version of buffer_subdata that includes information for the
- * simulator:
- */
- void (*buffer_subdata_typed)(struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned data_type);
-
-
- /* A cheat so we don't have to think about relocations in a couple
- * of places yet:
- */
- unsigned (*get_buffer_offset)( struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned flags );
-
-};
-
-#define BRW_BUFFER_ACCESS_WRITE 0x1
-#define BRW_BUFFER_ACCESS_READ 0x2
-
-#define BRW_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-
-
-struct pipe_context *brw_create(struct pipe_winsys *,
- struct brw_winsys *,
- unsigned pci_id);
-
-static inline boolean brw_batchbuffer_data(struct brw_winsys *winsys,
- const void *data,
- unsigned bytes)
-{
- static const unsigned incr = sizeof(unsigned);
- uint i;
- const unsigned *udata = (const unsigned*)(data);
- unsigned size = bytes/incr;
-
- winsys->batch_start(winsys, size, 0);
- for (i = 0; i < size; ++i) {
- winsys->batch_dword(winsys, udata[i]);
- }
- winsys->batch_end(winsys);
-
- return (i == size);
-}
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_wm.c b/src/mesa/pipe/i965simple/brw_wm.c
deleted file mode 100644
index 539b170744..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_util.h"
-#include "brw_wm.h"
-#include "brw_eu.h"
-#include "brw_state.h"
-#include "pipe/p_util.h"
-
-
-
-static void do_wm_prog( struct brw_context *brw,
- struct brw_fragment_program *fp,
- struct brw_wm_prog_key *key)
-{
- struct brw_wm_compile *c = CALLOC_STRUCT(brw_wm_compile);
- const unsigned *program;
- unsigned program_size;
-
- c->key = *key;
- c->fp = fp;
-
- c->delta_xy[0] = brw_null_reg();
- c->delta_xy[1] = brw_null_reg();
- c->pixel_xy[0] = brw_null_reg();
- c->pixel_xy[1] = brw_null_reg();
- c->pixel_w = brw_null_reg();
-
-
- debug_printf("XXXXXXXX FP\n");
-
- brw_wm_glsl_emit(c);
-
- /* get the program
- */
- program = brw_get_program(&c->func, &program_size);
-
- /*
- */
- brw->wm.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_WM_PROG],
- &c->key,
- sizeof(c->key),
- program,
- program_size,
- &c->prog_data,
- &brw->wm.prog_data );
-
- FREE(c);
-}
-
-
-
-static void brw_wm_populate_key( struct brw_context *brw,
- struct brw_wm_prog_key *key )
-{
- /* BRW_NEW_FRAGMENT_PROGRAM */
- struct brw_fragment_program *fp =
- (struct brw_fragment_program *)brw->attribs.FragmentProgram;
- unsigned lookup = 0;
- unsigned line_aa;
-
- memset(key, 0, sizeof(*key));
-
- /* Build the index for table lookup
- */
- /* BRW_NEW_DEPTH_STENCIL */
- if (fp->UsesKill ||
- brw->attribs.DepthStencil->alpha.enabled)
- lookup |= IZ_PS_KILL_ALPHATEST_BIT;
-
- if (fp->ComputesDepth)
- lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
-
- if (brw->attribs.DepthStencil->depth.enabled)
- lookup |= IZ_DEPTH_TEST_ENABLE_BIT;
-
- if (brw->attribs.DepthStencil->depth.enabled &&
- brw->attribs.DepthStencil->depth.writemask) /* ?? */
- lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
-
- if (brw->attribs.DepthStencil->stencil[0].enabled) {
- lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
-
- if (brw->attribs.DepthStencil->stencil[0].write_mask ||
- brw->attribs.DepthStencil->stencil[1].write_mask)
- lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
- }
-
- /* XXX: when should this be disabled?
- */
- if (1)
- lookup |= IZ_EARLY_DEPTH_TEST_BIT;
-
-
- line_aa = AA_NEVER;
-
- /* _NEW_LINE, _NEW_POLYGON, BRW_NEW_REDUCED_PRIMITIVE */
- if (brw->attribs.Raster->line_smooth) {
- if (brw->reduced_primitive == PIPE_PRIM_LINES) {
- line_aa = AA_ALWAYS;
- }
- else if (brw->reduced_primitive == PIPE_PRIM_TRIANGLES) {
- if (brw->attribs.Raster->fill_ccw == PIPE_POLYGON_MODE_LINE) {
- line_aa = AA_SOMETIMES;
-
- if (brw->attribs.Raster->fill_cw == PIPE_POLYGON_MODE_LINE ||
- (brw->attribs.Raster->cull_mode == PIPE_WINDING_CW))
- line_aa = AA_ALWAYS;
- }
- else if (brw->attribs.Raster->fill_cw == PIPE_POLYGON_MODE_LINE) {
- line_aa = AA_SOMETIMES;
-
- if (brw->attribs.Raster->cull_mode == PIPE_WINDING_CCW)
- line_aa = AA_ALWAYS;
- }
- }
- }
-
- brw_wm_lookup_iz(line_aa,
- lookup,
- key);
-
-
-#if 0
- /* BRW_NEW_SAMPLER
- *
- * Not doing any of this at the moment:
- */
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- const struct pipe_sampler_state *unit = brw->attribs.Samplers[i];
-
- if (unit) {
-
- if (unit->compare &&
- unit->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- key->shadowtex_mask |= 1<<i;
- }
- if (t->Image[0][t->BaseLevel]->InternalFormat == GL_YCBCR_MESA)
- key->yuvtex_mask |= 1<<i;
- }
- }
-#endif
-
-
- /* Extra info:
- */
- key->program_string_id = fp->id;
-
-}
-
-
-static void brw_upload_wm_prog( struct brw_context *brw )
-{
- struct brw_wm_prog_key key;
- struct brw_fragment_program *fp = (struct brw_fragment_program *)
- brw->attribs.FragmentProgram;
-
- brw_wm_populate_key(brw, &key);
-
- /* Make an early check for the key.
- */
- if (brw_search_cache(&brw->cache[BRW_WM_PROG],
- &key, sizeof(key),
- &brw->wm.prog_data,
- &brw->wm.prog_gs_offset))
- return;
-
- do_wm_prog(brw, fp, &key);
-}
-
-
-const struct brw_tracked_state brw_wm_prog = {
- .dirty = {
- .brw = (BRW_NEW_FS |
- BRW_NEW_REDUCED_PRIMITIVE),
- .cache = 0
- },
- .update = brw_upload_wm_prog
-};
-
diff --git a/src/mesa/pipe/i965simple/brw_wm.h b/src/mesa/pipe/i965simple/brw_wm.h
deleted file mode 100644
index a1ac0f504a..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef BRW_WM_H
-#define BRW_WM_H
-
-
-#include "brw_context.h"
-#include "brw_eu.h"
-
-/* A big lookup table is used to figure out which and how many
- * additional regs will inserted before the main payload in the WM
- * program execution. These mainly relate to depth and stencil
- * processing and the early-depth-test optimization.
- */
-#define IZ_PS_KILL_ALPHATEST_BIT 0x1
-#define IZ_PS_COMPUTES_DEPTH_BIT 0x2
-#define IZ_DEPTH_WRITE_ENABLE_BIT 0x4
-#define IZ_DEPTH_TEST_ENABLE_BIT 0x8
-#define IZ_STENCIL_WRITE_ENABLE_BIT 0x10
-#define IZ_STENCIL_TEST_ENABLE_BIT 0x20
-#define IZ_EARLY_DEPTH_TEST_BIT 0x40
-#define IZ_BIT_MAX 0x80
-
-#define AA_NEVER 0
-#define AA_SOMETIMES 1
-#define AA_ALWAYS 2
-
-struct brw_wm_prog_key {
- unsigned source_depth_reg:3;
- unsigned aa_dest_stencil_reg:3;
- unsigned dest_depth_reg:3;
- unsigned nr_depth_regs:3;
- unsigned shadowtex_mask:8;
- unsigned computes_depth:1; /* could be derived from program string */
- unsigned source_depth_to_render_target:1;
- unsigned runtime_check_aads_emit:1;
-
- unsigned yuvtex_mask:8;
-
- unsigned program_string_id;
-};
-
-
-
-
-
-#define PROGRAM_INTERNAL_PARAM
-#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 1024 /* 72 for GL_ARB_f_p */
-#define BRW_WM_MAX_INSN (MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS*3 + PIPE_ATTRIB_MAX + 3)
-#define BRW_WM_MAX_GRF 128 /* hardware limit */
-#define BRW_WM_MAX_VREG (BRW_WM_MAX_INSN * 4)
-#define BRW_WM_MAX_REF (BRW_WM_MAX_INSN * 12)
-#define BRW_WM_MAX_PARAM 256
-#define BRW_WM_MAX_CONST 256
-#define BRW_WM_MAX_KILLS MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS
-
-#define PAYLOAD_DEPTH (PIPE_ATTRIB_MAX)
-
-#define MAX_IFSN 32
-#define MAX_LOOP_DEPTH 32
-
-struct brw_wm_compile {
- struct brw_compile func;
- struct brw_wm_prog_key key;
- struct brw_wm_prog_data prog_data; /* result */
-
- struct brw_fragment_program *fp;
-
- unsigned grf_limit;
- unsigned max_wm_grf;
-
-
- struct brw_reg pixel_xy[2];
- struct brw_reg delta_xy[2];
- struct brw_reg pixel_w;
-
-
- struct brw_reg wm_regs[8][32][4];
-
- struct brw_reg payload_depth[4];
- struct brw_reg payload_coef[16];
-
- struct brw_reg emit_mask_reg;
-
- struct brw_instruction *if_inst[MAX_IFSN];
- int if_insn;
-
- struct brw_instruction *loop_inst[MAX_LOOP_DEPTH];
- int loop_insn;
-
- struct brw_instruction *inst0;
- struct brw_instruction *inst1;
-
- struct brw_reg stack;
- struct brw_indirect stack_index;
-
- unsigned reg_index;
-
- unsigned tmp_start;
- unsigned tmp_index;
-};
-
-
-
-void brw_wm_lookup_iz( unsigned line_aa,
- unsigned lookup,
- struct brw_wm_prog_key *key );
-
-void brw_wm_glsl_emit(struct brw_wm_compile *c);
-void brw_wm_emit_decls(struct brw_wm_compile *c);
-
-#endif
diff --git a/src/mesa/pipe/i965simple/brw_wm_decl.c b/src/mesa/pipe/i965simple/brw_wm_decl.c
deleted file mode 100644
index b45a333a2e..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_decl.c
+++ /dev/null
@@ -1,383 +0,0 @@
-
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_wm.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-
-static struct brw_reg alloc_tmp(struct brw_wm_compile *c)
-{
- c->tmp_index++;
- c->reg_index = MAX2(c->reg_index, c->tmp_start + c->tmp_index);
- return brw_vec8_grf(c->tmp_start + c->tmp_index, 0);
-}
-
-static void release_tmps(struct brw_wm_compile *c)
-{
- c->tmp_index = 0;
-}
-
-
-
-static int is_null( struct brw_reg reg )
-{
- return (reg.file == BRW_ARCHITECTURE_REGISTER_FILE &&
- reg.nr == BRW_ARF_NULL);
-}
-
-static void emit_pixel_xy( struct brw_wm_compile *c )
-{
- if (is_null(c->pixel_xy[0])) {
-
- struct brw_compile *p = &c->func;
- struct brw_reg r1_uw = retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW);
-
- c->pixel_xy[0] = vec8(retype(alloc_tmp(c), BRW_REGISTER_TYPE_UW));
- c->pixel_xy[1] = vec8(retype(alloc_tmp(c), BRW_REGISTER_TYPE_UW));
-
- /* Calculate pixel centers by adding 1 or 0 to each of the
- * micro-tile coordinates passed in r1.
- */
- brw_ADD(p,
- c->pixel_xy[0],
- stride(suboffset(r1_uw, 4), 2, 4, 0),
- brw_imm_v(0x10101010));
-
- brw_ADD(p,
- c->pixel_xy[1],
- stride(suboffset(r1_uw, 5), 2, 4, 0),
- brw_imm_v(0x11001100));
- }
-}
-
-
-
-
-
-
-static void emit_delta_xy( struct brw_wm_compile *c )
-{
- if (is_null(c->delta_xy[0])) {
- struct brw_compile *p = &c->func;
- struct brw_reg r1 = brw_vec1_grf(1, 0);
-
- emit_pixel_xy(c);
-
- c->delta_xy[0] = alloc_tmp(c);
- c->delta_xy[1] = alloc_tmp(c);
-
- /* Calc delta X,Y by subtracting origin in r1 from the pixel
- * centers.
- */
- brw_ADD(p,
- c->delta_xy[0],
- retype(c->pixel_xy[0], BRW_REGISTER_TYPE_UW),
- negate(r1));
-
- brw_ADD(p,
- c->delta_xy[1],
- retype(c->pixel_xy[1], BRW_REGISTER_TYPE_UW),
- negate(suboffset(r1,1)));
- }
-}
-
-
-
-#if 0
-static void emit_pixel_w( struct brw_wm_compile *c )
-{
- if (is_null(c->pixel_w)) {
- struct brw_compile *p = &c->func;
-
- struct brw_reg interp_wpos = c->coef_wpos;
-
- c->pixel_w = alloc_tmp(c);
-
- emit_delta_xy(c);
-
- /* Calc 1/w - just linterp wpos[3] optimized by putting the
- * result straight into a message reg.
- */
- struct brw_reg interp3 = brw_vec1_grf(interp_wpos.nr+1, 4);
- brw_LINE(p, brw_null_reg(), interp3, c->delta_xy[0]);
- brw_MAC(p, brw_message_reg(2), suboffset(interp3, 1), c->delta_xy[1]);
-
- /* Calc w */
- brw_math_16( p,
- c->pixel_w,
- BRW_MATH_FUNCTION_INV,
- BRW_MATH_SATURATE_NONE,
- 2,
- brw_null_reg(),
- BRW_MATH_PRECISION_FULL);
- }
-}
-#endif
-
-
-static void emit_cinterp(struct brw_wm_compile *c,
- int idx,
- int mask )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg interp[4];
- struct brw_reg coef = c->payload_coef[idx];
- int i;
-
- interp[0] = brw_vec1_grf(coef.nr, 0);
- interp[1] = brw_vec1_grf(coef.nr, 4);
- interp[2] = brw_vec1_grf(coef.nr+1, 0);
- interp[3] = brw_vec1_grf(coef.nr+1, 4);
-
- for(i = 0; i < 4; i++ ) {
- if (mask & (1<<i)) {
- struct brw_reg dst = c->wm_regs[TGSI_FILE_INPUT][idx][i];
- brw_MOV(p, dst, suboffset(interp[i],3));
- }
- }
-}
-
-static void emit_linterp(struct brw_wm_compile *c,
- int idx,
- int mask )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg interp[4];
- struct brw_reg coef = c->payload_coef[idx];
- int i;
-
- emit_delta_xy(c);
-
- interp[0] = brw_vec1_grf(coef.nr, 0);
- interp[1] = brw_vec1_grf(coef.nr, 4);
- interp[2] = brw_vec1_grf(coef.nr+1, 0);
- interp[3] = brw_vec1_grf(coef.nr+1, 4);
-
- for(i = 0; i < 4; i++ ) {
- if (mask & (1<<i)) {
- struct brw_reg dst = c->wm_regs[TGSI_FILE_INPUT][idx][i];
- brw_LINE(p, brw_null_reg(), interp[i], c->delta_xy[0]);
- brw_MAC(p, dst, suboffset(interp[i],1), c->delta_xy[1]);
- }
- }
-}
-
-#if 0
-static void emit_pinterp(struct brw_wm_compile *c,
- int idx,
- int mask )
-{
- struct brw_compile *p = &c->func;
- struct brw_reg interp[4];
- struct brw_reg coef = c->payload_coef[idx];
- int i;
-
- get_delta_xy(c);
- get_pixel_w(c);
-
- interp[0] = brw_vec1_grf(coef.nr, 0);
- interp[1] = brw_vec1_grf(coef.nr, 4);
- interp[2] = brw_vec1_grf(coef.nr+1, 0);
- interp[3] = brw_vec1_grf(coef.nr+1, 4);
-
- for(i = 0; i < 4; i++ ) {
- if (mask & (1<<i)) {
- struct brw_reg dst = allocate_reg(c, TGSI_FILE_INPUT, idx, i);
- brw_LINE(p, brw_null_reg(), interp[i], c->delta_xy[0]);
- brw_MAC(p, dst, suboffset(interp[i],1), c->delta_xy[1]);
- brw_MUL(p, dst, dst, c->pixel_w);
- }
- }
-}
-#endif
-
-
-
-#if 0
-static void emit_wpos( )
-{
- struct prog_dst_register dst = dst_reg(PROGRAM_INPUT, idx);
- struct tgsi_full_src_register interp = src_reg(PROGRAM_PAYLOAD, idx);
- struct tgsi_full_src_register deltas = get_delta_xy(c);
- struct tgsi_full_src_register arg2;
- unsigned opcode;
-
- opcode = WM_LINTERP;
- arg2 = src_undef();
-
- /* Have to treat wpos.xy specially:
- */
- emit_op(c,
- WM_WPOSXY,
- dst_mask(dst, WRITEMASK_XY),
- 0, 0, 0,
- get_pixel_xy(c),
- src_undef(),
- src_undef());
-
- dst = dst_mask(dst, WRITEMASK_ZW);
-
- /* PROGRAM_INPUT.attr.xyzw = INTERP payload.interp[attr].x, deltas.xyw
- */
- emit_op(c,
- WM_LINTERP,
- dst,
- 0, 0, 0,
- interp,
- deltas,
- arg2);
-}
-#endif
-
-
-
-
-/* Perform register allocation:
- *
- * -- r0???
- * -- passthrough depth regs (and stencil/aa??)
- * -- curbe ??
- * -- inputs (coefficients)
- *
- * Use a totally static register allocation. This will perform poorly
- * but is an easy way to get started (again).
- */
-static void prealloc_reg(struct brw_wm_compile *c)
-{
- int i, j;
- int nr_curbe_regs = 0;
-
- /* R0, then some depth related regs:
- */
- for (i = 0; i < c->key.nr_depth_regs; i++) {
- c->payload_depth[i] = brw_vec8_grf(i*2, 0);
- c->reg_index += 2;
- }
-
-
- /* Then a copy of our part of the CURBE entry:
- */
- {
- int nr_constants = c->fp->info.nr_regs[TGSI_FILE_CONSTANT];
- int index = 0;
-
- c->prog_data.max_const = 4*nr_constants;
- for (i = 0; i < nr_constants; i++) {
- for (j = 0; j < 4; j++, index++)
- c->wm_regs[TGSI_FILE_CONSTANT][i][j] = brw_vec1_grf(c->reg_index + index/8,
- index%8);
- }
-
- nr_curbe_regs = 2*((4*nr_constants+15)/16);
- c->reg_index += nr_curbe_regs;
- }
-
- /* Adjust for parameter coefficients for position, which are
- * currently always provided.
- */
-// c->position_coef[i] = brw_vec8_grf(c->reg_index, 0);
- c->reg_index += 2;
-
- /* Next we receive the plane coefficients for parameter
- * interpolation:
- */
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++) {
- c->payload_coef[i] = brw_vec8_grf(c->reg_index, 0);
- c->reg_index += 2;
- }
-
- c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
- c->prog_data.urb_read_length = (c->fp->program.num_inputs + 1) * 2;
- c->prog_data.curb_read_length = nr_curbe_regs;
-
- /* That's the end of the payload, now we can start allocating registers.
- */
- c->emit_mask_reg = brw_uw1_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0);
- c->reg_index++;
-
- c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, c->reg_index, 0);
- c->reg_index += 2;
-
- /* Now allocate room for the interpolated inputs and staging
- * registers for the outputs:
- */
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++)
- for (j = 0; j < 4; j++)
- c->wm_regs[TGSI_FILE_INPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );
-
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_OUTPUT]; i++)
- for (j = 0; j < 4; j++)
- c->wm_regs[TGSI_FILE_OUTPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );
-
- /* Beyond this we should only need registers for internal temporaries:
- */
- c->tmp_start = c->reg_index;
-}
-
-
-
-
-
-/* Need to interpolate fragment program inputs in as a preamble to the
- * shader. A more sophisticated compiler would do this on demand, but
- * we'll do it up front:
- */
-void brw_wm_emit_decls(struct brw_wm_compile *c)
-{
- struct tgsi_parse_context parse;
- int done = 0;
-
- prealloc_reg(c);
-
- tgsi_parse_init( &parse, c->fp->program.tokens );
-
- while( !done &&
- !tgsi_parse_end_of_tokens( &parse ) )
- {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- {
- const struct tgsi_full_declaration *decl = &parse.FullToken.FullDeclaration;
- unsigned first = decl->u.DeclarationRange.First;
- unsigned last = decl->u.DeclarationRange.Last;
- unsigned mask = decl->Declaration.UsageMask; /* ? */
- unsigned i;
-
- if (decl->Declaration.File != TGSI_FILE_INPUT)
- break;
-
- assert(decl->Declaration.Interpolate);
-
- for( i = first; i <= last; i++ ) {
- switch (decl->Interpolation.Interpolate) {
- case TGSI_INTERPOLATE_CONSTANT:
- emit_cinterp(c, i, mask);
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- emit_linterp(c, i, mask);
- break;
-
- case TGSI_INTERPOLATE_PERSPECTIVE:
- //emit_pinterp(c, i, mask);
- emit_linterp(c, i, mask);
- break;
- }
- }
- break;
- }
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- default:
- done = 1;
- break;
- }
- }
-
- tgsi_parse_free (&parse);
-
- release_tmps(c);
-}
diff --git a/src/mesa/pipe/i965simple/brw_wm_glsl.c b/src/mesa/pipe/i965simple/brw_wm_glsl.c
deleted file mode 100644
index d95645d108..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_glsl.c
+++ /dev/null
@@ -1,1079 +0,0 @@
-
-#include "brw_context.h"
-#include "brw_eu.h"
-#include "brw_wm.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-
-
-
-static int get_scalar_dst_index(struct tgsi_full_instruction *inst)
-{
- struct tgsi_dst_register dst = inst->FullDstRegisters[0].DstRegister;
- int i;
- for (i = 0; i < 4; i++)
- if (dst.WriteMask & (1<<i))
- break;
- return i;
-}
-
-static struct brw_reg alloc_tmp(struct brw_wm_compile *c)
-{
- c->tmp_index++;
- c->reg_index = MAX2(c->reg_index, c->tmp_index);
- return brw_vec8_grf(c->tmp_start + c->tmp_index, 0);
-}
-
-static void release_tmps(struct brw_wm_compile *c)
-{
- c->tmp_index = 0;
-}
-
-
-static struct brw_reg
-get_reg(struct brw_wm_compile *c, int file, int index, int component )
-{
- switch (file) {
- case TGSI_FILE_NULL:
- return brw_null_reg();
-
- case TGSI_FILE_SAMPLER:
- /* Should never get here:
- */
- assert (0);
- return brw_null_reg();
-
- case TGSI_FILE_IMMEDIATE:
- /* These need a different path:
- */
- assert(0);
- return brw_null_reg();
-
-
- case TGSI_FILE_CONSTANT:
- case TGSI_FILE_INPUT:
- case TGSI_FILE_OUTPUT:
- case TGSI_FILE_TEMPORARY:
- case TGSI_FILE_ADDRESS:
- return c->wm_regs[file][index][component];
-
- default:
- assert(0);
- return brw_null_reg();
- }
-}
-
-
-static struct brw_reg get_dst_reg(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst,
- int component)
-{
- return get_reg(c,
- inst->FullDstRegisters[0].DstRegister.File,
- inst->FullDstRegisters[0].DstRegister.Index,
- component);
-}
-
-static int get_swz( struct tgsi_src_register src, int index )
-{
- switch (index & 3) {
- case 0: return src.SwizzleX;
- case 1: return src.SwizzleY;
- case 2: return src.SwizzleZ;
- case 3: return src.SwizzleW;
- default: return 0;
- }
-}
-
-static int get_ext_swz( struct tgsi_src_register_ext_swz src, int index )
-{
- switch (index & 3) {
- case 0: return src.ExtSwizzleX;
- case 1: return src.ExtSwizzleY;
- case 2: return src.ExtSwizzleZ;
- case 3: return src.ExtSwizzleW;
- default: return 0;
- }
-}
-
-static struct brw_reg get_src_reg(struct brw_wm_compile *c,
- struct tgsi_full_src_register *src,
- int index)
-{
- struct brw_reg reg;
- int component = index;
- int neg = 0;
- int abs = 0;
-
- if (src->SrcRegister.Negate)
- neg = 1;
-
- component = get_swz(src->SrcRegister, component);
-
- /* Yes, there are multiple negates:
- */
- switch (component & 3) {
- case 0: neg ^= src->SrcRegisterExtSwz.NegateX; break;
- case 1: neg ^= src->SrcRegisterExtSwz.NegateY; break;
- case 2: neg ^= src->SrcRegisterExtSwz.NegateZ; break;
- case 3: neg ^= src->SrcRegisterExtSwz.NegateW; break;
- }
-
- /* And multiple swizzles, fun isn't it:
- */
- component = get_ext_swz(src->SrcRegisterExtSwz, component);
-
- /* Can't handle this, don't know if we need to:
- */
- assert(src->SrcRegisterExtSwz.ExtDivide == TGSI_EXTSWIZZLE_ONE);
-
- /* Not handling indirect lookups yet:
- */
- assert(src->SrcRegister.Indirect == 0);
-
- /* Don't know what dimension means:
- */
- assert(src->SrcRegister.Dimension == 0);
-
- /* Will never handle any of this stuff:
- */
- assert(src->SrcRegisterExtMod.Complement == 0);
- assert(src->SrcRegisterExtMod.Bias == 0);
- assert(src->SrcRegisterExtMod.Scale2X == 0);
-
- if (src->SrcRegisterExtMod.Absolute)
- abs = 1;
-
- /* Another negate! This is a post-absolute negate, which we
- * can't do. Need to clean the crap out of tgsi somehow.
- */
- assert(src->SrcRegisterExtMod.Negate == 0);
-
- switch( component ) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- reg = get_reg(c,
- src->SrcRegister.File,
- src->SrcRegister.Index,
- component );
-
- if (neg)
- reg = negate(reg);
-
- if (abs)
- reg = brw_abs(reg);
-
- break;
-
- /* XXX: this won't really work in the general case, but we know
- * that the extended swizzle is only allowed in the SWZ
- * instruction (right??), in which case using an immediate
- * directly will work.
- */
- case TGSI_EXTSWIZZLE_ZERO:
- reg = brw_imm_f(0);
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- if (neg && !abs)
- reg = brw_imm_f(-1.0);
- else
- reg = brw_imm_f(1.0);
- break;
-
- default:
- assert(0);
- break;
- }
-
-
- return reg;
-}
-
-static void emit_abs( struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
-
- int i;
- struct brw_compile *p = &c->func;
- brw_set_saturate(p, inst->Instruction.Saturate != TGSI_SAT_NONE);
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- struct brw_reg src, dst;
- dst = get_dst_reg(c, inst, i);
- src = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- brw_MOV(p, dst, brw_abs(src)); /* NOTE */
- }
- }
- brw_set_saturate(p, 0);
-}
-
-
-static void emit_xpd(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- int i;
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- for (i = 0; i < 4; i++) {
- unsigned i2 = (i+2)%3;
- unsigned i1 = (i+1)%3;
- if (mask & (1<<i)) {
- struct brw_reg src0, src1, dst;
- dst = get_dst_reg(c, inst, i);
- src0 = negate(get_src_reg(c, &inst->FullSrcRegisters[0], i2));
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i1);
- brw_MUL(p, brw_null_reg(), src0, src1);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i1);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i2);
- brw_set_saturate(p, inst->Instruction.Saturate != TGSI_SAT_NONE);
- brw_MAC(p, dst, src0, src1);
- brw_set_saturate(p, 0);
- }
- }
- brw_set_saturate(p, 0);
-}
-
-static void emit_dp3(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_reg src0[3], src1[3], dst;
- int i;
- struct brw_compile *p = &c->func;
- for (i = 0; i < 3; i++) {
- src0[i] = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1[i] = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- }
-
- dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
- brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_MAC(p, dst, src0[2], src1[2]);
- brw_set_saturate(p, 0);
-}
-
-static void emit_dp4(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_reg src0[4], src1[4], dst;
- int i;
- struct brw_compile *p = &c->func;
- for (i = 0; i < 4; i++) {
- src0[i] = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1[i] = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- }
- dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
- brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
- brw_MAC(p, brw_null_reg(), src0[2], src1[2]);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_MAC(p, dst, src0[3], src1[3]);
- brw_set_saturate(p, 0);
-}
-
-static void emit_dph(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_reg src0[4], src1[4], dst;
- int i;
- struct brw_compile *p = &c->func;
- for (i = 0; i < 4; i++) {
- src0[i] = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1[i] = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- }
- dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- brw_MUL(p, brw_null_reg(), src0[0], src1[0]);
- brw_MAC(p, brw_null_reg(), src0[1], src1[1]);
- brw_MAC(p, dst, src0[2], src1[2]);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_ADD(p, dst, src0[3], src1[3]);
- brw_set_saturate(p, 0);
-}
-
-static void emit_math1(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst, unsigned func)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg src0, dst;
-
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], 0);
- dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- brw_MOV(p, brw_message_reg(2), src0);
- brw_math(p,
- dst,
- func,
- ((inst->Instruction.Saturate != TGSI_SAT_NONE)
- ? BRW_MATH_SATURATE_SATURATE
- : BRW_MATH_SATURATE_NONE),
- 2,
- brw_null_reg(),
- BRW_MATH_DATA_VECTOR,
- BRW_MATH_PRECISION_FULL);
-}
-
-
-static void emit_alu2(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst,
- unsigned opcode)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg src0, src1, dst;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- int i;
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- for (i = 0 ; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- brw_alu2(p, opcode, dst, src0, src1);
- }
- }
- brw_set_saturate(p, 0);
-}
-
-
-static void emit_alu1(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst,
- unsigned opcode)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg src0, dst;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- int i;
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- for (i = 0 ; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- brw_alu1(p, opcode, dst, src0);
- }
- }
- if (inst->Instruction.Saturate != TGSI_SAT_NONE)
- brw_set_saturate(p, 0);
-}
-
-
-static void emit_max(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg src0, src1, dst;
- int i;
- brw_push_insn_state(p);
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_MOV(p, dst, src0);
- brw_set_saturate(p, 0);
-
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src0, src1);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- brw_MOV(p, dst, src1);
- brw_set_saturate(p, 0);
- brw_set_predicate_control_flag_value(p, 0xff);
- }
- }
- brw_pop_insn_state(p);
-}
-
-static void emit_min(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg src0, src1, dst;
- int i;
- brw_push_insn_state(p);
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_MOV(p, dst, src0);
- brw_set_saturate(p, 0);
-
- brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, src1, src0);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- brw_MOV(p, dst, src1);
- brw_set_saturate(p, 0);
- brw_set_predicate_control_flag_value(p, 0xff);
- }
- }
- brw_pop_insn_state(p);
-}
-
-static void emit_pow(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg dst, src0, src1;
- dst = get_dst_reg(c, inst, get_scalar_dst_index(inst));
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], 0);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], 0);
-
- brw_MOV(p, brw_message_reg(2), src0);
- brw_MOV(p, brw_message_reg(3), src1);
-
- brw_math(p,
- dst,
- BRW_MATH_FUNCTION_POW,
- (inst->Instruction.Saturate != TGSI_SAT_NONE
- ? BRW_MATH_SATURATE_SATURATE
- : BRW_MATH_SATURATE_NONE),
- 2,
- brw_null_reg(),
- BRW_MATH_DATA_VECTOR,
- BRW_MATH_PRECISION_FULL);
-}
-
-static void emit_lrp(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg dst, tmp1, tmp2, src0, src1, src2;
- int i;
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
-
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
-
- if (src1.nr == dst.nr) {
- tmp1 = alloc_tmp(c);
- brw_MOV(p, tmp1, src1);
- } else
- tmp1 = src1;
-
- src2 = get_src_reg(c, &inst->FullSrcRegisters[2], i);
- if (src2.nr == dst.nr) {
- tmp2 = alloc_tmp(c);
- brw_MOV(p, tmp2, src2);
- } else
- tmp2 = src2;
-
- brw_ADD(p, dst, negate(src0), brw_imm_f(1.0));
- brw_MUL(p, brw_null_reg(), dst, tmp2);
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_MAC(p, dst, src0, tmp1);
- brw_set_saturate(p, 0);
- }
- release_tmps(c);
- }
-}
-
-static void emit_kil(struct brw_wm_compile *c)
-{
- struct brw_compile *p = &c->func;
- struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
- brw_push_insn_state(p);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
- brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK
- brw_AND(p, depth, c->emit_mask_reg, depth);
- brw_pop_insn_state(p);
-}
-
-static void emit_mad(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg dst, src0, src1, src2;
- int i;
-
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- src2 = get_src_reg(c, &inst->FullSrcRegisters[2], i);
- brw_MUL(p, dst, src0, src1);
-
- brw_set_saturate(p, (inst->Instruction.Saturate != TGSI_SAT_NONE) ? 1 : 0);
- brw_ADD(p, dst, dst, src2);
- brw_set_saturate(p, 0);
- }
- }
-}
-
-static void emit_sop(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst, unsigned cond)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg dst, src0, src1;
- int i;
-
- brw_push_insn_state(p);
- for (i = 0; i < 4; i++) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], i);
- src1 = get_src_reg(c, &inst->FullSrcRegisters[1], i);
- brw_CMP(p, brw_null_reg(), cond, src0, src1);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- brw_MOV(p, dst, brw_imm_f(0.0));
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- brw_MOV(p, dst, brw_imm_f(1.0));
- }
- }
- brw_pop_insn_state(p);
-}
-
-
-static void emit_ddx(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg interp[4];
- struct brw_reg dst;
- struct brw_reg src0, w;
- unsigned nr, i;
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], 0);
- w = get_src_reg(c, &inst->FullSrcRegisters[1], 3);
- nr = src0.nr;
- interp[0] = brw_vec1_grf(nr, 0);
- interp[1] = brw_vec1_grf(nr, 4);
- interp[2] = brw_vec1_grf(nr+1, 0);
- interp[3] = brw_vec1_grf(nr+1, 4);
- brw_set_saturate(p, inst->Instruction.Saturate != TGSI_SAT_NONE);
- for(i = 0; i < 4; i++ ) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- brw_MOV(p, dst, interp[i]);
- brw_MUL(p, dst, dst, w);
- }
- }
- brw_set_saturate(p, 0);
-}
-
-static void emit_ddy(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- unsigned mask = inst->FullDstRegisters[0].DstRegister.WriteMask;
- struct brw_reg interp[4];
- struct brw_reg dst;
- struct brw_reg src0, w;
- unsigned nr, i;
-
- src0 = get_src_reg(c, &inst->FullSrcRegisters[0], 0);
- nr = src0.nr;
- w = get_src_reg(c, &inst->FullSrcRegisters[1], 3);
- interp[0] = brw_vec1_grf(nr, 0);
- interp[1] = brw_vec1_grf(nr, 4);
- interp[2] = brw_vec1_grf(nr+1, 0);
- interp[3] = brw_vec1_grf(nr+1, 4);
- brw_set_saturate(p, inst->Instruction.Saturate != TGSI_SAT_NONE);
- for(i = 0; i < 4; i++ ) {
- if (mask & (1<<i)) {
- dst = get_dst_reg(c, inst, i);
- brw_MOV(p, dst, suboffset(interp[i], 1));
- brw_MUL(p, dst, dst, w);
- }
- }
- brw_set_saturate(p, 0);
-}
-
-/* TODO
- BIAS on SIMD8 not workind yet...
-*/
-static void emit_txb(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
-#if 0
- struct brw_compile *p = &c->func;
- struct brw_reg payload_reg = c->payload_depth[0];
- struct brw_reg dst[4], src[4];
- unsigned i;
- for (i = 0; i < 4; i++)
- dst[i] = get_dst_reg(c, inst, i);
- for (i = 0; i < 4; i++)
- src[i] = get_src_reg(c, &inst->FullSrcRegisters[0], i);
-
-#if 0
- switch (inst->TexSrcTarget) {
- case TEXTURE_1D_INDEX:
- brw_MOV(p, brw_message_reg(2), src[0]);
- brw_MOV(p, brw_message_reg(3), brw_imm_f(0));
- brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
- break;
- case TEXTURE_2D_INDEX:
- case TEXTURE_RECT_INDEX:
- brw_MOV(p, brw_message_reg(2), src[0]);
- brw_MOV(p, brw_message_reg(3), src[1]);
- brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
- break;
- default:
- brw_MOV(p, brw_message_reg(2), src[0]);
- brw_MOV(p, brw_message_reg(3), src[1]);
- brw_MOV(p, brw_message_reg(4), src[2]);
- break;
- }
-#else
- brw_MOV(p, brw_message_reg(2), src[0]);
- brw_MOV(p, brw_message_reg(3), src[1]);
- brw_MOV(p, brw_message_reg(4), brw_imm_f(0));
-#endif
-
- brw_MOV(p, brw_message_reg(5), src[3]);
- brw_MOV(p, brw_message_reg(6), brw_imm_f(0));
- brw_SAMPLE(p,
- retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),
- 1,
- retype(payload_reg, BRW_REGISTER_TYPE_UW),
- inst->TexSrcUnit + 1, /* surface */
- inst->TexSrcUnit, /* sampler */
- inst->FullDstRegisters[0].DstRegister.WriteMask,
- BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS,
- 4,
- 4,
- 0);
-#endif
-}
-
-static void emit_tex(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
-#if 0
- struct brw_compile *p = &c->func;
- struct brw_reg payload_reg = c->payload_depth[0];
- struct brw_reg dst[4], src[4];
- unsigned msg_len;
- unsigned i, nr;
- unsigned emit;
- boolean shadow = (c->key.shadowtex_mask & (1<<inst->TexSrcUnit)) ? 1 : 0;
-
- for (i = 0; i < 4; i++)
- dst[i] = get_dst_reg(c, inst, i);
- for (i = 0; i < 4; i++)
- src[i] = get_src_reg(c, &inst->FullSrcRegisters[0], i);
-
-#if 0
- switch (inst->TexSrcTarget) {
- case TEXTURE_1D_INDEX:
- emit = WRITEMASK_X;
- nr = 1;
- break;
- case TEXTURE_2D_INDEX:
- case TEXTURE_RECT_INDEX:
- emit = WRITEMASK_XY;
- nr = 2;
- break;
- default:
- emit = WRITEMASK_XYZ;
- nr = 3;
- break;
- }
-#else
- emit = WRITEMASK_XY;
- nr = 2;
-#endif
-
- msg_len = 1;
-
- for (i = 0; i < nr; i++) {
- static const unsigned swz[4] = {0,1,2,2};
- if (emit & (1<<i))
- brw_MOV(p, brw_message_reg(msg_len+1), src[swz[i]]);
- else
- brw_MOV(p, brw_message_reg(msg_len+1), brw_imm_f(0));
- msg_len += 1;
- }
-
- if (shadow) {
- brw_MOV(p, brw_message_reg(5), brw_imm_f(0));
- brw_MOV(p, brw_message_reg(6), src[2]);
- }
-
- brw_SAMPLE(p,
- retype(vec8(dst[0]), BRW_REGISTER_TYPE_UW),
- 1,
- retype(payload_reg, BRW_REGISTER_TYPE_UW),
- inst->TexSrcUnit + 1, /* surface */
- inst->TexSrcUnit, /* sampler */
- inst->FullDstRegisters[0].DstRegister.WriteMask,
- BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE,
- 4,
- shadow ? 6 : 4,
- 0);
-
- if (shadow)
- brw_MOV(p, dst[3], brw_imm_f(1.0));
-#endif
-}
-
-
-
-
-
-
-
-
-static void emit_fb_write(struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst)
-{
- struct brw_compile *p = &c->func;
- int nr = 2;
- int channel;
- int base_reg = 0;
-
- // src0 = output color
- // src1 = payload_depth[0]
- // src2 = output depth
- // dst = ???
-
-
-
- /* Reserve a space for AA - may not be needed:
- */
- if (c->key.aa_dest_stencil_reg)
- nr += 1;
-
- {
- brw_push_insn_state(p);
- for (channel = 0; channel < 4; channel++) {
- struct brw_reg src0 = c->wm_regs[TGSI_FILE_OUTPUT][0][channel];
-
- /* mov (8) m2.0<1>:ud r28.0<8;8,1>:ud { Align1 } */
- /* mov (8) m6.0<1>:ud r29.0<8;8,1>:ud { Align1 SecHalf } */
- brw_MOV(p, brw_message_reg(nr + channel), src0);
- }
- /* skip over the regs populated above: */
- nr += 8;
- brw_pop_insn_state(p);
- }
-
-
- /* Pass through control information:
- */
- /* mov (8) m1.0<1>:ud r1.0<8;8,1>:ud { Align1 NoMask } */
- {
- brw_push_insn_state(p);
- brw_set_mask_control(p, BRW_MASK_DISABLE); /* ? */
- brw_MOV(p,
- brw_message_reg(base_reg + 1),
- brw_vec8_grf(1, 0));
- brw_pop_insn_state(p);
- }
-
- /* Send framebuffer write message: */
- brw_fb_WRITE(p,
- retype(vec8(brw_null_reg()), BRW_REGISTER_TYPE_UW),
- base_reg,
- retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW),
- 0, /* render surface always 0 */
- nr,
- 0,
- 1);
-
-}
-
-
-static void brw_wm_emit_instruction( struct brw_wm_compile *c,
- struct tgsi_full_instruction *inst )
-{
- struct brw_compile *p = &c->func;
-
-#if 0
- if (inst->CondUpdate)
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NZ);
- else
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
-#else
- brw_set_conditionalmod(p, BRW_CONDITIONAL_NONE);
-#endif
-
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ABS:
- emit_abs(c, inst);
- break;
- case TGSI_OPCODE_ADD:
- emit_alu2(c, inst, BRW_OPCODE_ADD);
- break;
- case TGSI_OPCODE_SUB:
- assert(0);
-// emit_alu2(c, inst, BRW_OPCODE_SUB);
- break;
- case TGSI_OPCODE_FRC:
- emit_alu1(c, inst, BRW_OPCODE_FRC);
- break;
- case TGSI_OPCODE_FLR:
- assert(0);
-// emit_alu1(c, inst, BRW_OPCODE_FLR);
- break;
- case TGSI_OPCODE_LRP:
- emit_lrp(c, inst);
- break;
- case TGSI_OPCODE_INT:
- emit_alu1(c, inst, BRW_OPCODE_RNDD);
- break;
- case TGSI_OPCODE_MOV:
- emit_alu1(c, inst, BRW_OPCODE_MOV);
- break;
- case TGSI_OPCODE_DP3:
- emit_dp3(c, inst);
- break;
- case TGSI_OPCODE_DP4:
- emit_dp4(c, inst);
- break;
- case TGSI_OPCODE_XPD:
- emit_xpd(c, inst);
- break;
- case TGSI_OPCODE_DPH:
- emit_dph(c, inst);
- break;
- case TGSI_OPCODE_RCP:
- emit_math1(c, inst, BRW_MATH_FUNCTION_INV);
- break;
- case TGSI_OPCODE_RSQ:
- emit_math1(c, inst, BRW_MATH_FUNCTION_RSQ);
- break;
- case TGSI_OPCODE_SIN:
- emit_math1(c, inst, BRW_MATH_FUNCTION_SIN);
- break;
- case TGSI_OPCODE_COS:
- emit_math1(c, inst, BRW_MATH_FUNCTION_COS);
- break;
- case TGSI_OPCODE_EX2:
- emit_math1(c, inst, BRW_MATH_FUNCTION_EXP);
- break;
- case TGSI_OPCODE_LG2:
- emit_math1(c, inst, BRW_MATH_FUNCTION_LOG);
- break;
- case TGSI_OPCODE_MAX:
- emit_max(c, inst);
- break;
- case TGSI_OPCODE_MIN:
- emit_min(c, inst);
- break;
- case TGSI_OPCODE_DDX:
- emit_ddx(c, inst);
- break;
- case TGSI_OPCODE_DDY:
- emit_ddy(c, inst);
- break;
- case TGSI_OPCODE_SLT:
- emit_sop(c, inst, BRW_CONDITIONAL_L);
- break;
- case TGSI_OPCODE_SLE:
- emit_sop(c, inst, BRW_CONDITIONAL_LE);
- break;
- case TGSI_OPCODE_SGT:
- emit_sop(c, inst, BRW_CONDITIONAL_G);
- break;
- case TGSI_OPCODE_SGE:
- emit_sop(c, inst, BRW_CONDITIONAL_GE);
- break;
- case TGSI_OPCODE_SEQ:
- emit_sop(c, inst, BRW_CONDITIONAL_EQ);
- break;
- case TGSI_OPCODE_SNE:
- emit_sop(c, inst, BRW_CONDITIONAL_NEQ);
- break;
- case TGSI_OPCODE_MUL:
- emit_alu2(c, inst, BRW_OPCODE_MUL);
- break;
- case TGSI_OPCODE_POW:
- emit_pow(c, inst);
- break;
- case TGSI_OPCODE_MAD:
- emit_mad(c, inst);
- break;
- case TGSI_OPCODE_TEX:
- emit_tex(c, inst);
- break;
- case TGSI_OPCODE_TXB:
- emit_txb(c, inst);
- break;
- case TGSI_OPCODE_TEXKILL:
- emit_kil(c);
- break;
- case TGSI_OPCODE_IF:
- assert(c->if_insn < MAX_IFSN);
- c->if_inst[c->if_insn++] = brw_IF(p, BRW_EXECUTE_8);
- break;
- case TGSI_OPCODE_ELSE:
- c->if_inst[c->if_insn-1] = brw_ELSE(p, c->if_inst[c->if_insn-1]);
- break;
- case TGSI_OPCODE_ENDIF:
- assert(c->if_insn > 0);
- brw_ENDIF(p, c->if_inst[--c->if_insn]);
- break;
- case TGSI_OPCODE_BGNSUB:
- case TGSI_OPCODE_ENDSUB:
- break;
- case TGSI_OPCODE_CAL:
- brw_push_insn_state(p);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_ADD(p, deref_1ud(c->stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
- brw_set_access_mode(p, BRW_ALIGN_16);
- brw_ADD(p,
- get_addr_reg(c->stack_index),
- get_addr_reg(c->stack_index), brw_imm_d(4));
-// orig_inst = inst->Data;
-// orig_inst->Data = &p->store[p->nr_insn];
- assert(0);
- brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
- brw_pop_insn_state(p);
- break;
-
- case TGSI_OPCODE_RET:
-#if 0
- brw_push_insn_state(p);
- brw_set_mask_control(p, BRW_MASK_DISABLE);
- brw_ADD(p,
- get_addr_reg(c->stack_index),
- get_addr_reg(c->stack_index), brw_imm_d(-4));
- brw_set_access_mode(p, BRW_ALIGN_1);
- brw_MOV(p, brw_ip_reg(), deref_1ud(c->stack_index, 0));
- brw_set_access_mode(p, BRW_ALIGN_16);
- brw_pop_insn_state(p);
-#else
- emit_fb_write(c, inst);
-#endif
-
- break;
- case TGSI_OPCODE_LOOP:
- c->loop_inst[c->loop_insn++] = brw_DO(p, BRW_EXECUTE_8);
- break;
- case TGSI_OPCODE_BRK:
- brw_BREAK(p);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- break;
- case TGSI_OPCODE_CONT:
- brw_CONT(p);
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
- break;
- case TGSI_OPCODE_ENDLOOP:
- c->loop_insn--;
- c->inst0 = c->inst1 = brw_WHILE(p, c->loop_inst[c->loop_insn]);
- /* patch all the BREAK instructions from
- last BEGINLOOP */
- while (c->inst0 > c->loop_inst[c->loop_insn]) {
- c->inst0--;
- if (c->inst0->header.opcode == BRW_OPCODE_BREAK) {
- c->inst0->bits3.if_else.jump_count = c->inst1 - c->inst0 + 1;
- c->inst0->bits3.if_else.pop_count = 0;
- } else if (c->inst0->header.opcode == BRW_OPCODE_CONTINUE) {
- c->inst0->bits3.if_else.jump_count = c->inst1 - c->inst0;
- c->inst0->bits3.if_else.pop_count = 0;
- }
- }
- break;
- case TGSI_OPCODE_END:
- emit_fb_write(c, inst);
- break;
-
- default:
- debug_printf("unsupported IR in fragment shader %d\n",
- inst->Instruction.Opcode);
- }
-#if 0
- if (inst->CondUpdate)
- brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
- else
- brw_set_predicate_control(p, BRW_PREDICATE_NONE);
-#endif
-}
-
-
-
-
-
-
-void brw_wm_glsl_emit(struct brw_wm_compile *c)
-{
- struct tgsi_parse_context parse;
- struct brw_compile *p = &c->func;
-
- brw_init_compile(&c->func);
- brw_set_compression_control(p, BRW_COMPRESSION_NONE);
-
- c->reg_index = 0;
- c->if_insn = 0;
- c->loop_insn = 0;
- c->stack_index = brw_indirect(0,0);
-
- /* Do static register allocation and parameter interpolation:
- */
- brw_wm_emit_decls( c );
-
- /* Emit the actual program. All done with very direct translation,
- * hopefully we can improve on this shortly...
- */
- brw_MOV(p, get_addr_reg(c->stack_index), brw_address(c->stack));
-
- tgsi_parse_init( &parse, c->fp->program.tokens );
-
- while( !tgsi_parse_end_of_tokens( &parse ) )
- {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- /* already done */
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- /* not handled yet */
- assert(0);
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- brw_wm_emit_instruction(c, &parse.FullToken.FullInstruction);
- break;
-
- default:
- assert( 0 );
- }
- }
-
- tgsi_parse_free (&parse);
-
- /* Fix up call targets:
- */
-#if 0
- {
- unsigned nr_insns = c->fp->program.Base.NumInstructions;
- unsigned insn, target_insn;
- struct tgsi_full_instruction *inst1, *inst2;
- struct brw_instruction *brw_inst1, *brw_inst2;
- int offset;
- for (insn = 0; insn < nr_insns; insn++) {
- inst1 = &c->fp->program.Base.Instructions[insn];
- brw_inst1 = inst1->Data;
- switch (inst1->Opcode) {
- case TGSI_OPCODE_CAL:
- target_insn = inst1->BranchTarget;
- inst2 = &c->fp->program.Base.Instructions[target_insn];
- brw_inst2 = inst2->Data;
- offset = brw_inst2 - brw_inst1;
- brw_set_src1(brw_inst1, brw_imm_d(offset*16));
- break;
- default:
- break;
- }
- }
- }
-#endif
-
- c->prog_data.total_grf = c->reg_index;
- c->prog_data.total_scratch = 0;
-}
diff --git a/src/mesa/pipe/i965simple/brw_wm_iz.c b/src/mesa/pipe/i965simple/brw_wm_iz.c
deleted file mode 100644
index 6c5f25bf39..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_iz.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_wm.h"
-
-
-#undef P /* prompted depth */
-#undef C /* computed */
-#undef N /* non-promoted? */
-
-#define P 0
-#define C 1
-#define N 2
-
-const struct {
- unsigned mode:2;
- unsigned sd_present:1;
- unsigned sd_to_rt:1;
- unsigned dd_present:1;
- unsigned ds_present:1;
-} wm_iz_table[IZ_BIT_MAX] =
-{
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 1, 1, 0, 0 },
- { C, 1, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 1, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 1, 1, 0, 0 },
- { C, 1, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 0, 1, 0, 0 },
- { C, 1, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 1, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 0, 0, 1 },
- { C, 0, 0, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 1, 1, 0, 1 },
- { C, 1, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 1, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 0, 0, 1 },
- { C, 0, 0, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 1, 1, 0, 1 },
- { C, 1, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 1, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 0 },
- { N, 0, 1, 0, 0 },
- { N, 0, 1, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 0 },
- { N, 0, 1, 0, 0 },
- { N, 0, 1, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 0 },
- { C, 0, 1, 1, 0 },
- { C, 0, 1, 1, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 1 },
- { N, 0, 1, 0, 1 },
- { N, 0, 1, 0, 1 },
- { P, 0, 0, 0, 0 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { P, 0, 0, 0, 0 },
- { N, 1, 1, 0, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { P, 0, 0, 0, 0 },
- { C, 0, 0, 0, 1 },
- { P, 0, 0, 0, 0 },
- { C, 0, 1, 0, 1 },
- { P, 0, 0, 0, 0 },
- { C, 1, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { C, 0, 1, 0, 1 },
- { P, 0, 0, 0, 0 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { P, 0, 0, 0, 0 },
- { C, 1, 1, 1, 1 },
- { C, 0, 1, 1, 1 },
- { C, 0, 1, 1, 1 }
-};
-
-void brw_wm_lookup_iz( unsigned line_aa,
- unsigned lookup,
- struct brw_wm_prog_key *key )
-{
- unsigned reg = 2;
-
- assert (lookup < IZ_BIT_MAX);
-
- if (lookup & IZ_PS_COMPUTES_DEPTH_BIT)
- key->computes_depth = 1;
-
- if (wm_iz_table[lookup].sd_present) {
- key->source_depth_reg = reg;
- reg += 2;
- }
-
- if (wm_iz_table[lookup].sd_to_rt)
- key->source_depth_to_render_target = 1;
-
- if (wm_iz_table[lookup].ds_present || line_aa != AA_NEVER) {
- key->aa_dest_stencil_reg = reg;
- key->runtime_check_aads_emit = (!wm_iz_table[lookup].ds_present &&
- line_aa == AA_SOMETIMES);
- reg++;
- }
-
- if (wm_iz_table[lookup].dd_present) {
- key->dest_depth_reg = reg;
- reg+=2;
- }
-
- key->nr_depth_regs = (reg+1)/2;
-}
-
diff --git a/src/mesa/pipe/i965simple/brw_wm_sampler_state.c b/src/mesa/pipe/i965simple/brw_wm_sampler_state.c
deleted file mode 100644
index de42ffc5b1..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_sampler_state.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-
-#include "pipe/p_util.h"
-
-
-#define COMPAREFUNC_ALWAYS 0
-#define COMPAREFUNC_NEVER 0x1
-#define COMPAREFUNC_LESS 0x2
-#define COMPAREFUNC_EQUAL 0x3
-#define COMPAREFUNC_LEQUAL 0x4
-#define COMPAREFUNC_GREATER 0x5
-#define COMPAREFUNC_NOTEQUAL 0x6
-#define COMPAREFUNC_GEQUAL 0x7
-
-/* Samplers aren't strictly wm state from the hardware's perspective,
- * but that is the only situation in which we use them in this driver.
- */
-
-static int intel_translate_shadow_compare_func(unsigned func)
-{
- switch(func) {
- case PIPE_FUNC_NEVER:
- return COMPAREFUNC_ALWAYS;
- case PIPE_FUNC_LESS:
- return COMPAREFUNC_LEQUAL;
- case PIPE_FUNC_LEQUAL:
- return COMPAREFUNC_LESS;
- case PIPE_FUNC_GREATER:
- return COMPAREFUNC_GEQUAL;
- case PIPE_FUNC_GEQUAL:
- return COMPAREFUNC_GREATER;
- case PIPE_FUNC_NOTEQUAL:
- return COMPAREFUNC_EQUAL;
- case PIPE_FUNC_EQUAL:
- return COMPAREFUNC_NOTEQUAL;
- case PIPE_FUNC_ALWAYS:
- return COMPAREFUNC_NEVER;
- }
-
- debug_printf("Unknown value in %s: %x\n", __FUNCTION__, func);
- return COMPAREFUNC_NEVER;
-}
-
-/* The brw (and related graphics cores) do not support GL_CLAMP. The
- * Intel drivers for "other operating systems" implement GL_CLAMP as
- * GL_CLAMP_TO_EDGE, so the same is done here.
- */
-static unsigned translate_wrap_mode( int wrap )
-{
- switch( wrap ) {
- case PIPE_TEX_WRAP_REPEAT:
- return BRW_TEXCOORDMODE_WRAP;
- case PIPE_TEX_WRAP_CLAMP:
- return BRW_TEXCOORDMODE_CLAMP;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- return BRW_TEXCOORDMODE_CLAMP; /* conform likes it this way */
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- return BRW_TEXCOORDMODE_CLAMP_BORDER;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- return BRW_TEXCOORDMODE_MIRROR;
- default:
- return BRW_TEXCOORDMODE_WRAP;
- }
-}
-
-
-static unsigned U_FIXED(float value, unsigned frac_bits)
-{
- value *= (1<<frac_bits);
- return value < 0 ? 0 : value;
-}
-
-static int S_FIXED(float value, unsigned frac_bits)
-{
- return value * (1<<frac_bits);
-}
-
-
-static unsigned upload_default_color( struct brw_context *brw,
- const float *color )
-{
- struct brw_sampler_default_color sdc;
-
- COPY_4V(sdc.color, color);
-
- return brw_cache_data( &brw->cache[BRW_SAMPLER_DEFAULT_COLOR], &sdc );
-}
-
-
-/*
- */
-static void brw_update_sampler_state( const struct pipe_sampler_state *pipe_sampler,
- unsigned sdc_gs_offset,
- struct brw_sampler_state *sampler)
-{
- memset(sampler, 0, sizeof(*sampler));
-
- switch (pipe_sampler->min_mip_filter) {
- case PIPE_TEX_FILTER_NEAREST:
- sampler->ss0.min_filter = BRW_MAPFILTER_NEAREST;
- break;
- case PIPE_TEX_FILTER_LINEAR:
- sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR;
- break;
- default:
- break;
- }
-
- switch (pipe_sampler->min_mip_filter) {
- case PIPE_TEX_MIPFILTER_NEAREST:
- sampler->ss0.mip_filter = BRW_MIPFILTER_NEAREST;
- break;
- case PIPE_TEX_MIPFILTER_LINEAR:
- sampler->ss0.mip_filter = BRW_MIPFILTER_LINEAR;
- break;
- case PIPE_TEX_MIPFILTER_NONE:
- sampler->ss0.mip_filter = BRW_MIPFILTER_NONE;
- break;
- default:
- break;
- }
- /* Set Anisotropy:
- */
- if (pipe_sampler->max_anisotropy > 1.0) {
- sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC;
- sampler->ss0.mag_filter = BRW_MAPFILTER_ANISOTROPIC;
-
- if (pipe_sampler->max_anisotropy > 2.0) {
- sampler->ss3.max_aniso = MAX2((pipe_sampler->max_anisotropy - 2) / 2,
- BRW_ANISORATIO_16);
- }
- }
- else {
- switch (pipe_sampler->mag_img_filter) {
- case PIPE_TEX_FILTER_NEAREST:
- sampler->ss0.mag_filter = BRW_MAPFILTER_NEAREST;
- break;
- case PIPE_TEX_FILTER_LINEAR:
- sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
- break;
- default:
- break;
- }
- }
-
- sampler->ss1.s_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_s);
- sampler->ss1.r_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_r);
- sampler->ss1.t_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_t);
-
- /* Fulsim complains if I don't do this. Hardware doesn't mind:
- */
-#if 0
- if (texObj->Target == GL_TEXTURE_CUBE_MAP_ARB) {
- sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
- sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
- sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
- }
-#endif
-
- /* Set shadow function:
- */
- if (pipe_sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- /* Shadowing is "enabled" by emitting a particular sampler
- * message (sample_c). So need to recompile WM program when
- * shadow comparison is enabled on each/any texture unit.
- */
- sampler->ss0.shadow_function = intel_translate_shadow_compare_func(pipe_sampler->compare_func);
- }
-
- /* Set LOD bias:
- */
- sampler->ss0.lod_bias = S_FIXED(CLAMP(pipe_sampler->lod_bias, -16, 15), 6);
-
- sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
- sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
-
- /* Set BaseMipLevel, MaxLOD, MinLOD:
- *
- * XXX: I don't think that using firstLevel, lastLevel works,
- * because we always setup the surface state as if firstLevel ==
- * level zero. Probably have to subtract firstLevel from each of
- * these:
- */
- sampler->ss0.base_level = U_FIXED(0, 1);
-
- sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(pipe_sampler->max_lod, 0), 13), 6);
- sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(pipe_sampler->min_lod, 0), 13), 6);
-
- sampler->ss2.default_color_pointer = sdc_gs_offset >> 5;
-}
-
-
-
-/* All samplers must be uploaded in a single contiguous array, which
- * complicates various things. However, this is still too confusing -
- * FIXME: simplify all the different new texture state flags.
- */
-static void upload_wm_samplers(struct brw_context *brw)
-{
- unsigned unit;
- unsigned sampler_count = 0;
-
- /* BRW_NEW_SAMPLER */
- for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
- /* determine unit enable/disable by looking for a bound texture */
- if (brw->attribs.Texture[unit]) {
- const struct pipe_sampler_state *sampler = brw->attribs.Samplers[unit];
- unsigned sdc_gs_offset = upload_default_color(brw, sampler->border_color);
-
- brw_update_sampler_state(sampler,
- sdc_gs_offset,
- &brw->wm.sampler[unit]);
-
- sampler_count = unit + 1;
- }
- }
-
- if (brw->wm.sampler_count != sampler_count) {
- brw->wm.sampler_count = sampler_count;
- brw->state.dirty.cache |= CACHE_NEW_SAMPLER;
- }
-
- brw->wm.sampler_gs_offset = 0;
-
- if (brw->wm.sampler_count)
- brw->wm.sampler_gs_offset =
- brw_cache_data_sz(&brw->cache[BRW_SAMPLER],
- brw->wm.sampler,
- sizeof(struct brw_sampler_state) * brw->wm.sampler_count);
-}
-
-const struct brw_tracked_state brw_wm_samplers = {
- .dirty = {
- .brw = BRW_NEW_SAMPLER,
- .cache = 0
- },
- .update = upload_wm_samplers
-};
-
diff --git a/src/mesa/pipe/i965simple/brw_wm_state.c b/src/mesa/pipe/i965simple/brw_wm_state.c
deleted file mode 100644
index 5ccd488842..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_state.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-#include "brw_wm.h"
-#include "pipe/p_util.h"
-
-/***********************************************************************
- * WM unit - fragment programs and rasterization
- */
-static void upload_wm_unit(struct brw_context *brw )
-{
- struct brw_wm_unit_state wm;
- unsigned max_threads;
- unsigned per_thread;
-
- if (BRW_DEBUG & DEBUG_SINGLE_THREAD)
- max_threads = 0;
- else
- max_threads = 31;
-
-
- memset(&wm, 0, sizeof(wm));
-
- /* CACHE_NEW_WM_PROG */
- wm.thread0.grf_reg_count = align(brw->wm.prog_data->total_grf, 16) / 16 - 1;
- wm.thread0.kernel_start_pointer = brw->wm.prog_gs_offset >> 6;
- wm.thread3.dispatch_grf_start_reg = brw->wm.prog_data->first_curbe_grf;
- wm.thread3.urb_entry_read_length = brw->wm.prog_data->urb_read_length;
- wm.thread3.const_urb_entry_read_length = brw->wm.prog_data->curb_read_length;
-
- wm.wm5.max_threads = max_threads;
-
- per_thread = align(brw->wm.prog_data->total_scratch, 1024);
- assert(per_thread <= 12 * 1024);
-
-#if 0
- if (brw->wm.prog_data->total_scratch) {
- unsigned total = per_thread * (max_threads + 1);
-
- /* Scratch space -- just have to make sure there is sufficient
- * allocated for the active program and current number of threads.
- */
- brw->wm.scratch_buffer_size = total;
- if (brw->wm.scratch_buffer &&
- brw->wm.scratch_buffer_size > brw->wm.scratch_buffer->size) {
- dri_bo_unreference(brw->wm.scratch_buffer);
- brw->wm.scratch_buffer = NULL;
- }
- if (!brw->wm.scratch_buffer) {
- brw->wm.scratch_buffer = dri_bo_alloc(intel->intelScreen->bufmgr,
- "wm scratch",
- brw->wm.scratch_buffer_size,
- 4096, DRM_BO_FLAG_MEM_TT);
- }
- }
- /* XXX: Scratch buffers are not implemented correectly.
- *
- * The scratch offset to be programmed into wm is relative to the general
- * state base address. However, using dri_bo_alloc/dri_bo_emit_reloc (or
- * the previous bmGenBuffers scheme), we get an offset relative to the
- * start of framebuffer. Even before then, it was broken in other ways,
- * so just fail for now if we hit that path.
- */
- assert(brw->wm.prog_data->total_scratch == 0);
-#endif
-
- /* CACHE_NEW_SURFACE */
- wm.thread1.binding_table_entry_count = brw->wm.nr_surfaces;
-
- /* BRW_NEW_CURBE_OFFSETS */
- wm.thread3.const_urb_entry_read_offset = brw->curbe.wm_start * 2;
-
- wm.thread3.urb_entry_read_offset = 0;
- wm.thread1.depth_coef_urb_read_offset = 1;
- wm.thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
-
- /* CACHE_NEW_SAMPLER */
- wm.wm4.sampler_count = (brw->wm.sampler_count + 1) / 4;
- wm.wm4.sampler_state_pointer = brw->wm.sampler_gs_offset >> 5;
-
- /* BRW_NEW_FRAGMENT_PROGRAM */
- {
- const struct brw_fragment_program *fp = brw->attribs.FragmentProgram;
-
- if (fp->UsesDepth)
- wm.wm5.program_uses_depth = 1; /* as far as we can tell */
-
- if (fp->ComputesDepth)
- wm.wm5.program_computes_depth = 1;
-
- /* BRW_NEW_ALPHA_TEST */
- if (fp->UsesKill ||
- brw->attribs.DepthStencil->alpha.enabled)
- wm.wm5.program_uses_killpixel = 1;
-
- wm.wm5.enable_8_pix = 1;
- }
-
- wm.wm5.thread_dispatch_enable = 1; /* AKA: color_write */
- wm.wm5.legacy_line_rast = 0;
- wm.wm5.legacy_global_depth_bias = 0;
- wm.wm5.early_depth_test = 1; /* never need to disable */
- wm.wm5.line_aa_region_width = 0;
- wm.wm5.line_endcap_aa_region_width = 1;
-
- /* BRW_NEW_RASTERIZER */
- if (brw->attribs.Raster->poly_stipple_enable)
- wm.wm5.polygon_stipple = 1;
-
-#if 0
- if (brw->attribs.Polygon->OffsetFill) {
- wm.wm5.depth_offset = 1;
- /* Something wierd going on with legacy_global_depth_bias,
- * offset_constant, scaling and MRD. This value passes glean
- * but gives some odd results elsewere (eg. the
- * quad-offset-units test).
- */
- wm.global_depth_offset_constant = brw->attribs.Polygon->OffsetUnits * 2;
-
- /* This is the only value that passes glean:
- */
- wm.global_depth_offset_scale = brw->attribs.Polygon->OffsetFactor;
- }
-#endif
-
- if (brw->attribs.Raster->line_stipple_enable) {
- wm.wm5.line_stipple = 1;
- }
-
- if (BRW_DEBUG & DEBUG_STATS)
- wm.wm4.stats_enable = 1;
-
- brw->wm.state_gs_offset = brw_cache_data( &brw->cache[BRW_WM_UNIT], &wm );
-
- if (brw->wm.prog_data->total_scratch) {
- /*
- dri_emit_reloc(brw->cache[BRW_WM_UNIT].pool->buffer,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- (per_thread / 1024) - 1,
- brw->wm.state_gs_offset +
- ((char *)&wm.thread2 - (char *)&wm),
- brw->wm.scratch_buffer);
- */
- } else {
- wm.thread2.scratch_space_base_pointer = 0;
- }
-}
-
-const struct brw_tracked_state brw_wm_unit = {
- .dirty = {
- .brw = (BRW_NEW_RASTERIZER |
- BRW_NEW_ALPHA_TEST |
- BRW_NEW_FS |
- BRW_NEW_CURBE_OFFSETS),
-
- .cache = (CACHE_NEW_SURFACE |
- CACHE_NEW_WM_PROG |
- CACHE_NEW_SAMPLER)
- },
- .update = upload_wm_unit
-};
-
diff --git a/src/mesa/pipe/i965simple/brw_wm_surface_state.c b/src/mesa/pipe/i965simple/brw_wm_surface_state.c
deleted file mode 100644
index d16d919bce..0000000000
--- a/src/mesa/pipe/i965simple/brw_wm_surface_state.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_context.h"
-#include "brw_state.h"
-#include "brw_defines.h"
-
-static unsigned translate_tex_target( enum pipe_texture_target target )
-{
- switch (target) {
- case PIPE_TEXTURE_1D:
- return BRW_SURFACE_1D;
-
- case PIPE_TEXTURE_2D:
- return BRW_SURFACE_2D;
-
- case PIPE_TEXTURE_3D:
- return BRW_SURFACE_3D;
-
- case PIPE_TEXTURE_CUBE:
- return BRW_SURFACE_CUBE;
-
- default:
- assert(0);
- return 0;
- }
-}
-
-static unsigned translate_tex_format( enum pipe_format pipe_format )
-{
- switch( pipe_format ) {
- case PIPE_FORMAT_U_L8:
- return BRW_SURFACEFORMAT_L8_UNORM;
-
- case PIPE_FORMAT_U_I8:
- return BRW_SURFACEFORMAT_I8_UNORM;
-
- case PIPE_FORMAT_U_A8:
- return BRW_SURFACEFORMAT_A8_UNORM;
-
- case PIPE_FORMAT_U_A8_L8:
- return BRW_SURFACEFORMAT_L8A8_UNORM;
-
- case PIPE_FORMAT_R8G8B8_UNORM:
- assert(0); /* not supported for sampling */
- return BRW_SURFACEFORMAT_R8G8B8_UNORM;
-
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
-
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- return BRW_SURFACEFORMAT_R8G8B8A8_UNORM;
-
- case PIPE_FORMAT_R5G6B5_UNORM:
- return BRW_SURFACEFORMAT_B5G6R5_UNORM;
-
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- return BRW_SURFACEFORMAT_B5G5R5A1_UNORM;
-
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- return BRW_SURFACEFORMAT_B4G4R4A4_UNORM;
-
- case PIPE_FORMAT_YCBCR_REV:
- return BRW_SURFACEFORMAT_YCRCB_NORMAL;
-
- case PIPE_FORMAT_YCBCR:
- return BRW_SURFACEFORMAT_YCRCB_SWAPUVY;
-#if 0
- case PIPE_FORMAT_RGB_FXT1:
- case PIPE_FORMAT_RGBA_FXT1:
- return BRW_SURFACEFORMAT_FXT1;
-#endif
-
- case PIPE_FORMAT_Z16_UNORM:
- return BRW_SURFACEFORMAT_I16_UNORM;
-#if 0
- case PIPE_FORMAT_RGB_DXT1:
- return BRW_SURFACEFORMAT_DXT1_RGB;
-
- case PIPE_FORMAT_RGBA_DXT1:
- return BRW_SURFACEFORMAT_BC1_UNORM;
-
- case PIPE_FORMAT_RGBA_DXT3:
- return BRW_SURFACEFORMAT_BC2_UNORM;
-
- case PIPE_FORMAT_RGBA_DXT5:
- return BRW_SURFACEFORMAT_BC3_UNORM;
-
- case PIPE_FORMAT_SRGBA8:
- return BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB;
- case PIPE_FORMAT_SRGB_DXT1:
- return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
-#endif
-
- default:
- assert(0);
- return 0;
- }
-}
-
-static unsigned brw_buffer_offset(struct brw_context *brw,
- struct pipe_buffer *buffer)
-{
- return brw->winsys->get_buffer_offset(brw->winsys,
- buffer,
- 0);
-}
-
-static
-void brw_update_texture_surface( struct brw_context *brw,
- unsigned unit )
-{
- const struct brw_texture *tObj = brw->attribs.Texture[unit];
- struct brw_surface_state surf;
-
- memset(&surf, 0, sizeof(surf));
-
- surf.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
- surf.ss0.surface_type = translate_tex_target(tObj->base.target);
- surf.ss0.surface_format = translate_tex_format(tObj->base.format);
-
- /* This is ok for all textures with channel width 8bit or less:
- */
-/* surf.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
-
- /* Updated in emit_reloc */
- surf.ss1.base_addr = brw_buffer_offset( brw, tObj->buffer );
-
- surf.ss2.mip_count = tObj->base.last_level;
- surf.ss2.width = tObj->base.width[0] - 1;
- surf.ss2.height = tObj->base.height[0] - 1;
-
- surf.ss3.tile_walk = BRW_TILEWALK_XMAJOR;
- surf.ss3.tiled_surface = 0; /* always zero */
- surf.ss3.pitch = tObj->pitch - 1;
- surf.ss3.depth = tObj->base.depth[0] - 1;
-
- surf.ss4.min_lod = 0;
-
- if (tObj->base.target == PIPE_TEXTURE_CUBE) {
- surf.ss0.cube_pos_x = 1;
- surf.ss0.cube_pos_y = 1;
- surf.ss0.cube_pos_z = 1;
- surf.ss0.cube_neg_x = 1;
- surf.ss0.cube_neg_y = 1;
- surf.ss0.cube_neg_z = 1;
- }
-
- brw->wm.bind.surf_ss_offset[unit + 1] =
- brw_cache_data( &brw->cache[BRW_SS_SURFACE], &surf );
-}
-
-
-
-#define OFFSET(TYPE, FIELD) ( (unsigned)&(((TYPE *)0)->FIELD) )
-
-
-static void upload_wm_surfaces(struct brw_context *brw )
-{
- unsigned i;
-
- {
- struct brw_surface_state surf;
-
- /* BRW_NEW_FRAMEBUFFER
- */
- struct pipe_surface *pipe_surface = brw->attribs.FrameBuffer.cbufs[0];/*fixme*/
-
- memset(&surf, 0, sizeof(surf));
-
- if (pipe_surface != NULL) {
- if (pipe_surface->cpp == 4)
- surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
- else
- surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM;
-
- surf.ss0.surface_type = BRW_SURFACE_2D;
-
- surf.ss1.base_addr = brw_buffer_offset( brw, pipe_surface->buffer );
-
- surf.ss2.width = pipe_surface->width - 1;
- surf.ss2.height = pipe_surface->height - 1;
- surf.ss3.tile_walk = BRW_TILEWALK_XMAJOR;
- surf.ss3.tiled_surface = 0;
- surf.ss3.pitch = (pipe_surface->pitch * pipe_surface->cpp) - 1;
- } else {
- surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
- surf.ss0.surface_type = BRW_SURFACE_NULL;
- }
-
- /* BRW_NEW_BLEND */
- surf.ss0.color_blend = (!brw->attribs.Blend->logicop_enable &&
- brw->attribs.Blend->blend_enable);
-
-
- surf.ss0.writedisable_red = !(brw->attribs.Blend->colormask & PIPE_MASK_R);
- surf.ss0.writedisable_green = !(brw->attribs.Blend->colormask & PIPE_MASK_G);
- surf.ss0.writedisable_blue = !(brw->attribs.Blend->colormask & PIPE_MASK_B);
- surf.ss0.writedisable_alpha = !(brw->attribs.Blend->colormask & PIPE_MASK_A);
-
-
-
-
- brw->wm.bind.surf_ss_offset[0] = brw_cache_data( &brw->cache[BRW_SS_SURFACE], &surf );
-
- brw->wm.nr_surfaces = 1;
- }
-
-
- /* BRW_NEW_TEXTURE
- */
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- const struct brw_texture *texUnit = brw->attribs.Texture[i];
-
- if (texUnit &&
- texUnit->base.refcount/*(texUnit->refcount > 0) == really used */) {
-
- brw_update_texture_surface(brw, i);
-
- brw->wm.nr_surfaces = i+2;
- }
- else {
- brw->wm.bind.surf_ss_offset[i+1] = 0;
- }
- }
-
- brw->wm.bind_ss_offset = brw_cache_data( &brw->cache[BRW_SS_SURF_BIND],
- &brw->wm.bind );
-}
-
-
-/* KW: Will find a different way to acheive this, see for example the
- * state caches with relocs in the i915 swz driver.
- */
-#if 0
-static void emit_reloc_wm_surfaces(struct brw_context *brw)
-{
- int unit;
-
- if (brw->state.draw_region != NULL) {
- /* Emit framebuffer relocation */
- dri_emit_reloc(brw_cache_buffer(brw, BRW_SS_SURFACE),
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0,
- brw->wm.bind.surf_ss_offset[0] +
- offsetof(struct brw_surface_state, ss1),
- brw->state.draw_region->buffer);
- }
-
- /* Emit relocations for texture buffers */
- for (unit = 0; unit < BRW_MAX_TEX_UNIT; unit++) {
- struct gl_texture_unit *texUnit = &brw->attribs.Texture->Unit[unit];
- struct gl_texture_object *tObj = texUnit->_Current;
- struct intel_texture_object *intelObj = intel_texture_object(tObj);
-
- if (texUnit->_ReallyEnabled && intelObj->mt != NULL) {
- dri_emit_reloc(brw_cache_buffer(brw, BRW_SS_SURFACE),
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- 0,
- brw->wm.bind.surf_ss_offset[unit + 1] +
- offsetof(struct brw_surface_state, ss1),
- intelObj->mt->region->buffer);
- }
- }
-}
-#endif
-
-const struct brw_tracked_state brw_wm_surfaces = {
- .dirty = {
- .brw = (BRW_NEW_FRAMEBUFFER |
- BRW_NEW_BLEND |
- BRW_NEW_TEXTURE),
- .cache = 0
- },
- .update = upload_wm_surfaces,
-};
diff --git a/src/mesa/pipe/llvm/Makefile b/src/mesa/pipe/llvm/Makefile
deleted file mode 100644
index a0494ba966..0000000000
--- a/src/mesa/pipe/llvm/Makefile
+++ /dev/null
@@ -1,85 +0,0 @@
-# -*-makefile-*-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = gallivm
-
-
-GALLIVM_SOURCES = \
- gallivm.cpp \
- gallivm_cpu.cpp \
- instructions.cpp \
- loweringpass.cpp \
- tgsitollvm.cpp \
- storage.cpp \
- storagesoa.cpp \
- instructionssoa.cpp
-
-INC_SOURCES = gallivm_builtins.cpp llvm_base_shader.cpp
-
-CPP_SOURCES = \
- $(GALLIVM_SOURCES)
-
-C_SOURCES =
-ASM_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/mesa/pipe \
- -I$(TOP)/src/mesa \
- -I$(TOP)/include
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(LLVM_CFLAGS) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(LLVM_CXXFLAGS) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-##### TARGETS #####
-
-default:: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile
- $(TOP)/bin/mklib -o $@ -static $(OBJECTS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(INC_SOURCES)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) $(INC_SOURCES) 2> /dev/null
-
-
-gallivm_builtins.cpp: llvm_builtins.c
- clang --emit-llvm $< |llvm-as|opt -std-compile-opts|llvm2cpp -gen-contents -o=$@ -f -for=shader -funcname=createGallivmBuiltins
-
-llvm_base_shader.cpp: llvm_entry.c
- clang --emit-llvm $< |llvm-as |opt -std-compile-opts |llvm2cpp -for=Shader -gen-module -o=$@ -f -funcname=createBaseShader
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean:
- -rm -f *.o */*.o *~ *.so *~ server/*.o
- -rm -f depend depend.bak
- -rm -f gallivm_builtins.cpp llvm_base_shader.cpp
-
-symlinks:
-
-
-include depend
diff --git a/src/mesa/pipe/llvm/gallivm.cpp b/src/mesa/pipe/llvm/gallivm.cpp
deleted file mode 100644
index da0105c2c9..0000000000
--- a/src/mesa/pipe/llvm/gallivm.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-#ifdef MESA_LLVM
-
-#include "gallivm.h"
-#include "gallivm_p.h"
-
-#include "instructions.h"
-#include "loweringpass.h"
-#include "storage.h"
-#include "tgsitollvm.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_shader_tokens.h"
-
-#include "pipe/tgsi/exec/tgsi_exec.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-
-#include <llvm/Module.h>
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/Pass.h>
-#include <llvm/PassManager.h>
-#include <llvm/ParameterAttributes.h>
-#include <llvm/Support/PatternMatch.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/Interpreter.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/Support/MemoryBuffer.h>
-#include <llvm/LinkAllPasses.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Analysis/LoopPass.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/Transforms/Utils/Cloning.h>
-
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-static int GLOBAL_ID = 0;
-
-using namespace llvm;
-
-static inline
-void AddStandardCompilePasses(PassManager &PM)
-{
- PM.add(new LoweringPass());
- PM.add(createVerifierPass()); // Verify that input is correct
-
- PM.add(createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp
-
- //PM.add(createStripSymbolsPass(true));
-
- PM.add(createRaiseAllocationsPass()); // call %malloc -> malloc inst
- PM.add(createCFGSimplificationPass()); // Clean up disgusting code
- PM.add(createPromoteMemoryToRegisterPass());// Kill useless allocas
- PM.add(createGlobalOptimizerPass()); // Optimize out global vars
- PM.add(createGlobalDCEPass()); // Remove unused fns and globs
- PM.add(createIPConstantPropagationPass());// IP Constant Propagation
- PM.add(createDeadArgEliminationPass()); // Dead argument elimination
- PM.add(createInstructionCombiningPass()); // Clean up after IPCP & DAE
- PM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
-
- PM.add(createPruneEHPass()); // Remove dead EH info
-
- PM.add(createFunctionInliningPass()); // Inline small functions
- PM.add(createArgumentPromotionPass()); // Scalarize uninlined fn args
-
- PM.add(createTailDuplicationPass()); // Simplify cfg by copying code
- PM.add(createInstructionCombiningPass()); // Cleanup for scalarrepl.
- PM.add(createCFGSimplificationPass()); // Merge & remove BBs
- PM.add(createScalarReplAggregatesPass()); // Break up aggregate allocas
- PM.add(createInstructionCombiningPass()); // Combine silly seq's
- PM.add(createCondPropagationPass()); // Propagate conditionals
-
- PM.add(createTailCallEliminationPass()); // Eliminate tail calls
- PM.add(createCFGSimplificationPass()); // Merge & remove BBs
- PM.add(createReassociatePass()); // Reassociate expressions
- PM.add(createLoopRotatePass());
- PM.add(createLICMPass()); // Hoist loop invariants
- PM.add(createLoopUnswitchPass()); // Unswitch loops.
- PM.add(createLoopIndexSplitPass()); // Index split loops.
- PM.add(createInstructionCombiningPass()); // Clean up after LICM/reassoc
- PM.add(createIndVarSimplifyPass()); // Canonicalize indvars
- PM.add(createLoopUnrollPass()); // Unroll small loops
- PM.add(createInstructionCombiningPass()); // Clean up after the unroller
- PM.add(createGVNPass()); // Remove redundancies
- PM.add(createSCCPPass()); // Constant prop with SCCP
-
- // Run instcombine after redundancy elimination to exploit opportunities
- // opened up by them.
- PM.add(createInstructionCombiningPass());
- PM.add(createCondPropagationPass()); // Propagate conditionals
-
- PM.add(createDeadStoreEliminationPass()); // Delete dead stores
- PM.add(createAggressiveDCEPass()); // SSA based 'Aggressive DCE'
- PM.add(createCFGSimplificationPass()); // Merge & remove BBs
- PM.add(createSimplifyLibCallsPass()); // Library Call Optimizations
- PM.add(createDeadTypeEliminationPass()); // Eliminate dead types
- PM.add(createConstantMergePass()); // Merge dup global constants
-}
-
-void gallivm_prog_delete(struct gallivm_prog *prog)
-{
- delete prog->module;
- prog->module = 0;
- prog->function = 0;
- free(prog);
-}
-
-static inline void
-constant_interpolation(float (*inputs)[16][4],
- const struct tgsi_interp_coef *coefs,
- unsigned attrib,
- unsigned chan)
-{
- unsigned i;
-
- for (i = 0; i < QUAD_SIZE; ++i) {
- inputs[i][attrib][chan] = coefs[attrib].a0[chan];
- }
-}
-
-static inline void
-linear_interpolation(float (*inputs)[16][4],
- const struct tgsi_interp_coef *coefs,
- unsigned attrib,
- unsigned chan)
-{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- const float x = inputs[i][0][0];
- const float y = inputs[i][0][1];
-
- inputs[i][attrib][chan] =
- coefs[attrib].a0[chan] +
- coefs[attrib].dadx[chan] * x +
- coefs[attrib].dady[chan] * y;
- }
-}
-
-static inline void
-perspective_interpolation(float (*inputs)[16][4],
- const struct tgsi_interp_coef *coefs,
- unsigned attrib,
- unsigned chan )
-{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- const float x = inputs[i][0][0];
- const float y = inputs[i][0][1];
- /* WPOS.w here is really 1/w */
- const float w = 1.0f / inputs[i][0][3];
- assert(inputs[i][0][3] != 0.0);
-
- inputs[i][attrib][chan] =
- (coefs[attrib].a0[chan] +
- coefs[attrib].dadx[chan] * x +
- coefs[attrib].dady[chan] * y) * w;
- }
-}
-
-void gallivm_ir_dump(struct gallivm_ir *ir, const char *file_prefix)
-{
- if (!ir || !ir->module)
- return;
-
- if (file_prefix) {
- std::ostringstream stream;
- stream << file_prefix;
- stream << ir->id;
- stream << ".ll";
- std::string name = stream.str();
- std::ofstream out(name.c_str());
- if (!out) {
- std::cerr<<"Can't open file : "<<stream.str()<<std::endl;;
- return;
- }
- out << (*ir->module);
- out.close();
- } else {
- const llvm::Module::FunctionListType &funcs = ir->module->getFunctionList();
- llvm::Module::FunctionListType::const_iterator itr;
- std::cout<<"; ---------- Start shader "<<ir->id<<std::endl;
- for (itr = funcs.begin(); itr != funcs.end(); ++itr) {
- const llvm::Function &func = (*itr);
- std::string name = func.getName();
- const llvm::Function *found = 0;
- if (name.find("vs_shader") != std::string::npos ||
- name.find("fs_shader") != std::string::npos ||
- name.find("function") != std::string::npos)
- found = &func;
- if (found) {
- std::cout<<*found<<std::endl;
- }
- }
- std::cout<<"; ---------- End shader "<<ir->id<<std::endl;
- }
-}
-
-
-void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
- float (*inputs)[16][4],
- const struct tgsi_interp_coef *coef)
-{
- for (int i = 0; i < prog->num_interp; ++i) {
- const gallivm_interpolate &interp = prog->interpolators[i];
- switch (interp.type) {
- case TGSI_INTERPOLATE_CONSTANT:
- constant_interpolation(inputs, coef, interp.attrib, interp.chan);
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- linear_interpolation(inputs, coef, interp.attrib, interp.chan);
- break;
-
- case TGSI_INTERPOLATE_PERSPECTIVE:
- perspective_interpolation(inputs, coef, interp.attrib, interp.chan);
- break;
-
- default:
- assert( 0 );
- }
- }
-}
-
-
-struct gallivm_ir * gallivm_ir_new(enum gallivm_shader_type type)
-{
- struct gallivm_ir *ir =
- (struct gallivm_ir *)calloc(1, sizeof(struct gallivm_ir));
- ++GLOBAL_ID;
- ir->id = GLOBAL_ID;
- ir->type = type;
-
- return ir;
-}
-
-void gallivm_ir_set_layout(struct gallivm_ir *ir,
- enum gallivm_vector_layout layout)
-{
- ir->layout = layout;
-}
-
-void gallivm_ir_set_components(struct gallivm_ir *ir, int num)
-{
- ir->num_components = num;
-}
-
-void gallivm_ir_fill_from_tgsi(struct gallivm_ir *ir,
- const struct tgsi_token *tokens)
-{
- std::cout << "Creating llvm from: " <<std::endl;
- tgsi_dump(tokens, 0);
-
-
- llvm::Module *mod = tgsi_to_llvmir(ir, tokens);
-
- //llvm::Module *mod = tgsi_to_llvm(ir, tokens);
- ir->module = mod;
- gallivm_ir_dump(ir, 0);
-}
-
-void gallivm_ir_delete(struct gallivm_ir *ir)
-{
- delete ir->module;
- free(ir);
-}
-
-struct gallivm_prog * gallivm_ir_compile(struct gallivm_ir *ir)
-{
- struct gallivm_prog *prog =
- (struct gallivm_prog *)calloc(1, sizeof(struct gallivm_prog));
- llvm::Module *mod = llvm::CloneModule(ir->module);
- prog->num_consts = ir->num_consts;
- memcpy(prog->interpolators, ir->interpolators, sizeof(prog->interpolators));
- prog->num_interp = ir->num_interp;
-
- /* Run optimization passes over it */
- PassManager passes;
- passes.add(new TargetData(mod));
- AddStandardCompilePasses(passes);
- passes.run(*mod);
- prog->module = mod;
-
- std::cout << "After optimizations:"<<std::endl;
- mod->dump();
-
- return prog;
-}
-
-#endif /* MESA_LLVM */
diff --git a/src/mesa/pipe/llvm/gallivm.h b/src/mesa/pipe/llvm/gallivm.h
deleted file mode 100644
index 92da4bca7f..0000000000
--- a/src/mesa/pipe/llvm/gallivm.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-
-#ifndef GALLIVM_H
-#define GALLIVM_H
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-#include "pipe/p_state.h"
-
-#ifdef MESA_LLVM
-
-struct tgsi_token;
-
-struct gallivm_ir;
-struct gallivm_prog;
-struct gallivm_cpu_engine;
-struct tgsi_interp_coef;
-struct tgsi_sampler;
-struct tgsi_exec_vector;
-
-enum gallivm_shader_type {
- GALLIVM_VS,
- GALLIVM_FS
-};
-
-enum gallivm_vector_layout {
- GALLIVM_AOS,
- GALLIVM_SOA
-};
-
-struct gallivm_ir *gallivm_ir_new(enum gallivm_shader_type type);
-void gallivm_ir_set_layout(struct gallivm_ir *ir,
- enum gallivm_vector_layout layout);
-void gallivm_ir_set_components(struct gallivm_ir *ir, int num);
-void gallivm_ir_fill_from_tgsi(struct gallivm_ir *ir,
- const struct tgsi_token *tokens);
-void gallivm_ir_delete(struct gallivm_ir *ir);
-
-
-struct gallivm_prog *gallivm_ir_compile(struct gallivm_ir *ir);
-
-void gallivm_prog_inputs_interpolate(struct gallivm_prog *prog,
- float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
- const struct tgsi_interp_coef *coefs);
-void gallivm_prog_dump(struct gallivm_prog *prog, const char *file_prefix);
-
-
-struct gallivm_cpu_engine *gallivm_cpu_engine_create(struct gallivm_prog *prog);
-struct gallivm_cpu_engine *gallivm_global_cpu_engine();
-int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
- struct tgsi_exec_vector *inputs,
- struct tgsi_exec_vector *dests,
- float (*consts)[4],
- struct tgsi_exec_vector *temps);
-int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
- float x, float y,
- float (*dests)[PIPE_MAX_SHADER_INPUTS][4],
- float (*inputs)[PIPE_MAX_SHADER_INPUTS][4],
- float (*consts)[4],
- struct tgsi_sampler *samplers);
-void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *ee, struct gallivm_prog *prog);
-void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
-
-
-#endif /* MESA_LLVM */
-
-#if defined __cplusplus
-} // extern "C"
-#endif
-
-#endif
diff --git a/src/mesa/pipe/llvm/gallivm_builtins.cpp b/src/mesa/pipe/llvm/gallivm_builtins.cpp
deleted file mode 100644
index 1796f0a177..0000000000
--- a/src/mesa/pipe/llvm/gallivm_builtins.cpp
+++ /dev/null
@@ -1,567 +0,0 @@
-// Generated by llvm2cpp - DO NOT MODIFY!
-
-
-Module* createGallivmBuiltins(Module *mod) {
-
-mod->setModuleIdentifier("shader");
-
-// Type Definitions
-ArrayType* ArrayTy_0 = ArrayType::get(IntegerType::get(8), 25);
-
-PointerType* PointerTy_1 = PointerType::get(ArrayTy_0, 0);
-
-std::vector<const Type*>FuncTy_2_args;
-FuncTy_2_args.push_back(Type::FloatTy);
-FuncTy_2_args.push_back(Type::FloatTy);
-FunctionType* FuncTy_2 = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/FuncTy_2_args,
- /*isVarArg=*/false);
-
-PointerType* PointerTy_3 = PointerType::get(FuncTy_2, 0);
-
-VectorType* VectorTy_4 = VectorType::get(Type::FloatTy, 4);
-
-std::vector<const Type*>FuncTy_5_args;
-FuncTy_5_args.push_back(VectorTy_4);
-FunctionType* FuncTy_5 = FunctionType::get(
- /*Result=*/VectorTy_4,
- /*Params=*/FuncTy_5_args,
- /*isVarArg=*/false);
-
-std::vector<const Type*>FuncTy_6_args;
-FuncTy_6_args.push_back(VectorTy_4);
-FuncTy_6_args.push_back(VectorTy_4);
-FuncTy_6_args.push_back(VectorTy_4);
-FunctionType* FuncTy_6 = FunctionType::get(
- /*Result=*/VectorTy_4,
- /*Params=*/FuncTy_6_args,
- /*isVarArg=*/false);
-
-VectorType* VectorTy_7 = VectorType::get(IntegerType::get(32), 4);
-
-std::vector<const Type*>FuncTy_9_args;
-FunctionType* FuncTy_9 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_9_args,
- /*isVarArg=*/true);
-
-PointerType* PointerTy_8 = PointerType::get(FuncTy_9, 0);
-
-PointerType* PointerTy_10 = PointerType::get(IntegerType::get(8), 0);
-
-std::vector<const Type*>FuncTy_12_args;
-FuncTy_12_args.push_back(Type::FloatTy);
-FunctionType* FuncTy_12 = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/FuncTy_12_args,
- /*isVarArg=*/false);
-
-PointerType* PointerTy_11 = PointerType::get(FuncTy_12, 0);
-
-std::vector<const Type*>FuncTy_13_args;
-FuncTy_13_args.push_back(VectorTy_4);
-FunctionType* FuncTy_13 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_13_args,
- /*isVarArg=*/false);
-
-
-// Function Declarations
-
-Function* func_approx = new Function(
- /*Type=*/FuncTy_2,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"approx", mod);
-func_approx->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_approx_PAL = 0;
-func_approx->setParamAttrs(func_approx_PAL);
-
-Function* func_powf = new Function(
- /*Type=*/FuncTy_2,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"powf", mod); // (external, no body)
-func_powf->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_powf_PAL = 0;
-func_powf->setParamAttrs(func_powf_PAL);
-
-Function* func_lit = new Function(
- /*Type=*/FuncTy_5,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"lit", mod);
-func_lit->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_lit_PAL = 0;
-func_lit->setParamAttrs(func_lit_PAL);
-
-Function* func_cmp = new Function(
- /*Type=*/FuncTy_6,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"cmp", mod);
-func_cmp->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_cmp_PAL = 0;
-{
- ParamAttrsVector Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind;
- Attrs.push_back(PAWI);
- func_cmp_PAL = ParamAttrsList::get(Attrs);
-
-}
-func_cmp->setParamAttrs(func_cmp_PAL);
-
-Function* func_vcos = new Function(
- /*Type=*/FuncTy_5,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"vcos", mod);
-func_vcos->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_vcos_PAL = 0;
-func_vcos->setParamAttrs(func_vcos_PAL);
-
-Function* func_printf = new Function(
- /*Type=*/FuncTy_9,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"printf", mod); // (external, no body)
-func_printf->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_printf_PAL = 0;
-func_printf->setParamAttrs(func_printf_PAL);
-
-Function* func_cosf = new Function(
- /*Type=*/FuncTy_12,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"cosf", mod); // (external, no body)
-func_cosf->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_cosf_PAL = 0;
-func_cosf->setParamAttrs(func_cosf_PAL);
-
-Function* func_scs = new Function(
- /*Type=*/FuncTy_5,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"scs", mod);
-func_scs->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_scs_PAL = 0;
-func_scs->setParamAttrs(func_scs_PAL);
-
-Function* func_sinf = new Function(
- /*Type=*/FuncTy_12,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"sinf", mod); // (external, no body)
-func_sinf->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_sinf_PAL = 0;
-func_sinf->setParamAttrs(func_sinf_PAL);
-
-Function* func_vsin = new Function(
- /*Type=*/FuncTy_5,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"vsin", mod);
-func_vsin->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_vsin_PAL = 0;
-func_vsin->setParamAttrs(func_vsin_PAL);
-
-Function* func_kilp = new Function(
- /*Type=*/FuncTy_13,
- /*Linkage=*/GlobalValue::WeakLinkage,
- /*Name=*/"kilp", mod);
-func_kilp->setCallingConv(CallingConv::C);
-const ParamAttrsList *func_kilp_PAL = 0;
-{
- ParamAttrsVector Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind;
- Attrs.push_back(PAWI);
- func_kilp_PAL = ParamAttrsList::get(Attrs);
-
-}
-func_kilp->setParamAttrs(func_kilp_PAL);
-
-// Global Variable Declarations
-
-
-GlobalVariable* gvar_array__str = new GlobalVariable(
-/*Type=*/ArrayTy_0,
-/*isConstant=*/true,
-/*Linkage=*/GlobalValue::InternalLinkage,
-/*Initializer=*/0, // has initializer, specified below
-/*Name=*/".str",
-mod);
-
-GlobalVariable* gvar_array__str1 = new GlobalVariable(
-/*Type=*/ArrayTy_0,
-/*isConstant=*/true,
-/*Linkage=*/GlobalValue::InternalLinkage,
-/*Initializer=*/0, // has initializer, specified below
-/*Name=*/".str1",
-mod);
-
-// Constant Definitions
-Constant* const_array_14 = ConstantArray::get("VEC IN is %f %f %f %f\x0A", true);
-Constant* const_array_15 = ConstantArray::get("VEC OUT is %f %f %f %f\x0A", true);
-ConstantFP* const_float_16 = ConstantFP::get(Type::FloatTy, APFloat(-1.280000e+02f));
-ConstantFP* const_float_17 = ConstantFP::get(Type::FloatTy, APFloat(1.280000e+02f));
-Constant* const_float_18 = Constant::getNullValue(Type::FloatTy);
-Constant* const_int32_19 = Constant::getNullValue(IntegerType::get(32));
-std::vector<Constant*> const_packed_20_elems;
-ConstantFP* const_float_21 = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f));
-const_packed_20_elems.push_back(const_float_21);
-UndefValue* const_float_22 = UndefValue::get(Type::FloatTy);
-const_packed_20_elems.push_back(const_float_22);
-const_packed_20_elems.push_back(const_float_22);
-const_packed_20_elems.push_back(const_float_21);
-Constant* const_packed_20 = ConstantVector::get(VectorTy_4, const_packed_20_elems);
-ConstantInt* const_int32_23 = ConstantInt::get(APInt(32, "1", 10));
-ConstantInt* const_int32_24 = ConstantInt::get(APInt(32, "3", 10));
-ConstantInt* const_int32_25 = ConstantInt::get(APInt(32, "2", 10));
-std::vector<Constant*> const_packed_26_elems;
-const_packed_26_elems.push_back(const_float_21);
-const_packed_26_elems.push_back(const_float_18);
-const_packed_26_elems.push_back(const_float_18);
-const_packed_26_elems.push_back(const_float_21);
-Constant* const_packed_26 = ConstantVector::get(VectorTy_4, const_packed_26_elems);
-Constant* const_double_27 = Constant::getNullValue(Type::DoubleTy);
-std::vector<Constant*> const_packed_28_elems;
-const_packed_28_elems.push_back(const_int32_19);
-ConstantInt* const_int32_29 = ConstantInt::get(APInt(32, "5", 10));
-const_packed_28_elems.push_back(const_int32_29);
-const_packed_28_elems.push_back(const_int32_25);
-const_packed_28_elems.push_back(const_int32_24);
-Constant* const_packed_28 = ConstantVector::get(VectorTy_7, const_packed_28_elems);
-std::vector<Constant*> const_packed_30_elems;
-const_packed_30_elems.push_back(const_int32_19);
-const_packed_30_elems.push_back(const_int32_23);
-ConstantInt* const_int32_31 = ConstantInt::get(APInt(32, "6", 10));
-const_packed_30_elems.push_back(const_int32_31);
-const_packed_30_elems.push_back(const_int32_24);
-Constant* const_packed_30 = ConstantVector::get(VectorTy_7, const_packed_30_elems);
-std::vector<Constant*> const_packed_32_elems;
-const_packed_32_elems.push_back(const_int32_19);
-const_packed_32_elems.push_back(const_int32_23);
-const_packed_32_elems.push_back(const_int32_25);
-ConstantInt* const_int32_33 = ConstantInt::get(APInt(32, "7", 10));
-const_packed_32_elems.push_back(const_int32_33);
-Constant* const_packed_32 = ConstantVector::get(VectorTy_7, const_packed_32_elems);
-std::vector<Constant*> const_ptr_34_indices;
-const_ptr_34_indices.push_back(const_int32_19);
-const_ptr_34_indices.push_back(const_int32_19);
-Constant* const_ptr_34 = ConstantExpr::getGetElementPtr(gvar_array__str, &const_ptr_34_indices[0], const_ptr_34_indices.size() );
-UndefValue* const_packed_35 = UndefValue::get(VectorTy_4);
-std::vector<Constant*> const_ptr_36_indices;
-const_ptr_36_indices.push_back(const_int32_19);
-const_ptr_36_indices.push_back(const_int32_19);
-Constant* const_ptr_36 = ConstantExpr::getGetElementPtr(gvar_array__str1, &const_ptr_36_indices[0], const_ptr_36_indices.size() );
-
-// Global Variable Definitions
-gvar_array__str->setInitializer(const_array_14);
-gvar_array__str1->setInitializer(const_array_15);
-
-// Function Definitions
-
-// Function: approx (func_approx)
-{
- Function::arg_iterator args = func_approx->arg_begin();
- Value* float_a = args++;
- float_a->setName("a");
- Value* float_b = args++;
- float_b->setName("b");
-
- BasicBlock* label_entry = new BasicBlock("entry",func_approx,0);
-
- // Block entry (label_entry)
- FCmpInst* int1_cmp = new FCmpInst(FCmpInst::FCMP_OLT, float_b, const_float_16, "cmp", label_entry);
- SelectInst* float_b_addr_0 = new SelectInst(int1_cmp, const_float_16, float_b, "b.addr.0", label_entry);
- FCmpInst* int1_cmp3 = new FCmpInst(FCmpInst::FCMP_OGT, float_b_addr_0, const_float_17, "cmp3", label_entry);
- SelectInst* float_b_addr_1 = new SelectInst(int1_cmp3, const_float_17, float_b_addr_0, "b.addr.1", label_entry);
- FCmpInst* int1_cmp7 = new FCmpInst(FCmpInst::FCMP_OLT, float_a, const_float_18, "cmp7", label_entry);
- SelectInst* float_a_addr_0 = new SelectInst(int1_cmp7, const_float_18, float_a, "a.addr.0", label_entry);
- std::vector<Value*> float_call_params;
- float_call_params.push_back(float_a_addr_0);
- float_call_params.push_back(float_b_addr_1);
- CallInst* float_call = new CallInst(func_powf, float_call_params.begin(), float_call_params.end(), "call", label_entry);
- float_call->setCallingConv(CallingConv::C);
- float_call->setTailCall(true);const ParamAttrsList *float_call_PAL = 0;
- float_call->setParamAttrs(float_call_PAL);
-
- new ReturnInst(float_call, label_entry);
-
-}
-
-// Function: lit (func_lit)
-{
- Function::arg_iterator args = func_lit->arg_begin();
- Value* packed_tmp = args++;
- packed_tmp->setName("tmp");
-
- BasicBlock* label_entry_38 = new BasicBlock("entry",func_lit,0);
- BasicBlock* label_ifthen = new BasicBlock("ifthen",func_lit,0);
- BasicBlock* label_UnifiedReturnBlock = new BasicBlock("UnifiedReturnBlock",func_lit,0);
-
- // Block entry (label_entry_38)
- ExtractElementInst* float_tmp6 = new ExtractElementInst(packed_tmp, const_int32_19, "tmp6", label_entry_38);
- FCmpInst* int1_cmp_39 = new FCmpInst(FCmpInst::FCMP_OGT, float_tmp6, const_float_18, "cmp", label_entry_38);
- new BranchInst(label_ifthen, label_UnifiedReturnBlock, int1_cmp_39, label_entry_38);
-
- // Block ifthen (label_ifthen)
- InsertElementInst* packed_tmp10 = new InsertElementInst(const_packed_20, float_tmp6, const_int32_23, "tmp10", label_ifthen);
- ExtractElementInst* float_tmp12 = new ExtractElementInst(packed_tmp, const_int32_23, "tmp12", label_ifthen);
- ExtractElementInst* float_tmp14 = new ExtractElementInst(packed_tmp, const_int32_24, "tmp14", label_ifthen);
- std::vector<Value*> float_call_41_params;
- float_call_41_params.push_back(float_tmp12);
- float_call_41_params.push_back(float_tmp14);
- CallInst* float_call_41 = new CallInst(func_approx, float_call_41_params.begin(), float_call_41_params.end(), "call", label_ifthen);
- float_call_41->setCallingConv(CallingConv::C);
- float_call_41->setTailCall(true);const ParamAttrsList *float_call_41_PAL = 0;
- float_call_41->setParamAttrs(float_call_41_PAL);
-
- InsertElementInst* packed_tmp16 = new InsertElementInst(packed_tmp10, float_call_41, const_int32_25, "tmp16", label_ifthen);
- new ReturnInst(packed_tmp16, label_ifthen);
-
- // Block UnifiedReturnBlock (label_UnifiedReturnBlock)
- new ReturnInst(const_packed_26, label_UnifiedReturnBlock);
-
-}
-
-// Function: cmp (func_cmp)
-{
- Function::arg_iterator args = func_cmp->arg_begin();
- Value* packed_tmp0 = args++;
- packed_tmp0->setName("tmp0");
- Value* packed_tmp1 = args++;
- packed_tmp1->setName("tmp1");
- Value* packed_tmp2 = args++;
- packed_tmp2->setName("tmp2");
-
- BasicBlock* label_entry_44 = new BasicBlock("entry",func_cmp,0);
- BasicBlock* label_cond__14 = new BasicBlock("cond.?14",func_cmp,0);
- BasicBlock* label_cond_cont20 = new BasicBlock("cond.cont20",func_cmp,0);
- BasicBlock* label_cond__28 = new BasicBlock("cond.?28",func_cmp,0);
- BasicBlock* label_cond_cont34 = new BasicBlock("cond.cont34",func_cmp,0);
- BasicBlock* label_cond__42 = new BasicBlock("cond.?42",func_cmp,0);
- BasicBlock* label_cond_cont48 = new BasicBlock("cond.cont48",func_cmp,0);
-
- // Block entry (label_entry_44)
- ExtractElementInst* float_tmp3 = new ExtractElementInst(packed_tmp0, const_int32_19, "tmp3", label_entry_44);
- CastInst* double_conv = new FPExtInst(float_tmp3, Type::DoubleTy, "conv", label_entry_44);
- FCmpInst* int1_cmp_45 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv, const_double_27, "cmp", label_entry_44);
- ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp0, const_int32_23, "tmp11", label_entry_44);
- CastInst* double_conv12 = new FPExtInst(float_tmp11, Type::DoubleTy, "conv12", label_entry_44);
- FCmpInst* int1_cmp13 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv12, const_double_27, "cmp13", label_entry_44);
- SelectInst* packed_tmp1_tmp2 = new SelectInst(int1_cmp_45, packed_tmp1, packed_tmp2, "tmp1.tmp2", label_entry_44);
- new BranchInst(label_cond__14, label_cond_cont20, int1_cmp13, label_entry_44);
-
- // Block cond.?14 (label_cond__14)
- ShuffleVectorInst* packed_tmp233 = new ShuffleVectorInst(packed_tmp1_tmp2, packed_tmp1, const_packed_28, "tmp233", label_cond__14);
- ExtractElementInst* float_tmp254 = new ExtractElementInst(packed_tmp0, const_int32_25, "tmp254", label_cond__14);
- CastInst* double_conv265 = new FPExtInst(float_tmp254, Type::DoubleTy, "conv265", label_cond__14);
- FCmpInst* int1_cmp276 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv265, const_double_27, "cmp276", label_cond__14);
- new BranchInst(label_cond__28, label_cond_cont34, int1_cmp276, label_cond__14);
-
- // Block cond.cont20 (label_cond_cont20)
- ShuffleVectorInst* packed_tmp23 = new ShuffleVectorInst(packed_tmp1_tmp2, packed_tmp2, const_packed_28, "tmp23", label_cond_cont20);
- ExtractElementInst* float_tmp25 = new ExtractElementInst(packed_tmp0, const_int32_25, "tmp25", label_cond_cont20);
- CastInst* double_conv26 = new FPExtInst(float_tmp25, Type::DoubleTy, "conv26", label_cond_cont20);
- FCmpInst* int1_cmp27 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv26, const_double_27, "cmp27", label_cond_cont20);
- new BranchInst(label_cond__28, label_cond_cont34, int1_cmp27, label_cond_cont20);
-
- // Block cond.?28 (label_cond__28)
- PHINode* packed_tmp23_reg2mem_0 = new PHINode(VectorTy_4, "tmp23.reg2mem.0", label_cond__28);
- packed_tmp23_reg2mem_0->reserveOperandSpace(2);
- packed_tmp23_reg2mem_0->addIncoming(packed_tmp233, label_cond__14);
- packed_tmp23_reg2mem_0->addIncoming(packed_tmp23, label_cond_cont20);
-
- ShuffleVectorInst* packed_tmp378 = new ShuffleVectorInst(packed_tmp23_reg2mem_0, packed_tmp1, const_packed_30, "tmp378", label_cond__28);
- ExtractElementInst* float_tmp399 = new ExtractElementInst(packed_tmp0, const_int32_24, "tmp399", label_cond__28);
- CastInst* double_conv4010 = new FPExtInst(float_tmp399, Type::DoubleTy, "conv4010", label_cond__28);
- FCmpInst* int1_cmp4111 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv4010, const_double_27, "cmp4111", label_cond__28);
- new BranchInst(label_cond__42, label_cond_cont48, int1_cmp4111, label_cond__28);
-
- // Block cond.cont34 (label_cond_cont34)
- PHINode* packed_tmp23_reg2mem_1 = new PHINode(VectorTy_4, "tmp23.reg2mem.1", label_cond_cont34);
- packed_tmp23_reg2mem_1->reserveOperandSpace(2);
- packed_tmp23_reg2mem_1->addIncoming(packed_tmp233, label_cond__14);
- packed_tmp23_reg2mem_1->addIncoming(packed_tmp23, label_cond_cont20);
-
- ShuffleVectorInst* packed_tmp37 = new ShuffleVectorInst(packed_tmp23_reg2mem_1, packed_tmp2, const_packed_30, "tmp37", label_cond_cont34);
- ExtractElementInst* float_tmp39 = new ExtractElementInst(packed_tmp0, const_int32_24, "tmp39", label_cond_cont34);
- CastInst* double_conv40 = new FPExtInst(float_tmp39, Type::DoubleTy, "conv40", label_cond_cont34);
- FCmpInst* int1_cmp41 = new FCmpInst(FCmpInst::FCMP_OLT, double_conv40, const_double_27, "cmp41", label_cond_cont34);
- new BranchInst(label_cond__42, label_cond_cont48, int1_cmp41, label_cond_cont34);
-
- // Block cond.?42 (label_cond__42)
- PHINode* packed_tmp37_reg2mem_0 = new PHINode(VectorTy_4, "tmp37.reg2mem.0", label_cond__42);
- packed_tmp37_reg2mem_0->reserveOperandSpace(2);
- packed_tmp37_reg2mem_0->addIncoming(packed_tmp378, label_cond__28);
- packed_tmp37_reg2mem_0->addIncoming(packed_tmp37, label_cond_cont34);
-
- ShuffleVectorInst* packed_tmp5113 = new ShuffleVectorInst(packed_tmp37_reg2mem_0, packed_tmp1, const_packed_32, "tmp5113", label_cond__42);
- new ReturnInst(packed_tmp5113, label_cond__42);
-
- // Block cond.cont48 (label_cond_cont48)
- PHINode* packed_tmp37_reg2mem_1 = new PHINode(VectorTy_4, "tmp37.reg2mem.1", label_cond_cont48);
- packed_tmp37_reg2mem_1->reserveOperandSpace(2);
- packed_tmp37_reg2mem_1->addIncoming(packed_tmp378, label_cond__28);
- packed_tmp37_reg2mem_1->addIncoming(packed_tmp37, label_cond_cont34);
-
- ShuffleVectorInst* packed_tmp51 = new ShuffleVectorInst(packed_tmp37_reg2mem_1, packed_tmp2, const_packed_32, "tmp51", label_cond_cont48);
- new ReturnInst(packed_tmp51, label_cond_cont48);
-
-}
-
-// Function: vcos (func_vcos)
-{
- Function::arg_iterator args = func_vcos->arg_begin();
- Value* packed_val = args++;
- packed_val->setName("val");
-
- BasicBlock* label_entry_53 = new BasicBlock("entry",func_vcos,0);
-
- // Block entry (label_entry_53)
- ExtractElementInst* float_tmp1 = new ExtractElementInst(packed_val, const_int32_19, "tmp1", label_entry_53);
- CastInst* double_conv_54 = new FPExtInst(float_tmp1, Type::DoubleTy, "conv", label_entry_53);
- ExtractElementInst* float_tmp3_55 = new ExtractElementInst(packed_val, const_int32_23, "tmp3", label_entry_53);
- CastInst* double_conv4 = new FPExtInst(float_tmp3_55, Type::DoubleTy, "conv4", label_entry_53);
- ExtractElementInst* float_tmp6_56 = new ExtractElementInst(packed_val, const_int32_25, "tmp6", label_entry_53);
- CastInst* double_conv7 = new FPExtInst(float_tmp6_56, Type::DoubleTy, "conv7", label_entry_53);
- ExtractElementInst* float_tmp9 = new ExtractElementInst(packed_val, const_int32_24, "tmp9", label_entry_53);
- CastInst* double_conv10 = new FPExtInst(float_tmp9, Type::DoubleTy, "conv10", label_entry_53);
- std::vector<Value*> int32_call_params;
- int32_call_params.push_back(const_ptr_34);
- int32_call_params.push_back(double_conv_54);
- int32_call_params.push_back(double_conv4);
- int32_call_params.push_back(double_conv7);
- int32_call_params.push_back(double_conv10);
- CallInst* int32_call = new CallInst(func_printf, int32_call_params.begin(), int32_call_params.end(), "call", label_entry_53);
- int32_call->setCallingConv(CallingConv::C);
- int32_call->setTailCall(true);const ParamAttrsList *int32_call_PAL = 0;
- int32_call->setParamAttrs(int32_call_PAL);
-
- CallInst* float_call13 = new CallInst(func_cosf, float_tmp1, "call13", label_entry_53);
- float_call13->setCallingConv(CallingConv::C);
- float_call13->setTailCall(true);const ParamAttrsList *float_call13_PAL = 0;
- float_call13->setParamAttrs(float_call13_PAL);
-
- InsertElementInst* packed_tmp15 = new InsertElementInst(const_packed_35, float_call13, const_int32_19, "tmp15", label_entry_53);
- CallInst* float_call18 = new CallInst(func_cosf, float_tmp1, "call18", label_entry_53);
- float_call18->setCallingConv(CallingConv::C);
- float_call18->setTailCall(true);const ParamAttrsList *float_call18_PAL = 0;
- float_call18->setParamAttrs(float_call18_PAL);
-
- InsertElementInst* packed_tmp20 = new InsertElementInst(packed_tmp15, float_call18, const_int32_23, "tmp20", label_entry_53);
- CallInst* float_call23 = new CallInst(func_cosf, float_tmp1, "call23", label_entry_53);
- float_call23->setCallingConv(CallingConv::C);
- float_call23->setTailCall(true);const ParamAttrsList *float_call23_PAL = 0;
- float_call23->setParamAttrs(float_call23_PAL);
-
- InsertElementInst* packed_tmp25 = new InsertElementInst(packed_tmp20, float_call23, const_int32_25, "tmp25", label_entry_53);
- CallInst* float_call28 = new CallInst(func_cosf, float_tmp1, "call28", label_entry_53);
- float_call28->setCallingConv(CallingConv::C);
- float_call28->setTailCall(true);const ParamAttrsList *float_call28_PAL = 0;
- float_call28->setParamAttrs(float_call28_PAL);
-
- InsertElementInst* packed_tmp30 = new InsertElementInst(packed_tmp25, float_call28, const_int32_24, "tmp30", label_entry_53);
- CastInst* double_conv33 = new FPExtInst(float_call13, Type::DoubleTy, "conv33", label_entry_53);
- CastInst* double_conv36 = new FPExtInst(float_call18, Type::DoubleTy, "conv36", label_entry_53);
- CastInst* double_conv39 = new FPExtInst(float_call23, Type::DoubleTy, "conv39", label_entry_53);
- CastInst* double_conv42 = new FPExtInst(float_call28, Type::DoubleTy, "conv42", label_entry_53);
- std::vector<Value*> int32_call43_params;
- int32_call43_params.push_back(const_ptr_36);
- int32_call43_params.push_back(double_conv33);
- int32_call43_params.push_back(double_conv36);
- int32_call43_params.push_back(double_conv39);
- int32_call43_params.push_back(double_conv42);
- CallInst* int32_call43 = new CallInst(func_printf, int32_call43_params.begin(), int32_call43_params.end(), "call43", label_entry_53);
- int32_call43->setCallingConv(CallingConv::C);
- int32_call43->setTailCall(true);const ParamAttrsList *int32_call43_PAL = 0;
- int32_call43->setParamAttrs(int32_call43_PAL);
-
- new ReturnInst(packed_tmp30, label_entry_53);
-
-}
-
-// Function: scs (func_scs)
-{
- Function::arg_iterator args = func_scs->arg_begin();
- Value* packed_val_58 = args++;
- packed_val_58->setName("val");
-
- BasicBlock* label_entry_59 = new BasicBlock("entry",func_scs,0);
-
- // Block entry (label_entry_59)
- ExtractElementInst* float_tmp2 = new ExtractElementInst(packed_val_58, const_int32_19, "tmp2", label_entry_59);
- CallInst* float_call_60 = new CallInst(func_cosf, float_tmp2, "call", label_entry_59);
- float_call_60->setCallingConv(CallingConv::C);
- float_call_60->setTailCall(true);const ParamAttrsList *float_call_60_PAL = 0;
- float_call_60->setParamAttrs(float_call_60_PAL);
-
- InsertElementInst* packed_tmp5 = new InsertElementInst(const_packed_35, float_call_60, const_int32_19, "tmp5", label_entry_59);
- CallInst* float_call7 = new CallInst(func_sinf, float_tmp2, "call7", label_entry_59);
- float_call7->setCallingConv(CallingConv::C);
- float_call7->setTailCall(true);const ParamAttrsList *float_call7_PAL = 0;
- float_call7->setParamAttrs(float_call7_PAL);
-
- InsertElementInst* packed_tmp9 = new InsertElementInst(packed_tmp5, float_call7, const_int32_23, "tmp9", label_entry_59);
- new ReturnInst(packed_tmp9, label_entry_59);
-
-}
-
-// Function: vsin (func_vsin)
-{
- Function::arg_iterator args = func_vsin->arg_begin();
- Value* packed_val_62 = args++;
- packed_val_62->setName("val");
-
- BasicBlock* label_entry_63 = new BasicBlock("entry",func_vsin,0);
-
- // Block entry (label_entry_63)
- ExtractElementInst* float_tmp2_64 = new ExtractElementInst(packed_val_62, const_int32_19, "tmp2", label_entry_63);
- CallInst* float_call_65 = new CallInst(func_sinf, float_tmp2_64, "call", label_entry_63);
- float_call_65->setCallingConv(CallingConv::C);
- float_call_65->setTailCall(true);const ParamAttrsList *float_call_65_PAL = 0;
- float_call_65->setParamAttrs(float_call_65_PAL);
-
- InsertElementInst* packed_tmp6 = new InsertElementInst(const_packed_35, float_call_65, const_int32_19, "tmp6", label_entry_63);
- InsertElementInst* packed_tmp9_66 = new InsertElementInst(packed_tmp6, float_call_65, const_int32_23, "tmp9", label_entry_63);
- InsertElementInst* packed_tmp12 = new InsertElementInst(packed_tmp9_66, float_call_65, const_int32_25, "tmp12", label_entry_63);
- InsertElementInst* packed_tmp15_67 = new InsertElementInst(packed_tmp12, float_call_65, const_int32_24, "tmp15", label_entry_63);
- new ReturnInst(packed_tmp15_67, label_entry_63);
-
-}
-
-// Function: kilp (func_kilp)
-{
- Function::arg_iterator args = func_kilp->arg_begin();
- Value* packed_val_69 = args++;
- packed_val_69->setName("val");
-
- BasicBlock* label_entry_70 = new BasicBlock("entry",func_kilp,0);
- BasicBlock* label_lor_rhs = new BasicBlock("lor_rhs",func_kilp,0);
- BasicBlock* label_lor_rhs5 = new BasicBlock("lor_rhs5",func_kilp,0);
- BasicBlock* label_lor_rhs11 = new BasicBlock("lor_rhs11",func_kilp,0);
- BasicBlock* label_UnifiedReturnBlock_71 = new BasicBlock("UnifiedReturnBlock",func_kilp,0);
-
- // Block entry (label_entry_70)
- ExtractElementInst* float_tmp1_72 = new ExtractElementInst(packed_val_69, const_int32_19, "tmp1", label_entry_70);
- FCmpInst* int1_cmp_73 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp1_72, const_float_18, "cmp", label_entry_70);
- new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs, int1_cmp_73, label_entry_70);
-
- // Block lor_rhs (label_lor_rhs)
- ExtractElementInst* float_tmp3_75 = new ExtractElementInst(packed_val_69, const_int32_23, "tmp3", label_lor_rhs);
- FCmpInst* int1_cmp4 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp3_75, const_float_18, "cmp4", label_lor_rhs);
- new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs5, int1_cmp4, label_lor_rhs);
-
- // Block lor_rhs5 (label_lor_rhs5)
- ExtractElementInst* float_tmp7 = new ExtractElementInst(packed_val_69, const_int32_25, "tmp7", label_lor_rhs5);
- FCmpInst* int1_cmp8 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp7, const_float_18, "cmp8", label_lor_rhs5);
- new BranchInst(label_UnifiedReturnBlock_71, label_lor_rhs11, int1_cmp8, label_lor_rhs5);
-
- // Block lor_rhs11 (label_lor_rhs11)
- ExtractElementInst* float_tmp13 = new ExtractElementInst(packed_val_69, const_int32_24, "tmp13", label_lor_rhs11);
- FCmpInst* int1_cmp14 = new FCmpInst(FCmpInst::FCMP_OLT, float_tmp13, const_float_18, "cmp14", label_lor_rhs11);
- CastInst* int32_retval = new ZExtInst(int1_cmp14, IntegerType::get(32), "retval", label_lor_rhs11);
- new ReturnInst(int32_retval, label_lor_rhs11);
-
- // Block UnifiedReturnBlock (label_UnifiedReturnBlock_71)
- new ReturnInst(const_int32_23, label_UnifiedReturnBlock_71);
-
-}
-
-return mod;
-
-}
diff --git a/src/mesa/pipe/llvm/gallivm_cpu.cpp b/src/mesa/pipe/llvm/gallivm_cpu.cpp
deleted file mode 100644
index dc4d92a72a..0000000000
--- a/src/mesa/pipe/llvm/gallivm_cpu.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-#ifdef MESA_LLVM
-
-#include "gallivm.h"
-#include "gallivm_p.h"
-
-#include "instructions.h"
-#include "loweringpass.h"
-#include "storage.h"
-#include "tgsitollvm.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_shader_tokens.h"
-
-#include "pipe/tgsi/exec/tgsi_exec.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-
-#include <llvm/Module.h>
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/Pass.h>
-#include <llvm/PassManager.h>
-#include <llvm/ParameterAttributes.h>
-#include <llvm/Support/PatternMatch.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/Interpreter.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/Support/MemoryBuffer.h>
-#include <llvm/LinkAllPasses.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Analysis/LoopPass.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/Transforms/Utils/Cloning.h>
-
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-struct gallivm_cpu_engine {
- llvm::ExecutionEngine *engine;
-};
-
-static struct gallivm_cpu_engine *CPU = 0;
-
-typedef int (*fragment_shader_runner)(float x, float y,
- float (*dests)[16][4],
- float (*inputs)[16][4],
- int num_attribs,
- float (*consts)[4], int num_consts,
- struct tgsi_sampler *samplers);
-
-int gallivm_cpu_fs_exec(struct gallivm_prog *prog,
- float fx, float fy,
- float (*dests)[16][4],
- float (*inputs)[16][4],
- float (*consts)[4],
- struct tgsi_sampler *samplers)
-{
- fragment_shader_runner runner = reinterpret_cast<fragment_shader_runner>(prog->function);
- assert(runner);
-
- return runner(fx, fy, dests, inputs, prog->num_interp,
- consts, prog->num_consts,
- samplers);
-}
-
-static inline llvm::Function *func_for_shader(struct gallivm_prog *prog)
-{
- llvm::Module *mod = prog->module;
- llvm::Function *func = 0;
-
- switch (prog->type) {
- case GALLIVM_VS:
- func = mod->getFunction("vs_shader");
- break;
- case GALLIVM_FS:
- func = mod->getFunction("fs_shader");
- break;
- default:
- assert(!"Unknown shader type!");
- break;
- }
- return func;
-}
-
-/*!
- This function creates a CPU based execution engine for the given gallivm_prog.
- gallivm_cpu_engine should be used as a singleton throughout the library. Before
- executing gallivm_prog_exec one needs to call gallivm_cpu_jit_compile.
- The gallivm_prog instance which is being passed to the constructor is being
- automatically JIT compiled so one shouldn't call gallivm_cpu_jit_compile
- with it again.
- */
-struct gallivm_cpu_engine * gallivm_cpu_engine_create(struct gallivm_prog *prog)
-{
- struct gallivm_cpu_engine *cpu = (struct gallivm_cpu_engine *)
- calloc(1, sizeof(struct gallivm_cpu_engine));
- llvm::Module *mod = static_cast<llvm::Module*>(prog->module);
- llvm::ExistingModuleProvider *mp = new llvm::ExistingModuleProvider(mod);
- llvm::ExecutionEngine *ee = llvm::ExecutionEngine::create(mp, false);
- ee->DisableLazyCompilation();
- cpu->engine = ee;
-
- llvm::Function *func = func_for_shader(prog);
-
- prog->function = ee->getPointerToFunction(func);
- CPU = cpu;
- return cpu;
-}
-
-
-/*!
- This function JIT compiles the given gallivm_prog with the given cpu based execution engine.
- The reference to the generated machine code entry point will be stored
- in the gallivm_prog program. After executing this function one can call gallivm_prog_exec
- in order to execute the gallivm_prog on the CPU.
- */
-void gallivm_cpu_jit_compile(struct gallivm_cpu_engine *cpu, struct gallivm_prog *prog)
-{
- llvm::Module *mod = static_cast<llvm::Module*>(prog->module);
- llvm::ExistingModuleProvider *mp = new llvm::ExistingModuleProvider(mod);
- llvm::ExecutionEngine *ee = cpu->engine;
- assert(ee);
- /*FIXME : remove */
- ee->DisableLazyCompilation();
- ee->addModuleProvider(mp);
-
- llvm::Function *func = func_for_shader(prog);
- prog->function = ee->getPointerToFunction(func);
-}
-
-void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *cpu)
-{
- free(cpu);
-}
-
-struct gallivm_cpu_engine * gallivm_global_cpu_engine()
-{
- return CPU;
-}
-
-
-typedef void (*vertex_shader_runner)(void *ainputs,
- void *dests,
- float (*aconsts)[4],
- void *temps);
-
-
-/*!
- This function is used to execute the gallivm_prog in software. Before calling
- this function the gallivm_prog has to be JIT compiled with the gallivm_cpu_jit_compile
- function.
- */
-int gallivm_cpu_vs_exec(struct gallivm_prog *prog,
- struct tgsi_exec_vector *inputs,
- struct tgsi_exec_vector *dests,
- float (*consts)[4],
- struct tgsi_exec_vector *temps)
-{
- vertex_shader_runner runner = reinterpret_cast<vertex_shader_runner>(prog->function);
- assert(runner);
- /*FIXME*/
- runner(inputs, dests, consts, temps);
-
- return 0;
-}
-
-#endif
diff --git a/src/mesa/pipe/llvm/gallivm_p.h b/src/mesa/pipe/llvm/gallivm_p.h
deleted file mode 100644
index cfe7b1901b..0000000000
--- a/src/mesa/pipe/llvm/gallivm_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef GALLIVM_P_H
-#define GALLIVM_P_H
-
-#ifdef MESA_LLVM
-
-#include "gallivm.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/p_compiler.h"
-
-namespace llvm {
- class Module;
-}
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-enum gallivm_shader_type;
-enum gallivm_vector_layout;
-
-struct gallivm_interpolate {
- int attrib;
- int chan;
- int type;
-};
-
-struct gallivm_ir {
- llvm::Module *module;
- int id;
- enum gallivm_shader_type type;
- enum gallivm_vector_layout layout;
- int num_components;
- int num_consts;
-
- //FIXME: this might not be enough for some shaders
- struct gallivm_interpolate interpolators[32*4];
- int num_interp;
-};
-
-struct gallivm_prog {
- llvm::Module *module;
- void *function;
-
- int id;
- enum gallivm_shader_type type;
-
- int num_consts;
-
- //FIXME: this might not be enough for some shaders
- struct gallivm_interpolate interpolators[32*4];
- int num_interp;
-};
-
-static INLINE void gallivm_swizzle_components(int swizzle,
- int *xc, int *yc,
- int *zc, int *wc)
-{
- int x = swizzle / 1000; swizzle -= x * 1000;
- int y = swizzle / 100; swizzle -= y * 100;
- int z = swizzle / 10; swizzle -= z * 10;
- int w = swizzle;
-
- if (xc) *xc = x;
- if (yc) *yc = y;
- if (zc) *zc = z;
- if (wc) *wc = w;
-}
-
-static INLINE boolean gallivm_is_swizzle(int swizzle)
-{
- const int NO_SWIZZLE = TGSI_SWIZZLE_X * 1000 + TGSI_SWIZZLE_Y * 100 +
- TGSI_SWIZZLE_Z * 10 + TGSI_SWIZZLE_W;
- return swizzle != NO_SWIZZLE;
-}
-
-static INLINE int gallivm_x_swizzle(int swizzle)
-{
- int x;
- gallivm_swizzle_components(swizzle, &x, 0, 0, 0);
- return x;
-}
-
-static INLINE int gallivm_y_swizzle(int swizzle)
-{
- int y;
- gallivm_swizzle_components(swizzle, 0, &y, 0, 0);
- return y;
-}
-
-static INLINE int gallivm_z_swizzle(int swizzle)
-{
- int z;
- gallivm_swizzle_components(swizzle, 0, 0, &z, 0);
- return z;
-}
-
-static INLINE int gallivm_w_swizzle(int swizzle)
-{
- int w;
- gallivm_swizzle_components(swizzle, 0, 0, 0, &w);
- return w;
-}
-
-#endif /* MESA_LLVM */
-
-#if defined __cplusplus
-} // extern "C"
-#endif
-
-#endif
diff --git a/src/mesa/pipe/llvm/instructions.cpp b/src/mesa/pipe/llvm/instructions.cpp
deleted file mode 100644
index 55d39fa5f1..0000000000
--- a/src/mesa/pipe/llvm/instructions.cpp
+++ /dev/null
@@ -1,889 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-#ifdef MESA_LLVM
-
-#include "instructions.h"
-
-#include "storage.h"
-
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/InstrTypes.h>
-#include <llvm/Instructions.h>
-#include <llvm/ParameterAttributes.h>
-
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-using namespace llvm;
-
-#include "gallivm_builtins.cpp"
-
-static inline std::string createFuncName(int label)
-{
- std::ostringstream stream;
- stream << "function";
- stream << label;
- return stream.str();
-}
-
-Instructions::Instructions(llvm::Module *mod, llvm::Function *func, llvm::BasicBlock *block,
- Storage *storage)
- : m_mod(mod), m_func(func), m_builder(block), m_idx(0),
- m_storage(storage)
-{
- m_floatVecType = VectorType::get(Type::FloatTy, 4);
-
- m_llvmFSqrt = 0;
- m_llvmFAbs = 0;
- m_llvmPow = 0;
- m_llvmFloor = 0;
- m_llvmFlog = 0;
- m_llvmLit = 0;
- m_fmtPtr = 0;
-
- createGallivmBuiltins(m_mod);
-}
-
-llvm::Value * Instructions::add(llvm::Value *in1, llvm::Value *in2)
-{
- return m_builder.CreateAdd(in1, in2, name("add"));
-}
-
-llvm::Value * Instructions::madd(llvm::Value *in1, llvm::Value *in2,
- llvm::Value *in3)
-{
- Value *mulRes = mul(in1, in2);
- return add(mulRes, in3);
-}
-
-llvm::Value * Instructions::mul(llvm::Value *in1, llvm::Value *in2)
-{
- return m_builder.CreateMul(in1, in2, name("mul"));
-}
-
-const char * Instructions::name(const char *prefix)
-{
- ++m_idx;
- snprintf(m_name, 32, "%s%d", prefix, m_idx);
- return m_name;
-}
-
-llvm::Value * Instructions::dp3(llvm::Value *in1, llvm::Value *in2)
-{
- Value *mulRes = mul(in1, in2);
- Value *x = m_builder.CreateExtractElement(mulRes,
- m_storage->constantInt(0),
- name("extractx"));
- Value *y = m_builder.CreateExtractElement(mulRes,
- m_storage->constantInt(1),
- name("extracty"));
- Value *z = m_builder.CreateExtractElement(mulRes,
- m_storage->constantInt(2),
- name("extractz"));
- Value *xy = m_builder.CreateAdd(x, y,name("xy"));
- Value *dot3 = m_builder.CreateAdd(xy, z, name("dot3"));
- return vectorFromVals(dot3, dot3, dot3, dot3);
-}
-
-llvm::Value *Instructions::callFSqrt(llvm::Value *val)
-{
- if (!m_llvmFSqrt) {
- // predeclare the intrinsic
- std::vector<const Type*> fsqrtArgs;
- fsqrtArgs.push_back(Type::FloatTy);
- ParamAttrsList *fsqrtPal = 0;
- FunctionType* fsqrtType = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/fsqrtArgs,
- /*isVarArg=*/false);
- m_llvmFSqrt = new Function(
- /*Type=*/fsqrtType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.sqrt.f32", m_mod);
- m_llvmFSqrt->setCallingConv(CallingConv::C);
- m_llvmFSqrt->setParamAttrs(fsqrtPal);
- }
- CallInst *call = m_builder.CreateCall(m_llvmFSqrt, val,
- name("sqrt"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::rsq(llvm::Value *in1)
-{
- Value *x = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(0),
- name("extractx"));
- Value *abs = callFAbs(x);
- Value *sqrt = callFSqrt(abs);
-
- Value *rsqrt = m_builder.CreateFDiv(ConstantFP::get(Type::FloatTy,
- APFloat(1.f)),
- sqrt,
- name("rsqrt"));
- return vectorFromVals(rsqrt, rsqrt, rsqrt, rsqrt);
-}
-
-llvm::Value * Instructions::vectorFromVals(llvm::Value *x, llvm::Value *y,
- llvm::Value *z, llvm::Value *w)
-{
- Constant *const_vec = Constant::getNullValue(m_floatVecType);
- Value *res = m_builder.CreateInsertElement(const_vec, x,
- m_storage->constantInt(0),
- name("vecx"));
- res = m_builder.CreateInsertElement(res, y, m_storage->constantInt(1),
- name("vecxy"));
- res = m_builder.CreateInsertElement(res, z, m_storage->constantInt(2),
- name("vecxyz"));
- if (w)
- res = m_builder.CreateInsertElement(res, w, m_storage->constantInt(3),
- name("vecxyzw"));
- return res;
-}
-
-llvm::Value *Instructions::callFAbs(llvm::Value *val)
-{
- if (!m_llvmFAbs) {
- // predeclare the intrinsic
- std::vector<const Type*> fabsArgs;
- fabsArgs.push_back(Type::FloatTy);
- ParamAttrsList *fabsPal = 0;
- FunctionType* fabsType = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/fabsArgs,
- /*isVarArg=*/false);
- m_llvmFAbs = new Function(
- /*Type=*/fabsType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"fabs", m_mod);
- m_llvmFAbs->setCallingConv(CallingConv::C);
- m_llvmFAbs->setParamAttrs(fabsPal);
- }
- CallInst *call = m_builder.CreateCall(m_llvmFAbs, val,
- name("fabs"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::lit(llvm::Value *in)
-{
- if (!m_llvmLit) {
- m_llvmLit = m_mod->getFunction("lit");
- }
- CallInst *call = m_builder.CreateCall(m_llvmLit, in, name("litres"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::sub(llvm::Value *in1, llvm::Value *in2)
-{
- Value *res = m_builder.CreateSub(in1, in2, name("sub"));
- return res;
-}
-
-llvm::Value * Instructions::callPow(llvm::Value *val1, llvm::Value *val2)
-{
- if (!m_llvmPow) {
- // predeclare the intrinsic
- std::vector<const Type*> powArgs;
- powArgs.push_back(Type::FloatTy);
- powArgs.push_back(Type::FloatTy);
- ParamAttrsList *powPal = 0;
- FunctionType* powType = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/powArgs,
- /*isVarArg=*/false);
- m_llvmPow = new Function(
- /*Type=*/powType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"llvm.pow.f32", m_mod);
- m_llvmPow->setCallingConv(CallingConv::C);
- m_llvmPow->setParamAttrs(powPal);
- }
- std::vector<Value*> params;
- params.push_back(val1);
- params.push_back(val2);
- CallInst *call = m_builder.CreateCall(m_llvmPow, params.begin(), params.end(),
- name("pow"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::pow(llvm::Value *in1, llvm::Value *in2)
-{
- Value *x1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(0),
- name("x1"));
- Value *x2 = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(0),
- name("x2"));
- llvm::Value *val = callPow(x1, x2);
- return vectorFromVals(val, val, val, val);
-}
-
-llvm::Value * Instructions::rcp(llvm::Value *in1)
-{
- Value *x1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(0),
- name("x1"));
- Value *res = m_builder.CreateFDiv(ConstantFP::get(Type::FloatTy,
- APFloat(1.f)),
- x1, name("rcp"));
- return vectorFromVals(res, res, res, res);
-}
-
-llvm::Value * Instructions::dp4(llvm::Value *in1, llvm::Value *in2)
-{
- Value *mulRes = mul(in1, in2);
- std::vector<llvm::Value*> vec = extractVector(mulRes);
- Value *xy = m_builder.CreateAdd(vec[0], vec[1], name("xy"));
- Value *xyz = m_builder.CreateAdd(xy, vec[2], name("xyz"));
- Value *dot4 = m_builder.CreateAdd(xyz, vec[3], name("dot4"));
- return vectorFromVals(dot4, dot4, dot4, dot4);
-}
-
-llvm::Value * Instructions::dph(llvm::Value *in1, llvm::Value *in2)
-{
- Value *mulRes = mul(in1, in2);
- std::vector<llvm::Value*> vec1 = extractVector(mulRes);
- Value *xy = m_builder.CreateAdd(vec1[0], vec1[1], name("xy"));
- Value *xyz = m_builder.CreateAdd(xy, vec1[2], name("xyz"));
- Value *dph = m_builder.CreateAdd(xyz, vec1[3], name("dph"));
- return vectorFromVals(dph, dph, dph, dph);
-}
-
-llvm::Value * Instructions::dst(llvm::Value *in1, llvm::Value *in2)
-{
- Value *y1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(1),
- name("y1"));
- Value *z = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(2),
- name("z"));
- Value *y2 = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(1),
- name("y2"));
- Value *w = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(3),
- name("w"));
- Value *ry = m_builder.CreateMul(y1, y2, name("tyuy"));
- return vectorFromVals(ConstantFP::get(Type::FloatTy, APFloat(1.f)),
- ry, z, w);
-}
-
-llvm::Value * Instructions::ex2(llvm::Value *in)
-{
- llvm::Value *val = callPow(ConstantFP::get(Type::FloatTy, APFloat(2.f)),
- m_builder.CreateExtractElement(
- in, m_storage->constantInt(0),
- name("x1")));
- return vectorFromVals(val, val, val, val);
-}
-
-llvm::Value * Instructions::callFloor(llvm::Value *val)
-{
- if (!m_llvmFloor) {
- // predeclare the intrinsic
- std::vector<const Type*> floorArgs;
- floorArgs.push_back(Type::FloatTy);
- ParamAttrsList *floorPal = 0;
- FunctionType* floorType = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/floorArgs,
- /*isVarArg=*/false);
- m_llvmFloor = new Function(
- /*Type=*/floorType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"floorf", m_mod);
- m_llvmFloor->setCallingConv(CallingConv::C);
- m_llvmFloor->setParamAttrs(floorPal);
- }
- CallInst *call = m_builder.CreateCall(m_llvmFloor, val,
- name("floorf"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::floor(llvm::Value *in)
-{
- std::vector<llvm::Value*> vec = extractVector(in);
- return vectorFromVals(callFloor(vec[0]), callFloor(vec[1]),
- callFloor(vec[2]), callFloor(vec[3]));
-}
-
-llvm::Value * Instructions::arl(llvm::Value *in)
-{
- return floor(in);
-}
-
-llvm::Value * Instructions::frc(llvm::Value *in)
-{
- llvm::Value *flr = floor(in);
- return sub(in, flr);
-}
-
-llvm::Value * Instructions::callFLog(llvm::Value *val)
-{
- if (!m_llvmFlog) {
- // predeclare the intrinsic
- std::vector<const Type*> flogArgs;
- flogArgs.push_back(Type::FloatTy);
- ParamAttrsList *flogPal = 0;
- FunctionType* flogType = FunctionType::get(
- /*Result=*/Type::FloatTy,
- /*Params=*/flogArgs,
- /*isVarArg=*/false);
- m_llvmFlog = new Function(
- /*Type=*/flogType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"logf", m_mod);
- m_llvmFlog->setCallingConv(CallingConv::C);
- m_llvmFlog->setParamAttrs(flogPal);
- }
- CallInst *call = m_builder.CreateCall(m_llvmFlog, val,
- name("logf"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::lg2(llvm::Value *in)
-{
- std::vector<llvm::Value*> vec = extractVector(in);
- llvm::Value *const_vec = constVector(1.442695f, 1.442695f,
- 1.442695f, 1.442695f);
- return mul(vectorFromVals(callFLog(vec[0]), callFLog(vec[1]),
- callFLog(vec[2]), callFLog(vec[3])), const_vec);
-}
-
-llvm::Value * Instructions::min(llvm::Value *in1, llvm::Value *in2)
-{
- std::vector<llvm::Value*> vec1 = extractVector(in1);
- std::vector<llvm::Value*> vec2 = extractVector(in2);
-
- Value *xcmp = m_builder.CreateFCmpOLT(vec1[0], vec2[0], name("xcmp"));
- Value *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0],
- name("selx"));
-
- Value *ycmp = m_builder.CreateFCmpOLT(vec1[1], vec2[1], name("ycmp"));
- Value *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1],
- name("sely"));
-
- Value *zcmp = m_builder.CreateFCmpOLT(vec1[2], vec2[2], name("zcmp"));
- Value *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2],
- name("selz"));
-
- Value *wcmp = m_builder.CreateFCmpOLT(vec1[3], vec2[3], name("wcmp"));
- Value *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3],
- name("selw"));
-
- return vectorFromVals(selx, sely, selz, selw);
-}
-
-llvm::Value * Instructions::max(llvm::Value *in1, llvm::Value *in2)
-{
- std::vector<llvm::Value*> vec1 = extractVector(in1);
- std::vector<llvm::Value*> vec2 = extractVector(in2);
-
- Value *xcmp = m_builder.CreateFCmpOGT(vec1[0], vec2[0],
- name("xcmp"));
- Value *selx = m_builder.CreateSelect(xcmp, vec1[0], vec2[0],
- name("selx"));
-
- Value *ycmp = m_builder.CreateFCmpOGT(vec1[1], vec2[1],
- name("ycmp"));
- Value *sely = m_builder.CreateSelect(ycmp, vec1[1], vec2[1],
- name("sely"));
-
- Value *zcmp = m_builder.CreateFCmpOGT(vec1[2], vec2[2],
- name("zcmp"));
- Value *selz = m_builder.CreateSelect(zcmp, vec1[2], vec2[2],
- name("selz"));
-
- Value *wcmp = m_builder.CreateFCmpOGT(vec1[3], vec2[3],
- name("wcmp"));
- Value *selw = m_builder.CreateSelect(wcmp, vec1[3], vec2[3],
- name("selw"));
-
- return vectorFromVals(selx, sely, selz, selw);
-}
-
-void Instructions::printVector(llvm::Value *val)
-{
- static const char *frmt = "Vector is [%f, %f, %f, %f]\x0A";
-
- if (!m_fmtPtr) {
- Constant *format = ConstantArray::get(frmt, true);
- ArrayType *arrayTy = ArrayType::get(IntegerType::get(8), strlen(frmt) + 1);
- GlobalVariable* globalFormat = new GlobalVariable(
- /*Type=*/arrayTy,
- /*isConstant=*/true,
- /*Linkage=*/GlobalValue::InternalLinkage,
- /*Initializer=*/0, // has initializer, specified below
- /*Name=*/name(".str"),
- m_mod);
- globalFormat->setInitializer(format);
-
- Constant* const_int0 = Constant::getNullValue(IntegerType::get(32));
- std::vector<Constant*> const_ptr_21_indices;
- const_ptr_21_indices.push_back(const_int0);
- const_ptr_21_indices.push_back(const_int0);
- m_fmtPtr = ConstantExpr::getGetElementPtr(globalFormat,
- &const_ptr_21_indices[0], const_ptr_21_indices.size());
- }
-
- Function *func_printf = m_mod->getFunction("printf");
- if (!func_printf)
- func_printf = declarePrintf();
- assert(func_printf);
- std::vector<llvm::Value*> vec = extractVector(val);
- Value *dx = m_builder.CreateFPExt(vec[0], Type::DoubleTy, name("dx"));
- Value *dy = m_builder.CreateFPExt(vec[1], Type::DoubleTy, name("dy"));
- Value *dz = m_builder.CreateFPExt(vec[2], Type::DoubleTy, name("dz"));
- Value *dw = m_builder.CreateFPExt(vec[3], Type::DoubleTy, name("dw"));
- std::vector<Value*> params;
- params.push_back(m_fmtPtr);
- params.push_back(dx);
- params.push_back(dy);
- params.push_back(dz);
- params.push_back(dw);
- CallInst *call = m_builder.CreateCall(func_printf, params.begin(), params.end(),
- name("printf"));
- call->setCallingConv(CallingConv::C);
- call->setTailCall(true);
-}
-
-llvm::Function * Instructions::declarePrintf()
-{
- std::vector<const Type*> args;
- ParamAttrsList *params = 0;
- FunctionType* funcTy = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/args,
- /*isVarArg=*/true);
- Function* func_printf = new Function(
- /*Type=*/funcTy,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"printf", m_mod);
- func_printf->setCallingConv(CallingConv::C);
- func_printf->setParamAttrs(params);
- return func_printf;
-}
-
-
-llvm::Value * Instructions::sgt(llvm::Value *in1, llvm::Value *in2)
-{
- Constant *const1f = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f));
- Constant *const0f = Constant::getNullValue(Type::FloatTy);
-
- std::vector<llvm::Value*> vec1 = extractVector(in1);
- std::vector<llvm::Value*> vec2 = extractVector(in2);
- Value *xcmp = m_builder.CreateFCmpOGT(vec1[0], vec2[0], name("xcmp"));
- Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel"));
-
- Value *ycmp = m_builder.CreateFCmpOGT(vec1[1], vec2[1], name("ycmp"));
- Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel"));
-
- Value *zcmp = m_builder.CreateFCmpOGT(vec1[2], vec2[2], name("zcmp"));
- Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel"));
-
- Value *wcmp = m_builder.CreateFCmpOGT(vec1[3], vec2[3], name("wcmp"));
- Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel"));
-
- return vectorFromVals(x, y, z, w);
-}
-llvm::Value * Instructions::sge(llvm::Value *in1, llvm::Value *in2)
-{
- Constant *const1f = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f));
- Constant *const0f = Constant::getNullValue(Type::FloatTy);
-
- std::vector<llvm::Value*> vec1 = extractVector(in1);
- std::vector<llvm::Value*> vec2 = extractVector(in2);
-
- Value *xcmp = m_builder.CreateFCmpOGE(vec1[0], vec2[0], name("xcmp"));
- Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel"));
-
- Value *ycmp = m_builder.CreateFCmpOGE(vec1[1], vec2[1], name("ycmp"));
- Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel"));
-
- Value *zcmp = m_builder.CreateFCmpOGE(vec1[2], vec2[2], name("zcmp"));
- Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel"));
-
- Value *wcmp = m_builder.CreateFCmpOGE(vec1[3], vec2[3], name("wcmp"));
- Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel"));
-
- return vectorFromVals(x, y, z, w);
-}
-
-
-llvm::Value * Instructions::slt(llvm::Value *in1, llvm::Value *in2)
-{
- Constant *const1f = ConstantFP::get(Type::FloatTy, APFloat(1.000000e+00f));
- Constant *const0f = Constant::getNullValue(Type::FloatTy);
-
- std::vector<llvm::Value*> vec1 = extractVector(in1);
- std::vector<llvm::Value*> vec2 = extractVector(in2);
-
- Value *xcmp = m_builder.CreateFCmpOLT(vec1[0], vec2[0], name("xcmp"));
- Value *x = m_builder.CreateSelect(xcmp, const1f, const0f, name("xsel"));
-
- Value *ycmp = m_builder.CreateFCmpOLT(vec1[1], vec2[1], name("ycmp"));
- Value *y = m_builder.CreateSelect(ycmp, const1f, const0f, name("ysel"));
-
- Value *zcmp = m_builder.CreateFCmpOLT(vec1[2], vec2[2], name("zcmp"));
- Value *z = m_builder.CreateSelect(zcmp, const1f, const0f, name("zsel"));
-
- Value *wcmp = m_builder.CreateFCmpOLT(vec1[3], vec2[3], name("wcmp"));
- Value *w = m_builder.CreateSelect(wcmp, const1f, const0f, name("wsel"));
-
- return vectorFromVals(x, y, z, w);
-}
-
-llvm::Value * Instructions::cross(llvm::Value *in1, llvm::Value *in2)
-{
- Value *x1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(0),
- name("x1"));
- Value *y1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(1),
- name("y1"));
- Value *z1 = m_builder.CreateExtractElement(in1,
- m_storage->constantInt(2),
- name("z1"));
-
- Value *x2 = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(0),
- name("x2"));
- Value *y2 = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(1),
- name("y2"));
- Value *z2 = m_builder.CreateExtractElement(in2,
- m_storage->constantInt(2),
- name("z2"));
- Value *y1z2 = mul(y1, z2);
- Value *z1y2 = mul(z1, y2);
-
- Value *z1x2 = mul(z1, x2);
- Value *x1z2 = mul(x1, z2);
-
- Value *x1y2 = mul(x1, y2);
- Value *y1x2 = mul(y1, x2);
-
- return vectorFromVals(sub(y1z2, z1y2), sub(z1x2, x1z2), sub(x1y2, y1x2));
-}
-
-
-llvm::Value * Instructions::abs(llvm::Value *in)
-{
- std::vector<llvm::Value*> vec = extractVector(in);
- Value *xabs = callFAbs(vec[0]);
- Value *yabs = callFAbs(vec[1]);
- Value *zabs = callFAbs(vec[2]);
- Value *wabs = callFAbs(vec[3]);
- return vectorFromVals(xabs, yabs, zabs, wabs);
-}
-
-void Instructions::ifop(llvm::Value *in)
-{
- BasicBlock *ifthen = new BasicBlock(name("ifthen"), m_func,0);
- BasicBlock *ifend = new BasicBlock(name("ifthenend"), m_func,0);
-
- //BasicBlock *yblock = new BasicBlock(name("yblock"), m_func,0);
- //BasicBlock *zblock = new BasicBlock(name("zblock"), m_func,0);
- //BasicBlock *wblock = new BasicBlock(name("wblock"), m_func,0);
-
- Constant *float0 = Constant::getNullValue(Type::FloatTy);
-
- Value *x = m_builder.CreateExtractElement(in, m_storage->constantInt(0),
- name("extractx"));
- Value *xcmp = m_builder.CreateFCmpUNE(x, float0, name("xcmp"));
- m_builder.CreateCondBr(xcmp, ifthen, ifend);
- //m_builder.SetInsertPoint(yblock);
-
- m_builder.SetInsertPoint(ifthen);
- m_ifStack.push(ifend);
-}
-
-llvm::BasicBlock * Instructions::currentBlock() const
-{
- return m_builder.GetInsertBlock();
-}
-
-void Instructions::elseop()
-{
- assert(!m_ifStack.empty());
- BasicBlock *ifend = new BasicBlock(name("ifend"), m_func,0);
- m_builder.CreateBr(ifend);
- m_builder.SetInsertPoint(m_ifStack.top());
- currentBlock()->setName(name("ifelse"));
- m_ifStack.pop();
- m_ifStack.push(ifend);
-}
-
-void Instructions::endif()
-{
- assert(!m_ifStack.empty());
- m_builder.CreateBr(m_ifStack.top());
- m_builder.SetInsertPoint(m_ifStack.top());
- m_ifStack.pop();
-}
-
-llvm::Value * Instructions::lerp(llvm::Value *in1, llvm::Value *in2,
- llvm::Value *in3)
-{
- llvm::Value *m = mul(in1, in2);
- llvm::Value *vec1 = constVector(1.f, 1.f, 1.f, 1.f);
- llvm::Value *s = sub(vec1, in1);
- return add(m, mul(s, in3));
-}
-
-void Instructions::beginLoop()
-{
- BasicBlock *begin = new BasicBlock(name("loop"), m_func,0);
- BasicBlock *end = new BasicBlock(name("endloop"), m_func,0);
-
- m_builder.CreateBr(begin);
- Loop loop;
- loop.begin = begin;
- loop.end = end;
- m_builder.SetInsertPoint(begin);
- m_loopStack.push(loop);
-}
-
-void Instructions::endLoop()
-{
- assert(!m_loopStack.empty());
- Loop loop = m_loopStack.top();
- m_builder.CreateBr(loop.begin);
- loop.end->moveAfter(currentBlock());
- m_builder.SetInsertPoint(loop.end);
- m_loopStack.pop();
-}
-
-void Instructions::brk()
-{
- assert(!m_loopStack.empty());
- BasicBlock *unr = new BasicBlock(name("unreachable"), m_func,0);
- m_builder.CreateBr(m_loopStack.top().end);
- m_builder.SetInsertPoint(unr);
-}
-
-llvm::Value * Instructions::trunc(llvm::Value *in)
-{
- std::vector<llvm::Value*> vec = extractVector(in);
- Value *icastx = m_builder.CreateFPToSI(vec[0], IntegerType::get(32),
- name("ftoix"));
- Value *icasty = m_builder.CreateFPToSI(vec[1], IntegerType::get(32),
- name("ftoiy"));
- Value *icastz = m_builder.CreateFPToSI(vec[2], IntegerType::get(32),
- name("ftoiz"));
- Value *icastw = m_builder.CreateFPToSI(vec[3], IntegerType::get(32),
- name("ftoiw"));
- Value *fx = m_builder.CreateSIToFP(icastx, Type::FloatTy,
- name("fx"));
- Value *fy = m_builder.CreateSIToFP(icasty, Type::FloatTy,
- name("fy"));
- Value *fz = m_builder.CreateSIToFP(icastz, Type::FloatTy,
- name("fz"));
- Value *fw = m_builder.CreateSIToFP(icastw, Type::FloatTy,
- name("fw"));
- return vectorFromVals(fx, fy, fz, fw);
-}
-
-void Instructions::end()
-{
- m_builder.CreateRetVoid();
-}
-
-void Instructions::cal(int label, llvm::Value *input)
-{
- std::vector<Value*> params;
- params.push_back(input);
- llvm::Function *func = findFunction(label);
-
- m_builder.CreateCall(func, params.begin(), params.end());
-}
-
-llvm::Function * Instructions::declareFunc(int label)
-{
- PointerType *vecPtr = PointerType::getUnqual(m_floatVecType);
- std::vector<const Type*> args;
- args.push_back(vecPtr);
- args.push_back(vecPtr);
- args.push_back(vecPtr);
- args.push_back(vecPtr);
- ParamAttrsList *params = 0;
- FunctionType *funcType = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/args,
- /*isVarArg=*/false);
- std::string name = createFuncName(label);
- Function *func = new Function(
- /*Type=*/funcType,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/name.c_str(), m_mod);
- func->setCallingConv(CallingConv::C);
- func->setParamAttrs(params);
- return func;
-}
-
-void Instructions::bgnSub(unsigned label)
-{
- llvm::Function *func = findFunction(label);
-
- Function::arg_iterator args = func->arg_begin();
- Value *ptr_INPUT = args++;
- ptr_INPUT->setName("INPUT");
- m_storage->pushArguments(ptr_INPUT);
-
- llvm::BasicBlock *entry = new BasicBlock("entry", func, 0);
-
- m_func = func;
- m_builder.SetInsertPoint(entry);
-}
-
-void Instructions::endSub()
-{
- m_func = 0;
- m_builder.SetInsertPoint(0);
-}
-
-llvm::Function * Instructions::findFunction(int label)
-{
- llvm::Function *func = m_functions[label];
- if (!func) {
- func = declareFunc(label);
- m_functions[label] = func;
- }
- return func;
-}
-
-llvm::Value * Instructions::constVector(float x, float y, float z, float w)
-{
- std::vector<Constant*> vec(4);
- vec[0] = ConstantFP::get(Type::FloatTy, APFloat(x));
- vec[1] = ConstantFP::get(Type::FloatTy, APFloat(y));
- vec[2] = ConstantFP::get(Type::FloatTy, APFloat(z));
- vec[3] = ConstantFP::get(Type::FloatTy, APFloat(w));
- return ConstantVector::get(m_floatVecType, vec);
-}
-
-
-std::vector<llvm::Value*> Instructions::extractVector(llvm::Value *vec)
-{
- std::vector<llvm::Value*> elems(4);
- elems[0] = m_builder.CreateExtractElement(vec, m_storage->constantInt(0),
- name("x"));
- elems[1] = m_builder.CreateExtractElement(vec, m_storage->constantInt(1),
- name("y"));
- elems[2] = m_builder.CreateExtractElement(vec, m_storage->constantInt(2),
- name("z"));
- elems[3] = m_builder.CreateExtractElement(vec, m_storage->constantInt(3),
- name("w"));
- return elems;
-}
-
-llvm::Value * Instructions::cmp(llvm::Value *in1, llvm::Value *in2, llvm::Value *in3)
-{
- llvm::Function *func = m_mod->getFunction("cmp");
- assert(func);
-
- std::vector<Value*> params;
- params.push_back(in1);
- params.push_back(in2);
- params.push_back(in3);
- CallInst *call = m_builder.CreateCall(func, params.begin(), params.end(), name("cmpres"));
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::cos(llvm::Value *in)
-{
-#if 0
- llvm::Function *func = m_mod->getFunction("vcos");
- assert(func);
-
- CallInst *call = m_builder.CreateCall(func, in, name("cosres"));
- call->setTailCall(false);
- return call;
-#else
- std::vector<llvm::Value*> elems = extractVector(in);
- Function *func = m_mod->getFunction("cosf");
- assert(func);
- CallInst *cos = m_builder.CreateCall(func, elems[0], name("cosres"));
- cos->setCallingConv(CallingConv::C);
- cos->setTailCall(true);
- return vectorFromVals(cos, cos, cos, cos);
-#endif
-}
-
-llvm::Value * Instructions::scs(llvm::Value *in)
-{
- llvm::Function *func = m_mod->getFunction("scs");
- assert(func);
-
- CallInst *call = m_builder.CreateCall(func, in, name("scsres"));
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::kilp(llvm::Value *in)
-{
- llvm::Function *func = m_mod->getFunction("kilp");
- assert(func);
-
- CallInst *call = m_builder.CreateCall(func, in, name("kilpres"));
- call->setTailCall(false);
- return call;
-}
-
-llvm::Value * Instructions::sin(llvm::Value *in)
-{
- llvm::Function *func = m_mod->getFunction("vsin");
- assert(func);
-
- CallInst *call = m_builder.CreateCall(func, in, name("sinres"));
- call->setTailCall(false);
- return call;
-}
-#endif //MESA_LLVM
-
-
diff --git a/src/mesa/pipe/llvm/instructions.h b/src/mesa/pipe/llvm/instructions.h
deleted file mode 100644
index 9ebc17dd8e..0000000000
--- a/src/mesa/pipe/llvm/instructions.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-
-#ifndef INSTRUCTIONS_H
-#define INSTRUCTIONS_H
-
-#include <llvm/BasicBlock.h>
-#include <llvm/Module.h>
-#include <llvm/Value.h>
-#include <llvm/Support/LLVMBuilder.h>
-
-#include <map>
-#include <stack>
-
-namespace llvm {
- class VectorType;
- class Function;
-}
-
-class Storage;
-
-class Instructions
-{
-public:
- Instructions(llvm::Module *mod, llvm::Function *func, llvm::BasicBlock *block,
- Storage *storage);
-
- llvm::BasicBlock *currentBlock() const;
-
- llvm::Value *abs(llvm::Value *in1);
- llvm::Value *arl(llvm::Value *in1);
- llvm::Value *add(llvm::Value *in1, llvm::Value *in2);
- void beginLoop();
- void bgnSub(unsigned);
- void brk();
- void cal(int label, llvm::Value *input);
- llvm::Value *cmp(llvm::Value *in1, llvm::Value *in2, llvm::Value *in3);
- llvm::Value *cos(llvm::Value *in);
- llvm::Value *cross(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *dp3(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *dp4(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *dph(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *dst(llvm::Value *in1, llvm::Value *in2);
- void elseop();
- void endif();
- void endLoop();
- void end();
- void endSub();
- llvm::Value *ex2(llvm::Value *in);
- llvm::Value *floor(llvm::Value *in);
- llvm::Value *frc(llvm::Value *in);
- void ifop(llvm::Value *in);
- llvm::Value *kilp(llvm::Value *in);
- llvm::Value *lerp(llvm::Value *in1, llvm::Value *in2,
- llvm::Value *in3);
- llvm::Value *lit(llvm::Value *in);
- llvm::Value *lg2(llvm::Value *in);
- llvm::Value *madd(llvm::Value *in1, llvm::Value *in2,
- llvm::Value *in2);
- llvm::Value *min(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *max(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *mul(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *pow(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *rcp(llvm::Value *in);
- llvm::Value *rsq(llvm::Value *in);
- llvm::Value *scs(llvm::Value *in);
- llvm::Value *sge(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *sgt(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *sin(llvm::Value *in);
- llvm::Value *slt(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *sub(llvm::Value *in1, llvm::Value *in2);
- llvm::Value *trunc(llvm::Value *in);
-
- void printVector(llvm::Value *val);
-private:
- const char *name(const char *prefix);
-
- llvm::Value *callFAbs(llvm::Value *val);
- llvm::Value *callFloor(llvm::Value *val);
- llvm::Value *callFSqrt(llvm::Value *val);
- llvm::Value *callFLog(llvm::Value *val);
- llvm::Value *callPow(llvm::Value *val1, llvm::Value *val2);
-
- llvm::Value *vectorFromVals(llvm::Value *x, llvm::Value *y,
- llvm::Value *z, llvm::Value *w=0);
-
- llvm::Value *constVector(float x, float y, float z, float w);
-
- llvm::Function *declarePrintf();
- llvm::Function *declareFunc(int label);
-
- llvm::Function *findFunction(int label);
-
- std::vector<llvm::Value*> extractVector(llvm::Value *vec);
-private:
- llvm::Module *m_mod;
- llvm::Function *m_func;
- char m_name[32];
- llvm::LLVMFoldingBuilder m_builder;
- int m_idx;
-
- llvm::VectorType *m_floatVecType;
-
- llvm::Function *m_llvmFSqrt;
- llvm::Function *m_llvmFAbs;
- llvm::Function *m_llvmPow;
- llvm::Function *m_llvmFloor;
- llvm::Function *m_llvmFlog;
- llvm::Function *m_llvmLit;
-
- llvm::Constant *m_fmtPtr;
-
- std::stack<llvm::BasicBlock*> m_ifStack;
- struct Loop {
- llvm::BasicBlock *begin;
- llvm::BasicBlock *end;
- };
- std::stack<Loop> m_loopStack;
- std::map<int, llvm::Function*> m_functions;
- Storage *m_storage;
-};
-
-#endif
diff --git a/src/mesa/pipe/llvm/instructionssoa.cpp b/src/mesa/pipe/llvm/instructionssoa.cpp
deleted file mode 100644
index 0c2032e56f..0000000000
--- a/src/mesa/pipe/llvm/instructionssoa.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-#include "instructionssoa.h"
-
-InstructionsSoa::InstructionsSoa(llvm::Module *mod, llvm::Function *func,
- llvm::BasicBlock *block, StorageSoa *storage)
- : m_builder(block),
- m_idx(0)
-{
-}
-
-std::vector<llvm::Value*> InstructionsSoa::add(const std::vector<llvm::Value*> in1,
- const std::vector<llvm::Value*> in2)
-{
- std::vector<llvm::Value*> res(4);
-
- res[0] = m_builder.CreateAdd(in1[0], in2[0], name("addx"));
- res[1] = m_builder.CreateAdd(in1[1], in2[1], name("addy"));
- res[2] = m_builder.CreateAdd(in1[2], in2[2], name("addz"));
- res[3] = m_builder.CreateAdd(in1[3], in2[3], name("addw"));
-
- return res;
-}
-
-std::vector<llvm::Value*> InstructionsSoa::mul(const std::vector<llvm::Value*> in1,
- const std::vector<llvm::Value*> in2)
-{
- std::vector<llvm::Value*> res(4);
-
- res[0] = m_builder.CreateMul(in1[0], in2[0], name("mulx"));
- res[1] = m_builder.CreateMul(in1[1], in2[1], name("muly"));
- res[2] = m_builder.CreateMul(in1[2], in2[2], name("mulz"));
- res[3] = m_builder.CreateMul(in1[3], in2[3], name("mulw"));
-
- return res;
-}
-
-void InstructionsSoa::end()
-{
- m_builder.CreateRetVoid();
-}
-
-const char * InstructionsSoa::name(const char *prefix) const
-{
- ++m_idx;
- snprintf(m_name, 32, "%s%d", prefix, m_idx);
- return m_name;
-}
diff --git a/src/mesa/pipe/llvm/instructionssoa.h b/src/mesa/pipe/llvm/instructionssoa.h
deleted file mode 100644
index 0195501584..0000000000
--- a/src/mesa/pipe/llvm/instructionssoa.h
+++ /dev/null
@@ -1,66 +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 INSTRUCTIONSSOA_H
-#define INSTRUCTIONSSOA_H
-
-#include <llvm/Support/LLVMBuilder.h>
-
-#include <vector>
-
-namespace llvm {
- class Module;
- class Function;
- class BasicBlock;
- class Value;
-}
-class StorageSoa;
-
-class InstructionsSoa
-{
-public:
- InstructionsSoa(llvm::Module *mod, llvm::Function *func,
- llvm::BasicBlock *block, StorageSoa *storage);
-
- std::vector<llvm::Value*> add(const std::vector<llvm::Value*> in1,
- const std::vector<llvm::Value*> in2);
- std::vector<llvm::Value*> mul(const std::vector<llvm::Value*> in1,
- const std::vector<llvm::Value*> in2);
- void end();
-
-private:
- const char * name(const char *prefix) const;
-private:
- llvm::LLVMFoldingBuilder m_builder;
-
-private:
- mutable int m_idx;
- mutable char m_name[32];
-};
-
-
-#endif
diff --git a/src/mesa/pipe/llvm/llvm_base_shader.cpp b/src/mesa/pipe/llvm/llvm_base_shader.cpp
deleted file mode 100644
index 90a25a440a..0000000000
--- a/src/mesa/pipe/llvm/llvm_base_shader.cpp
+++ /dev/null
@@ -1,833 +0,0 @@
-// Generated by llvm2cpp - DO NOT MODIFY!
-
-
-Module* createBaseShader() {
- // Module Construction
- Module* mod = new Module("Shader");
- mod->setDataLayout("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128");
- mod->setTargetTriple("i686-pc-linux-gnu");
-
- // Type Definitions
- std::vector<const Type*>StructTy_struct_ShaderInput_fields;
- VectorType* VectorTy_1 = VectorType::get(Type::FloatTy, 4);
-
- PointerType* PointerTy_0 = PointerType::get(VectorTy_1, 0);
-
- StructTy_struct_ShaderInput_fields.push_back(PointerTy_0);
- StructTy_struct_ShaderInput_fields.push_back(PointerTy_0);
- StructTy_struct_ShaderInput_fields.push_back(PointerTy_0);
- StructTy_struct_ShaderInput_fields.push_back(PointerTy_0);
- StructTy_struct_ShaderInput_fields.push_back(IntegerType::get(32));
- StructType* StructTy_struct_ShaderInput = StructType::get(StructTy_struct_ShaderInput_fields, /*isPacked=*/false);
- mod->addTypeName("struct.ShaderInput", StructTy_struct_ShaderInput);
-
- OpaqueType* OpaqueTy_struct_pipe_sampler_state = OpaqueType::get();
- mod->addTypeName("struct.pipe_sampler_state", OpaqueTy_struct_pipe_sampler_state);
-
- OpaqueType* OpaqueTy_struct_softpipe_tile_cache = OpaqueType::get();
- mod->addTypeName("struct.softpipe_tile_cache", OpaqueTy_struct_softpipe_tile_cache);
-
- std::vector<const Type*>StructTy_struct_tgsi_sampler_fields;
- PointerType* PointerTy_2 = PointerType::get(OpaqueTy_struct_pipe_sampler_state, 0);
-
- StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_2);
- std::vector<const Type*>FuncTy_4_args;
- PATypeHolder StructTy_struct_tgsi_sampler_fwd = OpaqueType::get();
- PointerType* PointerTy_5 = PointerType::get(StructTy_struct_tgsi_sampler_fwd, 0);
-
- FuncTy_4_args.push_back(PointerTy_5);
- PointerType* PointerTy_6 = PointerType::get(Type::FloatTy, 0);
-
- FuncTy_4_args.push_back(PointerTy_6);
- FuncTy_4_args.push_back(PointerTy_6);
- FuncTy_4_args.push_back(PointerTy_6);
- FuncTy_4_args.push_back(Type::FloatTy);
- ArrayType* ArrayTy_8 = ArrayType::get(Type::FloatTy, 4);
-
- PointerType* PointerTy_7 = PointerType::get(ArrayTy_8, 0);
-
- FuncTy_4_args.push_back(PointerTy_7);
- FunctionType* FuncTy_4 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_4_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_3 = PointerType::get(FuncTy_4, 0);
-
- StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_3);
- PointerType* PointerTy_9 = PointerType::get(IntegerType::get(8), 0);
-
- StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_9);
- PointerType* PointerTy_10 = PointerType::get(OpaqueTy_struct_softpipe_tile_cache, 0);
-
- StructTy_struct_tgsi_sampler_fields.push_back(PointerTy_10);
- StructType* StructTy_struct_tgsi_sampler = StructType::get(StructTy_struct_tgsi_sampler_fields, /*isPacked=*/false);
- mod->addTypeName("struct.tgsi_sampler", StructTy_struct_tgsi_sampler);
- cast<OpaqueType>(StructTy_struct_tgsi_sampler_fwd.get())->refineAbstractTypeTo(StructTy_struct_tgsi_sampler);
- StructTy_struct_tgsi_sampler = cast<StructType>(StructTy_struct_tgsi_sampler_fwd.get());
-
-
- std::vector<const Type*>FuncTy_11_args;
- ArrayType* ArrayTy_13 = ArrayType::get(VectorTy_1, 16);
-
- PointerType* PointerTy_12 = PointerType::get(ArrayTy_13, 0);
-
- FuncTy_11_args.push_back(PointerTy_12);
- ArrayType* ArrayTy_15 = ArrayType::get(ArrayTy_8, 16);
-
- PointerType* PointerTy_14 = PointerType::get(ArrayTy_15, 0);
-
- FuncTy_11_args.push_back(PointerTy_14);
- FuncTy_11_args.push_back(IntegerType::get(32));
- FuncTy_11_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_11 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_11_args,
- /*isVarArg=*/false);
-
- std::vector<const Type*>FuncTy_16_args;
- FuncTy_16_args.push_back(PointerTy_0);
- FuncTy_16_args.push_back(PointerTy_7);
- FuncTy_16_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_16 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_16_args,
- /*isVarArg=*/false);
-
- std::vector<const Type*>FuncTy_17_args;
- FuncTy_17_args.push_back(PointerTy_7);
- FuncTy_17_args.push_back(PointerTy_0);
- FuncTy_17_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_17 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_17_args,
- /*isVarArg=*/false);
-
- std::vector<const Type*>FuncTy_18_args;
- FuncTy_18_args.push_back(PointerTy_9);
- FuncTy_18_args.push_back(PointerTy_9);
- FuncTy_18_args.push_back(PointerTy_7);
- FuncTy_18_args.push_back(IntegerType::get(32));
- FuncTy_18_args.push_back(IntegerType::get(32));
- FuncTy_18_args.push_back(IntegerType::get(32));
- FuncTy_18_args.push_back(IntegerType::get(32));
- FunctionType* FuncTy_18 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_18_args,
- /*isVarArg=*/false);
-
- ArrayType* ArrayTy_20 = ArrayType::get(VectorTy_1, 32);
-
- PointerType* PointerTy_19 = PointerType::get(ArrayTy_20, 0);
-
- ArrayType* ArrayTy_22 = ArrayType::get(VectorTy_1, 128);
-
- PointerType* PointerTy_21 = PointerType::get(ArrayTy_22, 0);
-
- PointerType* PointerTy_23 = PointerType::get(StructTy_struct_ShaderInput, 0);
-
- PointerType* PointerTy_24 = PointerType::get(PointerTy_0, 0);
-
- std::vector<const Type*>FuncTy_26_args;
- FuncTy_26_args.push_back(PointerTy_23);
- FunctionType* FuncTy_26 = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/FuncTy_26_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_25 = PointerType::get(FuncTy_26, 0);
-
- std::vector<const Type*>FuncTy_27_args;
- FuncTy_27_args.push_back(Type::FloatTy);
- FuncTy_27_args.push_back(Type::FloatTy);
- FuncTy_27_args.push_back(PointerTy_12);
- FuncTy_27_args.push_back(PointerTy_12);
- FuncTy_27_args.push_back(IntegerType::get(32));
- FuncTy_27_args.push_back(PointerTy_7);
- FuncTy_27_args.push_back(IntegerType::get(32));
- FuncTy_27_args.push_back(PointerTy_5);
- FunctionType* FuncTy_27 = FunctionType::get(
- /*Result=*/IntegerType::get(32),
- /*Params=*/FuncTy_27_args,
- /*isVarArg=*/false);
-
- PointerType* PointerTy_28 = PointerType::get(IntegerType::get(32), 0);
-
-
- // Function Declarations
-
- Function* func_from_array = new Function(
- /*Type=*/FuncTy_11,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"from_array", mod);
- func_from_array->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_from_array_PAL = 0;
- {
- ParamAttrsVector Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind;
- Attrs.push_back(PAWI);
- func_from_array_PAL = ParamAttrsList::get(Attrs);
-
- }
- func_from_array->setParamAttrs(func_from_array_PAL);
-
- Function* func_from_consts = new Function(
- /*Type=*/FuncTy_16,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"from_consts", mod);
- func_from_consts->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_from_consts_PAL = 0;
- {
- ParamAttrsVector Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind;
- Attrs.push_back(PAWI);
- func_from_consts_PAL = ParamAttrsList::get(Attrs);
-
- }
- func_from_consts->setParamAttrs(func_from_consts_PAL);
-
- Function* func_to_array = new Function(
- /*Type=*/FuncTy_17,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"to_array", mod);
- func_to_array->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_to_array_PAL = 0;
- {
- ParamAttrsVector Attrs;
- ParamAttrsWithIndex PAWI;
- PAWI.index = 0; PAWI.attrs = 0 | ParamAttr::NoUnwind;
- Attrs.push_back(PAWI);
- func_to_array_PAL = ParamAttrsList::get(Attrs);
-
- }
- func_to_array->setParamAttrs(func_to_array_PAL);
-
- Function* func_run_vertex_shader = new Function(
- /*Type=*/FuncTy_18,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"run_vertex_shader", mod);
- func_run_vertex_shader->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_run_vertex_shader_PAL = 0;
- func_run_vertex_shader->setParamAttrs(func_run_vertex_shader_PAL);
-
- Function* func_execute_shader = new Function(
- /*Type=*/FuncTy_26,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"execute_shader", mod); // (external, no body)
- func_execute_shader->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_execute_shader_PAL = 0;
- func_execute_shader->setParamAttrs(func_execute_shader_PAL);
-
- Function* func_run_fragment_shader = new Function(
- /*Type=*/FuncTy_27,
- /*Linkage=*/GlobalValue::ExternalLinkage,
- /*Name=*/"run_fragment_shader", mod);
- func_run_fragment_shader->setCallingConv(CallingConv::C);
- const ParamAttrsList *func_run_fragment_shader_PAL = 0;
- func_run_fragment_shader->setParamAttrs(func_run_fragment_shader_PAL);
-
- // Global Variable Declarations
-
-
- // Constant Definitions
- Constant* const_int32_29 = Constant::getNullValue(IntegerType::get(32));
- ConstantInt* const_int32_30 = ConstantInt::get(APInt(32, "-1", 10));
- ConstantInt* const_int32_31 = ConstantInt::get(APInt(32, "1", 10));
- UndefValue* const_packed_32 = UndefValue::get(VectorTy_1);
- ConstantInt* const_int32_33 = ConstantInt::get(APInt(32, "2", 10));
- ConstantInt* const_int32_34 = ConstantInt::get(APInt(32, "3", 10));
- ConstantInt* const_int32_35 = ConstantInt::get(APInt(32, "4", 10));
-
- // Global Variable Definitions
-
- // Function Definitions
-
- // Function: from_array (func_from_array)
- {
- Function::arg_iterator args = func_from_array->arg_begin();
- Value* ptr_res = args++;
- ptr_res->setName("res");
- Value* ptr_ainputs = args++;
- ptr_ainputs->setName("ainputs");
- Value* int32_count = args++;
- int32_count->setName("count");
- Value* int32_num_attribs = args++;
- int32_num_attribs->setName("num_attribs");
-
- BasicBlock* label_entry = new BasicBlock("entry",func_from_array,0);
- BasicBlock* label_forcond2_preheader_split = new BasicBlock("forcond2.preheader.split",func_from_array,0);
- BasicBlock* label_forcond2 = new BasicBlock("forcond2",func_from_array,0);
- BasicBlock* label_forbody6 = new BasicBlock("forbody6",func_from_array,0);
- BasicBlock* label_forinc57 = new BasicBlock("forinc57",func_from_array,0);
- BasicBlock* label_afterfor60 = new BasicBlock("afterfor60",func_from_array,0);
-
- // Block entry (label_entry)
- ICmpInst* int1_cmp = new ICmpInst(ICmpInst::ICMP_SGT, int32_count, const_int32_29, "cmp", label_entry);
- ICmpInst* int1_cmp5 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs, const_int32_29, "cmp5", label_entry);
- BinaryOperator* int1_bothcond = BinaryOperator::create(Instruction::And, int1_cmp, int1_cmp5, "bothcond", label_entry);
- new BranchInst(label_forcond2_preheader_split, label_afterfor60, int1_bothcond, label_entry);
-
- // Block forcond2.preheader.split (label_forcond2_preheader_split)
- BinaryOperator* int32_tmp21 = BinaryOperator::create(Instruction::Add, int32_count, const_int32_30, "tmp21", label_forcond2_preheader_split);
- ICmpInst* int1_tmp22 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp21, const_int32_29, "tmp22", label_forcond2_preheader_split);
- SelectInst* int32_tmp25 = new SelectInst(int1_tmp22, const_int32_31, int32_count, "tmp25", label_forcond2_preheader_split);
- new BranchInst(label_forcond2, label_forcond2_preheader_split);
-
- // Block forcond2 (label_forcond2)
- Argument* fwdref_38 = new Argument(IntegerType::get(32));
- PHINode* int32_i_0_reg2mem_0 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forcond2);
- int32_i_0_reg2mem_0->reserveOperandSpace(2);
- int32_i_0_reg2mem_0->addIncoming(const_int32_29, label_forcond2_preheader_split);
- int32_i_0_reg2mem_0->addIncoming(fwdref_38, label_forinc57);
-
- Argument* fwdref_39 = new Argument(VectorTy_1);
- PHINode* packed_vec_1_reg2mem_0 = new PHINode(VectorTy_1, "vec.1.reg2mem.0", label_forcond2);
- packed_vec_1_reg2mem_0->reserveOperandSpace(2);
- packed_vec_1_reg2mem_0->addIncoming(const_packed_32, label_forcond2_preheader_split);
- packed_vec_1_reg2mem_0->addIncoming(fwdref_39, label_forinc57);
-
- BinaryOperator* int32_tmp = BinaryOperator::create(Instruction::Add, int32_num_attribs, const_int32_30, "tmp", label_forcond2);
- ICmpInst* int1_tmp18 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp, const_int32_29, "tmp18", label_forcond2);
- SelectInst* int32_tmp19 = new SelectInst(int1_tmp18, const_int32_31, int32_num_attribs, "tmp19", label_forcond2);
- new BranchInst(label_forbody6, label_forcond2);
-
- // Block forbody6 (label_forbody6)
- Argument* fwdref_41 = new Argument(IntegerType::get(32));
- PHINode* int32_j_0_reg2mem_0 = new PHINode(IntegerType::get(32), "j.0.reg2mem.0", label_forbody6);
- int32_j_0_reg2mem_0->reserveOperandSpace(2);
- int32_j_0_reg2mem_0->addIncoming(const_int32_29, label_forcond2);
- int32_j_0_reg2mem_0->addIncoming(fwdref_41, label_forbody6);
-
- PHINode* packed_vec_0_reg2mem_0 = new PHINode(VectorTy_1, "vec.0.reg2mem.0", label_forbody6);
- packed_vec_0_reg2mem_0->reserveOperandSpace(2);
- packed_vec_0_reg2mem_0->addIncoming(packed_vec_1_reg2mem_0, label_forcond2);
- packed_vec_0_reg2mem_0->addIncoming(fwdref_39, label_forbody6);
-
- std::vector<Value*> ptr_arraydecay11_indices;
- ptr_arraydecay11_indices.push_back(int32_i_0_reg2mem_0);
- ptr_arraydecay11_indices.push_back(int32_j_0_reg2mem_0);
- ptr_arraydecay11_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay11 = new GetElementPtrInst(ptr_ainputs, ptr_arraydecay11_indices.begin(), ptr_arraydecay11_indices.end(), "arraydecay11", label_forbody6);
- LoadInst* float_tmp13 = new LoadInst(ptr_arraydecay11, "tmp13", false, label_forbody6);
- InsertElementInst* packed_tmp15 = new InsertElementInst(packed_vec_0_reg2mem_0, float_tmp13, const_int32_29, "tmp15", label_forbody6);
- std::vector<Value*> ptr_arrayidx23_indices;
- ptr_arrayidx23_indices.push_back(int32_i_0_reg2mem_0);
- ptr_arrayidx23_indices.push_back(int32_j_0_reg2mem_0);
- ptr_arrayidx23_indices.push_back(const_int32_31);
- Instruction* ptr_arrayidx23 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx23_indices.begin(), ptr_arrayidx23_indices.end(), "arrayidx23", label_forbody6);
- LoadInst* float_tmp24 = new LoadInst(ptr_arrayidx23, "tmp24", false, label_forbody6);
- InsertElementInst* packed_tmp26 = new InsertElementInst(packed_tmp15, float_tmp24, const_int32_31, "tmp26", label_forbody6);
- std::vector<Value*> ptr_arrayidx34_indices;
- ptr_arrayidx34_indices.push_back(int32_i_0_reg2mem_0);
- ptr_arrayidx34_indices.push_back(int32_j_0_reg2mem_0);
- ptr_arrayidx34_indices.push_back(const_int32_33);
- Instruction* ptr_arrayidx34 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx34_indices.begin(), ptr_arrayidx34_indices.end(), "arrayidx34", label_forbody6);
- LoadInst* float_tmp35 = new LoadInst(ptr_arrayidx34, "tmp35", false, label_forbody6);
- InsertElementInst* packed_tmp37 = new InsertElementInst(packed_tmp26, float_tmp35, const_int32_33, "tmp37", label_forbody6);
- std::vector<Value*> ptr_arrayidx45_indices;
- ptr_arrayidx45_indices.push_back(int32_i_0_reg2mem_0);
- ptr_arrayidx45_indices.push_back(int32_j_0_reg2mem_0);
- ptr_arrayidx45_indices.push_back(const_int32_34);
- Instruction* ptr_arrayidx45 = new GetElementPtrInst(ptr_ainputs, ptr_arrayidx45_indices.begin(), ptr_arrayidx45_indices.end(), "arrayidx45", label_forbody6);
- LoadInst* float_tmp46 = new LoadInst(ptr_arrayidx45, "tmp46", false, label_forbody6);
- InsertElementInst* packed_tmp48 = new InsertElementInst(packed_tmp37, float_tmp46, const_int32_34, "tmp48", label_forbody6);
- std::vector<Value*> ptr_arrayidx54_indices;
- ptr_arrayidx54_indices.push_back(int32_i_0_reg2mem_0);
- ptr_arrayidx54_indices.push_back(int32_j_0_reg2mem_0);
- Instruction* ptr_arrayidx54 = new GetElementPtrInst(ptr_res, ptr_arrayidx54_indices.begin(), ptr_arrayidx54_indices.end(), "arrayidx54", label_forbody6);
- StoreInst* void_42 = new StoreInst(packed_tmp48, ptr_arrayidx54, false, label_forbody6);
- BinaryOperator* int32_indvar_next = BinaryOperator::create(Instruction::Add, int32_j_0_reg2mem_0, const_int32_31, "indvar.next", label_forbody6);
- ICmpInst* int1_exitcond = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next, int32_tmp19, "exitcond", label_forbody6);
- new BranchInst(label_forinc57, label_forbody6, int1_exitcond, label_forbody6);
-
- // Block forinc57 (label_forinc57)
- BinaryOperator* int32_indvar_next20 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0, const_int32_31, "indvar.next20", label_forinc57);
- ICmpInst* int1_exitcond26 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next20, int32_tmp25, "exitcond26", label_forinc57);
- new BranchInst(label_afterfor60, label_forcond2, int1_exitcond26, label_forinc57);
-
- // Block afterfor60 (label_afterfor60)
- new ReturnInst(label_afterfor60);
-
- // Resolve Forward References
- fwdref_39->replaceAllUsesWith(packed_tmp48); delete fwdref_39;
- fwdref_41->replaceAllUsesWith(int32_indvar_next); delete fwdref_41;
- fwdref_38->replaceAllUsesWith(int32_indvar_next20); delete fwdref_38;
-
- }
-
- // Function: from_consts (func_from_consts)
- {
- Function::arg_iterator args = func_from_consts->arg_begin();
- Value* ptr_res_46 = args++;
- ptr_res_46->setName("res");
- Value* ptr_ainputs_47 = args++;
- ptr_ainputs_47->setName("ainputs");
- Value* int32_count_48 = args++;
- int32_count_48->setName("count");
-
- BasicBlock* label_entry_49 = new BasicBlock("entry",func_from_consts,0);
- BasicBlock* label_forbody_preheader = new BasicBlock("forbody.preheader",func_from_consts,0);
- BasicBlock* label_forbody = new BasicBlock("forbody",func_from_consts,0);
- BasicBlock* label_afterfor = new BasicBlock("afterfor",func_from_consts,0);
-
- // Block entry (label_entry_49)
- ICmpInst* int1_cmp_50 = new ICmpInst(ICmpInst::ICMP_SGT, int32_count_48, const_int32_29, "cmp", label_entry_49);
- new BranchInst(label_forbody_preheader, label_afterfor, int1_cmp_50, label_entry_49);
-
- // Block forbody.preheader (label_forbody_preheader)
- BinaryOperator* int32_tmp_52 = BinaryOperator::create(Instruction::Add, int32_count_48, const_int32_30, "tmp", label_forbody_preheader);
- ICmpInst* int1_tmp9 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_52, const_int32_29, "tmp9", label_forbody_preheader);
- SelectInst* int32_tmp10 = new SelectInst(int1_tmp9, const_int32_31, int32_count_48, "tmp10", label_forbody_preheader);
- new BranchInst(label_forbody, label_forbody_preheader);
-
- // Block forbody (label_forbody)
- Argument* fwdref_55 = new Argument(IntegerType::get(32));
- PHINode* int32_i_0_reg2mem_0_54 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody);
- int32_i_0_reg2mem_0_54->reserveOperandSpace(2);
- int32_i_0_reg2mem_0_54->addIncoming(const_int32_29, label_forbody_preheader);
- int32_i_0_reg2mem_0_54->addIncoming(fwdref_55, label_forbody);
-
- Argument* fwdref_57 = new Argument(VectorTy_1);
- PHINode* packed_vec_0_reg2mem_0_56 = new PHINode(VectorTy_1, "vec.0.reg2mem.0", label_forbody);
- packed_vec_0_reg2mem_0_56->reserveOperandSpace(2);
- packed_vec_0_reg2mem_0_56->addIncoming(const_packed_32, label_forbody_preheader);
- packed_vec_0_reg2mem_0_56->addIncoming(fwdref_57, label_forbody);
-
- std::vector<Value*> ptr_arraydecay_indices;
- ptr_arraydecay_indices.push_back(int32_i_0_reg2mem_0_54);
- ptr_arraydecay_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay = new GetElementPtrInst(ptr_ainputs_47, ptr_arraydecay_indices.begin(), ptr_arraydecay_indices.end(), "arraydecay", label_forbody);
- LoadInst* float_tmp5 = new LoadInst(ptr_arraydecay, "tmp5", false, label_forbody);
- InsertElementInst* packed_tmp7 = new InsertElementInst(packed_vec_0_reg2mem_0_56, float_tmp5, const_int32_29, "tmp7", label_forbody);
- std::vector<Value*> ptr_arrayidx12_indices;
- ptr_arrayidx12_indices.push_back(int32_i_0_reg2mem_0_54);
- ptr_arrayidx12_indices.push_back(const_int32_31);
- Instruction* ptr_arrayidx12 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx12_indices.begin(), ptr_arrayidx12_indices.end(), "arrayidx12", label_forbody);
- LoadInst* float_tmp13_58 = new LoadInst(ptr_arrayidx12, "tmp13", false, label_forbody);
- InsertElementInst* packed_tmp15_59 = new InsertElementInst(packed_tmp7, float_tmp13_58, const_int32_31, "tmp15", label_forbody);
- std::vector<Value*> ptr_arrayidx20_indices;
- ptr_arrayidx20_indices.push_back(int32_i_0_reg2mem_0_54);
- ptr_arrayidx20_indices.push_back(const_int32_33);
- Instruction* ptr_arrayidx20 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx20_indices.begin(), ptr_arrayidx20_indices.end(), "arrayidx20", label_forbody);
- LoadInst* float_tmp21 = new LoadInst(ptr_arrayidx20, "tmp21", false, label_forbody);
- InsertElementInst* packed_tmp23 = new InsertElementInst(packed_tmp15_59, float_tmp21, const_int32_33, "tmp23", label_forbody);
- std::vector<Value*> ptr_arrayidx28_indices;
- ptr_arrayidx28_indices.push_back(int32_i_0_reg2mem_0_54);
- ptr_arrayidx28_indices.push_back(const_int32_34);
- Instruction* ptr_arrayidx28 = new GetElementPtrInst(ptr_ainputs_47, ptr_arrayidx28_indices.begin(), ptr_arrayidx28_indices.end(), "arrayidx28", label_forbody);
- LoadInst* float_tmp29 = new LoadInst(ptr_arrayidx28, "tmp29", false, label_forbody);
- InsertElementInst* packed_tmp31 = new InsertElementInst(packed_tmp23, float_tmp29, const_int32_34, "tmp31", label_forbody);
- GetElementPtrInst* ptr_arrayidx34_60 = new GetElementPtrInst(ptr_res_46, int32_i_0_reg2mem_0_54, "arrayidx34", label_forbody);
- StoreInst* void_61 = new StoreInst(packed_tmp31, ptr_arrayidx34_60, false, label_forbody);
- BinaryOperator* int32_indvar_next_62 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_54, const_int32_31, "indvar.next", label_forbody);
- ICmpInst* int1_exitcond_63 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_62, int32_tmp10, "exitcond", label_forbody);
- new BranchInst(label_afterfor, label_forbody, int1_exitcond_63, label_forbody);
-
- // Block afterfor (label_afterfor)
- new ReturnInst(label_afterfor);
-
- // Resolve Forward References
- fwdref_57->replaceAllUsesWith(packed_tmp31); delete fwdref_57;
- fwdref_55->replaceAllUsesWith(int32_indvar_next_62); delete fwdref_55;
-
- }
-
- // Function: to_array (func_to_array)
- {
- Function::arg_iterator args = func_to_array->arg_begin();
- Value* ptr_dests = args++;
- ptr_dests->setName("dests");
- Value* ptr_in = args++;
- ptr_in->setName("in");
- Value* int32_num_attribs_66 = args++;
- int32_num_attribs_66->setName("num_attribs");
-
- BasicBlock* label_entry_67 = new BasicBlock("entry",func_to_array,0);
- BasicBlock* label_forbody_preheader_68 = new BasicBlock("forbody.preheader",func_to_array,0);
- BasicBlock* label_forbody_69 = new BasicBlock("forbody",func_to_array,0);
- BasicBlock* label_afterfor_70 = new BasicBlock("afterfor",func_to_array,0);
-
- // Block entry (label_entry_67)
- ICmpInst* int1_cmp_71 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_attribs_66, const_int32_29, "cmp", label_entry_67);
- new BranchInst(label_forbody_preheader_68, label_afterfor_70, int1_cmp_71, label_entry_67);
-
- // Block forbody.preheader (label_forbody_preheader_68)
- BinaryOperator* int32_tmp_73 = BinaryOperator::create(Instruction::Add, int32_num_attribs_66, const_int32_30, "tmp", label_forbody_preheader_68);
- ICmpInst* int1_tmp9_74 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_73, const_int32_29, "tmp9", label_forbody_preheader_68);
- SelectInst* int32_tmp10_75 = new SelectInst(int1_tmp9_74, const_int32_31, int32_num_attribs_66, "tmp10", label_forbody_preheader_68);
- new BranchInst(label_forbody_69, label_forbody_preheader_68);
-
- // Block forbody (label_forbody_69)
- Argument* fwdref_78 = new Argument(IntegerType::get(32));
- PHINode* int32_i_0_reg2mem_0_77 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0", label_forbody_69);
- int32_i_0_reg2mem_0_77->reserveOperandSpace(2);
- int32_i_0_reg2mem_0_77->addIncoming(const_int32_29, label_forbody_preheader_68);
- int32_i_0_reg2mem_0_77->addIncoming(fwdref_78, label_forbody_69);
-
- std::vector<Value*> ptr_arraydecay_79_indices;
- ptr_arraydecay_79_indices.push_back(int32_i_0_reg2mem_0_77);
- ptr_arraydecay_79_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay_79 = new GetElementPtrInst(ptr_dests, ptr_arraydecay_79_indices.begin(), ptr_arraydecay_79_indices.end(), "arraydecay", label_forbody_69);
- GetElementPtrInst* ptr_arrayidx6 = new GetElementPtrInst(ptr_in, int32_i_0_reg2mem_0_77, "arrayidx6", label_forbody_69);
- LoadInst* packed_tmp7_80 = new LoadInst(ptr_arrayidx6, "tmp7", false, label_forbody_69);
- ExtractElementInst* float_tmp11 = new ExtractElementInst(packed_tmp7_80, const_int32_29, "tmp11", label_forbody_69);
- StoreInst* void_81 = new StoreInst(float_tmp11, ptr_arraydecay_79, false, label_forbody_69);
- std::vector<Value*> ptr_arrayidx13_indices;
- ptr_arrayidx13_indices.push_back(int32_i_0_reg2mem_0_77);
- ptr_arrayidx13_indices.push_back(const_int32_31);
- Instruction* ptr_arrayidx13 = new GetElementPtrInst(ptr_dests, ptr_arrayidx13_indices.begin(), ptr_arrayidx13_indices.end(), "arrayidx13", label_forbody_69);
- ExtractElementInst* float_tmp15 = new ExtractElementInst(packed_tmp7_80, const_int32_31, "tmp15", label_forbody_69);
- StoreInst* void_82 = new StoreInst(float_tmp15, ptr_arrayidx13, false, label_forbody_69);
- std::vector<Value*> ptr_arrayidx17_indices;
- ptr_arrayidx17_indices.push_back(int32_i_0_reg2mem_0_77);
- ptr_arrayidx17_indices.push_back(const_int32_33);
- Instruction* ptr_arrayidx17 = new GetElementPtrInst(ptr_dests, ptr_arrayidx17_indices.begin(), ptr_arrayidx17_indices.end(), "arrayidx17", label_forbody_69);
- ExtractElementInst* float_tmp19 = new ExtractElementInst(packed_tmp7_80, const_int32_33, "tmp19", label_forbody_69);
- StoreInst* void_83 = new StoreInst(float_tmp19, ptr_arrayidx17, false, label_forbody_69);
- std::vector<Value*> ptr_arrayidx21_indices;
- ptr_arrayidx21_indices.push_back(int32_i_0_reg2mem_0_77);
- ptr_arrayidx21_indices.push_back(const_int32_34);
- Instruction* ptr_arrayidx21 = new GetElementPtrInst(ptr_dests, ptr_arrayidx21_indices.begin(), ptr_arrayidx21_indices.end(), "arrayidx21", label_forbody_69);
- ExtractElementInst* float_tmp23 = new ExtractElementInst(packed_tmp7_80, const_int32_34, "tmp23", label_forbody_69);
- StoreInst* void_84 = new StoreInst(float_tmp23, ptr_arrayidx21, false, label_forbody_69);
- BinaryOperator* int32_indvar_next_85 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_77, const_int32_31, "indvar.next", label_forbody_69);
- ICmpInst* int1_exitcond_86 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_85, int32_tmp10_75, "exitcond", label_forbody_69);
- new BranchInst(label_afterfor_70, label_forbody_69, int1_exitcond_86, label_forbody_69);
-
- // Block afterfor (label_afterfor_70)
- new ReturnInst(label_afterfor_70);
-
- // Resolve Forward References
- fwdref_78->replaceAllUsesWith(int32_indvar_next_85); delete fwdref_78;
-
- }
-
- // Function: run_vertex_shader (func_run_vertex_shader)
- {
- Function::arg_iterator args = func_run_vertex_shader->arg_begin();
- Value* ptr_inputs = args++;
- ptr_inputs->setName("inputs");
- Value* ptr_results = args++;
- ptr_results->setName("results");
- Value* ptr_aconsts = args++;
- ptr_aconsts->setName("aconsts");
- Value* int32_num_vertices = args++;
- int32_num_vertices->setName("num_vertices");
- Value* int32_num_inputs = args++;
- int32_num_inputs->setName("num_inputs");
- Value* int32_num_attribs_89 = args++;
- int32_num_attribs_89->setName("num_attribs");
- Value* int32_num_consts = args++;
- int32_num_consts->setName("num_consts");
-
- BasicBlock* label_entry_90 = new BasicBlock("entry",func_run_vertex_shader,0);
- BasicBlock* label_forbody_preheader_i = new BasicBlock("forbody.preheader.i",func_run_vertex_shader,0);
- BasicBlock* label_forbody_i = new BasicBlock("forbody.i",func_run_vertex_shader,0);
- BasicBlock* label_from_consts_exit = new BasicBlock("from_consts.exit",func_run_vertex_shader,0);
-
- // Block entry (label_entry_90)
- AllocaInst* ptr_consts = new AllocaInst(ArrayTy_20, "consts", label_entry_90);
- AllocaInst* ptr_temps = new AllocaInst(ArrayTy_22, "temps", label_entry_90);
- AllocaInst* ptr_args = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_90);
- std::vector<Value*> ptr_tmp_indices;
- ptr_tmp_indices.push_back(const_int32_29);
- ptr_tmp_indices.push_back(const_int32_29);
- Instruction* ptr_tmp = new GetElementPtrInst(ptr_args, ptr_tmp_indices.begin(), ptr_tmp_indices.end(), "tmp", label_entry_90);
- CastInst* ptr_conv = new BitCastInst(ptr_results, PointerTy_0, "conv", label_entry_90);
- StoreInst* void_91 = new StoreInst(ptr_conv, ptr_tmp, false, label_entry_90);
- std::vector<Value*> ptr_tmp2_indices;
- ptr_tmp2_indices.push_back(const_int32_29);
- ptr_tmp2_indices.push_back(const_int32_31);
- Instruction* ptr_tmp2 = new GetElementPtrInst(ptr_args, ptr_tmp2_indices.begin(), ptr_tmp2_indices.end(), "tmp2", label_entry_90);
- CastInst* ptr_conv4 = new BitCastInst(ptr_inputs, PointerTy_0, "conv4", label_entry_90);
- StoreInst* void_92 = new StoreInst(ptr_conv4, ptr_tmp2, false, label_entry_90);
- ICmpInst* int1_cmp_i = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts, const_int32_29, "cmp.i", label_entry_90);
- new BranchInst(label_forbody_preheader_i, label_from_consts_exit, int1_cmp_i, label_entry_90);
-
- // Block forbody.preheader.i (label_forbody_preheader_i)
- BinaryOperator* int32_tmp_i = BinaryOperator::create(Instruction::Add, int32_num_consts, const_int32_30, "tmp.i", label_forbody_preheader_i);
- ICmpInst* int1_tmp9_i = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i, const_int32_29, "tmp9.i", label_forbody_preheader_i);
- SelectInst* int32_tmp10_i = new SelectInst(int1_tmp9_i, const_int32_31, int32_num_consts, "tmp10.i", label_forbody_preheader_i);
- new BranchInst(label_forbody_i, label_forbody_preheader_i);
-
- // Block forbody.i (label_forbody_i)
- Argument* fwdref_95 = new Argument(IntegerType::get(32));
- PHINode* int32_i_0_reg2mem_0_i = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i);
- int32_i_0_reg2mem_0_i->reserveOperandSpace(2);
- int32_i_0_reg2mem_0_i->addIncoming(const_int32_29, label_forbody_preheader_i);
- int32_i_0_reg2mem_0_i->addIncoming(fwdref_95, label_forbody_i);
-
- Argument* fwdref_96 = new Argument(VectorTy_1);
- PHINode* packed_vec_0_reg2mem_0_i = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i);
- packed_vec_0_reg2mem_0_i->reserveOperandSpace(2);
- packed_vec_0_reg2mem_0_i->addIncoming(const_packed_32, label_forbody_preheader_i);
- packed_vec_0_reg2mem_0_i->addIncoming(fwdref_96, label_forbody_i);
-
- std::vector<Value*> ptr_arraydecay_i_indices;
- ptr_arraydecay_i_indices.push_back(int32_i_0_reg2mem_0_i);
- ptr_arraydecay_i_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay_i = new GetElementPtrInst(ptr_aconsts, ptr_arraydecay_i_indices.begin(), ptr_arraydecay_i_indices.end(), "arraydecay.i", label_forbody_i);
- LoadInst* float_tmp5_i = new LoadInst(ptr_arraydecay_i, "tmp5.i", false, label_forbody_i);
- InsertElementInst* packed_tmp7_i = new InsertElementInst(packed_vec_0_reg2mem_0_i, float_tmp5_i, const_int32_29, "tmp7.i", label_forbody_i);
- std::vector<Value*> ptr_arrayidx12_i_indices;
- ptr_arrayidx12_i_indices.push_back(int32_i_0_reg2mem_0_i);
- ptr_arrayidx12_i_indices.push_back(const_int32_31);
- Instruction* ptr_arrayidx12_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx12_i_indices.begin(), ptr_arrayidx12_i_indices.end(), "arrayidx12.i", label_forbody_i);
- LoadInst* float_tmp13_i = new LoadInst(ptr_arrayidx12_i, "tmp13.i", false, label_forbody_i);
- InsertElementInst* packed_tmp15_i = new InsertElementInst(packed_tmp7_i, float_tmp13_i, const_int32_31, "tmp15.i", label_forbody_i);
- std::vector<Value*> ptr_arrayidx20_i_indices;
- ptr_arrayidx20_i_indices.push_back(int32_i_0_reg2mem_0_i);
- ptr_arrayidx20_i_indices.push_back(const_int32_33);
- Instruction* ptr_arrayidx20_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx20_i_indices.begin(), ptr_arrayidx20_i_indices.end(), "arrayidx20.i", label_forbody_i);
- LoadInst* float_tmp21_i = new LoadInst(ptr_arrayidx20_i, "tmp21.i", false, label_forbody_i);
- InsertElementInst* packed_tmp23_i = new InsertElementInst(packed_tmp15_i, float_tmp21_i, const_int32_33, "tmp23.i", label_forbody_i);
- std::vector<Value*> ptr_arrayidx28_i_indices;
- ptr_arrayidx28_i_indices.push_back(int32_i_0_reg2mem_0_i);
- ptr_arrayidx28_i_indices.push_back(const_int32_34);
- Instruction* ptr_arrayidx28_i = new GetElementPtrInst(ptr_aconsts, ptr_arrayidx28_i_indices.begin(), ptr_arrayidx28_i_indices.end(), "arrayidx28.i", label_forbody_i);
- LoadInst* float_tmp29_i = new LoadInst(ptr_arrayidx28_i, "tmp29.i", false, label_forbody_i);
- InsertElementInst* packed_tmp31_i = new InsertElementInst(packed_tmp23_i, float_tmp29_i, const_int32_34, "tmp31.i", label_forbody_i);
- std::vector<Value*> ptr_arrayidx34_i_indices;
- ptr_arrayidx34_i_indices.push_back(const_int32_29);
- ptr_arrayidx34_i_indices.push_back(int32_i_0_reg2mem_0_i);
- Instruction* ptr_arrayidx34_i = new GetElementPtrInst(ptr_consts, ptr_arrayidx34_i_indices.begin(), ptr_arrayidx34_i_indices.end(), "arrayidx34.i", label_forbody_i);
- StoreInst* void_97 = new StoreInst(packed_tmp31_i, ptr_arrayidx34_i, false, label_forbody_i);
- BinaryOperator* int32_indvar_next_98 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i, const_int32_31, "indvar.next", label_forbody_i);
- ICmpInst* int1_exitcond_99 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next_98, int32_tmp10_i, "exitcond", label_forbody_i);
- new BranchInst(label_from_consts_exit, label_forbody_i, int1_exitcond_99, label_forbody_i);
-
- // Block from_consts.exit (label_from_consts_exit)
- std::vector<Value*> ptr_tmp7_indices;
- ptr_tmp7_indices.push_back(const_int32_29);
- ptr_tmp7_indices.push_back(const_int32_34);
- Instruction* ptr_tmp7 = new GetElementPtrInst(ptr_args, ptr_tmp7_indices.begin(), ptr_tmp7_indices.end(), "tmp7", label_from_consts_exit);
- std::vector<Value*> ptr_arraydecay8_indices;
- ptr_arraydecay8_indices.push_back(const_int32_29);
- ptr_arraydecay8_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay8 = new GetElementPtrInst(ptr_consts, ptr_arraydecay8_indices.begin(), ptr_arraydecay8_indices.end(), "arraydecay8", label_from_consts_exit);
- StoreInst* void_101 = new StoreInst(ptr_arraydecay8, ptr_tmp7, false, label_from_consts_exit);
- std::vector<Value*> ptr_tmp9_indices;
- ptr_tmp9_indices.push_back(const_int32_29);
- ptr_tmp9_indices.push_back(const_int32_33);
- Instruction* ptr_tmp9 = new GetElementPtrInst(ptr_args, ptr_tmp9_indices.begin(), ptr_tmp9_indices.end(), "tmp9", label_from_consts_exit);
- std::vector<Value*> ptr_arraydecay10_indices;
- ptr_arraydecay10_indices.push_back(const_int32_29);
- ptr_arraydecay10_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay10 = new GetElementPtrInst(ptr_temps, ptr_arraydecay10_indices.begin(), ptr_arraydecay10_indices.end(), "arraydecay10", label_from_consts_exit);
- StoreInst* void_102 = new StoreInst(ptr_arraydecay10, ptr_tmp9, false, label_from_consts_exit);
- CallInst* void_103 = new CallInst(func_execute_shader, ptr_args, "", label_from_consts_exit);
- void_103->setCallingConv(CallingConv::C);
- void_103->setTailCall(false);const ParamAttrsList *void_103_PAL = 0;
- void_103->setParamAttrs(void_103_PAL);
-
- new ReturnInst(label_from_consts_exit);
-
- // Resolve Forward References
- fwdref_96->replaceAllUsesWith(packed_tmp31_i); delete fwdref_96;
- fwdref_95->replaceAllUsesWith(int32_indvar_next_98); delete fwdref_95;
-
- }
-
- // Function: run_fragment_shader (func_run_fragment_shader)
- {
- Function::arg_iterator args = func_run_fragment_shader->arg_begin();
- Value* float_x = args++;
- float_x->setName("x");
- Value* float_y = args++;
- float_y->setName("y");
- Value* ptr_results_105 = args++;
- ptr_results_105->setName("results");
- Value* ptr_inputs_106 = args++;
- ptr_inputs_106->setName("inputs");
- Value* int32_num_inputs_107 = args++;
- int32_num_inputs_107->setName("num_inputs");
- Value* ptr_aconsts_108 = args++;
- ptr_aconsts_108->setName("aconsts");
- Value* int32_num_consts_109 = args++;
- int32_num_consts_109->setName("num_consts");
- Value* ptr_samplers = args++;
- ptr_samplers->setName("samplers");
-
- BasicBlock* label_entry_110 = new BasicBlock("entry",func_run_fragment_shader,0);
- BasicBlock* label_forbody_preheader_i_111 = new BasicBlock("forbody.preheader.i",func_run_fragment_shader,0);
- BasicBlock* label_forbody_i_112 = new BasicBlock("forbody.i",func_run_fragment_shader,0);
- BasicBlock* label_from_consts_exit_113 = new BasicBlock("from_consts.exit",func_run_fragment_shader,0);
-
- // Block entry (label_entry_110)
- AllocaInst* ptr_consts_114 = new AllocaInst(ArrayTy_20, "consts", label_entry_110);
- AllocaInst* ptr_temps_115 = new AllocaInst(ArrayTy_22, "temps", label_entry_110);
- AllocaInst* ptr_args_116 = new AllocaInst(StructTy_struct_ShaderInput, "args", label_entry_110);
- std::vector<Value*> ptr_tmp_117_indices;
- ptr_tmp_117_indices.push_back(const_int32_29);
- ptr_tmp_117_indices.push_back(const_int32_35);
- Instruction* ptr_tmp_117 = new GetElementPtrInst(ptr_args_116, ptr_tmp_117_indices.begin(), ptr_tmp_117_indices.end(), "tmp", label_entry_110);
- StoreInst* void_118 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_entry_110);
- ICmpInst* int1_cmp_i_119 = new ICmpInst(ICmpInst::ICMP_SGT, int32_num_consts_109, const_int32_29, "cmp.i", label_entry_110);
- new BranchInst(label_forbody_preheader_i_111, label_from_consts_exit_113, int1_cmp_i_119, label_entry_110);
-
- // Block forbody.preheader.i (label_forbody_preheader_i_111)
- BinaryOperator* int32_tmp_i_121 = BinaryOperator::create(Instruction::Add, int32_num_consts_109, const_int32_30, "tmp.i", label_forbody_preheader_i_111);
- ICmpInst* int1_tmp9_i_122 = new ICmpInst(ICmpInst::ICMP_SLT, int32_tmp_i_121, const_int32_29, "tmp9.i", label_forbody_preheader_i_111);
- SelectInst* int32_tmp10_i_123 = new SelectInst(int1_tmp9_i_122, const_int32_31, int32_num_consts_109, "tmp10.i", label_forbody_preheader_i_111);
- new BranchInst(label_forbody_i_112, label_forbody_preheader_i_111);
-
- // Block forbody.i (label_forbody_i_112)
- Argument* fwdref_126 = new Argument(IntegerType::get(32));
- PHINode* int32_i_0_reg2mem_0_i_125 = new PHINode(IntegerType::get(32), "i.0.reg2mem.0.i", label_forbody_i_112);
- int32_i_0_reg2mem_0_i_125->reserveOperandSpace(2);
- int32_i_0_reg2mem_0_i_125->addIncoming(const_int32_29, label_forbody_preheader_i_111);
- int32_i_0_reg2mem_0_i_125->addIncoming(fwdref_126, label_forbody_i_112);
-
- Argument* fwdref_128 = new Argument(VectorTy_1);
- PHINode* packed_vec_0_reg2mem_0_i_127 = new PHINode(VectorTy_1, "vec.0.reg2mem.0.i", label_forbody_i_112);
- packed_vec_0_reg2mem_0_i_127->reserveOperandSpace(2);
- packed_vec_0_reg2mem_0_i_127->addIncoming(const_packed_32, label_forbody_preheader_i_111);
- packed_vec_0_reg2mem_0_i_127->addIncoming(fwdref_128, label_forbody_i_112);
-
- std::vector<Value*> ptr_arraydecay_i_129_indices;
- ptr_arraydecay_i_129_indices.push_back(int32_i_0_reg2mem_0_i_125);
- ptr_arraydecay_i_129_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay_i_129 = new GetElementPtrInst(ptr_aconsts_108, ptr_arraydecay_i_129_indices.begin(), ptr_arraydecay_i_129_indices.end(), "arraydecay.i", label_forbody_i_112);
- LoadInst* float_tmp5_i_130 = new LoadInst(ptr_arraydecay_i_129, "tmp5.i", false, label_forbody_i_112);
- InsertElementInst* packed_tmp7_i_131 = new InsertElementInst(packed_vec_0_reg2mem_0_i_127, float_tmp5_i_130, const_int32_29, "tmp7.i", label_forbody_i_112);
- std::vector<Value*> ptr_arrayidx12_i_132_indices;
- ptr_arrayidx12_i_132_indices.push_back(int32_i_0_reg2mem_0_i_125);
- ptr_arrayidx12_i_132_indices.push_back(const_int32_31);
- Instruction* ptr_arrayidx12_i_132 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx12_i_132_indices.begin(), ptr_arrayidx12_i_132_indices.end(), "arrayidx12.i", label_forbody_i_112);
- LoadInst* float_tmp13_i_133 = new LoadInst(ptr_arrayidx12_i_132, "tmp13.i", false, label_forbody_i_112);
- InsertElementInst* packed_tmp15_i_134 = new InsertElementInst(packed_tmp7_i_131, float_tmp13_i_133, const_int32_31, "tmp15.i", label_forbody_i_112);
- std::vector<Value*> ptr_arrayidx20_i_135_indices;
- ptr_arrayidx20_i_135_indices.push_back(int32_i_0_reg2mem_0_i_125);
- ptr_arrayidx20_i_135_indices.push_back(const_int32_33);
- Instruction* ptr_arrayidx20_i_135 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx20_i_135_indices.begin(), ptr_arrayidx20_i_135_indices.end(), "arrayidx20.i", label_forbody_i_112);
- LoadInst* float_tmp21_i_136 = new LoadInst(ptr_arrayidx20_i_135, "tmp21.i", false, label_forbody_i_112);
- InsertElementInst* packed_tmp23_i_137 = new InsertElementInst(packed_tmp15_i_134, float_tmp21_i_136, const_int32_33, "tmp23.i", label_forbody_i_112);
- std::vector<Value*> ptr_arrayidx28_i_138_indices;
- ptr_arrayidx28_i_138_indices.push_back(int32_i_0_reg2mem_0_i_125);
- ptr_arrayidx28_i_138_indices.push_back(const_int32_34);
- Instruction* ptr_arrayidx28_i_138 = new GetElementPtrInst(ptr_aconsts_108, ptr_arrayidx28_i_138_indices.begin(), ptr_arrayidx28_i_138_indices.end(), "arrayidx28.i", label_forbody_i_112);
- LoadInst* float_tmp29_i_139 = new LoadInst(ptr_arrayidx28_i_138, "tmp29.i", false, label_forbody_i_112);
- InsertElementInst* packed_tmp31_i_140 = new InsertElementInst(packed_tmp23_i_137, float_tmp29_i_139, const_int32_34, "tmp31.i", label_forbody_i_112);
- std::vector<Value*> ptr_arrayidx34_i_141_indices;
- ptr_arrayidx34_i_141_indices.push_back(const_int32_29);
- ptr_arrayidx34_i_141_indices.push_back(int32_i_0_reg2mem_0_i_125);
- Instruction* ptr_arrayidx34_i_141 = new GetElementPtrInst(ptr_consts_114, ptr_arrayidx34_i_141_indices.begin(), ptr_arrayidx34_i_141_indices.end(), "arrayidx34.i", label_forbody_i_112);
- StoreInst* void_142 = new StoreInst(packed_tmp31_i_140, ptr_arrayidx34_i_141, false, label_forbody_i_112);
- BinaryOperator* int32_indvar_next7 = BinaryOperator::create(Instruction::Add, int32_i_0_reg2mem_0_i_125, const_int32_31, "indvar.next7", label_forbody_i_112);
- ICmpInst* int1_exitcond8 = new ICmpInst(ICmpInst::ICMP_EQ, int32_indvar_next7, int32_tmp10_i_123, "exitcond8", label_forbody_i_112);
- new BranchInst(label_from_consts_exit_113, label_forbody_i_112, int1_exitcond8, label_forbody_i_112);
-
- // Block from_consts.exit (label_from_consts_exit_113)
- std::vector<Value*> ptr_tmp3_indices;
- ptr_tmp3_indices.push_back(const_int32_29);
- ptr_tmp3_indices.push_back(const_int32_34);
- Instruction* ptr_tmp3 = new GetElementPtrInst(ptr_args_116, ptr_tmp3_indices.begin(), ptr_tmp3_indices.end(), "tmp3", label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay4_indices;
- ptr_arraydecay4_indices.push_back(const_int32_29);
- ptr_arraydecay4_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay4 = new GetElementPtrInst(ptr_consts_114, ptr_arraydecay4_indices.begin(), ptr_arraydecay4_indices.end(), "arraydecay4", label_from_consts_exit_113);
- StoreInst* void_144 = new StoreInst(ptr_arraydecay4, ptr_tmp3, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_tmp5_indices;
- ptr_tmp5_indices.push_back(const_int32_29);
- ptr_tmp5_indices.push_back(const_int32_33);
- Instruction* ptr_tmp5 = new GetElementPtrInst(ptr_args_116, ptr_tmp5_indices.begin(), ptr_tmp5_indices.end(), "tmp5", label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay6_indices;
- ptr_arraydecay6_indices.push_back(const_int32_29);
- ptr_arraydecay6_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay6 = new GetElementPtrInst(ptr_temps_115, ptr_arraydecay6_indices.begin(), ptr_arraydecay6_indices.end(), "arraydecay6", label_from_consts_exit_113);
- StoreInst* void_145 = new StoreInst(ptr_arraydecay6, ptr_tmp5, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_tmp8_indices;
- ptr_tmp8_indices.push_back(const_int32_29);
- ptr_tmp8_indices.push_back(const_int32_31);
- Instruction* ptr_tmp8 = new GetElementPtrInst(ptr_args_116, ptr_tmp8_indices.begin(), ptr_tmp8_indices.end(), "tmp8", label_from_consts_exit_113);
- std::vector<Value*> ptr_tmp12_indices;
- ptr_tmp12_indices.push_back(const_int32_29);
- ptr_tmp12_indices.push_back(const_int32_29);
- Instruction* ptr_tmp12 = new GetElementPtrInst(ptr_args_116, ptr_tmp12_indices.begin(), ptr_tmp12_indices.end(), "tmp12", label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay11_146_indices;
- ptr_arraydecay11_146_indices.push_back(const_int32_29);
- ptr_arraydecay11_146_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay11_146 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_146_indices.begin(), ptr_arraydecay11_146_indices.end(), "arraydecay11", label_from_consts_exit_113);
- StoreInst* void_147 = new StoreInst(ptr_arraydecay11_146, ptr_tmp8, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay16_indices;
- ptr_arraydecay16_indices.push_back(const_int32_29);
- ptr_arraydecay16_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay16 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_indices.begin(), ptr_arraydecay16_indices.end(), "arraydecay16", label_from_consts_exit_113);
- StoreInst* void_148 = new StoreInst(ptr_arraydecay16, ptr_tmp12, false, label_from_consts_exit_113);
- StoreInst* void_149 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
- CallInst* void_150 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
- void_150->setCallingConv(CallingConv::C);
- void_150->setTailCall(false);const ParamAttrsList *void_150_PAL = 0;
- void_150->setParamAttrs(void_150_PAL);
-
- LoadInst* int32_tmp23 = new LoadInst(ptr_tmp_117, "tmp23", false, label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay11_1_indices;
- ptr_arraydecay11_1_indices.push_back(const_int32_31);
- ptr_arraydecay11_1_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay11_1 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_1_indices.begin(), ptr_arraydecay11_1_indices.end(), "arraydecay11.1", label_from_consts_exit_113);
- StoreInst* void_151 = new StoreInst(ptr_arraydecay11_1, ptr_tmp8, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay16_1_indices;
- ptr_arraydecay16_1_indices.push_back(const_int32_31);
- ptr_arraydecay16_1_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay16_1 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_1_indices.begin(), ptr_arraydecay16_1_indices.end(), "arraydecay16.1", label_from_consts_exit_113);
- StoreInst* void_152 = new StoreInst(ptr_arraydecay16_1, ptr_tmp12, false, label_from_consts_exit_113);
- StoreInst* void_153 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
- CallInst* void_154 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
- void_154->setCallingConv(CallingConv::C);
- void_154->setTailCall(false);const ParamAttrsList *void_154_PAL = 0;
- void_154->setParamAttrs(void_154_PAL);
-
- LoadInst* int32_tmp23_1 = new LoadInst(ptr_tmp_117, "tmp23.1", false, label_from_consts_exit_113);
- BinaryOperator* int32_shl_1 = BinaryOperator::create(Instruction::Shl, int32_tmp23_1, const_int32_31, "shl.1", label_from_consts_exit_113);
- BinaryOperator* int32_or_1 = BinaryOperator::create(Instruction::Or, int32_shl_1, int32_tmp23, "or.1", label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay11_2_indices;
- ptr_arraydecay11_2_indices.push_back(const_int32_33);
- ptr_arraydecay11_2_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay11_2 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_2_indices.begin(), ptr_arraydecay11_2_indices.end(), "arraydecay11.2", label_from_consts_exit_113);
- StoreInst* void_155 = new StoreInst(ptr_arraydecay11_2, ptr_tmp8, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay16_2_indices;
- ptr_arraydecay16_2_indices.push_back(const_int32_33);
- ptr_arraydecay16_2_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay16_2 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_2_indices.begin(), ptr_arraydecay16_2_indices.end(), "arraydecay16.2", label_from_consts_exit_113);
- StoreInst* void_156 = new StoreInst(ptr_arraydecay16_2, ptr_tmp12, false, label_from_consts_exit_113);
- StoreInst* void_157 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
- CallInst* void_158 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
- void_158->setCallingConv(CallingConv::C);
- void_158->setTailCall(false);const ParamAttrsList *void_158_PAL = 0;
- void_158->setParamAttrs(void_158_PAL);
-
- LoadInst* int32_tmp23_2 = new LoadInst(ptr_tmp_117, "tmp23.2", false, label_from_consts_exit_113);
- BinaryOperator* int32_shl_2 = BinaryOperator::create(Instruction::Shl, int32_tmp23_2, const_int32_33, "shl.2", label_from_consts_exit_113);
- BinaryOperator* int32_or_2 = BinaryOperator::create(Instruction::Or, int32_shl_2, int32_or_1, "or.2", label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay11_3_indices;
- ptr_arraydecay11_3_indices.push_back(const_int32_34);
- ptr_arraydecay11_3_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay11_3 = new GetElementPtrInst(ptr_inputs_106, ptr_arraydecay11_3_indices.begin(), ptr_arraydecay11_3_indices.end(), "arraydecay11.3", label_from_consts_exit_113);
- StoreInst* void_159 = new StoreInst(ptr_arraydecay11_3, ptr_tmp8, false, label_from_consts_exit_113);
- std::vector<Value*> ptr_arraydecay16_3_indices;
- ptr_arraydecay16_3_indices.push_back(const_int32_34);
- ptr_arraydecay16_3_indices.push_back(const_int32_29);
- Instruction* ptr_arraydecay16_3 = new GetElementPtrInst(ptr_results_105, ptr_arraydecay16_3_indices.begin(), ptr_arraydecay16_3_indices.end(), "arraydecay16.3", label_from_consts_exit_113);
- StoreInst* void_160 = new StoreInst(ptr_arraydecay16_3, ptr_tmp12, false, label_from_consts_exit_113);
- StoreInst* void_161 = new StoreInst(const_int32_29, ptr_tmp_117, false, label_from_consts_exit_113);
- CallInst* void_162 = new CallInst(func_execute_shader, ptr_args_116, "", label_from_consts_exit_113);
- void_162->setCallingConv(CallingConv::C);
- void_162->setTailCall(false);const ParamAttrsList *void_162_PAL = 0;
- void_162->setParamAttrs(void_162_PAL);
-
- LoadInst* int32_tmp23_3 = new LoadInst(ptr_tmp_117, "tmp23.3", false, label_from_consts_exit_113);
- BinaryOperator* int32_shl_3 = BinaryOperator::create(Instruction::Shl, int32_tmp23_3, const_int32_34, "shl.3", label_from_consts_exit_113);
- BinaryOperator* int32_or_3 = BinaryOperator::create(Instruction::Or, int32_shl_3, int32_or_2, "or.3", label_from_consts_exit_113);
- BinaryOperator* int32_neg = BinaryOperator::create(Instruction::Xor, int32_or_3, const_int32_30, "neg", label_from_consts_exit_113);
- new ReturnInst(int32_neg, label_from_consts_exit_113);
-
- // Resolve Forward References
- fwdref_128->replaceAllUsesWith(packed_tmp31_i_140); delete fwdref_128;
- fwdref_126->replaceAllUsesWith(int32_indvar_next7); delete fwdref_126;
-
- }
-
- return mod;
-}
diff --git a/src/mesa/pipe/llvm/llvm_builtins.c b/src/mesa/pipe/llvm/llvm_builtins.c
deleted file mode 100644
index 4f98d754ba..0000000000
--- a/src/mesa/pipe/llvm/llvm_builtins.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*clang --emit-llvm llvm_builtins.c |llvm-as|opt -std-compile-opts|llvm2cpp -gen-contents -o=gallivm_builtins.cpp -f -for=shader -funcname=createGallivmBuiltins*/
-/**************************************************************************
- *
- * 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:
- * Zack Rusin zack@tungstengraphics.com
- */
-typedef __attribute__(( ocu_vector_type(4) )) float float4;
-
-extern float powf(float a, float b);
-
-inline float approx(float a, float b)
-{
- if (b < -128.0f) b = -128.0f;
- if (b > 128.0f) b = 128.0f;
- if (a < 0) a = 0;
- return powf(a, b);
-}
-
-inline float4 lit(float4 tmp)
-{
- float4 result;
- result.x = 1.0;
- result.w = 1.0;
- if (tmp.x > 0) {
- result.y = tmp.x;
- result.z = approx(tmp.y, tmp.w);
- } else {
- result.y = 0;
- result.z = 0;
- }
- return result;
-}
-
-inline float4 cmp(float4 tmp0, float4 tmp1, float4 tmp2)
-{
- float4 result;
-
- result.x = (tmp0.x < 0.0) ? tmp1.x : tmp2.x;
- result.y = (tmp0.y < 0.0) ? tmp1.y : tmp2.y;
- result.z = (tmp0.z < 0.0) ? tmp1.z : tmp2.z;
- result.w = (tmp0.w < 0.0) ? tmp1.w : tmp2.w;
-
- return result;
-}
-
-extern float cosf(float val);
-extern float sinf(float val);
-
-inline float4 vcos(float4 val)
-{
- float4 result;
- printf("VEC IN is %f %f %f %f\n", val.x, val.y, val.z, val.w);
- result.x = cosf(val.x);
- result.y = cosf(val.x);
- result.z = cosf(val.x);
- result.w = cosf(val.x);
- printf("VEC OUT is %f %f %f %f\n", result.x, result.y, result.z, result.w);
- return result;
-}
-
-inline float4 scs(float4 val)
-{
- float4 result;
- float tmp = val.x;
- result.x = cosf(tmp);
- result.y = sinf(tmp);
- return result;
-}
-
-
-inline float4 vsin(float4 val)
-{
- float4 result;
- float tmp = val.x;
- float res = sinf(tmp);
- result.x = res;
- result.y = res;
- result.z = res;
- result.w = res;
- return result;
-}
-
-inline int kilp(float4 val)
-{
- if (val.x < 0 || val.y < 0 || val.z < 0 || val.w < 0)
- return 1;
- else
- return 0;
-}
diff --git a/src/mesa/pipe/llvm/llvm_entry.c b/src/mesa/pipe/llvm/llvm_entry.c
deleted file mode 100644
index fa50b60e66..0000000000
--- a/src/mesa/pipe/llvm/llvm_entry.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* clang --emit-llvm llvm_entry.c |llvm-as |opt -std-compile-opts |llvm2cpp -for=Shader -gen-module -funcname=createBaseShader */
-/**************************************************************************
- *
- * 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:
- * Zack Rusin zack@tungstengraphics.com
- */
-
-/* clang --emit-llvm llvm_builtins.c |llvm-as |opt -std-compile-opts |llvm-dis */
-typedef __attribute__(( ocu_vector_type(4) )) float float4;
-
-void from_array(float4 (*res)[16], float (*ainputs)[16][4],
- int count, int num_attribs)
-{
- for (int i = 0; i < count; ++i) {
- for (int j = 0; j < num_attribs; ++j) {
- float4 vec;
- vec.x = ainputs[i][j][0];
- vec.y = ainputs[i][j][1];
- vec.z = ainputs[i][j][2];
- vec.w = ainputs[i][j][3];
- res[i][j] = vec;
- }
- }
-}
-
-void from_consts(float4 *res, float (*ainputs)[4],
- int count)
-{
- for (int i = 0; i < count; ++i) {
- float4 vec;
- vec.x = ainputs[i][0];
- vec.y = ainputs[i][1];
- vec.z = ainputs[i][2];
- vec.w = ainputs[i][3];
- res[i] = vec;
- }
-}
-
-void to_array(float (*dests)[4], float4 *in, int num_attribs)
-{
- for (int i = 0; i < num_attribs; ++i) {
- float *rd = dests[i];
- float4 ri = in[i];
- rd[0] = ri.x;
- rd[1] = ri.y;
- rd[2] = ri.z;
- rd[3] = ri.w;
- }
-}
-
-
-struct ShaderInput
-{
- float4 *dests;
- float4 *inputs;
- float4 *temps;
- float4 *consts;
- int kilmask;
-};
-
-extern void execute_shader(struct ShaderInput *input);
-
-void run_vertex_shader(void *inputs,
- void *results,
- float (*aconsts)[4],
- int num_vertices,
- int num_inputs,
- int num_attribs,
- int num_consts)
-{
- float4 consts[32];
- float4 temps[128];//MAX_PROGRAM_TEMPS
-
- struct ShaderInput args;
- args.dests = results;
- args.inputs = inputs;
-
- /*printf("XXX LLVM run_vertex_shader vertices = %d, inputs = %d, attribs = %d, consts = %d\n",
- num_vertices, num_inputs, num_attribs, num_consts);*/
- from_consts(consts, aconsts, num_consts);
- args.consts = consts;
- args.temps = temps;
-
- execute_shader(&args);
-}
-
-
-struct pipe_sampler_state;
-struct softpipe_tile_cache;
-
-#define NUM_CHANNELS 4 /* R,G,B,A */
-#define QUAD_SIZE 4 /* 4 pixel/quad */
-
-struct tgsi_sampler
-{
- const struct pipe_sampler_state *state;
- /** Get samples for four fragments in a quad */
- void (*get_samples)(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE]);
- void *pipe; /*XXX temporary*/
- struct softpipe_tile_cache *cache;
-};
-
-
-int run_fragment_shader(float x, float y,
- float4 (*results)[16],
- float4 (*inputs)[16],
- int num_inputs,
- float (*aconsts)[4],
- int num_consts,
- struct tgsi_sampler *samplers)
-{
- float4 consts[32];
- float4 temps[128];//MAX_PROGRAM_TEMPS
- struct ShaderInput args;
- int mask = 0;
- args.kilmask = 0;
-
- from_consts(consts, aconsts, num_consts);
- args.consts = consts;
- args.temps = temps;
- //printf("AAAAAAAAAAAAAAAAAAAAAAA FRAGMENT SHADER %f %f\n", x, y);
- for (int i = 0; i < 4; ++i) {
- args.inputs = inputs[i];
- args.dests = results[i];
- mask = args.kilmask;
- args.kilmask = 0;
- execute_shader(&args);
- args.kilmask = mask | (args.kilmask << i);
- }
- return ~args.kilmask;
-}
-
diff --git a/src/mesa/pipe/llvm/loweringpass.cpp b/src/mesa/pipe/llvm/loweringpass.cpp
deleted file mode 100644
index 556dbec366..0000000000
--- a/src/mesa/pipe/llvm/loweringpass.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "loweringpass.h"
-
-using namespace llvm;
-
-char LoweringPass::ID = 0;
-RegisterPass<LoweringPass> X("lowering", "Lowering Pass");
-
-LoweringPass::LoweringPass()
- : ModulePass((intptr_t)&ID)
-{
-}
-
-bool LoweringPass::runOnModule(Module &m)
-{
- llvm::cerr << "Hello: " << m.getModuleIdentifier() << "\n";
- return false;
-}
diff --git a/src/mesa/pipe/llvm/loweringpass.h b/src/mesa/pipe/llvm/loweringpass.h
deleted file mode 100644
index f62dcf6ba7..0000000000
--- a/src/mesa/pipe/llvm/loweringpass.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef LOWERINGPASS_H
-#define LOWERINGPASS_H
-
-#include "llvm/Pass.h"
-#include "llvm/Module.h"
-
-struct LoweringPass : public llvm::ModulePass
-{
- static char ID;
- LoweringPass();
-
- virtual bool runOnModule(llvm::Module &m);
-};
-
-#endif
diff --git a/src/mesa/pipe/llvm/storage.cpp b/src/mesa/pipe/llvm/storage.cpp
deleted file mode 100644
index c4326de8c5..0000000000
--- a/src/mesa/pipe/llvm/storage.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-#ifdef MESA_LLVM
-
-#include "storage.h"
-
-#include "gallivm_p.h"
-
-#include "pipe/p_shader_tokens.h"
-#include <llvm/BasicBlock.h>
-#include <llvm/Module.h>
-#include <llvm/Value.h>
-
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/InstrTypes.h>
-#include <llvm/Instructions.h>
-
-using namespace llvm;
-
-Storage::Storage(llvm::BasicBlock *block, llvm::Value *input)
- : m_block(block),
- m_INPUT(input),
- m_addrs(32),
- m_idx(0)
-{
- m_floatVecType = VectorType::get(Type::FloatTy, 4);
- m_intVecType = VectorType::get(IntegerType::get(32), 4);
-
- m_undefFloatVec = UndefValue::get(m_floatVecType);
- m_undefIntVec = UndefValue::get(m_intVecType);
- m_extSwizzleVec = 0;
-
- m_numConsts = 0;
-}
-
-//can only build vectors with all members in the [0, 9] range
-llvm::Constant *Storage::shuffleMask(int vec)
-{
- if (!m_extSwizzleVec) {
- std::vector<Constant*> elems;
- elems.push_back(ConstantFP::get(Type::FloatTy, APFloat(0.f)));
- elems.push_back(ConstantFP::get(Type::FloatTy, APFloat(1.f)));
- elems.push_back(ConstantFP::get(Type::FloatTy, APFloat(0.f)));
- elems.push_back(ConstantFP::get(Type::FloatTy, APFloat(1.f)));
- m_extSwizzleVec = ConstantVector::get(m_floatVecType, elems);
- }
-
- if (m_intVecs.find(vec) != m_intVecs.end()) {
- return m_intVecs[vec];
- }
- int origVec = vec;
- Constant* const_vec = 0;
- if (origVec == 0) {
- const_vec = Constant::getNullValue(m_intVecType);
- } else {
- int x = gallivm_x_swizzle(vec);
- int y = gallivm_y_swizzle(vec);
- int z = gallivm_z_swizzle(vec);
- int w = gallivm_w_swizzle(vec);
- std::vector<Constant*> elems;
- elems.push_back(constantInt(x));
- elems.push_back(constantInt(y));
- elems.push_back(constantInt(z));
- elems.push_back(constantInt(w));
- const_vec = ConstantVector::get(m_intVecType, elems);
- }
-
- m_intVecs[origVec] = const_vec;
- return const_vec;
-}
-
-llvm::ConstantInt *Storage::constantInt(int idx)
-{
- if (m_constInts.find(idx) != m_constInts.end()) {
- return m_constInts[idx];
- }
- ConstantInt *const_int = ConstantInt::get(APInt(32, idx));
- m_constInts[idx] = const_int;
- return const_int;
-}
-
-llvm::Value *Storage::inputElement(int idx, llvm::Value *indIdx)
-{
- Value *val = element(InputsArg, idx, indIdx);
- LoadInst *load = new LoadInst(val, name("input"), false, m_block);
- load->setAlignment(8);
-
- return load;
-}
-
-llvm::Value *Storage::constElement(int idx, llvm::Value *indIdx)
-{
- m_numConsts = ((idx + 1) > m_numConsts) ? (idx + 1) : m_numConsts;
-
- Value *elem = element(ConstsArg, idx, indIdx);
- LoadInst *load = new LoadInst(elem, name("const"), false, m_block);
- load->setAlignment(8);
- return load;
-}
-
-llvm::Value *Storage::shuffleVector(llvm::Value *vec, int shuffle)
-{
- Constant *mask = shuffleMask(shuffle);
- ShuffleVectorInst *res =
- new ShuffleVectorInst(vec, m_extSwizzleVec, mask,
- name("shuffle"), m_block);
- return res;
-}
-
-
-llvm::Value *Storage::tempElement(int idx, llvm::Value *indIdx)
-{
- Value *elem = element(TempsArg, idx, indIdx);
-
- LoadInst *load = new LoadInst(elem, name("temp"), false, m_block);
- load->setAlignment(8);
-
- return load;
-}
-
-void Storage::setTempElement(int idx, llvm::Value *val, int mask)
-{
- if (mask != TGSI_WRITEMASK_XYZW) {
- llvm::Value *templ = 0;
- if (m_tempWriteMap[idx])
- templ = tempElement(idx);
- val = maskWrite(val, mask, templ);
- }
- Value *elem = element(TempsArg, idx);
- StoreInst *st = new StoreInst(val, elem, false, m_block);
- st->setAlignment(8);
- m_tempWriteMap[idx] = true;
-}
-
-void Storage::setOutputElement(int dstIdx, llvm::Value *val, int mask)
-{
- if (mask != TGSI_WRITEMASK_XYZW) {
- llvm::Value *templ = 0;
- if (m_destWriteMap[dstIdx])
- templ = outputElement(dstIdx);
- val = maskWrite(val, mask, templ);
- }
-
- Value *elem = element(DestsArg, dstIdx);
- StoreInst *st = new StoreInst(val, elem, false, m_block);
- st->setAlignment(8);
- m_destWriteMap[dstIdx] = true;
-}
-
-llvm::Value *Storage::maskWrite(llvm::Value *src, int mask, llvm::Value *templ)
-{
- llvm::Value *dst = templ;
- if (!dst)
- dst = Constant::getNullValue(m_floatVecType);
- if ((mask & TGSI_WRITEMASK_X)) {
- llvm::Value *x = new ExtractElementInst(src, unsigned(0),
- name("x"), m_block);
- dst = new InsertElementInst(dst, x, unsigned(0),
- name("dstx"), m_block);
- }
- if ((mask & TGSI_WRITEMASK_Y)) {
- llvm::Value *y = new ExtractElementInst(src, unsigned(1),
- name("y"), m_block);
- dst = new InsertElementInst(dst, y, unsigned(1),
- name("dsty"), m_block);
- }
- if ((mask & TGSI_WRITEMASK_Z)) {
- llvm::Value *z = new ExtractElementInst(src, unsigned(2),
- name("z"), m_block);
- dst = new InsertElementInst(dst, z, unsigned(2),
- name("dstz"), m_block);
- }
- if ((mask & TGSI_WRITEMASK_W)) {
- llvm::Value *w = new ExtractElementInst(src, unsigned(3),
- name("w"), m_block);
- dst = new InsertElementInst(dst, w, unsigned(3),
- name("dstw"), m_block);
- }
- return dst;
-}
-
-const char * Storage::name(const char *prefix)
-{
- ++m_idx;
- snprintf(m_name, 32, "%s%d", prefix, m_idx);
- return m_name;
-}
-
-int Storage::numConsts() const
-{
- return m_numConsts;
-}
-
-llvm::Value * Storage::addrElement(int idx) const
-{
- Value *ret = m_addrs[idx];
- if (!ret)
- return m_undefFloatVec;
- return ret;
-}
-
-void Storage::setAddrElement(int idx, llvm::Value *val, int mask)
-{
- if (mask != TGSI_WRITEMASK_XYZW) {
- llvm::Value *templ = m_addrs[idx];
- val = maskWrite(val, mask, templ);
- }
- m_addrs[idx] = val;
-}
-
-llvm::Value * Storage::extractIndex(llvm::Value *vec)
-{
- llvm::Value *x = new ExtractElementInst(vec, unsigned(0),
- name("x"), m_block);
- return new FPToSIInst(x, IntegerType::get(32), name("intidx"), m_block);
-}
-
-void Storage::setCurrentBlock(llvm::BasicBlock *block)
-{
- m_block = block;
-}
-
-llvm::Value * Storage::outputElement(int idx, llvm::Value *indIdx)
-{
- Value *elem = element(DestsArg, idx, indIdx);
- LoadInst *load = new LoadInst(elem, name("output"), false, m_block);
- load->setAlignment(8);
-
- return load;
-}
-
-llvm::Value * Storage::inputPtr() const
-{
- return m_INPUT;
-}
-
-void Storage::pushArguments(llvm::Value *input)
-{
- m_argStack.push(m_INPUT);
-
- m_INPUT = input;
-}
-
-void Storage::popArguments()
-{
- m_INPUT = m_argStack.top();
- m_argStack.pop();
-}
-
-void Storage::pushTemps()
-{
- m_extSwizzleVec = 0;
-}
-
-void Storage::popTemps()
-{
-}
-
-llvm::Value * Storage::immediateElement(int idx)
-{
- return m_immediates[idx];
-}
-
-void Storage::addImmediate(float *val)
-{
- std::vector<Constant*> vec(4);
- vec[0] = ConstantFP::get(Type::FloatTy, APFloat(val[0]));
- vec[1] = ConstantFP::get(Type::FloatTy, APFloat(val[1]));
- vec[2] = ConstantFP::get(Type::FloatTy, APFloat(val[2]));
- vec[3] = ConstantFP::get(Type::FloatTy, APFloat(val[3]));
- m_immediates.push_back(ConstantVector::get(m_floatVecType, vec));
-}
-
-
-llvm::Value * Storage::elemPtr(Args arg)
-{
- std::vector<Value*> indices;
- indices.push_back(constantInt(0));
- indices.push_back(constantInt(static_cast<int>(arg)));
- GetElementPtrInst *getElem = new GetElementPtrInst(m_INPUT,
- indices.begin(),
- indices.end(),
- name("input_ptr"),
- m_block);
- return new LoadInst(getElem, name("input_field"), false, m_block);
-}
-
-llvm::Value * Storage::elemIdx(llvm::Value *ptr, int idx,
- llvm::Value *indIdx )
-{
- GetElementPtrInst *getElem = 0;
-
- if (indIdx) {
- getElem = new GetElementPtrInst(ptr,
- BinaryOperator::create(Instruction::Add,
- indIdx,
- constantInt(idx),
- name("add"),
- m_block),
- name("field"),
- m_block);
- } else {
- getElem = new GetElementPtrInst(ptr,
- constantInt(idx),
- name("field"),
- m_block);
- }
- return getElem;
-}
-
-llvm::Value * Storage::element(Args arg, int idx, llvm::Value *indIdx )
-{
- Value *val = elemPtr(arg);
- return elemIdx(val, idx, indIdx);
-}
-
-void Storage::setKilElement(llvm::Value *val)
-{
- std::vector<Value*> indices;
- indices.push_back(constantInt(0));
- indices.push_back(constantInt(static_cast<int>(KilArg)));
- GetElementPtrInst *elem = new GetElementPtrInst(m_INPUT,
- indices.begin(),
- indices.end(),
- name("kil_ptr"),
- m_block);
- StoreInst *st = new StoreInst(val, elem, false, m_block);
- st->setAlignment(8);
-}
-
-#endif //MESA_LLVM
-
-
diff --git a/src/mesa/pipe/llvm/storage.h b/src/mesa/pipe/llvm/storage.h
deleted file mode 100644
index 8574f7554e..0000000000
--- a/src/mesa/pipe/llvm/storage.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Zack Rusin zack@tungstengraphics.com
- */
-
-#ifndef STORAGE_H
-#define STORAGE_H
-
-#include <map>
-#include <set>
-#include <stack>
-#include <vector>
-
-namespace llvm {
- class BasicBlock;
- class Constant;
- class ConstantInt;
- class LoadInst;
- class Value;
- class VectorType;
-}
-
-class Storage
-{
-public:
- Storage(llvm::BasicBlock *block,
- llvm::Value *input);
-
- llvm::Value *inputPtr() const;
-
- void setCurrentBlock(llvm::BasicBlock *block);
-
- llvm::ConstantInt *constantInt(int);
- llvm::Constant *shuffleMask(int vec);
- llvm::Value *inputElement(int idx, llvm::Value *indIdx =0);
- llvm::Value *constElement(int idx, llvm::Value *indIdx =0);
- llvm::Value *outputElement(int idx, llvm::Value *indIdx =0);
- llvm::Value *tempElement(int idx, llvm::Value *indIdx =0);
- llvm::Value *immediateElement(int idx);
-
- void setOutputElement(int dstIdx, llvm::Value *val, int mask);
- void setTempElement(int idx, llvm::Value *val, int mask);
-
- llvm::Value *addrElement(int idx) const;
- void setAddrElement(int idx, llvm::Value *val, int mask);
-
- void setKilElement(llvm::Value *val);
-
- llvm::Value *shuffleVector(llvm::Value *vec, int shuffle);
-
- llvm::Value *extractIndex(llvm::Value *vec);
-
- int numConsts() const;
-
- void pushArguments(llvm::Value *input);
- void popArguments();
- void pushTemps();
- void popTemps();
-
- void addImmediate(float *val);
-
-private:
- llvm::Value *maskWrite(llvm::Value *src, int mask, llvm::Value *templ);
- const char *name(const char *prefix);
-
- enum Args {
- DestsArg = 0,
- InputsArg = 1,
- TempsArg = 2,
- ConstsArg = 3,
- KilArg = 4
- };
- llvm::Value *elemPtr(Args arg);
- llvm::Value *elemIdx(llvm::Value *ptr, int idx,
- llvm::Value *indIdx = 0);
- llvm::Value *element(Args arg, int idx, llvm::Value *indIdx = 0);
-
-private:
- llvm::BasicBlock *m_block;
- llvm::Value *m_INPUT;
-
- std::map<int, llvm::ConstantInt*> m_constInts;
- std::map<int, llvm::Constant*> m_intVecs;
- std::vector<llvm::Value*> m_addrs;
- std::vector<llvm::Constant*> m_immediates;
-
- llvm::VectorType *m_floatVecType;
- llvm::VectorType *m_intVecType;
-
- char m_name[32];
- int m_idx;
-
- int m_numConsts;
-
- std::map<int, bool > m_destWriteMap;
- std::map<int, bool > m_tempWriteMap;
-
- llvm::Value *m_undefFloatVec;
- llvm::Value *m_undefIntVec;
- llvm::Value *m_extSwizzleVec;
-
- std::stack<llvm::Value*> m_argStack;
- std::stack<std::vector<llvm::Value*> > m_tempStack;
-};
-
-#endif
diff --git a/src/mesa/pipe/llvm/storagesoa.cpp b/src/mesa/pipe/llvm/storagesoa.cpp
deleted file mode 100644
index e09e9e8fe7..0000000000
--- a/src/mesa/pipe/llvm/storagesoa.cpp
+++ /dev/null
@@ -1,208 +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.
- *
- **************************************************************************/
-
-#include "storagesoa.h"
-
-
-#include "pipe/p_shader_tokens.h"
-#include <llvm/BasicBlock.h>
-#include <llvm/Module.h>
-#include <llvm/Value.h>
-
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/InstrTypes.h>
-#include <llvm/Instructions.h>
-
-using namespace llvm;
-
-StorageSoa::StorageSoa(llvm::BasicBlock *block,
- llvm::Value *input,
- llvm::Value *output,
- llvm::Value *consts,
- llvm::Value *temps)
- : m_block(block),
- m_input(input),
- m_output(output),
- m_consts(consts),
- m_temps(temps),
- m_idx(0)
-{
-}
-
-void StorageSoa::addImmediate(float *vec)
-{
-}
-
-llvm::Value *StorageSoa::addrElement(int idx) const
-{
- return 0;
-}
-
-std::vector<llvm::Value*> StorageSoa::inputElement(int idx, int swizzle,
- llvm::Value *indIdx)
-{
- std::vector<llvm::Value*> res(4);
-
- res[0] = element(m_input, idx, 0);
- res[1] = element(m_input, idx, 1);
- res[2] = element(m_input, idx, 2);
- res[3] = element(m_input, idx, 3);
-
- return res;
-}
-
-std::vector<llvm::Value*> StorageSoa::constElement(int idx, int swizzle,
- llvm::Value *indIdx)
-{
- std::vector<llvm::Value*> res(4);
-
- return res;
-}
-
-std::vector<llvm::Value*> StorageSoa::outputElement(int idx, int swizzle,
- llvm::Value *indIdx)
-{
- std::vector<llvm::Value*> res(4);
-
- res[0] = element(m_output, idx, 0);
- res[1] = element(m_output, idx, 1);
- res[2] = element(m_output, idx, 2);
- res[3] = element(m_output, idx, 3);
-
- return res;
-}
-
-std::vector<llvm::Value*> StorageSoa::tempElement(int idx, int swizzle,
- llvm::Value *indIdx)
-{
- std::vector<llvm::Value*> res(4);
-
- res[0] = element(m_temps, idx, 0);
- res[1] = element(m_temps, idx, 1);
- res[2] = element(m_temps, idx, 2);
- res[3] = element(m_temps, idx, 3);
-
- return res;
-}
-
-std::vector<llvm::Value*> StorageSoa::immediateElement(int idx, int swizzle)
-{
- std::vector<llvm::Value*> res(4);
-
- return res;
-}
-
-llvm::Value * StorageSoa::extractIndex(llvm::Value *vec)
-{
- return 0;
-}
-
-void StorageSoa::storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
- int mask)
-{
- if (mask != TGSI_WRITEMASK_XYZW) {
- fprintf(stderr, "requires swizzle!!\n");
- assert(0);
- } else {
- llvm::Value *xChannel = elementPointer(m_output, dstIdx, 0);
- llvm::Value *yChannel = elementPointer(m_output, dstIdx, 1);
- llvm::Value *zChannel = elementPointer(m_output, dstIdx, 2);
- llvm::Value *wChannel = elementPointer(m_output, dstIdx, 3);
-
- StoreInst *st = new StoreInst(val[0], xChannel, false, m_block);
- st = new StoreInst(val[1], yChannel, false, m_block);
- st = new StoreInst(val[2], zChannel, false, m_block);
- st = new StoreInst(val[3], wChannel, false, m_block);
- }
-}
-
-void StorageSoa::storeTemp(int idx, const std::vector<llvm::Value*> &val,
- int mask)
-{
- if (mask != TGSI_WRITEMASK_XYZW) {
- fprintf(stderr, "requires swizzle!!\n");
- assert(0);
- } else {
- llvm::Value *xChannel = elementPointer(m_temps, idx, 0);
- llvm::Value *yChannel = elementPointer(m_temps, idx, 1);
- llvm::Value *zChannel = elementPointer(m_temps, idx, 2);
- llvm::Value *wChannel = elementPointer(m_temps, idx, 3);
-
- StoreInst *st = new StoreInst(val[0], xChannel, false, m_block);
- st = new StoreInst(val[1], yChannel, false, m_block);
- st = new StoreInst(val[2], zChannel, false, m_block);
- st = new StoreInst(val[3], wChannel, false, m_block);
- }
-}
-
-void StorageSoa::storeAddress(int idx, const std::vector<llvm::Value*> &val,
- int mask)
-{
-}
-
-llvm::Value * StorageSoa::elementPointer(llvm::Value *ptr, int index,
- int channel) const
-{
- std::vector<Value*> indices;
- indices.push_back(constantInt(index));
- indices.push_back(constantInt(channel));
-
- GetElementPtrInst *getElem = new GetElementPtrInst(ptr,
- indices.begin(),
- indices.end(),
- name("ptr"),
- m_block);
- return getElem;
-}
-
-llvm::Value * StorageSoa::element(llvm::Value *ptr, int index,
- int channel) const
-{
- llvm::Value *res = elementPointer(ptr, index, channel);
- LoadInst *load = new LoadInst(res, name("element"), false, m_block);
- //load->setAlignment(8);
- return load;
-}
-
-const char * StorageSoa::name(const char *prefix) const
-{
- ++m_idx;
- snprintf(m_name, 32, "%s%d", prefix, m_idx);
- return m_name;
-}
-
-llvm::ConstantInt * StorageSoa::constantInt(int idx) const
-{
- if (m_constInts.find(idx) != m_constInts.end()) {
- return m_constInts[idx];
- }
- ConstantInt *constInt = ConstantInt::get(APInt(32, idx));
- m_constInts[idx] = constInt;
- return constInt;
-}
diff --git a/src/mesa/pipe/llvm/storagesoa.h b/src/mesa/pipe/llvm/storagesoa.h
deleted file mode 100644
index 84db7726a7..0000000000
--- a/src/mesa/pipe/llvm/storagesoa.h
+++ /dev/null
@@ -1,90 +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 STORAGESOA_H
-#define STORAGESOA_H
-
-#include <vector>
-#include <map>
-
-namespace llvm {
- class BasicBlock;
- class Constant;
- class ConstantInt;
- class LoadInst;
- class Value;
- class VectorType;
-}
-
-class StorageSoa
-{
-public:
- StorageSoa(llvm::BasicBlock *block,
- llvm::Value *input,
- llvm::Value *output,
- llvm::Value *consts,
- llvm::Value *temps);
-
- void addImmediate(float *vec);
-
- llvm::Value * addrElement(int idx) const;
-
- std::vector<llvm::Value*> inputElement(int idx, int swizzle, llvm::Value *indIdx =0);
- std::vector<llvm::Value*> constElement(int idx, int swizzle, llvm::Value *indIdx =0);
- std::vector<llvm::Value*> outputElement(int idx, int swizzle, llvm::Value *indIdx =0);
- std::vector<llvm::Value*> tempElement(int idx, int swizzle, llvm::Value *indIdx =0);
- std::vector<llvm::Value*> immediateElement(int idx, int swizzle);
-
- llvm::Value *extractIndex(llvm::Value *vec);
-
- void storeOutput(int dstIdx, const std::vector<llvm::Value*> &val,
- int mask);
- void storeTemp(int idx, const std::vector<llvm::Value*> &val,
- int mask);
- void storeAddress(int idx, const std::vector<llvm::Value*> &val,
- int mask);
-private:
- llvm::Value *elementPointer(llvm::Value *ptr, int index,
- int channel) const;
- llvm::Value *element(llvm::Value *ptr, int index,
- int channel) const;
- const char *name(const char *prefix) const;
- llvm::ConstantInt *constantInt(int) const;
-private:
- llvm::BasicBlock *m_block;
-
- llvm::Value *m_input;
- llvm::Value *m_output;
- llvm::Value *m_consts;
- llvm::Value *m_temps;
-
- mutable std::map<int, llvm::ConstantInt*> m_constInts;
- mutable char m_name[32];
- mutable int m_idx;
-};
-
-#endif
diff --git a/src/mesa/pipe/llvm/tgsitollvm.cpp b/src/mesa/pipe/llvm/tgsitollvm.cpp
deleted file mode 100644
index 3497eebcd9..0000000000
--- a/src/mesa/pipe/llvm/tgsitollvm.cpp
+++ /dev/null
@@ -1,1208 +0,0 @@
-#include "tgsitollvm.h"
-
-#include "gallivm.h"
-#include "gallivm_p.h"
-
-#include "storage.h"
-#include "instructions.h"
-#include "storagesoa.h"
-#include "instructionssoa.h"
-
-#include "pipe/p_shader_tokens.h"
-
-#include "pipe/tgsi/util/tgsi_parse.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-#include "pipe/tgsi/util/tgsi_util.h"
-#include "pipe/tgsi/util/tgsi_build.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-
-
-#include <llvm/Module.h>
-#include <llvm/CallingConv.h>
-#include <llvm/Constants.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/Pass.h>
-#include <llvm/PassManager.h>
-#include <llvm/ParameterAttributes.h>
-#include <llvm/Support/PatternMatch.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/Interpreter.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/Support/MemoryBuffer.h>
-#include <llvm/LinkAllPasses.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Analysis/LoopPass.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Bitcode/ReaderWriter.h>
-#include <llvm/Transforms/Utils/Cloning.h>
-
-
-#include <sstream>
-#include <fstream>
-#include <iostream>
-
-using namespace llvm;
-#include "llvm_base_shader.cpp"
-
-static inline FunctionType *vertexShaderFunctionType()
-{
- //Function takes three arguments,
- // the calling code has to make sure the types it will
- // pass are castable to the following:
- // [4 x <4 x float>] inputs,
- // [4 x <4 x float>] output,
- // [4 x [4 x float]] consts,
- // [4 x <4 x float>] temps
-
- std::vector<const Type*> funcArgs;
- VectorType *vectorType = VectorType::get(Type::FloatTy, 4);
- ArrayType *vectorArray = ArrayType::get(vectorType, 4);
- PointerType *vectorArrayPtr = PointerType::get(vectorArray, 0);
-
- ArrayType *floatArray = ArrayType::get(Type::FloatTy, 4);
- ArrayType *constsArray = ArrayType::get(floatArray, 4);
- PointerType *constsArrayPtr = PointerType::get(constsArray, 0);
-
- funcArgs.push_back(vectorArrayPtr);//inputs
- funcArgs.push_back(vectorArrayPtr);//output
- funcArgs.push_back(constsArrayPtr);//consts
- funcArgs.push_back(vectorArrayPtr);//temps
-
- FunctionType *functionType = FunctionType::get(
- /*Result=*/Type::VoidTy,
- /*Params=*/funcArgs,
- /*isVarArg=*/false);
-
- return functionType;
-}
-
-static inline void
-add_interpolator(struct gallivm_ir *ir,
- struct gallivm_interpolate *interp)
-{
- ir->interpolators[ir->num_interp] = *interp;
- ++ir->num_interp;
-}
-
-static void
-translate_declaration(struct gallivm_ir *prog,
- llvm::Module *module,
- Storage *storage,
- struct tgsi_full_declaration *decl,
- struct tgsi_full_declaration *fd)
-{
- if (decl->Declaration.File == TGSI_FILE_INPUT) {
- unsigned first, last, mask;
- uint interp_method;
-
- assert(decl->Declaration.Declare == TGSI_DECLARE_RANGE);
-
- first = decl->u.DeclarationRange.First;
- last = decl->u.DeclarationRange.Last;
- mask = decl->Declaration.UsageMask;
-
- /* Do not touch WPOS.xy */
- if (first == 0) {
- mask &= ~TGSI_WRITEMASK_XY;
- if (mask == TGSI_WRITEMASK_NONE) {
- first++;
- if (first > last) {
- return;
- }
- }
- }
-
- interp_method = decl->Interpolation.Interpolate;
-
- if (mask == TGSI_WRITEMASK_XYZW) {
- unsigned i, j;
-
- for (i = first; i <= last; i++) {
- for (j = 0; j < NUM_CHANNELS; j++) {
- //interp( mach, i, j );
- struct gallivm_interpolate interp;
- interp.type = interp_method;
- interp.attrib = i;
- interp.chan = j;
- add_interpolator(prog, &interp);
- }
- }
- } else {
- unsigned i, j;
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- if( mask & (1 << j) ) {
- for( i = first; i <= last; i++ ) {
- struct gallivm_interpolate interp;
- interp.type = interp_method;
- interp.attrib = i;
- interp.chan = j;
- add_interpolator(prog, &interp);
- }
- }
- }
- }
- }
-}
-
-static void
-translate_declarationir(struct gallivm_ir *,
- llvm::Module *,
- StorageSoa *,
- struct tgsi_full_declaration *,
- struct tgsi_full_declaration *)
-{
-}
-
-static void
-translate_immediate(Storage *storage,
- struct tgsi_full_immediate *imm)
-{
- float vec[4];
- int i;
- for (i = 0; i < imm->Immediate.Size - 1; ++i) {
- switch (imm->Immediate.DataType) {
- case TGSI_IMM_FLOAT32:
- vec[i] = imm->u.ImmediateFloat32[i].Float;
- break;
- default:
- assert(0);
- }
- }
- storage->addImmediate(vec);
-}
-
-
-static void
-translate_immediateir(StorageSoa *storage,
- struct tgsi_full_immediate *imm)
-{
- float vec[4];
- int i;
- for (i = 0; i < imm->Immediate.Size - 1; ++i) {
- switch (imm->Immediate.DataType) {
- case TGSI_IMM_FLOAT32:
- vec[i] = imm->u.ImmediateFloat32[i].Float;
- break;
- default:
- assert(0);
- }
- }
- storage->addImmediate(vec);
-}
-
-static inline int
-swizzleInt(struct tgsi_full_src_register *src)
-{
- int swizzle = 0;
- int start = 1000;
-
- for (int k = 0; k < 4; ++k) {
- swizzle += tgsi_util_get_full_src_register_extswizzle(src, k) * start;
- start /= 10;
- }
- return swizzle;
-}
-
-static inline llvm::Value *
-swizzleVector(llvm::Value *val, struct tgsi_full_src_register *src,
- Storage *storage)
-{
- int swizzle = swizzleInt(src);
-
- if (gallivm_is_swizzle(swizzle)) {
- /*fprintf(stderr, "XXXXXXXX swizzle = %d\n", swizzle);*/
- val = storage->shuffleVector(val, swizzle);
- }
- return val;
-}
-
-static void
-translate_instruction(llvm::Module *module,
- Storage *storage,
- Instructions *instr,
- struct tgsi_full_instruction *inst,
- struct tgsi_full_instruction *fi,
- unsigned instno)
-{
- llvm::Value *inputs[4];
- inputs[0] = 0;
- inputs[1] = 0;
- inputs[2] = 0;
- inputs[3] = 0;
-
- for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
- llvm::Value *val = 0;
- llvm::Value *indIdx = 0;
-
- if (src->SrcRegister.Indirect) {
- indIdx = storage->addrElement(src->SrcRegisterInd.Index);
- indIdx = storage->extractIndex(indIdx);
- }
- if (src->SrcRegister.File == TGSI_FILE_CONSTANT) {
- val = storage->constElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_INPUT) {
- val = storage->inputElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
- val = storage->tempElement(src->SrcRegister.Index);
- } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) {
- val = storage->outputElement(src->SrcRegister.Index, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_IMMEDIATE) {
- val = storage->immediateElement(src->SrcRegister.Index);
- } else {
- fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File);
- return;
- }
-
- inputs[i] = swizzleVector(val, src, storage);
- }
-
- /*if (inputs[0])
- instr->printVector(inputs[0]);
- if (inputs[1])
- instr->printVector(inputs[1]);*/
- llvm::Value *out = 0;
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ARL: {
- out = instr->arl(inputs[0]);
- }
- break;
- case TGSI_OPCODE_MOV: {
- out = inputs[0];
- }
- break;
- case TGSI_OPCODE_LIT: {
- out = instr->lit(inputs[0]);
- }
- break;
- case TGSI_OPCODE_RCP: {
- out = instr->rcp(inputs[0]);
- }
- break;
- case TGSI_OPCODE_RSQ: {
- out = instr->rsq(inputs[0]);
- }
- break;
- case TGSI_OPCODE_EXP:
- break;
- case TGSI_OPCODE_LOG:
- break;
- case TGSI_OPCODE_MUL: {
- out = instr->mul(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_ADD: {
- out = instr->add(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_DP3: {
- out = instr->dp3(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_DP4: {
- out = instr->dp4(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_DST: {
- out = instr->dst(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_MIN: {
- out = instr->min(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_MAX: {
- out = instr->max(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_SLT: {
- out = instr->slt(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_SGE: {
- out = instr->sge(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_MAD: {
- out = instr->madd(inputs[0], inputs[1], inputs[2]);
- }
- break;
- case TGSI_OPCODE_SUB: {
- out = instr->sub(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_LERP: {
- out = instr->lerp(inputs[0], inputs[1], inputs[2]);
- }
- break;
- case TGSI_OPCODE_CND:
- break;
- case TGSI_OPCODE_CND0:
- break;
- case TGSI_OPCODE_DOT2ADD:
- break;
- case TGSI_OPCODE_INDEX:
- break;
- case TGSI_OPCODE_NEGATE:
- break;
- case TGSI_OPCODE_FRAC: {
- out = instr->frc(inputs[0]);
- }
- break;
- case TGSI_OPCODE_CLAMP:
- break;
- case TGSI_OPCODE_FLOOR: {
- out = instr->floor(inputs[0]);
- }
- break;
- case TGSI_OPCODE_ROUND:
- break;
- case TGSI_OPCODE_EXPBASE2: {
- out = instr->ex2(inputs[0]);
- }
- break;
- case TGSI_OPCODE_LOGBASE2: {
- out = instr->lg2(inputs[0]);
- }
- break;
- case TGSI_OPCODE_POWER: {
- out = instr->pow(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_CROSSPRODUCT: {
- out = instr->cross(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_MULTIPLYMATRIX:
- break;
- case TGSI_OPCODE_ABS: {
- out = instr->abs(inputs[0]);
- }
- break;
- case TGSI_OPCODE_RCC:
- break;
- case TGSI_OPCODE_DPH: {
- out = instr->dph(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_COS: {
- out = instr->cos(inputs[0]);
- }
- break;
- case TGSI_OPCODE_DDX:
- break;
- case TGSI_OPCODE_DDY:
- break;
- case TGSI_OPCODE_KILP: {
- out = instr->kilp(inputs[0]);
- storage->setKilElement(out);
- return;
- }
- break;
- case TGSI_OPCODE_PK2H:
- break;
- case TGSI_OPCODE_PK2US:
- break;
- case TGSI_OPCODE_PK4B:
- break;
- case TGSI_OPCODE_PK4UB:
- break;
- case TGSI_OPCODE_RFL:
- break;
- case TGSI_OPCODE_SEQ:
- break;
- case TGSI_OPCODE_SFL:
- break;
- case TGSI_OPCODE_SGT: {
- out = instr->sgt(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_SIN: {
- out = instr->sin(inputs[0]);
- }
- break;
- case TGSI_OPCODE_SLE:
- break;
- case TGSI_OPCODE_SNE:
- break;
- case TGSI_OPCODE_STR:
- break;
- case TGSI_OPCODE_TEX:
- break;
- case TGSI_OPCODE_TXD:
- break;
- case TGSI_OPCODE_UP2H:
- break;
- case TGSI_OPCODE_UP2US:
- break;
- case TGSI_OPCODE_UP4B:
- break;
- case TGSI_OPCODE_UP4UB:
- break;
- case TGSI_OPCODE_X2D:
- break;
- case TGSI_OPCODE_ARA:
- break;
- case TGSI_OPCODE_ARR:
- break;
- case TGSI_OPCODE_BRA:
- break;
- case TGSI_OPCODE_CAL: {
- instr->cal(inst->InstructionExtLabel.Label, storage->inputPtr());
- return;
- }
- break;
- case TGSI_OPCODE_RET: {
- instr->end();
- return;
- }
- break;
- case TGSI_OPCODE_SSG:
- break;
- case TGSI_OPCODE_CMP: {
- out = instr->cmp(inputs[0], inputs[1], inputs[2]);
- }
- break;
- case TGSI_OPCODE_SCS: {
- out = instr->scs(inputs[0]);
- }
- break;
- case TGSI_OPCODE_TXB:
- break;
- case TGSI_OPCODE_NRM:
- break;
- case TGSI_OPCODE_DIV:
- break;
- case TGSI_OPCODE_DP2:
- break;
- case TGSI_OPCODE_TXL:
- break;
- case TGSI_OPCODE_BRK: {
- instr->brk();
- return;
- }
- break;
- case TGSI_OPCODE_IF: {
- instr->ifop(inputs[0]);
- storage->setCurrentBlock(instr->currentBlock());
- return; //just update the state
- }
- break;
- case TGSI_OPCODE_LOOP:
- break;
- case TGSI_OPCODE_REP:
- break;
- case TGSI_OPCODE_ELSE: {
- instr->elseop();
- storage->setCurrentBlock(instr->currentBlock());
- return; //only state update
- }
- break;
- case TGSI_OPCODE_ENDIF: {
- instr->endif();
- storage->setCurrentBlock(instr->currentBlock());
- return; //just update the state
- }
- break;
- case TGSI_OPCODE_ENDLOOP:
- break;
- case TGSI_OPCODE_ENDREP:
- break;
- case TGSI_OPCODE_PUSHA:
- break;
- case TGSI_OPCODE_POPA:
- break;
- case TGSI_OPCODE_CEIL:
- break;
- case TGSI_OPCODE_I2F:
- break;
- case TGSI_OPCODE_NOT:
- break;
- case TGSI_OPCODE_TRUNC: {
- out = instr->trunc(inputs[0]);
- }
- break;
- case TGSI_OPCODE_SHL:
- break;
- case TGSI_OPCODE_SHR:
- break;
- case TGSI_OPCODE_AND:
- break;
- case TGSI_OPCODE_OR:
- break;
- case TGSI_OPCODE_MOD:
- break;
- case TGSI_OPCODE_XOR:
- break;
- case TGSI_OPCODE_SAD:
- break;
- case TGSI_OPCODE_TXF:
- break;
- case TGSI_OPCODE_TXQ:
- break;
- case TGSI_OPCODE_CONT:
- break;
- case TGSI_OPCODE_EMIT:
- break;
- case TGSI_OPCODE_ENDPRIM:
- break;
- case TGSI_OPCODE_BGNLOOP2: {
- instr->beginLoop();
- storage->setCurrentBlock(instr->currentBlock());
- return;
- }
- break;
- case TGSI_OPCODE_BGNSUB: {
- instr->bgnSub(instno);
- storage->setCurrentBlock(instr->currentBlock());
- storage->pushTemps();
- return;
- }
- break;
- case TGSI_OPCODE_ENDLOOP2: {
- instr->endLoop();
- storage->setCurrentBlock(instr->currentBlock());
- return;
- }
- break;
- case TGSI_OPCODE_ENDSUB: {
- instr->endSub();
- storage->setCurrentBlock(instr->currentBlock());
- storage->popArguments();
- storage->popTemps();
- return;
- }
- break;
- case TGSI_OPCODE_NOISE1:
- break;
- case TGSI_OPCODE_NOISE2:
- break;
- case TGSI_OPCODE_NOISE3:
- break;
- case TGSI_OPCODE_NOISE4:
- break;
- case TGSI_OPCODE_NOP:
- break;
- case TGSI_OPCODE_TEXBEM:
- break;
- case TGSI_OPCODE_TEXBEML:
- break;
- case TGSI_OPCODE_TEXREG2AR:
- break;
- case TGSI_OPCODE_TEXM3X2PAD:
- break;
- case TGSI_OPCODE_TEXM3X2TEX:
- break;
- case TGSI_OPCODE_TEXM3X3PAD:
- break;
- case TGSI_OPCODE_TEXM3X3TEX:
- break;
- case TGSI_OPCODE_TEXM3X3SPEC:
- break;
- case TGSI_OPCODE_TEXM3X3VSPEC:
- break;
- case TGSI_OPCODE_TEXREG2GB:
- break;
- case TGSI_OPCODE_TEXREG2RGB:
- break;
- case TGSI_OPCODE_TEXDP3TEX:
- break;
- case TGSI_OPCODE_TEXDP3:
- break;
- case TGSI_OPCODE_TEXM3X3:
- break;
- case TGSI_OPCODE_TEXM3X2DEPTH:
- break;
- case TGSI_OPCODE_TEXDEPTH:
- break;
- case TGSI_OPCODE_BEM:
- break;
- case TGSI_OPCODE_M4X3:
- break;
- case TGSI_OPCODE_M3X4:
- break;
- case TGSI_OPCODE_M3X3:
- break;
- case TGSI_OPCODE_M3X2:
- break;
- case TGSI_OPCODE_NRM4:
- break;
- case TGSI_OPCODE_CALLNZ:
- break;
- case TGSI_OPCODE_IFC:
- break;
- case TGSI_OPCODE_BREAKC:
- break;
- case TGSI_OPCODE_KIL:
- break;
- case TGSI_OPCODE_END:
- instr->end();
- return;
- break;
- default:
- fprintf(stderr, "ERROR: Unknown opcode %d\n",
- inst->Instruction.Opcode);
- assert(0);
- break;
- }
-
- if (!out) {
- fprintf(stderr, "ERROR: unsupported opcode %d\n",
- inst->Instruction.Opcode);
- assert(!"Unsupported opcode");
- }
-
- /* # not sure if we need this */
- switch( inst->Instruction.Saturate ) {
- case TGSI_SAT_NONE:
- break;
- case TGSI_SAT_ZERO_ONE:
- /*TXT( "_SAT" );*/
- break;
- case TGSI_SAT_MINUS_PLUS_ONE:
- /*TXT( "_SAT[-1,1]" );*/
- break;
- default:
- assert( 0 );
- }
-
- /* store results */
- for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-
- if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
- storage->setOutputElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_TEMPORARY) {
- storage->setTempElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_ADDRESS) {
- storage->setAddrElement(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else {
- fprintf(stderr, "ERROR: unsupported LLVM destination!");
- assert(!"wrong destination");
- }
- }
-}
-
-
-static void
-translate_instructionir(llvm::Module *module,
- StorageSoa *storage,
- InstructionsSoa *instr,
- struct tgsi_full_instruction *inst,
- struct tgsi_full_instruction *fi,
- unsigned instno)
-{
- std::vector< std::vector<llvm::Value*> > inputs(inst->Instruction.NumSrcRegs);
-
- for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
- std::vector<llvm::Value*> val;
- llvm::Value *indIdx = 0;
- int swizzle = swizzleInt(src);
-
- if (src->SrcRegister.Indirect) {
- indIdx = storage->addrElement(src->SrcRegisterInd.Index);
- indIdx = storage->extractIndex(indIdx);
- }
- if (src->SrcRegister.File == TGSI_FILE_CONSTANT) {
- val = storage->constElement(src->SrcRegister.Index, swizzle, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_INPUT) {
- val = storage->inputElement(src->SrcRegister.Index, swizzle, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_TEMPORARY) {
- val = storage->tempElement(src->SrcRegister.Index, swizzle);
- } else if (src->SrcRegister.File == TGSI_FILE_OUTPUT) {
- val = storage->outputElement(src->SrcRegister.Index, swizzle, indIdx);
- } else if (src->SrcRegister.File == TGSI_FILE_IMMEDIATE) {
- val = storage->immediateElement(src->SrcRegister.Index, swizzle);
- } else {
- fprintf(stderr, "ERROR: not supported llvm source %d\n", src->SrcRegister.File);
- return;
- }
-
- inputs[i] = val;
- }
-
- std::vector<llvm::Value*> out(4);
- switch (inst->Instruction.Opcode) {
- case TGSI_OPCODE_ARL: {
- }
- break;
- case TGSI_OPCODE_MOV: {
- out = inputs[0];
- }
- break;
- case TGSI_OPCODE_LIT: {
- }
- break;
- case TGSI_OPCODE_RCP: {
- }
- break;
- case TGSI_OPCODE_RSQ: {
- }
- break;
- case TGSI_OPCODE_EXP:
- break;
- case TGSI_OPCODE_LOG:
- break;
- case TGSI_OPCODE_MUL: {
- out = instr->mul(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_ADD: {
- out = instr->add(inputs[0], inputs[1]);
- }
- break;
- case TGSI_OPCODE_DP3: {
- }
- break;
- case TGSI_OPCODE_DP4: {
- }
- break;
- case TGSI_OPCODE_DST: {
- }
- break;
- case TGSI_OPCODE_MIN: {
- }
- break;
- case TGSI_OPCODE_MAX: {
- }
- break;
- case TGSI_OPCODE_SLT: {
- }
- break;
- case TGSI_OPCODE_SGE: {
- }
- break;
- case TGSI_OPCODE_MAD: {
- }
- break;
- case TGSI_OPCODE_SUB: {
- }
- break;
- case TGSI_OPCODE_LERP: {
- }
- break;
- case TGSI_OPCODE_CND:
- break;
- case TGSI_OPCODE_CND0:
- break;
- case TGSI_OPCODE_DOT2ADD:
- break;
- case TGSI_OPCODE_INDEX:
- break;
- case TGSI_OPCODE_NEGATE:
- break;
- case TGSI_OPCODE_FRAC: {
- }
- break;
- case TGSI_OPCODE_CLAMP:
- break;
- case TGSI_OPCODE_FLOOR: {
- }
- break;
- case TGSI_OPCODE_ROUND:
- break;
- case TGSI_OPCODE_EXPBASE2: {
- }
- break;
- case TGSI_OPCODE_LOGBASE2: {
- }
- break;
- case TGSI_OPCODE_POWER: {
- }
- break;
- case TGSI_OPCODE_CROSSPRODUCT: {
- }
- break;
- case TGSI_OPCODE_MULTIPLYMATRIX:
- break;
- case TGSI_OPCODE_ABS: {
- }
- break;
- case TGSI_OPCODE_RCC:
- break;
- case TGSI_OPCODE_DPH: {
- }
- break;
- case TGSI_OPCODE_COS: {
- }
- break;
- case TGSI_OPCODE_DDX:
- break;
- case TGSI_OPCODE_DDY:
- break;
- case TGSI_OPCODE_KILP: {
- }
- break;
- case TGSI_OPCODE_PK2H:
- break;
- case TGSI_OPCODE_PK2US:
- break;
- case TGSI_OPCODE_PK4B:
- break;
- case TGSI_OPCODE_PK4UB:
- break;
- case TGSI_OPCODE_RFL:
- break;
- case TGSI_OPCODE_SEQ:
- break;
- case TGSI_OPCODE_SFL:
- break;
- case TGSI_OPCODE_SGT: {
- }
- break;
- case TGSI_OPCODE_SIN: {
- }
- break;
- case TGSI_OPCODE_SLE:
- break;
- case TGSI_OPCODE_SNE:
- break;
- case TGSI_OPCODE_STR:
- break;
- case TGSI_OPCODE_TEX:
- break;
- case TGSI_OPCODE_TXD:
- break;
- case TGSI_OPCODE_UP2H:
- break;
- case TGSI_OPCODE_UP2US:
- break;
- case TGSI_OPCODE_UP4B:
- break;
- case TGSI_OPCODE_UP4UB:
- break;
- case TGSI_OPCODE_X2D:
- break;
- case TGSI_OPCODE_ARA:
- break;
- case TGSI_OPCODE_ARR:
- break;
- case TGSI_OPCODE_BRA:
- break;
- case TGSI_OPCODE_CAL: {
- }
- break;
- case TGSI_OPCODE_RET: {
- }
- break;
- case TGSI_OPCODE_SSG:
- break;
- case TGSI_OPCODE_CMP: {
- }
- break;
- case TGSI_OPCODE_SCS: {
- }
- break;
- case TGSI_OPCODE_TXB:
- break;
- case TGSI_OPCODE_NRM:
- break;
- case TGSI_OPCODE_DIV:
- break;
- case TGSI_OPCODE_DP2:
- break;
- case TGSI_OPCODE_TXL:
- break;
- case TGSI_OPCODE_BRK: {
- }
- break;
- case TGSI_OPCODE_IF: {
- }
- break;
- case TGSI_OPCODE_LOOP:
- break;
- case TGSI_OPCODE_REP:
- break;
- case TGSI_OPCODE_ELSE: {
- }
- break;
- case TGSI_OPCODE_ENDIF: {
- }
- break;
- case TGSI_OPCODE_ENDLOOP:
- break;
- case TGSI_OPCODE_ENDREP:
- break;
- case TGSI_OPCODE_PUSHA:
- break;
- case TGSI_OPCODE_POPA:
- break;
- case TGSI_OPCODE_CEIL:
- break;
- case TGSI_OPCODE_I2F:
- break;
- case TGSI_OPCODE_NOT:
- break;
- case TGSI_OPCODE_TRUNC: {
- }
- break;
- case TGSI_OPCODE_SHL:
- break;
- case TGSI_OPCODE_SHR:
- break;
- case TGSI_OPCODE_AND:
- break;
- case TGSI_OPCODE_OR:
- break;
- case TGSI_OPCODE_MOD:
- break;
- case TGSI_OPCODE_XOR:
- break;
- case TGSI_OPCODE_SAD:
- break;
- case TGSI_OPCODE_TXF:
- break;
- case TGSI_OPCODE_TXQ:
- break;
- case TGSI_OPCODE_CONT:
- break;
- case TGSI_OPCODE_EMIT:
- break;
- case TGSI_OPCODE_ENDPRIM:
- break;
- case TGSI_OPCODE_BGNLOOP2: {
- }
- break;
- case TGSI_OPCODE_BGNSUB: {
- }
- break;
- case TGSI_OPCODE_ENDLOOP2: {
- }
- break;
- case TGSI_OPCODE_ENDSUB: {
- }
- break;
- case TGSI_OPCODE_NOISE1:
- break;
- case TGSI_OPCODE_NOISE2:
- break;
- case TGSI_OPCODE_NOISE3:
- break;
- case TGSI_OPCODE_NOISE4:
- break;
- case TGSI_OPCODE_NOP:
- break;
- case TGSI_OPCODE_TEXBEM:
- break;
- case TGSI_OPCODE_TEXBEML:
- break;
- case TGSI_OPCODE_TEXREG2AR:
- break;
- case TGSI_OPCODE_TEXM3X2PAD:
- break;
- case TGSI_OPCODE_TEXM3X2TEX:
- break;
- case TGSI_OPCODE_TEXM3X3PAD:
- break;
- case TGSI_OPCODE_TEXM3X3TEX:
- break;
- case TGSI_OPCODE_TEXM3X3SPEC:
- break;
- case TGSI_OPCODE_TEXM3X3VSPEC:
- break;
- case TGSI_OPCODE_TEXREG2GB:
- break;
- case TGSI_OPCODE_TEXREG2RGB:
- break;
- case TGSI_OPCODE_TEXDP3TEX:
- break;
- case TGSI_OPCODE_TEXDP3:
- break;
- case TGSI_OPCODE_TEXM3X3:
- break;
- case TGSI_OPCODE_TEXM3X2DEPTH:
- break;
- case TGSI_OPCODE_TEXDEPTH:
- break;
- case TGSI_OPCODE_BEM:
- break;
- case TGSI_OPCODE_M4X3:
- break;
- case TGSI_OPCODE_M3X4:
- break;
- case TGSI_OPCODE_M3X3:
- break;
- case TGSI_OPCODE_M3X2:
- break;
- case TGSI_OPCODE_NRM4:
- break;
- case TGSI_OPCODE_CALLNZ:
- break;
- case TGSI_OPCODE_IFC:
- break;
- case TGSI_OPCODE_BREAKC:
- break;
- case TGSI_OPCODE_KIL:
- break;
- case TGSI_OPCODE_END:
- instr->end();
- return;
- break;
- default:
- fprintf(stderr, "ERROR: Unknown opcode %d\n",
- inst->Instruction.Opcode);
- assert(0);
- break;
- }
-
- if (!out[0]) {
- fprintf(stderr, "ERROR: unsupported opcode %d\n",
- inst->Instruction.Opcode);
- assert(!"Unsupported opcode");
- }
-
- /* store results */
- for (int i = 0; i < inst->Instruction.NumDstRegs; ++i) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-
- if (dst->DstRegister.File == TGSI_FILE_OUTPUT) {
- storage->storeOutput(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_TEMPORARY) {
- storage->storeTemp(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else if (dst->DstRegister.File == TGSI_FILE_ADDRESS) {
- storage->storeAddress(dst->DstRegister.Index, out, dst->DstRegister.WriteMask);
- } else {
- fprintf(stderr, "ERROR: unsupported LLVM destination!");
- assert(!"wrong destination");
- }
- }
-}
-
-llvm::Module *
-tgsi_to_llvm(struct gallivm_ir *ir, const struct tgsi_token *tokens)
-{
- llvm::Module *mod = createBaseShader();
- struct tgsi_parse_context parse;
- struct tgsi_full_instruction fi;
- struct tgsi_full_declaration fd;
- unsigned instno = 0;
- Function* shader = mod->getFunction("execute_shader");
- std::ostringstream stream;
- if (ir->type == GALLIVM_VS) {
- stream << "vs_shader";
- } else {
- stream << "fs_shader";
- }
- stream << ir->id;
- std::string func_name = stream.str();
- shader->setName(func_name.c_str());
-
- Function::arg_iterator args = shader->arg_begin();
- Value *ptr_INPUT = args++;
- ptr_INPUT->setName("input");
-
- BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
-
- tgsi_parse_init(&parse, tokens);
-
- fi = tgsi_default_full_instruction();
- fd = tgsi_default_full_declaration();
- Storage storage(label_entry, ptr_INPUT);
- Instructions instr(mod, shader, label_entry, &storage);
- while(!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
-
- switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- translate_declaration(ir, mod, &storage,
- &parse.FullToken.FullDeclaration,
- &fd);
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- translate_immediate(&storage,
- &parse.FullToken.FullImmediate);
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- translate_instruction(mod, &storage, &instr,
- &parse.FullToken.FullInstruction,
- &fi, instno);
- ++instno;
- break;
-
- default:
- assert(0);
- }
- }
-
- tgsi_parse_free(&parse);
-
- ir->num_consts = storage.numConsts();
- return mod;
-}
-
-llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
- const struct tgsi_token *tokens)
-{
- llvm::Module *mod = new Module("shader");
- struct tgsi_parse_context parse;
- struct tgsi_full_instruction fi;
- struct tgsi_full_declaration fd;
- unsigned instno = 0;
- std::ostringstream stream;
- if (ir->type == GALLIVM_VS) {
- stream << "vs_shader";
- } else {
- stream << "fs_shader";
- }
- //stream << ir->id;
- std::string func_name = stream.str();
- Function *shader = llvm::cast<Function>(mod->getOrInsertFunction(
- func_name.c_str(),
- vertexShaderFunctionType()));
-
- Function::arg_iterator args = shader->arg_begin();
- Value *input = args++;
- input->setName("inputs");
- Value *output = args++;
- output->setName("outputs");
- Value *consts = args++;
- consts->setName("consts");
- Value *temps = args++;
- temps->setName("temps");
-
- BasicBlock *label_entry = new BasicBlock("entry", shader, 0);
-
- tgsi_parse_init(&parse, tokens);
-
- fi = tgsi_default_full_instruction();
- fd = tgsi_default_full_declaration();
-
- StorageSoa storage(label_entry, input, output, consts, temps);
- InstructionsSoa instr(mod, shader, label_entry, &storage);
-
- while(!tgsi_parse_end_of_tokens(&parse)) {
- tgsi_parse_token(&parse);
-
- switch (parse.FullToken.Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- translate_declarationir(ir, mod, &storage,
- &parse.FullToken.FullDeclaration,
- &fd);
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- translate_immediateir(&storage,
- &parse.FullToken.FullImmediate);
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- translate_instructionir(mod, &storage, &instr,
- &parse.FullToken.FullInstruction,
- &fi, instno);
- ++instno;
- break;
-
- default:
- assert(0);
- }
- }
-
- tgsi_parse_free(&parse);
-
- return mod;
-}
diff --git a/src/mesa/pipe/llvm/tgsitollvm.h b/src/mesa/pipe/llvm/tgsitollvm.h
deleted file mode 100644
index 7ada04d629..0000000000
--- a/src/mesa/pipe/llvm/tgsitollvm.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef TGSITOLLVM_H
-#define TGSITOLLVM_H
-
-
-namespace llvm {
- class Module;
-}
-
-struct gallivm_ir;
-struct tgsi_token;
-
-
-llvm::Module * tgsi_to_llvm(struct gallivm_ir *ir,
- const struct tgsi_token *tokens);
-
-
-llvm::Module * tgsi_to_llvmir(struct gallivm_ir *ir,
- const struct tgsi_token *tokens);
-
-#endif
diff --git a/src/mesa/pipe/p_compiler.h b/src/mesa/pipe/p_compiler.h
deleted file mode 100644
index 30cd729c56..0000000000
--- a/src/mesa/pipe/p_compiler.h
+++ /dev/null
@@ -1,116 +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_COMPILER_H
-#define P_COMPILER_H
-
-
-#include <stdlib.h>
-#include <string.h>
-
-
-#if defined(_WIN32) && !defined(__WIN32__)
-#define __WIN32__
-#endif
-
-#if defined(_MSC_VER) && !defined(__MSC__)
-#define __MSC__
-#endif
-
-
-typedef unsigned int uint;
-typedef unsigned char ubyte;
-typedef unsigned char boolean;
-typedef unsigned short ushort;
-typedef unsigned long long uint64;
-
-
-#if defined(__MSC__)
-
-typedef char int8_t;
-typedef unsigned char uint8_t;
-typedef short int16_t;
-typedef unsigned short uint16_t;
-typedef long int32_t;
-typedef unsigned long uint32_t;
-typedef long long int64_t;
-typedef unsigned long long uint64_t;
-
-#if defined(_WIN64)
-typedef unsigned __int64 uintptr_t;
-#else
-typedef unsigned int uintptr_t;
-#endif
-
-#else
-#include <stdint.h>
-#endif
-
-
-#define TRUE 1
-#define FALSE 0
-
-
-/* Function inlining */
-#if defined(__GNUC__)
-# define INLINE __inline__
-#elif defined(__MSC__)
-# define INLINE __inline
-#elif defined(__ICL)
-# define INLINE __inline
-#elif defined(__INTEL_COMPILER)
-# define INLINE inline
-#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
-# define INLINE __inline
-#else
-# define INLINE
-#endif
-
-
-#if defined __GNUC__
-#define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___aligned[SIZE] __attribute__(( aligned( 16 ) ))
-#define ALIGN16_ASSIGN(NAME) NAME##___aligned
-#define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) ))
-#else
-#define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1]
-#define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned)
-#define ALIGN16_ATTRIB
-#endif
-
-
-
-/** For calling code-gen'd functions */
-#if !defined(XSTDCALL)
-#if defined(WIN32)
-#define XSTDCALL __stdcall
-#else
-#define XSTDCALL
-#endif
-#endif
-
-
-#endif /* P_COMPILER_H */
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
deleted file mode 100644
index 39f95695fb..0000000000
--- a/src/mesa/pipe/p_context.h
+++ /dev/null
@@ -1,221 +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 PIPE_CONTEXT_H
-#define PIPE_CONTEXT_H
-
-#include "p_state.h"
-
-
-struct pipe_state_cache;
-
-/* Opaque driver handles:
- */
-struct pipe_query;
-
-/**
- * Gallium rendering context. Basically:
- * - state setting functions
- * - VBO drawing functions
- * - surface functions
- * - device queries
- */
-struct pipe_context {
- struct pipe_winsys *winsys;
-
- void *priv; /** context private data (for DRI for example) */
-
- void (*destroy)( struct pipe_context * );
-
- /*
- * Queries
- */
- /** type is one of PIPE_SURFACE, PIPE_TEXTURE, etc. */
- boolean (*is_format_supported)( struct pipe_context *pipe,
- enum pipe_format format, uint type );
-
- const char *(*get_name)( struct pipe_context *pipe );
-
- const char *(*get_vendor)( struct pipe_context *pipe );
-
- int (*get_param)( struct pipe_context *pipe, int param );
- float (*get_paramf)( struct pipe_context *pipe, int param );
-
-
- /*
- * Drawing.
- * Return false on fallbacks (temporary??)
- */
- boolean (*draw_arrays)( struct pipe_context *pipe,
- unsigned mode, unsigned start, unsigned count);
-
- boolean (*draw_elements)( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count);
-
-
- /**
- * Query objects
- */
- struct pipe_query *(*create_query)( struct pipe_context *pipe,
- unsigned query_type );
-
- void (*destroy_query)(struct pipe_context *pipe,
- struct pipe_query *q);
-
- void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q);
- void (*end_query)(struct pipe_context *pipe, struct pipe_query *q);
-
- boolean (*get_query_result)(struct pipe_context *pipe,
- struct pipe_query *q,
- boolean wait,
- uint64 *result);
-
- /*
- * State functions
- */
- void * (*create_blend_state)(struct pipe_context *,
- const struct pipe_blend_state *);
- void (*bind_blend_state)(struct pipe_context *, void *);
- void (*delete_blend_state)(struct pipe_context *, void *);
-
- void * (*create_sampler_state)(struct pipe_context *,
- const struct pipe_sampler_state *);
- void (*bind_sampler_state)(struct pipe_context *, unsigned unit, void *);
- void (*delete_sampler_state)(struct pipe_context *, void *);
-
- void * (*create_rasterizer_state)(struct pipe_context *,
- const struct pipe_rasterizer_state *);
- void (*bind_rasterizer_state)(struct pipe_context *, void *);
- void (*delete_rasterizer_state)(struct pipe_context *, void *);
-
- void * (*create_depth_stencil_alpha_state)(struct pipe_context *,
- const struct pipe_depth_stencil_alpha_state *);
- void (*bind_depth_stencil_alpha_state)(struct pipe_context *, void *);
- void (*delete_depth_stencil_alpha_state)(struct pipe_context *, void *);
-
- void * (*create_fs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
- void (*bind_fs_state)(struct pipe_context *, void *);
- void (*delete_fs_state)(struct pipe_context *, void *);
-
- void * (*create_vs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
- void (*bind_vs_state)(struct pipe_context *, void *);
- void (*delete_vs_state)(struct pipe_context *, void *);
-
- /* The following look more properties than states.
- * maybe combine a few of them into states or pass them
- * in the bind calls to the state */
- void (*set_blend_color)( struct pipe_context *,
- const struct pipe_blend_color * );
-
- void (*set_clip_state)( struct pipe_context *,
- const struct pipe_clip_state * );
-
- void (*set_constant_buffer)( struct pipe_context *,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf );
-
- void (*set_framebuffer_state)( struct pipe_context *,
- const struct pipe_framebuffer_state * );
-
- void (*set_polygon_stipple)( struct pipe_context *,
- const struct pipe_poly_stipple * );
-
- void (*set_scissor_state)( struct pipe_context *,
- const struct pipe_scissor_state * );
-
-
- /* Currently a sampler is constrained to sample from a single texture:
- */
- void (*set_sampler_texture)( struct pipe_context *,
- unsigned sampler,
- struct pipe_texture * );
-
- void (*set_viewport_state)( struct pipe_context *,
- const struct pipe_viewport_state * );
-
- /*
- * Vertex arrays
- */
- void (*set_vertex_buffer)( struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_buffer * );
-
- void (*set_vertex_element)( struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_element * );
-
-
- /*
- * Surface functions
- */
-
- void (*surface_copy)(struct pipe_context *pipe,
- unsigned do_flip, /*<< flip surface contents vertically */
- struct pipe_surface *dest,
- unsigned destx, unsigned desty,
- struct pipe_surface *src, /* don't make this const -
- need to map/unmap */
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height);
-
- void (*surface_fill)(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height,
- unsigned value);
-
- void (*clear)(struct pipe_context *pipe,
- struct pipe_surface *ps,
- unsigned clearValue);
-
-
- /*
- * Texture functions
- */
- struct pipe_texture * (*texture_create)(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
- void (*texture_release)(struct pipe_context *pipe,
- struct pipe_texture **pt);
-
- /** Get a surface which is a "view" into a texture */
- struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level,
- unsigned zslice);
-
- /* Flush rendering:
- */
- void (*flush)( struct pipe_context *pipe,
- unsigned flags );
-};
-
-#endif /* PIPE_CONTEXT_H */
diff --git a/src/mesa/pipe/p_debug.h b/src/mesa/pipe/p_debug.h
deleted file mode 100644
index 2a11627b36..0000000000
--- a/src/mesa/pipe/p_debug.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * @file
- * Cross-platform debugging helpers.
- *
- * For now it just has assert and printf replacements, but it might be extended
- * with stack trace reports and more advanced logging in the near future.
- *
- * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef P_DEBUG_H_
-#define P_DEBUG_H_
-
-
-#include <stdarg.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#ifdef DBG
-#ifndef DEBUG
-#define DEBUG 1
-#endif
-#else
-#ifndef NDEBUG
-#define NDEBUG 1
-#endif
-#endif
-
-
-void debug_printf(const char *format, ...);
-
-void debug_vprintf(const char *format, va_list ap);
-
-void debug_assert_fail(const char *expr, const char *file, unsigned line);
-
-
-/** Assert macro */
-#ifdef DEBUG
-#define debug_assert(expr) ((expr) ? (void)0 : debug_assert_fail(#expr, __FILE__, __LINE__))
-#else
-#define debug_assert(expr) ((void)0)
-#endif
-
-
-#ifdef assert
-#undef assert
-#endif
-#define assert(expr) debug_assert(expr)
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* P_DEBUG_H_ */
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
deleted file mode 100644
index 0bf53ecb79..0000000000
--- a/src/mesa/pipe/p_defines.h
+++ /dev/null
@@ -1,270 +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 PIPE_DEFINES_H
-#define PIPE_DEFINES_H
-
-#include "p_format.h"
-
-#define PIPE_BLENDFACTOR_ONE 0x1
-#define PIPE_BLENDFACTOR_SRC_COLOR 0x2
-#define PIPE_BLENDFACTOR_SRC_ALPHA 0x3
-#define PIPE_BLENDFACTOR_DST_ALPHA 0x4
-#define PIPE_BLENDFACTOR_DST_COLOR 0x5
-#define PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
-#define PIPE_BLENDFACTOR_CONST_COLOR 0x7
-#define PIPE_BLENDFACTOR_CONST_ALPHA 0x8
-#define PIPE_BLENDFACTOR_SRC1_COLOR 0x9
-#define PIPE_BLENDFACTOR_SRC1_ALPHA 0x0A
-#define PIPE_BLENDFACTOR_ZERO 0x11
-#define PIPE_BLENDFACTOR_INV_SRC_COLOR 0x12
-#define PIPE_BLENDFACTOR_INV_SRC_ALPHA 0x13
-#define PIPE_BLENDFACTOR_INV_DST_ALPHA 0x14
-#define PIPE_BLENDFACTOR_INV_DST_COLOR 0x15
-#define PIPE_BLENDFACTOR_INV_CONST_COLOR 0x17
-#define PIPE_BLENDFACTOR_INV_CONST_ALPHA 0x18
-#define PIPE_BLENDFACTOR_INV_SRC1_COLOR 0x19
-#define PIPE_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
-
-#define PIPE_BLEND_ADD 0
-#define PIPE_BLEND_SUBTRACT 1
-#define PIPE_BLEND_REVERSE_SUBTRACT 2
-#define PIPE_BLEND_MIN 3
-#define PIPE_BLEND_MAX 4
-
-#define PIPE_LOGICOP_CLEAR 0
-#define PIPE_LOGICOP_NOR 1
-#define PIPE_LOGICOP_AND_INVERTED 2
-#define PIPE_LOGICOP_COPY_INVERTED 3
-#define PIPE_LOGICOP_AND_REVERSE 4
-#define PIPE_LOGICOP_INVERT 5
-#define PIPE_LOGICOP_XOR 6
-#define PIPE_LOGICOP_NAND 7
-#define PIPE_LOGICOP_AND 8
-#define PIPE_LOGICOP_EQUIV 9
-#define PIPE_LOGICOP_NOOP 10
-#define PIPE_LOGICOP_OR_INVERTED 11
-#define PIPE_LOGICOP_COPY 12
-#define PIPE_LOGICOP_OR_REVERSE 13
-#define PIPE_LOGICOP_OR 14
-#define PIPE_LOGICOP_SET 15
-
-#define PIPE_MASK_R 0x1
-#define PIPE_MASK_G 0x2
-#define PIPE_MASK_B 0x4
-#define PIPE_MASK_A 0x8
-#define PIPE_MASK_RGBA 0xf
-
-
-/**
- * Inequality functions. Used for depth test, stencil compare, alpha
- * test, shadow compare, etc.
- */
-#define PIPE_FUNC_NEVER 0
-#define PIPE_FUNC_LESS 1
-#define PIPE_FUNC_EQUAL 2
-#define PIPE_FUNC_LEQUAL 3
-#define PIPE_FUNC_GREATER 4
-#define PIPE_FUNC_NOTEQUAL 5
-#define PIPE_FUNC_GEQUAL 6
-#define PIPE_FUNC_ALWAYS 7
-
-/** Polygon fill mode */
-#define PIPE_POLYGON_MODE_FILL 0
-#define PIPE_POLYGON_MODE_LINE 1
-#define PIPE_POLYGON_MODE_POINT 2
-
-/** Polygon front/back window, also for culling */
-#define PIPE_WINDING_NONE 0
-#define PIPE_WINDING_CW 1
-#define PIPE_WINDING_CCW 2
-#define PIPE_WINDING_BOTH (PIPE_WINDING_CW | PIPE_WINDING_CCW)
-
-/** Stencil ops */
-#define PIPE_STENCIL_OP_KEEP 0
-#define PIPE_STENCIL_OP_ZERO 1
-#define PIPE_STENCIL_OP_REPLACE 2
-#define PIPE_STENCIL_OP_INCR 3
-#define PIPE_STENCIL_OP_DECR 4
-#define PIPE_STENCIL_OP_INCR_WRAP 5
-#define PIPE_STENCIL_OP_DECR_WRAP 6
-#define PIPE_STENCIL_OP_INVERT 7
-
-/** Texture types */
-enum pipe_texture_target {
- PIPE_TEXTURE_1D = 0,
- PIPE_TEXTURE_2D = 1,
- PIPE_TEXTURE_3D = 2,
- PIPE_TEXTURE_CUBE = 3
-};
-
-#define PIPE_TEX_FACE_POS_X 0
-#define PIPE_TEX_FACE_NEG_X 1
-#define PIPE_TEX_FACE_POS_Y 2
-#define PIPE_TEX_FACE_NEG_Y 3
-#define PIPE_TEX_FACE_POS_Z 4
-#define PIPE_TEX_FACE_NEG_Z 5
-
-#define PIPE_TEX_WRAP_REPEAT 0
-#define PIPE_TEX_WRAP_CLAMP 1
-#define PIPE_TEX_WRAP_CLAMP_TO_EDGE 2
-#define PIPE_TEX_WRAP_CLAMP_TO_BORDER 3
-#define PIPE_TEX_WRAP_MIRROR_REPEAT 4
-#define PIPE_TEX_WRAP_MIRROR_CLAMP 5
-#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE 6
-#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER 7
-
-/* Between mipmaps, ie mipfilter
- */
-#define PIPE_TEX_MIPFILTER_NEAREST 0
-#define PIPE_TEX_MIPFILTER_LINEAR 1
-#define PIPE_TEX_MIPFILTER_NONE 2
-
-/* Within a mipmap, ie min/mag filter
- */
-#define PIPE_TEX_FILTER_NEAREST 0
-#define PIPE_TEX_FILTER_LINEAR 1
-//#define PIPE_TEX_FILTER_ANISO 2
-
-
-#define PIPE_TEX_COMPARE_NONE 0
-#define PIPE_TEX_COMPARE_R_TO_TEXTURE 1
-
-#define PIPE_TEX_FACE_POS_X 0
-#define PIPE_TEX_FACE_NEG_X 1
-#define PIPE_TEX_FACE_POS_Y 2
-#define PIPE_TEX_FACE_NEG_Y 3
-#define PIPE_TEX_FACE_POS_Z 4
-#define PIPE_TEX_FACE_NEG_Z 5
-#define PIPE_TEX_FACE_MAX 6
-
-/**
- * Surfaces, textures, etc. (others may be added)
- */
-#define PIPE_TEXTURE 1
-#define PIPE_SURFACE 2 /**< user-created surfaces */
-
-
-/**
- * Surface status
- */
-#define PIPE_SURFACE_STATUS_UNDEFINED 0
-#define PIPE_SURFACE_STATUS_DEFINED 1
-#define PIPE_SURFACE_STATUS_CLEAR 2
-
-
-/**
- * Buffer usage flags
- */
-#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0)
-#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1)
-#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2)
-#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3)
-#define PIPE_BUFFER_USAGE_PIXEL (1 << 4)
-#define PIPE_BUFFER_USAGE_VERTEX (1 << 5)
-#define PIPE_BUFFER_USAGE_INDEX (1 << 6)
-#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
-/** Pipe driver custam usage flags should be greater or equal to this value */
-#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
-
-
-/**
- * Flush types:
- */
-#define PIPE_FLUSH_RENDER_CACHE 0x1
-#define PIPE_FLUSH_TEXTURE_CACHE 0x2
-#define PIPE_FLUSH_WAIT 0x4
-#define PIPE_FLUSH_SWAPBUFFERS 0x8
-
-
-/**
- * Shaders
- */
-#define PIPE_SHADER_VERTEX 0
-#define PIPE_SHADER_FRAGMENT 1
-#define PIPE_SHADER_TYPES 2
-
-
-/**
- * Primitive types:
- */
-#define PIPE_PRIM_POINTS 0
-#define PIPE_PRIM_LINES 1
-#define PIPE_PRIM_LINE_LOOP 2
-#define PIPE_PRIM_LINE_STRIP 3
-#define PIPE_PRIM_TRIANGLES 4
-#define PIPE_PRIM_TRIANGLE_STRIP 5
-#define PIPE_PRIM_TRIANGLE_FAN 6
-#define PIPE_PRIM_QUADS 7
-#define PIPE_PRIM_QUAD_STRIP 8
-#define PIPE_PRIM_POLYGON 9
-
-
-/**
- * Query object types
- */
-#define PIPE_QUERY_OCCLUSION_COUNTER 0
-#define PIPE_QUERY_PRIMITIVES_GENERATED 1
-#define PIPE_QUERY_PRIMITIVES_EMITTED 2
-#define PIPE_QUERY_TYPES 3
-
-
-/**
- * Point sprite coord modes
- */
-#define PIPE_SPRITE_COORD_NONE 0
-#define PIPE_SPRITE_COORD_UPPER_LEFT 1
-#define PIPE_SPRITE_COORD_LOWER_LEFT 2
-
-
-/**
- * Implementation capabilities/limits
- * Passed to pipe->get_param()
- * XXX this will need some fine tuning...
- */
-#define PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS 1
-#define PIPE_CAP_NPOT_TEXTURES 2
-#define PIPE_CAP_TWO_SIDED_STENCIL 3
-#define PIPE_CAP_GLSL 4 /* XXX need something better */
-#define PIPE_CAP_S3TC 5
-#define PIPE_CAP_ANISOTROPIC_FILTER 6
-#define PIPE_CAP_POINT_SPRITE 7
-#define PIPE_CAP_MAX_RENDER_TARGETS 8
-#define PIPE_CAP_OCCLUSION_QUERY 9
-#define PIPE_CAP_TEXTURE_SHADOW_MAP 10
-#define PIPE_CAP_MAX_TEXTURE_2D_LEVELS 11
-#define PIPE_CAP_MAX_TEXTURE_3D_LEVELS 12
-#define PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS 13
-#define PIPE_CAP_MAX_LINE_WIDTH 14
-#define PIPE_CAP_MAX_LINE_WIDTH_AA 15
-#define PIPE_CAP_MAX_POINT_WIDTH 16
-#define PIPE_CAP_MAX_POINT_WIDTH_AA 17
-#define PIPE_CAP_MAX_TEXTURE_ANISOTROPY 18
-#define PIPE_CAP_MAX_TEXTURE_LOD_BIAS 19
-#define PIPE_CAP_BITMAP_TEXCOORD_BIAS 20
-
-#endif
diff --git a/src/mesa/pipe/p_format.h b/src/mesa/pipe/p_format.h
deleted file mode 100644
index c9ad324315..0000000000
--- a/src/mesa/pipe/p_format.h
+++ /dev/null
@@ -1,421 +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 PIPE_FORMAT_H
-#define PIPE_FORMAT_H
-
-#include <stdio.h> // for sprintf
-
-#include "p_compiler.h"
-#include "p_debug.h"
-
-/**
- * The PIPE_FORMAT is a 32-bit wide bitfield that encodes all the information
- * needed to uniquely describe a pixel format.
- */
-
-/**
- * Possible format layouts -- occupy first 2 bits. The interpretation of
- * the remaining 30 bits depends on a particual format layout.
- */
-#define PIPE_FORMAT_LAYOUT_RGBAZS 0
-#define PIPE_FORMAT_LAYOUT_YCBCR 1
-
-static INLINE uint pf_layout(uint f) /**< PIPE_FORMAT_LAYOUT_ */
-{
- return f & 0x3;
-}
-
-/**
- * RGBAZS Format Layout.
- */
-
-/**
- * Format component selectors for RGBAZS layout.
- */
-#define PIPE_FORMAT_COMP_R 0
-#define PIPE_FORMAT_COMP_G 1
-#define PIPE_FORMAT_COMP_B 2
-#define PIPE_FORMAT_COMP_A 3
-#define PIPE_FORMAT_COMP_0 4
-#define PIPE_FORMAT_COMP_1 5
-#define PIPE_FORMAT_COMP_Z 6
-#define PIPE_FORMAT_COMP_S 7
-
-/**
- * Format types for RGBAZS layout.
- */
-#define PIPE_FORMAT_TYPE_UNKNOWN 0
-#define PIPE_FORMAT_TYPE_FLOAT 1
-#define PIPE_FORMAT_TYPE_UNORM 2
-#define PIPE_FORMAT_TYPE_SNORM 3
-#define PIPE_FORMAT_TYPE_USCALED 4
-#define PIPE_FORMAT_TYPE_SSCALED 5
-
-/**
- * Because the destination vector is assumed to be RGBA FLOAT, we
- * need to know how to swizzle and expand components from the source
- * vector.
- * Let's take U_A1_R5_G5_B5 as an example. X swizzle is A, X size
- * is 1 bit and type is UNORM. So we take the most significant bit
- * from source vector, convert 0 to 0.0 and 1 to 1.0 and save it
- * in the last component of the destination RGBA component.
- * Next, Y swizzle is R, Y size is 5 and type is UNORM. We normalize
- * those 5 bits into [0.0; 1.0] range and put it into second
- * component of the destination vector. Rinse and repeat for
- * components Z and W.
- * If any of size fields is zero, it means the source format contains
- * less than four components.
- * If any swizzle is 0 or 1, the corresponding destination component
- * should be filled with 0.0 and 1.0, respectively.
- */
-typedef uint pipe_format_rgbazs_t;
-
-static INLINE uint pf_get(pipe_format_rgbazs_t f, uint shift, uint mask)
-{
- return (f >> shift) & mask;
-}
-
-/* XXX: The bit layout needs to be revised, can't currently encode 10-bit components. */
-
-#define pf_swizzle_x(f) pf_get(f, 2, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_y(f) pf_get(f, 5, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_z(f) pf_get(f, 8, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_w(f) pf_get(f, 11, 0x7) /**< PIPE_FORMAT_COMP_ */
-#define pf_swizzle_xyzw(f,i) pf_get(f, 2+((i)*3), 0x7)
-#define pf_size_x(f) pf_get(f, 14, 0x7) /**< Size of X */
-#define pf_size_y(f) pf_get(f, 17, 0x7) /**< Size of Y */
-#define pf_size_z(f) pf_get(f, 20, 0x7) /**< Size of Z */
-#define pf_size_w(f) pf_get(f, 23, 0x7) /**< Size of W */
-#define pf_size_xyzw(f,i) pf_get(f, 14+((i)*3), 0x7)
-#define pf_exp8(f) pf_get(f, 26, 0x3) /**< Scale size by 8 ^ exp8 */
-#define pf_type(f) pf_get(f, 28, 0xf) /**< PIPE_FORMAT_TYPE_ */
-
-/**
- * Helper macro to encode the above structure into a 32-bit value.
- */
-#define _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, EXP8, TYPE ) (\
- (PIPE_FORMAT_LAYOUT_RGBAZS << 0) |\
- ((SWZ) << 2) |\
- ((SIZEX) << 14) |\
- ((SIZEY) << 17) |\
- ((SIZEZ) << 20) |\
- ((SIZEW) << 23) |\
- ((EXP8) << 26) |\
- ((TYPE) << 28) )
-
-/**
- * Helper macro to encode the swizzle part of the structure above.
- */
-#define _PIPE_FORMAT_SWZ( SWZX, SWZY, SWZZ, SWZW ) (((SWZX) << 0) | ((SWZY) << 3) | ((SWZZ) << 6) | ((SWZW) << 9))
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 1-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_1( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
- _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 0, TYPE )
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 8-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_8( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
- _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 1, TYPE )
-
-/**
- * Shorthand macro for RGBAZS layout with component sizes in 64-bit units.
- */
-#define _PIPE_FORMAT_RGBAZS_64( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, TYPE )\
- _PIPE_FORMAT_RGBAZS( SWZ, SIZEX, SIZEY, SIZEZ, SIZEW, 2, TYPE )
-
-/**
- * Shorthand macro for common format swizzles.
- */
-#define _PIPE_FORMAT_R000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_RG00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_RGB0 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_RGBA _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_A )
-#define _PIPE_FORMAT_ARGB _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_A, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_B )
-#define _PIPE_FORMAT_BGRA _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_B, PIPE_FORMAT_COMP_G, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_A )
-#define _PIPE_FORMAT_0000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_000R _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_RRR1 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_1 )
-#define _PIPE_FORMAT_RRRR _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R )
-#define _PIPE_FORMAT_RRRG _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_R, PIPE_FORMAT_COMP_G )
-#define _PIPE_FORMAT_Z000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_SZ00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_ZS00 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_Z, PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-#define _PIPE_FORMAT_S000 _PIPE_FORMAT_SWZ( PIPE_FORMAT_COMP_S, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0, PIPE_FORMAT_COMP_0 )
-
-/**
- * YCBCR Format Layout.
- */
-
-/**
- * This only contains a flag that indicates whether the format is reversed or
- * not.
- */
-typedef uint pipe_format_ycbcr_t;
-
-/**
- * Helper macro to encode the above structure into a 32-bit value.
- */
-#define _PIPE_FORMAT_YCBCR( REV ) (\
- (PIPE_FORMAT_LAYOUT_YCBCR << 0) |\
- ((REV) << 2) )
-
-static INLINE uint pf_rev(pipe_format_ycbcr_t f)
-{
- return (f >> 2) & 0x1;
-}
-
-/**
- * Texture/surface image formats (preliminary)
- */
-
-/* KW: Added lots of surface formats to support vertex element layout
- * definitions, and eventually render-to-vertex-buffer. Could
- * consider making float/int/uint/scaled/normalized a separate
- * parameter, but on the other hand there are special cases like
- * z24s8, compressed textures, ycbcr, etc that won't fit that model.
- */
-
-enum pipe_format {
- PIPE_FORMAT_NONE = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_0000, 0, 0, 0, 0, PIPE_FORMAT_TYPE_UNKNOWN ),
- PIPE_FORMAT_A8R8G8B8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ARGB, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_B8G8R8A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_BGRA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_A1R5G5B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_A4R4G4B4_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R5G6B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_RGB0, 5, 6, 5, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_U_L8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte luminance */
- PIPE_FORMAT_U_A8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_000R, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha */
- PIPE_FORMAT_U_I8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRR, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte intensity */
- PIPE_FORMAT_U_A8_L8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha, luminance */
- PIPE_FORMAT_YCBCR = _PIPE_FORMAT_YCBCR( 0 ),
- PIPE_FORMAT_YCBCR_REV = _PIPE_FORMAT_YCBCR( 1 ),
- PIPE_FORMAT_Z16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_Z32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_Z32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_S8Z24_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_SZ00, 1, 3, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_Z24S8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_ZS00, 3, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_S8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_S000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte stencil */
- PIPE_FORMAT_R64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R64G64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R64G64B64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R64G64B64A64_FLOAT = _PIPE_FORMAT_RGBAZS_64( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R32G32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 4, 4, 0, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R32G32B32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 4, 4, 4, 0, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R32G32B32A32_FLOAT = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_FLOAT ),
- PIPE_FORMAT_R32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R32G32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 4, 4, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R32G32B32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 4, 4, 4, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R32G32B32A32_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R32G32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 4, 4, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R32G32B32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 4, 4, 4, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R32G32B32A32_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R32G32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R32G32B32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R32G32B32A32_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 4, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R32G32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 4, 4, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R32G32B32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 4, 4, 4, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R32G32B32A32_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 4, 4, 4, 4, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R16G16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 2, 2, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R16G16B16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 2, 2, 2, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R16G16B16A16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R16G16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 2, 2, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R16G16B16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 2, 2, 2, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R16G16B16A16_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R16G16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R16G16B16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R16G16B16A16_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R16G16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 2, 2, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R16G16B16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 2, 2, 2, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R16G16B16A16_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 2, 2, 2, 2, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R8G8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R8G8B8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R8G8B8A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_R8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R8G8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R8G8B8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R8G8B8A8_USCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_USCALED ),
- PIPE_FORMAT_R8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R8G8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R8G8B8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R8G8B8A8_SNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SNORM ),
- PIPE_FORMAT_R8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_R000, 1, 0, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R8G8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RG00, 1, 1, 0, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R8G8B8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGB0, 1, 1, 1, 0, PIPE_FORMAT_TYPE_SSCALED ),
- PIPE_FORMAT_R8G8B8A8_SSCALED = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RGBA, 1, 1, 1, 1, PIPE_FORMAT_TYPE_SSCALED )
-};
-
-
-/**
- * XXX should remove this, but S8_UNORM is a poor name
- */
-#define PIPE_FORMAT_U_S8 PIPE_FORMAT_S8_UNORM
-
-
-/**
- * Builds pipe format name from format token.
- */
-static INLINE char *pf_sprint_name( char *str, uint format )
-{
- strcpy( str, "PIPE_FORMAT_" );
- switch (pf_layout( format )) {
- case PIPE_FORMAT_LAYOUT_RGBAZS: {
- pipe_format_rgbazs_t rgbazs = (pipe_format_rgbazs_t) format;
- uint i;
- uint scale = 1 << (pf_exp8( rgbazs ) * 3);
-
- for (i = 0; i < 4; i++) {
- uint size = pf_size_xyzw( rgbazs, i );
-
- if (size == 0) {
- break;
- }
- switch (pf_swizzle_xyzw( rgbazs, i )) {
- case PIPE_FORMAT_COMP_R:
- strcat( str, "R" );
- break;
- case PIPE_FORMAT_COMP_G:
- strcat( str, "G" );
- break;
- case PIPE_FORMAT_COMP_B:
- strcat( str, "B" );
- break;
- case PIPE_FORMAT_COMP_A:
- strcat( str, "A" );
- break;
- case PIPE_FORMAT_COMP_0:
- strcat( str, "0" );
- break;
- case PIPE_FORMAT_COMP_1:
- strcat( str, "1" );
- break;
- case PIPE_FORMAT_COMP_Z:
- strcat( str, "Z" );
- break;
- case PIPE_FORMAT_COMP_S:
- strcat( str, "S" );
- break;
- }
- sprintf( &str[strlen( str )], "%u", size * scale );
- }
- if (i != 0) {
- strcat( str, "_" );
- }
- switch (pf_type( rgbazs )) {
- case PIPE_FORMAT_TYPE_UNKNOWN:
- strcat( str, "NONE" );
- break;
- case PIPE_FORMAT_TYPE_FLOAT:
- strcat( str, "FLOAT" );
- break;
- case PIPE_FORMAT_TYPE_UNORM:
- strcat( str, "UNORM" );
- break;
- case PIPE_FORMAT_TYPE_SNORM:
- strcat( str, "SNORM" );
- break;
- case PIPE_FORMAT_TYPE_USCALED:
- strcat( str, "USCALED" );
- break;
- case PIPE_FORMAT_TYPE_SSCALED:
- strcat( str, "SSCALED" );
- break;
- }
- }
- break;
- case PIPE_FORMAT_LAYOUT_YCBCR: {
- pipe_format_ycbcr_t ycbcr = (pipe_format_ycbcr_t) format;
-
- strcat( str, "YCBCR" );
- if (pf_rev( ycbcr )) {
- strcat( str, "_REV" );
- }
- }
- break;
- }
- return str;
-}
-
-static INLINE uint pf_get_component_bits( enum pipe_format format, uint comp )
-{
- uint size;
-
- if (pf_swizzle_x(format) == comp) {
- size = pf_size_x(format);
- }
- else if (pf_swizzle_y(format) == comp) {
- size = pf_size_y(format);
- }
- else if (pf_swizzle_z(format) == comp) {
- size = pf_size_z(format);
- }
- else if (pf_swizzle_w(format) == comp) {
- size = pf_size_w(format);
- }
- else {
- size = 0;
- }
- return size << (pf_exp8(format) * 3);
-}
-
-static INLINE uint pf_get_bits( enum pipe_format format )
-{
- if (pf_layout(format) == PIPE_FORMAT_LAYOUT_RGBAZS) {
- return
- pf_get_component_bits( format, PIPE_FORMAT_COMP_R ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_G ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_B ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_A ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
- pf_get_component_bits( format, PIPE_FORMAT_COMP_S );
- }
- else {
- assert( pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR );
-
- /* TODO */
- assert( 0 );
- return 0;
- }
-}
-
-static INLINE uint pf_get_size( enum pipe_format format ) {
- assert(pf_get_bits(format) % 8 == 0);
- return pf_get_bits(format) / 8;
-}
-
-#endif
diff --git a/src/mesa/pipe/p_inlines.h b/src/mesa/pipe/p_inlines.h
deleted file mode 100644
index ebf6ed86bc..0000000000
--- a/src/mesa/pipe/p_inlines.h
+++ /dev/null
@@ -1,112 +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_INLINES_H
-#define P_INLINES_H
-
-#include "p_context.h"
-#include "p_defines.h"
-#include "p_winsys.h"
-
-
-static INLINE void *
-pipe_surface_map(struct pipe_surface *surface)
-{
- return (char *)surface->winsys->buffer_map( surface->winsys, surface->buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ )
- + surface->offset;
-}
-
-static INLINE void
-pipe_surface_unmap(struct pipe_surface *surface)
-{
- surface->winsys->buffer_unmap( surface->winsys, surface->buffer );
-}
-
-/**
- * Set 'ptr' to point to 'surf' and update reference counting.
- * The old thing pointed to, if any, will be unreferenced first.
- * 'surf' may be NULL.
- */
-static INLINE void
-pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
-{
- /* bump the refcount first */
- if (surf)
- surf->refcount++;
-
- if (*ptr /* && --(*ptr)->refcount == 0 */) {
- struct pipe_winsys *winsys = (*ptr)->winsys;
- winsys->surface_release(winsys, ptr);
- assert(!*ptr);
- }
-
- *ptr = surf;
-}
-
-
-/* XXX: thread safety issues!
- */
-static INLINE void
-pipe_buffer_reference(struct pipe_winsys *winsys,
- struct pipe_buffer **ptr,
- struct pipe_buffer *buf)
-{
- if (buf)
- buf->refcount++;
-
- if (*ptr && --(*ptr)->refcount == 0)
- winsys->buffer_destroy( winsys, *ptr );
-
- *ptr = buf;
-}
-
-
-
-/**
- * \sa pipe_surface_reference
- */
-static INLINE void
-pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
- struct pipe_texture *pt)
-{
- assert(ptr);
-
- if (pt)
- pt->refcount++;
-
- if (*ptr) {
- pipe->texture_release(pipe, ptr);
- assert(!*ptr);
- }
-
- *ptr = pt;
-}
-
-
-#endif /* P_INLINES_H */
diff --git a/src/mesa/pipe/p_shader_tokens.h b/src/mesa/pipe/p_shader_tokens.h
deleted file mode 100644
index 3ce35310f6..0000000000
--- a/src/mesa/pipe/p_shader_tokens.h
+++ /dev/null
@@ -1,806 +0,0 @@
-#if !defined TGSI_TOKEN_H
-#define TGSI_TOKEN_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-struct tgsi_version
-{
- unsigned MajorVersion : 8;
- unsigned MinorVersion : 8;
- unsigned Padding : 16;
-};
-
-struct tgsi_header
-{
- unsigned HeaderSize : 8;
- unsigned BodySize : 24;
-};
-
-#define TGSI_PROCESSOR_FRAGMENT 0
-#define TGSI_PROCESSOR_VERTEX 1
-#define TGSI_PROCESSOR_GEOMETRY 2
-
-struct tgsi_processor
-{
- unsigned Processor : 4; /* TGSI_PROCESSOR_ */
- unsigned Padding : 28;
-};
-
-#define TGSI_TOKEN_TYPE_DECLARATION 0
-#define TGSI_TOKEN_TYPE_IMMEDIATE 1
-#define TGSI_TOKEN_TYPE_INSTRUCTION 2
-
-struct tgsi_token
-{
- unsigned Type : 4; /* TGSI_TOKEN_TYPE_ */
- unsigned Size : 8; /* UINT */
- unsigned Padding : 19;
- unsigned Extended : 1; /* BOOL */
-};
-
-#define TGSI_FILE_NULL 0
-#define TGSI_FILE_CONSTANT 1
-#define TGSI_FILE_INPUT 2
-#define TGSI_FILE_OUTPUT 3
-#define TGSI_FILE_TEMPORARY 4
-#define TGSI_FILE_SAMPLER 5
-#define TGSI_FILE_ADDRESS 6
-#define TGSI_FILE_IMMEDIATE 7
-
-#define TGSI_DECLARE_RANGE 0
-#define TGSI_DECLARE_MASK 1
-
-#define TGSI_WRITEMASK_NONE 0x00
-#define TGSI_WRITEMASK_X 0x01
-#define TGSI_WRITEMASK_Y 0x02
-#define TGSI_WRITEMASK_XY 0x03
-#define TGSI_WRITEMASK_Z 0x04
-#define TGSI_WRITEMASK_XZ 0x05
-#define TGSI_WRITEMASK_YZ 0x06
-#define TGSI_WRITEMASK_XYZ 0x07
-#define TGSI_WRITEMASK_W 0x08
-#define TGSI_WRITEMASK_XW 0x09
-#define TGSI_WRITEMASK_YW 0x0A
-#define TGSI_WRITEMASK_XYW 0x0B
-#define TGSI_WRITEMASK_ZW 0x0C
-#define TGSI_WRITEMASK_XZW 0x0D
-#define TGSI_WRITEMASK_YZW 0x0E
-#define TGSI_WRITEMASK_XYZW 0x0F
-
-struct tgsi_declaration
-{
- unsigned Type : 4; /* TGSI_TOKEN_TYPE_DECLARATION */
- unsigned Size : 8; /* UINT */
- unsigned File : 4; /* one of TGSI_FILE_x */
- unsigned Declare : 4; /* one of TGSI_DECLARE_x */
- unsigned UsageMask : 4; /* bitmask of TGSI_WRITEMASK_x flags */
- unsigned Interpolate : 1; /* BOOL, any interpolation info? */
- unsigned Semantic : 1; /* BOOL, any semantic info? */
- unsigned Padding : 5;
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_declaration_range
-{
- unsigned First : 16; /* UINT */
- unsigned Last : 16; /* UINT */
-};
-
-struct tgsi_declaration_mask
-{
- unsigned Mask : 32; /* UINT */
-};
-
-#define TGSI_INTERPOLATE_CONSTANT 0
-#define TGSI_INTERPOLATE_LINEAR 1
-#define TGSI_INTERPOLATE_PERSPECTIVE 2
-
-struct tgsi_declaration_interpolation
-{
- unsigned Interpolate : 4; /* TGSI_INTERPOLATE_ */
- unsigned Padding : 28;
-};
-
-#define TGSI_SEMANTIC_POSITION 0
-#define TGSI_SEMANTIC_COLOR 1
-#define TGSI_SEMANTIC_BCOLOR 2 /**< back-face color */
-#define TGSI_SEMANTIC_FOG 3
-#define TGSI_SEMANTIC_PSIZE 4
-#define TGSI_SEMANTIC_GENERIC 5
-#define TGSI_SEMANTIC_NORMAL 6
-#define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */
-
-struct tgsi_declaration_semantic
-{
- unsigned SemanticName : 8; /* one of TGSI_SEMANTIC_ */
- unsigned SemanticIndex : 16; /* UINT */
- unsigned Padding : 8;
-};
-
-#define TGSI_IMM_FLOAT32 0
-
-struct tgsi_immediate
-{
- unsigned Type : 4; /* TGSI_TOKEN_TYPE_IMMEDIATE */
- unsigned Size : 8; /* UINT */
- unsigned DataType : 4; /* TGSI_IMM_ */
- unsigned Padding : 15;
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_immediate_float32
-{
- float Float;
-};
-
-/*
- * GL_NV_vertex_program
- */
-#define TGSI_OPCODE_ARL 0
-#define TGSI_OPCODE_MOV 1
-#define TGSI_OPCODE_LIT 2
-#define TGSI_OPCODE_RCP 3
-#define TGSI_OPCODE_RSQ 4
-#define TGSI_OPCODE_EXP 5
-#define TGSI_OPCODE_LOG 6
-#define TGSI_OPCODE_MUL 7
-#define TGSI_OPCODE_ADD 8
-#define TGSI_OPCODE_DP3 9
-#define TGSI_OPCODE_DP4 10
-#define TGSI_OPCODE_DST 11
-#define TGSI_OPCODE_MIN 12
-#define TGSI_OPCODE_MAX 13
-#define TGSI_OPCODE_SLT 14
-#define TGSI_OPCODE_SGE 15
-#define TGSI_OPCODE_MAD 16
-
-/*
- * GL_ATI_fragment_shader
- */
-#define TGSI_OPCODE_SUB 17
-#define TGSI_OPCODE_DOT3 TGSI_OPCODE_DP3
-#define TGSI_OPCODE_DOT4 TGSI_OPCODE_DP4
-#define TGSI_OPCODE_LERP 18
-#define TGSI_OPCODE_CND 19
-#define TGSI_OPCODE_CND0 20
-#define TGSI_OPCODE_DOT2ADD 21
-
-/*
- * GL_EXT_vertex_shader
- */
-#define TGSI_OPCODE_INDEX 22
-#define TGSI_OPCODE_NEGATE 23
-#define TGSI_OPCODE_MADD TGSI_OPCODE_MAD
-#define TGSI_OPCODE_FRAC 24
-#define TGSI_OPCODE_SETGE TGSI_OPCODE_SGE
-#define TGSI_OPCODE_SETLT TGSI_OPCODE_SLT
-#define TGSI_OPCODE_CLAMP 25
-#define TGSI_OPCODE_FLOOR 26
-#define TGSI_OPCODE_ROUND 27
-#define TGSI_OPCODE_EXPBASE2 28
-#define TGSI_OPCODE_LOGBASE2 29
-#define TGSI_OPCODE_POWER 30
-#define TGSI_OPCODE_RECIP TGSI_OPCODE_RCP
-#define TGSI_OPCODE_RECIPSQRT TGSI_OPCODE_RSQ
-#define TGSI_OPCODE_CROSSPRODUCT 31
-#define TGSI_OPCODE_MULTIPLYMATRIX 32
-
-/*
- * GL_NV_vertex_program1_1
- */
-#define TGSI_OPCODE_ABS 33
-#define TGSI_OPCODE_RCC 34
-#define TGSI_OPCODE_DPH 35
-
-/*
- * GL_NV_fragment_program
- */
-#define TGSI_OPCODE_COS 36
-#define TGSI_OPCODE_DDX 37
-#define TGSI_OPCODE_DDY 38
-#define TGSI_OPCODE_EX2 TGSI_OPCODE_EXPBASE2
-#define TGSI_OPCODE_FLR TGSI_OPCODE_FLOOR
-#define TGSI_OPCODE_FRC TGSI_OPCODE_FRAC
-#define TGSI_OPCODE_KILP 39 /* predicated kill */
-#define TGSI_OPCODE_LG2 TGSI_OPCODE_LOGBASE2
-#define TGSI_OPCODE_LRP TGSI_OPCODE_LERP
-#define TGSI_OPCODE_PK2H 40
-#define TGSI_OPCODE_PK2US 41
-#define TGSI_OPCODE_PK4B 42
-#define TGSI_OPCODE_PK4UB 43
-#define TGSI_OPCODE_POW TGSI_OPCODE_POWER
-#define TGSI_OPCODE_RFL 44
-#define TGSI_OPCODE_SEQ 45
-#define TGSI_OPCODE_SFL 46
-#define TGSI_OPCODE_SGT 47
-#define TGSI_OPCODE_SIN 48
-#define TGSI_OPCODE_SLE 49
-#define TGSI_OPCODE_SNE 50
-#define TGSI_OPCODE_STR 51
-#define TGSI_OPCODE_TEX 52
-#define TGSI_OPCODE_TXD 53
-#define TGSI_OPCODE_UP2H 54
-#define TGSI_OPCODE_UP2US 55
-#define TGSI_OPCODE_UP4B 56
-#define TGSI_OPCODE_UP4UB 57
-#define TGSI_OPCODE_X2D 58
-
-/*
- * GL_NV_vertex_program2
- */
-#define TGSI_OPCODE_ARA 59
-#define TGSI_OPCODE_ARR 60
-#define TGSI_OPCODE_BRA 61
-#define TGSI_OPCODE_CAL 62
-#define TGSI_OPCODE_RET 63
-#define TGSI_OPCODE_SSG 64
-
-/*
- * GL_ARB_vertex_program
- */
-#define TGSI_OPCODE_SWZ TGSI_OPCODE_MOV
-#define TGSI_OPCODE_XPD TGSI_OPCODE_CROSSPRODUCT
-
-/*
- * GL_ARB_fragment_program
- */
-#define TGSI_OPCODE_CMP 65
-#define TGSI_OPCODE_SCS 66
-#define TGSI_OPCODE_TXB 67
-
-/*
- * GL_NV_fragment_program_option
- */
-/* No new opcode */
-
-/*
- * GL_NV_fragment_program2
- */
-#define TGSI_OPCODE_NRM 68
-#define TGSI_OPCODE_DIV 69
-#define TGSI_OPCODE_DP2 70
-#define TGSI_OPCODE_DP2A TGSI_OPCODE_DOT2ADD
-#define TGSI_OPCODE_TXL 71
-#define TGSI_OPCODE_BRK 72
-#define TGSI_OPCODE_IF 73
-#define TGSI_OPCODE_LOOP 74
-#define TGSI_OPCODE_REP 75
-#define TGSI_OPCODE_ELSE 76
-#define TGSI_OPCODE_ENDIF 77
-#define TGSI_OPCODE_ENDLOOP 78
-#define TGSI_OPCODE_ENDREP 79
-
-/*
- * GL_NV_vertex_program2_option
- */
-
-/*
- * GL_NV_vertex_program3
- */
-#define TGSI_OPCODE_PUSHA 80
-#define TGSI_OPCODE_POPA 81
-
-/*
- * GL_NV_gpu_program4
- */
-#define TGSI_OPCODE_CEIL 82
-#define TGSI_OPCODE_I2F 83
-#define TGSI_OPCODE_NOT 84
-#define TGSI_OPCODE_TRUNC 85
-#define TGSI_OPCODE_SHL 86
-#define TGSI_OPCODE_SHR 87
-#define TGSI_OPCODE_AND 88
-#define TGSI_OPCODE_OR 89
-#define TGSI_OPCODE_MOD 90
-#define TGSI_OPCODE_XOR 91
-#define TGSI_OPCODE_SAD 92
-#define TGSI_OPCODE_TXF 93
-#define TGSI_OPCODE_TXQ 94
-#define TGSI_OPCODE_CONT 95
-
-/*
- * GL_NV_vertex_program4
- */
-/* Same as GL_NV_gpu_program4 */
-
-/*
- * GL_NV_fragment_program4
- */
-/* Same as GL_NV_gpu_program4 */
-
-/*
- * GL_NV_geometry_program4
- */
-/* Same as GL_NV_gpu_program4 */
-#define TGSI_OPCODE_EMIT 96
-#define TGSI_OPCODE_ENDPRIM 97
-
-/*
- * GLSL
- */
-#define TGSI_OPCODE_BGNLOOP2 98
-#define TGSI_OPCODE_BGNSUB 99
-#define TGSI_OPCODE_ENDLOOP2 100
-#define TGSI_OPCODE_ENDSUB 101
-#define TGSI_OPCODE_INT TGSI_OPCODE_TRUNC
-#define TGSI_OPCODE_NOISE1 102
-#define TGSI_OPCODE_NOISE2 103
-#define TGSI_OPCODE_NOISE3 104
-#define TGSI_OPCODE_NOISE4 105
-#define TGSI_OPCODE_NOP 106
-
-/*
- * ps_1_1
- */
-#define TGSI_OPCODE_TEXCOORD TGSI_OPCODE_NOP
-#define TGSI_OPCODE_TEXKILL TGSI_OPCODE_KIL
-#define TGSI_OPCODE_TEXBEM 107
-#define TGSI_OPCODE_TEXBEML 108
-#define TGSI_OPCODE_TEXREG2AR 109
-#define TGSI_OPCODE_TEXM3X2PAD 110
-#define TGSI_OPCODE_TEXM3X2TEX 111
-#define TGSI_OPCODE_TEXM3X3PAD 112
-#define TGSI_OPCODE_TEXM3X3TEX 113
-#define TGSI_OPCODE_TEXM3X3SPEC 114
-#define TGSI_OPCODE_TEXM3X3VSPEC 115
-
-/*
- * ps_1_2
- */
-#define TGSI_OPCODE_TEXREG2GB 116
-#define TGSI_OPCODE_TEXREG2RGB 117
-#define TGSI_OPCODE_TEXDP3TEX 118
-#define TGSI_OPCODE_TEXDP3 119
-#define TGSI_OPCODE_TEXM3X3 120
-/* CMP - use TGSI_OPCODE_CND0 */
-
-/*
- * ps_1_3
- */
-#define TGSI_OPCODE_TEXM3X2DEPTH 121
-/* CMP - use TGSI_OPCODE_CND0 */
-
-/*
- * ps_1_4
- */
-#define TGSI_OPCODE_TEXCRD TGSI_OPCODE_TEXCOORD
-#define TGSI_OPCODE_TEXLD TGSI_OPCODE_TEX
-#define TGSI_OPCODE_TEXDEPTH 122
-#define TGSI_OPCODE_BEM 123
-
-/*
- * ps_2_0
- */
-#define TGSI_OPCODE_M4X4 TGSI_OPCODE_MULTIPLYMATRIX
-#define TGSI_OPCODE_M4X3 124
-#define TGSI_OPCODE_M3X4 125
-#define TGSI_OPCODE_M3X3 126
-#define TGSI_OPCODE_M3X2 127
-#define TGSI_OPCODE_CRS TGSI_OPCODE_XPD
-#define TGSI_OPCODE_NRM4 128
-#define TGSI_OPCODE_SINCOS TGSI_OPCODE_SCS
-#define TGSI_OPCODE_TEXLDB TGSI_OPCODE_TXB
-#define TGSI_OPCODE_DP2ADD TGSI_OPCODE_DP2A
-
-/*
- * ps_2_x
- */
-#define TGSI_OPCODE_CALL TGSI_OPCODE_CAL
-#define TGSI_OPCODE_CALLNZ 129
-#define TGSI_OPCODE_IFC 130
-#define TGSI_OPCODE_BREAK TGSI_OPCODE_BRK
-#define TGSI_OPCODE_BREAKC 131
-#define TGSI_OPCODE_DSX TGSI_OPCODE_DDX
-#define TGSI_OPCODE_DSY TGSI_OPCODE_DDY
-#define TGSI_OPCODE_TEXLDD TGSI_OPCODE_TXD
-
-/*
- * vs_1_1
- */
-#define TGSI_OPCODE_EXPP TGSI_OPCODE_EXP
-#define TGSI_OPCODE_LOGP TGSI_OPCODE_LG2
-
-/*
- * vs_2_0
- */
-#define TGSI_OPCODE_SGN TGSI_OPCODE_SSG
-#define TGSI_OPCODE_MOVA TGSI_OPCODE_ARR
-
-/*
- * vs_2_x
- */
-
-#define TGSI_OPCODE_KIL 132 /* unpredicated kill */
-#define TGSI_OPCODE_END 133 /* aka HALT */
-
-#define TGSI_OPCODE_LAST 134
-
-#define TGSI_SAT_NONE 0 /* do not saturate */
-#define TGSI_SAT_ZERO_ONE 1 /* clamp to [0,1] */
-#define TGSI_SAT_MINUS_PLUS_ONE 2 /* clamp to [-1,1] */
-
-/*
- * Opcode is the operation code to execute. A given operation defines the
- * semantics how the source registers (if any) are interpreted and what is
- * written to the destination registers (if any) as a result of execution.
- *
- * NumDstRegs and NumSrcRegs is the number of destination and source registers,
- * respectively. For a given operation code, those numbers are fixed and are
- * present here only for convenience.
- *
- * If Extended is TRUE, it is now executed.
- *
- * Saturate controls how are final results in destination registers modified.
- */
-
-struct tgsi_instruction
-{
- unsigned Type : 4; /* TGSI_TOKEN_TYPE_INSTRUCTION */
- unsigned Size : 8; /* UINT */
- unsigned Opcode : 8; /* TGSI_OPCODE_ */
- unsigned Saturate : 2; /* TGSI_SAT_ */
- unsigned NumDstRegs : 2; /* UINT */
- unsigned NumSrcRegs : 4; /* UINT */
- unsigned Padding : 3;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * If tgsi_instruction::Extended is TRUE, tgsi_instruction_ext follows.
- *
- * Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
- *
- * Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
- *
- * tgsi_instruction::Size contains the total number of words that make the
- * instruction, including the instruction word.
- */
-
-#define TGSI_INSTRUCTION_EXT_TYPE_NV 0
-#define TGSI_INSTRUCTION_EXT_TYPE_LABEL 1
-#define TGSI_INSTRUCTION_EXT_TYPE_TEXTURE 2
-#define TGSI_INSTRUCTION_EXT_TYPE_PREDICATE 3
-
-struct tgsi_instruction_ext
-{
- unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_ */
- unsigned Padding : 27;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_NV, it should
- * be cast to tgsi_instruction_ext_nv.
- *
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_LABEL, it
- * should be cast to tgsi_instruction_ext_label.
- *
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_TEXTURE, it
- * should be cast to tgsi_instruction_ext_texture.
- *
- * If tgsi_instruction_ext::Type is TGSI_INSTRUCTION_EXT_TYPE_PREDICATE, it
- * should be cast to tgsi_instruction_ext_predicate.
- *
- * If tgsi_instruction_ext::Extended is TRUE, another tgsi_instruction_ext
- * follows.
- */
-
-#define TGSI_PRECISION_DEFAULT 0
-#define TGSI_PRECISION_FLOAT32 1
-#define TGSI_PRECISION_FLOAT16 2
-#define TGSI_PRECISION_FIXED12 3
-
-#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_SWIZZLE_X 0
-#define TGSI_SWIZZLE_Y 1
-#define TGSI_SWIZZLE_Z 2
-#define TGSI_SWIZZLE_W 3
-
-/*
- * Precision controls the precision at which the operation should be executed.
- *
- * CondDstUpdate enables condition code register writes. When this field is
- * TRUE, CondDstIndex specifies the index of the condition code register to
- * update.
- *
- * CondFlowEnable enables conditional execution of the operation. When this
- * field is TRUE, CondFlowIndex specifies the index of the condition code
- * register to test against CondMask with component swizzle controled by
- * CondSwizzleX, CondSwizzleY, CondSwizzleZ and CondSwizzleW. If the test fails,
- * the operation is not executed.
- */
-
-struct tgsi_instruction_ext_nv
-{
- unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_NV */
- unsigned Precision : 4; /* TGSI_PRECISION_ */
- unsigned CondDstIndex : 4; /* UINT */
- unsigned CondFlowIndex : 4; /* UINT */
- unsigned CondMask : 4; /* TGSI_CC_ */
- unsigned CondSwizzleX : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleY : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleZ : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned CondDstUpdate : 1; /* BOOL */
- unsigned CondFlowEnable : 1; /* BOOL */
- unsigned Padding : 1;
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_instruction_ext_label
-{
- unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_LABEL */
- unsigned Label : 24; /* UINT */
- unsigned Padding : 3;
- unsigned Extended : 1; /* BOOL */
-};
-
-#define TGSI_TEXTURE_UNKNOWN 0
-#define TGSI_TEXTURE_1D 1
-#define TGSI_TEXTURE_2D 2
-#define TGSI_TEXTURE_3D 3
-#define TGSI_TEXTURE_CUBE 4
-#define TGSI_TEXTURE_RECT 5
-#define TGSI_TEXTURE_SHADOW1D 6
-#define TGSI_TEXTURE_SHADOW2D 7
-#define TGSI_TEXTURE_SHADOWRECT 8
-
-struct tgsi_instruction_ext_texture
-{
- unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_TEXTURE */
- unsigned Texture : 8; /* TGSI_TEXTURE_ */
- unsigned Padding : 19;
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_instruction_ext_predicate
-{
- unsigned Type : 4; /* TGSI_INSTRUCTION_EXT_TYPE_PREDICATE */
- unsigned PredDstIndex : 4; /* UINT */
- unsigned PredWriteMask : 4; /* TGSI_WRITEMASK_ */
- unsigned Padding : 19;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * File specifies the register array to access.
- *
- * Index specifies the element number of a register in the register file.
- *
- * If Indirect is TRUE, Index should be offset by the X component of a source
- * register that follows. The register can be now fetched into local storage
- * for further processing.
- *
- * If Negate is TRUE, all components of the fetched register are negated.
- *
- * The fetched register components are swizzled according to SwizzleX, SwizzleY,
- * SwizzleZ and SwizzleW.
- *
- * If Extended is TRUE, any further modifications to the source register are
- * made to this temporary storage.
- */
-
-struct tgsi_src_register
-{
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned SwizzleX : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
- unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned Negate : 1; /* BOOL */
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- int Index : 16; /* SINT */
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * If tgsi_src_register::Extended is TRUE, tgsi_src_register_ext follows.
- *
- * Then, if tgsi_src_register::Indirect is TRUE, another tgsi_src_register
- * follows.
- *
- * Then, if tgsi_src_register::Dimension is TRUE, tgsi_dimension follows.
- */
-
-#define TGSI_SRC_REGISTER_EXT_TYPE_SWZ 0
-#define TGSI_SRC_REGISTER_EXT_TYPE_MOD 1
-
-struct tgsi_src_register_ext
-{
- unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_ */
- unsigned Padding : 27;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_SWZ,
- * it should be cast to tgsi_src_register_ext_swz.
- *
- * If tgsi_src_register_ext::Type is TGSI_SRC_REGISTER_EXT_TYPE_MOD,
- * it should be cast to tgsi_src_register_ext_mod.
- *
- * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
- * follows.
- */
-
-#define TGSI_EXTSWIZZLE_X TGSI_SWIZZLE_X
-#define TGSI_EXTSWIZZLE_Y TGSI_SWIZZLE_Y
-#define TGSI_EXTSWIZZLE_Z TGSI_SWIZZLE_Z
-#define TGSI_EXTSWIZZLE_W TGSI_SWIZZLE_W
-#define TGSI_EXTSWIZZLE_ZERO 4
-#define TGSI_EXTSWIZZLE_ONE 5
-
-/*
- * ExtSwizzleX, ExtSwizzleY, ExtSwizzleZ and ExtSwizzleW swizzle the source
- * register in an extended manner.
- *
- * NegateX, NegateY, NegateZ and NegateW negate individual components of the
- * source register.
- *
- * ExtDivide specifies which component is used to divide all components of the
- * source register.
- */
-
-struct tgsi_src_register_ext_swz
-{
- unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_SWZ */
- unsigned ExtSwizzleX : 4; /* TGSI_EXTSWIZZLE_ */
- unsigned ExtSwizzleY : 4; /* TGSI_EXTSWIZZLE_ */
- unsigned ExtSwizzleZ : 4; /* TGSI_EXTSWIZZLE_ */
- unsigned ExtSwizzleW : 4; /* TGSI_EXTSWIZZLE_ */
- unsigned NegateX : 1; /* BOOL */
- unsigned NegateY : 1; /* BOOL */
- unsigned NegateZ : 1; /* BOOL */
- unsigned NegateW : 1; /* BOOL */
- unsigned ExtDivide : 4; /* TGSI_EXTSWIZZLE_ */
- unsigned Padding : 3;
- unsigned Extended : 1; /* BOOL */
-};
-
-/**
- * Extra src register modifiers
- *
- * If Complement is TRUE, the source register is modified by subtracting it
- * from 1.0.
- *
- * If Bias is TRUE, the source register is modified by subtracting 0.5 from it.
- *
- * If Scale2X is TRUE, the source register is modified by multiplying it by 2.0.
- *
- * If Absolute is TRUE, the source register is modified by removing the sign.
- *
- * If Negate is TRUE, the source register is modified by negating it.
- */
-
-struct tgsi_src_register_ext_mod
-{
- unsigned Type : 4; /* TGSI_SRC_REGISTER_EXT_TYPE_MOD */
- unsigned Complement : 1; /* BOOL */
- unsigned Bias : 1; /* BOOL */
- unsigned Scale2X : 1; /* BOOL */
- unsigned Absolute : 1; /* BOOL */
- unsigned Negate : 1; /* BOOL */
- unsigned Padding : 22;
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_dimension
-{
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- unsigned Padding : 13;
- int Index : 16; /* SINT */
- unsigned Extended : 1; /* BOOL */
-};
-
-struct tgsi_dst_register
-{
- unsigned File : 4; /* TGSI_FILE_ */
- unsigned WriteMask : 4; /* TGSI_WRITEMASK_ */
- unsigned Indirect : 1; /* BOOL */
- unsigned Dimension : 1; /* BOOL */
- int Index : 16; /* SINT */
- unsigned Padding : 5;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * If tgsi_dst_register::Extended is TRUE, tgsi_dst_register_ext follows.
- *
- * Then, if tgsi_dst_register::Indirect is TRUE, tgsi_src_register follows.
- */
-
-#define TGSI_DST_REGISTER_EXT_TYPE_CONDCODE 0
-#define TGSI_DST_REGISTER_EXT_TYPE_MODULATE 1
-#define TGSI_DST_REGISTER_EXT_TYPE_PREDICATE 2
-
-struct tgsi_dst_register_ext
-{
- unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_ */
- unsigned Padding : 27;
- unsigned Extended : 1; /* BOOL */
-};
-
-/**
- * Extra destination register modifiers
- *
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_CONDCODE,
- * it should be cast to tgsi_dst_register_ext_condcode.
- *
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_MODULATE,
- * it should be cast to tgsi_dst_register_ext_modulate.
- *
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_PREDICATE,
- * it should be cast to tgsi_dst_register_ext_predicate.
- *
- * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
- * follows.
- */
-struct tgsi_dst_register_ext_concode
-{
- unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_CONDCODE */
- unsigned CondMask : 4; /* TGSI_CC_ */
- unsigned CondSwizzleX : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleY : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleZ : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned CondSrcIndex : 4; /* UINT */
- unsigned Padding : 11;
- unsigned Extended : 1; /* BOOL */
-};
-
-#define TGSI_MODULATE_1X 0
-#define TGSI_MODULATE_2X 1
-#define TGSI_MODULATE_4X 2
-#define TGSI_MODULATE_8X 3
-#define TGSI_MODULATE_HALF 4
-#define TGSI_MODULATE_QUARTER 5
-#define TGSI_MODULATE_EIGHTH 6
-
-struct tgsi_dst_register_ext_modulate
-{
- unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_MODULATE */
- unsigned Modulate : 4; /* TGSI_MODULATE_ */
- unsigned Padding : 23;
- unsigned Extended : 1; /* BOOL */
-};
-
-/*
- * Currently, the following constraints apply.
- *
- * - PredSwizzleXYZW is either set to identity or replicate.
- * - PredSrcIndex is 0.
- */
-
-struct tgsi_dst_register_ext_predicate
-{
- unsigned Type : 4; /* TGSI_DST_REGISTER_EXT_TYPE_PREDICATE */
- unsigned PredSwizzleX : 2; /* TGSI_SWIZZLE_ */
- unsigned PredSwizzleY : 2; /* TGSI_SWIZZLE_ */
- unsigned PredSwizzleZ : 2; /* TGSI_SWIZZLE_ */
- unsigned PredSwizzleW : 2; /* TGSI_SWIZZLE_ */
- unsigned PredSrcIndex : 4; /* UINT */
- unsigned Negate : 1; /* BOOL */
- unsigned Padding : 14;
- unsigned Extended : 1; /* BOOL */
-};
-
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_TOKEN_H
-
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
deleted file mode 100644
index 1082343e2f..0000000000
--- a/src/mesa/pipe/p_state.h
+++ /dev/null
@@ -1,322 +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.
- *
- **************************************************************************/
-
-
-/**
- * Abstract graphics pipe state objects.
- *
- * Basic notes:
- * 1. Want compact representations, so we use bitfields.
- * 2. Put bitfields before other (GLfloat) fields.
- */
-
-
-#ifndef PIPE_STATE_H
-#define PIPE_STATE_H
-
-#include "p_compiler.h"
-#include "p_defines.h"
-#include "p_format.h"
-
-/**
- * Implementation limits
- */
-#define PIPE_MAX_SAMPLERS 8
-#define PIPE_MAX_CLIP_PLANES 6
-#define PIPE_MAX_CONSTANT 32
-#define PIPE_ATTRIB_MAX 32
-#define PIPE_MAX_COLOR_BUFS 8
-#define PIPE_MAX_TEXTURE_LEVELS 16
-#define PIPE_MAX_FEEDBACK_ATTRIBS 16
-#define PIPE_MAX_SHADER_INPUTS 16
-#define PIPE_MAX_SHADER_OUTPUTS 16
-
-
-/* fwd decls */
-struct pipe_surface;
-struct pipe_winsys;
-
-
-
-/**
- * The driver will certainly subclass this to include actual memory
- * management information.
- */
-struct pipe_buffer {
- unsigned alignment;
- unsigned usage;
- unsigned size;
-
- /** Reference count */
- unsigned refcount;
-};
-
-
-
-
-/**
- * Primitive (point/line/tri) rasterization info
- */
-struct pipe_rasterizer_state
-{
- unsigned flatshade:1;
- unsigned light_twoside:1;
- unsigned front_winding:2; /**< PIPE_WINDING_x */
- unsigned cull_mode:2; /**< PIPE_WINDING_x */
- unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned offset_cw:1;
- unsigned offset_ccw:1;
- unsigned scissor:1;
- unsigned poly_smooth:1;
- unsigned poly_stipple_enable:1;
- unsigned point_smooth:1;
- unsigned point_sprite:1;
- unsigned point_size_per_vertex:1; /**< size computed in vertex shader */
- unsigned multisample:1; /* XXX maybe more ms state in future */
- unsigned line_smooth:1;
- unsigned line_stipple_enable:1;
- unsigned line_stipple_factor:8; /**< [1..256] actually */
- unsigned line_stipple_pattern:16;
- unsigned bypass_clipping:1;
- unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */
-
- float line_width;
- float point_size; /**< used when no per-vertex size */
- float offset_units;
- float offset_scale;
- ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */
-};
-
-
-struct pipe_poly_stipple {
- unsigned stipple[32];
-};
-
-
-struct pipe_viewport_state {
- float scale[4];
- float translate[4];
-};
-
-
-struct pipe_scissor_state {
- unsigned minx:16;
- unsigned miny:16;
- unsigned maxx:16;
- unsigned maxy:16;
-};
-
-
-struct pipe_clip_state {
- float ucp[PIPE_MAX_CLIP_PLANES][4];
- unsigned nr;
-};
-
-
-/**
- * Constants for vertex/fragment shaders
- */
-struct pipe_constant_buffer {
- struct pipe_buffer *buffer;
- unsigned size; /** in bytes */
-};
-
-
-struct pipe_shader_state {
- const struct tgsi_token *tokens;
- ubyte num_inputs;
- ubyte num_outputs;
- ubyte input_map[PIPE_MAX_SHADER_INPUTS]; /* XXX this may be temporary */
- ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
- ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
- ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
- ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
-};
-
-
-struct pipe_depth_stencil_alpha_state
-{
- struct {
- unsigned enabled:1; /**< depth test enabled? */
- unsigned writemask:1; /**< allow depth buffer writes? */
- unsigned func:3; /**< depth test func (PIPE_FUNC_x) */
- unsigned occlusion_count:1; /**< do occlusion counting? */
- } depth;
- struct {
- unsigned enabled:1;
- unsigned func:3; /**< PIPE_FUNC_x */
- unsigned fail_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned zpass_op:3; /**< PIPE_STENCIL_OP_x */
- unsigned zfail_op:3; /**< PIPE_STENCIL_OP_x */
- ubyte ref_value;
- ubyte value_mask;
- ubyte write_mask;
- } stencil[2]; /**< [0] = front, [1] = back */
- struct {
- unsigned enabled:1;
- unsigned func:3; /**< PIPE_FUNC_x */
- float ref; /**< reference value */
- } alpha;
-};
-
-
-struct pipe_blend_state {
- unsigned blend_enable:1;
-
- unsigned rgb_func:3; /**< PIPE_BLEND_x */
- unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */
- unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
-
- unsigned alpha_func:3; /**< PIPE_BLEND_x */
- unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */
- unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
-
- unsigned logicop_enable:1;
- unsigned logicop_func:4; /**< PIPE_LOGICOP_x */
-
- unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */
- unsigned dither:1;
-};
-
-
-struct pipe_blend_color {
- float color[4];
-};
-
-
-struct pipe_framebuffer_state
-{
- /** multiple colorbuffers for multiple render targets */
- unsigned num_cbufs;
- struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];
-
- struct pipe_surface *zsbuf; /**< Z/stencil buffer */
-};
-
-
-/**
- * Texture sampler state.
- */
-struct pipe_sampler_state
-{
- unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */
- unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */
- unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */
- unsigned min_img_filter:2; /**< PIPE_TEX_FILTER_x */
- unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */
- unsigned mag_img_filter:2; /**< PIPE_TEX_FILTER_x */
- unsigned compare:1; /**< shadow/depth compare enabled? */
- unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */
- unsigned compare_func:3; /**< PIPE_FUNC_x */
- unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */
- float shadow_ambient; /**< shadow test fail color/intensity */
- float lod_bias; /**< LOD/lambda bias */
- float min_lod, max_lod; /**< LOD clamp range, after bias */
- float border_color[4];
- float max_anisotropy;
-};
-
-
-/**
- * 2D surface. This is basically a view into a memory buffer.
- * May be a renderbuffer, texture mipmap level, etc.
- */
-struct pipe_surface
-{
- struct pipe_buffer *buffer; /**< driver private buffer handle */
- enum pipe_format format; /**< PIPE_FORMAT_x */
- unsigned status; /**< PIPE_SURFACE_STATUS_x */
- unsigned clear_value; /**< may be temporary */
- unsigned cpp; /**< bytes per pixel */
- unsigned width;
- unsigned height;
- unsigned pitch; /**< in pixels */
- unsigned offset; /**< offset from start of buffer, in bytes */
- unsigned refcount;
- struct pipe_winsys *winsys; /**< winsys which owns/created the surface */
-};
-
-
-/**
- * Texture. Represents one or several texture images on one or several mipmap
- * levels.
- */
-struct pipe_texture
-{
- /* Effectively the key:
- */
- enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
- enum pipe_format format; /**< PIPE_FORMAT_x */
-
- unsigned width[PIPE_MAX_TEXTURE_LEVELS];
- unsigned height[PIPE_MAX_TEXTURE_LEVELS];
- unsigned depth[PIPE_MAX_TEXTURE_LEVELS];
-
- unsigned cpp:8;
- unsigned last_level:8; /**< Index of last mipmap level present/defined */
- unsigned compressed:1;
-
- /* These are also refcounted:
- */
- unsigned refcount;
-};
-
-
-/**
- * A vertex buffer. Typically, all the vertex data/attributes for
- * drawing something will be in one buffer. But it's also possible, for
- * example, to put colors in one buffer and texcoords in another.
- */
-struct pipe_vertex_buffer
-{
- unsigned pitch; /**< stride to same attrib in next vertex, in bytes */
- unsigned max_index; /**< number of vertices in this buffer */
- unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
- struct pipe_buffer *buffer; /**< the actual buffer */
-};
-
-
-/**
- * Information to describe a vertex attribute (position, color, etc)
- */
-struct pipe_vertex_element
-{
- /** Offset of this attribute, in bytes, from the start of the vertex */
- unsigned src_offset;
-
- /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does
- * this attribute live in?
- */
- unsigned vertex_buffer_index:8;
- unsigned nr_components:8;
-
- enum pipe_format src_format; /**< PIPE_FORMAT_* */
-};
-
-
-#endif
diff --git a/src/mesa/pipe/p_thread.h b/src/mesa/pipe/p_thread.h
deleted file mode 100644
index cd432c547c..0000000000
--- a/src/mesa/pipe/p_thread.h
+++ /dev/null
@@ -1,54 +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.
- *
- **************************************************************************/
-
-#ifndef P_THREAD_H
-#define P_THREAD_H
-
-#include "p_compiler.h"
-
-/*
- * XXX: We should come up with a system-independent thread definitions.
- * XXX: Patching glthread defs for now.
- */
-
-#ifndef __MSC__
-
-#include "glapi/glthread.h"
-
-#else /* __MSC__ */
-
-typedef int _glthread_Mutex;
-
-#define _glthread_INIT_MUTEX( M ) ((void) (M))
-#define _glthread_LOCK_MUTEX( M ) ((void) (M))
-#define _glthread_UNLOCK_MUTEX( M ) ((void) (M))
-
-#define sched_yield() ((void) 0)
-
-#endif /* __MSC__ */
-
-#endif /* P_THREAD_H */
diff --git a/src/mesa/pipe/p_util.h b/src/mesa/pipe/p_util.h
deleted file mode 100644
index a8938a7e43..0000000000
--- a/src/mesa/pipe/p_util.h
+++ /dev/null
@@ -1,408 +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_compiler.h"
-#include "p_debug.h"
-#include <math.h>
-
-
-#ifdef WIN32
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-void * __stdcall
-EngAllocMem(
- unsigned long Flags,
- unsigned long MemSize,
- unsigned long Tag );
-
-void __stdcall
-EngFreeMem(
- void *Mem );
-
-#ifdef __cplusplus
-}
-#endif
-
-static INLINE void *
-MALLOC( unsigned size )
-{
- return EngAllocMem( 0, size, 'D3AG' );
-}
-
-static INLINE void *
-CALLOC( unsigned count, unsigned size )
-{
- void *ptr = MALLOC( count * size );
- if( ptr ) {
- memset( ptr, 0, count * size );
- }
- return ptr;
-}
-
-static INLINE void
-FREE( void *ptr )
-{
- if( ptr ) {
- EngFreeMem( ptr );
- }
-}
-
-static INLINE void *
-REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
-{
- void *new_ptr;
- if( new_size <= old_size ) {
- return old_ptr;
- }
- new_ptr = MALLOC( new_size );
- if( new_ptr ) {
- memcpy( new_ptr, old_ptr, old_size );
- }
- FREE( old_ptr );
- return new_ptr;
-}
-
-#define GETENV( X ) NULL
-
-#else /* WIN32 */
-
-#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 )
-
-#define GETENV( X ) getenv( X )
-
-#endif /* WIN32 */
-
-#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
-
-#define CALLOC_STRUCT(T) (struct T *) CALLOC(1, sizeof(struct T))
-
-
-/**
- * Return a pointer aligned to next multiple of N bytes.
- */
-static INLINE void *
-align_pointer( void *unaligned, uint alignment )
-{
- if (sizeof(void *) == 64) {
- union {
- void *p;
- uint64 u;
- } pu;
- pu.p = unaligned;
- pu.u = (pu.u + alignment - 1) & ~(uint64) (alignment - 1);
- return pu.p;
- }
- else {
- /* 32-bit pointers */
- union {
- void *p;
- uint u;
- } pu;
- pu.p = unaligned;
- pu.u = (pu.u + alignment - 1) & ~(alignment - 1);
- return pu.p;
- }
-}
-
-/**
- * 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 of 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) )
-
-#define Elements(x) sizeof(x)/sizeof(*(x))
-#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(__MSC__) && defined(__WIN32__)
-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(__GNUC__) && defined(__i386__)
-static INLINE int iround(float f)
-{
- int r;
- __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
- return r;
-}
-#elif defined(__MSC__) && defined(__WIN32__)
-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, unsigned cpp, unsigned dst_pitch,
- unsigned dst_x, unsigned dst_y, unsigned width,
- unsigned height, const ubyte * src,
- int src_pitch, unsigned src_x, int src_y);
-
-
-#endif
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
deleted file mode 100644
index 1e81eebd78..0000000000
--- a/src/mesa/pipe/p_winsys.h
+++ /dev/null
@@ -1,160 +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_WINSYS_H
-#define P_WINSYS_H
-
-
-#include "p_format.h"
-
-/**
- * \file
- * This is the interface that Gallium3D requires any window system
- * hosting it to implement. This is the only include file in Gallium3D
- * which is public.
- */
-
-
-/** Opaque type */
-struct pipe_fence_handle;
-
-struct pipe_surface;
-
-
-/**
- * Gallium3D drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-struct pipe_winsys
-{
- /** Returns name of this winsys interface */
- const char *(*get_name)( struct pipe_winsys *sws );
-
- /**
- * Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct pipe_winsys *sws,
- struct pipe_surface *surf,
- void *context_private );
-
- /** Debug output */
- void (*printf)( struct pipe_winsys *sws,
- const char *, ... );
-
-
- /** allocate a new surface (no context dependency) */
- struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws);
-
- /**
- * Allocate storage for a pipe_surface.
- * Returns 0 if succeeds.
- */
- int (*surface_alloc_storage)(struct pipe_winsys *ws,
- struct pipe_surface *surf,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags);
-
- void (*surface_release)(struct pipe_winsys *ws, struct pipe_surface **s);
-
-
- /**
- * Buffer management. Buffer attributes are mostly fixed over its lifetime.
- *
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
- */
- struct pipe_buffer *(*buffer_create)( struct pipe_winsys *sws,
- unsigned alignment,
- unsigned usage,
- unsigned size );
-
- /** Create a buffer that wraps user-space data */
- struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *sws,
- void *ptr,
- unsigned bytes);
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
- */
- void *(*buffer_map)( struct pipe_winsys *sws,
- struct pipe_buffer *buf,
- unsigned usage );
-
- void (*buffer_unmap)( struct pipe_winsys *sws,
- struct pipe_buffer *buf );
-
- void (*buffer_destroy)( struct pipe_winsys *sws,
- struct pipe_buffer *buf );
-
-
- /** Set ptr = fence, with reference counting */
- void (*fence_reference)( struct pipe_winsys *sws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence );
-
- /**
- * Checks whether the fence has been signalled.
- *
- * The meaning of flag is pipe-driver specific.
- *
- * Returns zero if it has.
- */
- int (*fence_signalled)( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
- /**
- * Wait for the fence to finish.
- *
- * The meaning of flag is pipe-driver specific.
- *
- * Returns zero on success.
- */
- int (*fence_finish)( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag );
-
-
-};
-
-
-
-#endif /* P_WINSYS_H */
diff --git a/src/mesa/pipe/pipebuffer/Makefile b/src/mesa/pipe/pipebuffer/Makefile
deleted file mode 100644
index 75764a9a18..0000000000
--- a/src/mesa/pipe/pipebuffer/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = pipebuffer
-
-DRIVER_SOURCES = \
- pb_buffer_fenced.c \
- pb_buffer_malloc.c \
- pb_bufmgr_fenced.c \
- pb_bufmgr_mm.c \
- pb_bufmgr_pool.c \
- pb_winsys.c
-
-C_SOURCES = \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-include ../Makefile.template
-
-symlinks:
-
diff --git a/src/mesa/pipe/pipebuffer/linked_list.h b/src/mesa/pipe/pipebuffer/linked_list.h
deleted file mode 100644
index e99817fb13..0000000000
--- a/src/mesa/pipe/pipebuffer/linked_list.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- **************************************************************************/
-
-/**
- * \file
- * List macros heavily inspired by the Linux kernel
- * list handling. No list looping yet.
- *
- * Is not threadsafe, so common operations need to
- * be protected using an external mutex.
- */
-
-#ifndef LINKED_LIST_H_
-#define LINKED_LIST_H_
-
-
-#include <stddef.h>
-
-
-struct list_head
-{
- struct list_head *prev;
- struct list_head *next;
-};
-
-
-#define LIST_INITHEAD(__item) \
- do { \
- (__item)->prev = (__item); \
- (__item)->next = (__item); \
- } while (0)
-
-#define LIST_ADD(__item, __list) \
- do { \
- (__item)->prev = (__list); \
- (__item)->next = (__list)->next; \
- (__list)->next->prev = (__item); \
- (__list)->next = (__item); \
- } while (0)
-
-#define LIST_ADDTAIL(__item, __list) \
- do { \
- (__item)->next = (__list); \
- (__item)->prev = (__list)->prev; \
- (__list)->prev->next = (__item); \
- (__list)->prev = (__item); \
- } while(0)
-
-#define LIST_DEL(__item) \
- do { \
- (__item)->prev->next = (__item)->next; \
- (__item)->next->prev = (__item)->prev; \
- } while(0)
-
-#define LIST_DELINIT(__item) \
- do { \
- (__item)->prev->next = (__item)->next; \
- (__item)->next->prev = (__item)->prev; \
- (__item)->next = (__item); \
- (__item)->prev = (__item); \
- } while(0)
-
-#define LIST_ENTRY(__type, __item, __field) \
- ((__type *)(((char *)(__item)) - offsetof(__type, __field)))
-
-
-#endif /*LINKED_LIST_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.h b/src/mesa/pipe/pipebuffer/pb_buffer.h
deleted file mode 100644
index 97beb5f72a..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Generic code for buffers.
- *
- * Behind a pipe buffle handle there can be DMA buffers, client (or user)
- * buffers, regular malloced buffers, etc. This file provides an abstract base
- * buffer handle that allows the driver to cope with all those kinds of buffers
- * in a more flexible way.
- *
- * There is no obligation of a winsys driver to use this library. And a pipe
- * driver should be completly agnostic about it.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef PB_BUFFER_H_
-#define PB_BUFFER_H_
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-
-
-struct pb_vtbl;
-
-/**
- * Buffer description.
- *
- * Used when allocating the buffer.
- */
-struct pb_desc
-{
- unsigned alignment;
- unsigned usage;
-};
-
-
-/**
- * Base class for all pb_* buffers.
- */
-struct pb_buffer
-{
- struct pipe_buffer base;
-
- /**
- * Pointer to the virtual function table.
- *
- * Avoid accessing this table directly. Use the inline functions below
- * instead to avoid mistakes.
- */
- const struct pb_vtbl *vtbl;
-};
-
-
-/**
- * Virtual function table for the buffer storage operations.
- *
- * Note that creation is not done through this table.
- */
-struct pb_vtbl
-{
- void (*destroy)( struct pb_buffer *buf );
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
- */
- void *(*map)( struct pb_buffer *buf,
- unsigned flags );
-
- void (*unmap)( struct pb_buffer *buf );
-
- /**
- * Get the base buffer and the offset.
- *
- * A buffer can be subdivided in smaller buffers. This method should return
- * the underlaying buffer, and the relative offset.
- *
- * Buffers without an underlaying base buffer should return themselves, with
- * a zero offset.
- *
- * Note that this will increase the reference count of the base buffer.
- */
- void (*get_base_buffer)( struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset );
-};
-
-
-static INLINE struct pipe_buffer *
-pb_pipe_buffer( struct pb_buffer *pbuf )
-{
- assert(pbuf);
- return &pbuf->base;
-}
-
-
-static INLINE struct pb_buffer *
-pb_buffer( struct pipe_buffer *buf )
-{
- assert(buf);
- /* Could add a magic cookie check on debug builds.
- */
- return (struct pb_buffer *)buf;
-}
-
-
-/* Accessor functions for pb->vtbl:
- */
-static INLINE void *
-pb_map(struct pb_buffer *buf,
- unsigned flags)
-{
- assert(buf);
- return buf->vtbl->map(buf, flags);
-}
-
-
-static INLINE void
-pb_unmap(struct pb_buffer *buf)
-{
- assert(buf);
- buf->vtbl->unmap(buf);
-}
-
-
-static INLINE void
-pb_get_base_buffer( struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset )
-{
- buf->vtbl->get_base_buffer(buf, base_buf, offset);
-}
-
-
-static INLINE void
-pb_destroy(struct pb_buffer *buf)
-{
- assert(buf);
- buf->vtbl->destroy(buf);
-}
-
-
-/* XXX: thread safety issues!
- */
-static INLINE void
-pb_reference(struct pb_buffer **dst,
- struct pb_buffer *src)
-{
- if (src)
- src->base.refcount++;
-
- if (*dst && --(*dst)->base.refcount == 0)
- pb_destroy( *dst );
-
- *dst = src;
-}
-
-
-/**
- * Malloc-based buffer to store data that can't be used by the graphics
- * hardware.
- */
-struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
- const struct pb_desc *desc);
-
-
-void
-pb_init_winsys(struct pipe_winsys *winsys);
-
-
-#endif /*PB_BUFFER_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
deleted file mode 100644
index f4fc3f6d71..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
+++ /dev/null
@@ -1,299 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Implementation of fenced buffers.
- *
- * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
- * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-
-#include "linked_list.h"
-
-#include "p_compiler.h"
-#include "p_debug.h"
-#include "p_winsys.h"
-#include "p_thread.h"
-#include "p_util.h"
-
-#include "pb_buffer.h"
-#include "pb_buffer_fenced.h"
-
-#ifndef __MSC__
-#include <unistd.h>
-#endif
-
-
-/**
- * Convenience macro (type safe).
- */
-#define SUPER(__derived) (&(__derived)->base)
-
-
-struct fenced_buffer_list
-{
- _glthread_Mutex mutex;
-
- struct pipe_winsys *winsys;
-
- size_t numDelayed;
- size_t checkDelayed;
-
- struct list_head delayed;
-};
-
-
-/**
- * Wrapper around a pipe buffer which adds fencing and reference counting.
- */
-struct fenced_buffer
-{
- struct pb_buffer base;
-
- struct pb_buffer *buffer;
-
- struct pipe_fence_handle *fence;
-
- struct list_head head;
- struct fenced_buffer_list *list;
-};
-
-
-static INLINE struct fenced_buffer *
-fenced_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- assert(buf->vtbl == &fenced_buffer_vtbl);
- return (struct fenced_buffer *)buf;
-}
-
-
-
-
-static void
-_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
- int wait)
-{
- struct pipe_winsys *winsys = fenced_list->winsys;
- struct fenced_buffer *fenced_buf;
- struct list_head *list, *prev;
- int signaled = -1;
-
- list = fenced_list->delayed.next;
-
- if (fenced_list->numDelayed > 3) {
- unsigned i;
-
- for (i = 0; i < fenced_list->numDelayed; i += 3) {
- list = list->next;
- }
- }
-
- prev = list->prev;
- for (; list != &fenced_list->delayed; list = prev, prev = list->prev) {
-
- fenced_buf = LIST_ENTRY(struct fenced_buffer, list, head);
-
- if (signaled != 0) {
- if (wait) {
- signaled = winsys->fence_finish(winsys, fenced_buf->fence, 0);
- }
- else {
- signaled = winsys->fence_signalled(winsys, fenced_buf->fence, 0);
- }
- }
-
- if (signaled != 0)
- /* XXX: we are assuming that buffers are freed in the same order they
- * are fenced which may not always be true...
- */
- break;
-
- winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
-
- LIST_DEL(list);
- fenced_list->numDelayed--;
-
- /* Do the delayed destroy:
- */
- pb_reference(&fenced_buf->buffer, NULL);
- FREE(fenced_buf);
- }
-}
-
-
-static void
-fenced_buffer_destroy(struct pb_buffer *buf)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
- if (fenced_buf->fence) {
- LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
- fenced_list->numDelayed++;
- }
- else {
- pb_reference(&fenced_buf->buffer, NULL);
- FREE(fenced_buf);
- }
-
- if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
- _fenced_buffer_list_check_free(fenced_list, 0);
-}
-
-
-static void *
-fenced_buffer_map(struct pb_buffer *buf,
- unsigned flags)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- return pb_map(fenced_buf->buffer, flags);
-}
-
-
-static void
-fenced_buffer_unmap(struct pb_buffer *buf)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- pb_unmap(fenced_buf->buffer);
-}
-
-
-static void
-fenced_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
-}
-
-
-const struct pb_vtbl
-fenced_buffer_vtbl = {
- fenced_buffer_destroy,
- fenced_buffer_map,
- fenced_buffer_unmap,
- fenced_buffer_get_base_buffer
-};
-
-
-struct pb_buffer *
-fenced_buffer_create(struct fenced_buffer_list *fenced_list,
- struct pb_buffer *buffer)
-{
- struct fenced_buffer *buf;
-
- if(!buffer)
- return NULL;
-
- buf = CALLOC_STRUCT(fenced_buffer);
- if(!buf)
- return NULL;
-
- buf->base.base.refcount = 1;
- buf->base.base.alignment = buffer->base.alignment;
- buf->base.base.usage = buffer->base.usage;
- buf->base.base.size = buffer->base.size;
-
- buf->base.vtbl = &fenced_buffer_vtbl;
- buf->buffer = buffer;
- buf->list = fenced_list;
-
- return &buf->base;
-}
-
-
-void
-buffer_fence(struct pb_buffer *buf,
- struct pipe_fence_handle *fence)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
- struct pipe_winsys *winsys = fenced_list->winsys;
-
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- winsys->fence_reference(winsys, &fenced_buf->fence, fence);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
-}
-
-
-struct fenced_buffer_list *
-fenced_buffer_list_create(struct pipe_winsys *winsys)
-{
- struct fenced_buffer_list *fenced_list;
-
- fenced_list = (struct fenced_buffer_list *)CALLOC(1, sizeof(*fenced_list));
- if (!fenced_list)
- return NULL;
-
- fenced_list->winsys = winsys;
-
- LIST_INITHEAD(&fenced_list->delayed);
-
- fenced_list->numDelayed = 0;
-
- /* TODO: don't hard code this */
- fenced_list->checkDelayed = 5;
-
- _glthread_INIT_MUTEX(fenced_list->mutex);
-
- return fenced_list;
-}
-
-
-void
-fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
- int wait)
-{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- _fenced_buffer_list_check_free(fenced_list, wait);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
-}
-
-
-void
-fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
-{
- _glthread_LOCK_MUTEX(fenced_list->mutex);
-
- /* Wait on outstanding fences */
- while (fenced_list->numDelayed) {
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
- sched_yield();
- _fenced_buffer_list_check_free(fenced_list, 1);
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- }
-
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
-
- FREE(fenced_list);
-}
-
-
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
deleted file mode 100644
index c40b9c75e1..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Buffer fencing.
- *
- * "Fenced buffers" is actually a misnomer. They should be referred as
- * "fenceable buffers", i.e, buffers that can be fenced, but I couldn't find
- * the word "fenceable" in the dictionary.
- *
- * A "fenced buffer" is a decorator around a normal buffer, which adds two
- * special properties:
- * - the ability for the destruction to be delayed by a fence;
- * - reference counting.
- *
- * Usually DMA buffers have a life-time that will extend the life-time of its
- * handle. The end-of-life is dictated by the fence signalling.
- *
- * Between the handle's destruction, and the fence signalling, the buffer is
- * stored in a fenced buffer list.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef PB_BUFFER_FENCED_H_
-#define PB_BUFFER_FENCED_H_
-
-
-#include "pipe/p_debug.h"
-
-
-struct pipe_winsys;
-struct pipe_buffer;
-struct pipe_fence_handle;
-
-
-/**
- * List of buffers which are awaiting fence signalling.
- */
-struct fenced_buffer_list;
-
-
-/**
- * The fenced buffer's virtual function table.
- *
- * NOTE: Made public for debugging purposes.
- */
-extern const struct pb_vtbl fenced_buffer_vtbl;
-
-
-/**
- * Create a fenced buffer list.
- *
- * See also fenced_bufmgr_create for a more convenient way to use this.
- */
-struct fenced_buffer_list *
-fenced_buffer_list_create(struct pipe_winsys *winsys);
-
-
-/**
- * Walk the fenced buffer list to check and free signalled buffers.
- */
-void
-fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
- int wait);
-
-void
-fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
-
-
-/**
- * Wrap a buffer in a fenced buffer.
- *
- * NOTE: this will not increase the buffer reference count.
- */
-struct pb_buffer *
-fenced_buffer_create(struct fenced_buffer_list *fenced,
- struct pb_buffer *buffer);
-
-
-/**
- * Set a buffer's fence.
- *
- * NOTE: Although it takes a generic pb_buffer argument, it will fail
- * on everything but buffers returned by fenced_buffer_create.
- */
-void
-buffer_fence(struct pb_buffer *buf,
- struct pipe_fence_handle *fence);
-
-
-#endif /*PB_BUFFER_FENCED_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
deleted file mode 100644
index c1b7759874..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Implementation of malloc-based buffers to store data that can't be processed
- * by the hardware.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-#include "pb_buffer.h"
-
-
-struct malloc_buffer
-{
- struct pb_buffer base;
- void *data;
-};
-
-
-extern const struct pb_vtbl malloc_buffer_vtbl;
-
-static INLINE struct malloc_buffer *
-malloc_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- assert(buf->vtbl == &malloc_buffer_vtbl);
- return (struct malloc_buffer *)buf;
-}
-
-
-static void
-malloc_buffer_destroy(struct pb_buffer *buf)
-{
- align_free(malloc_buffer(buf)->data);
- FREE(buf);
-}
-
-
-static void *
-malloc_buffer_map(struct pb_buffer *buf,
- unsigned flags)
-{
- return malloc_buffer(buf)->data;
-}
-
-
-static void
-malloc_buffer_unmap(struct pb_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-malloc_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-const struct pb_vtbl
-malloc_buffer_vtbl = {
- malloc_buffer_destroy,
- malloc_buffer_map,
- malloc_buffer_unmap,
- malloc_buffer_get_base_buffer
-};
-
-
-struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
- const struct pb_desc *desc)
-{
- struct malloc_buffer *buf;
-
- /* TODO: do a single allocation */
-
- buf = CALLOC_STRUCT(malloc_buffer);
- if(!buf)
- return NULL;
-
- buf->base.base.refcount = 1;
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
- buf->base.vtbl = &malloc_buffer_vtbl;
-
- buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment);
- if(!buf->data) {
- FREE(buf);
- return NULL;
- }
-
- return &buf->base;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
deleted file mode 100644
index 1ddf784c97..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Buffer management.
- *
- * A buffer manager does only one basic thing: it creates buffers. Actually,
- * "buffer factory" would probably a more accurate description.
- *
- * You can chain buffer managers so that you can have a finer grained memory
- * management and pooling.
- *
- * For example, for a simple batch buffer manager you would chain:
- * - the native buffer manager, which provides DMA memory from the graphics
- * memory space;
- * - the pool buffer manager, which keep around a pool of equally sized buffers
- * to avoid latency associated with the native buffer manager;
- * - the fenced buffer manager, which will delay buffer destruction until the
- * the moment the card finishing processing it.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef PB_BUFMGR_H_
-#define PB_BUFMGR_H_
-
-
-#include <stddef.h>
-
-
-struct pb_desc;
-struct pipe_buffer;
-struct pipe_winsys;
-
-
-/**
- * Abstract base class for all buffer managers.
- */
-struct pb_manager
-{
- /* XXX: we will likely need more allocation flags */
- struct pb_buffer *
- (*create_buffer)( struct pb_manager *mgr,
- size_t size,
- const struct pb_desc *desc);
-
- void
- (*destroy)( struct pb_manager *mgr );
-};
-
-
-/**
- * Static buffer pool manager.
- *
- * Manages the allocation of equally sized buffers. It does so by allocating
- * a single big buffer and divide it equally sized buffers.
- *
- * It is meant to manage the allocation of batch buffer pools.
- */
-struct pb_manager *
-pool_bufmgr_create(struct pb_manager *provider,
- size_t n, size_t size,
- const struct pb_desc *desc);
-
-
-/**
- * Wraper around the old memory manager.
- *
- * It managers buffers of different sizes. It does so by allocating a buffer
- * with the size of the heap, and then using the old mm memory manager to manage
- * that heap.
- */
-struct pb_manager *
-mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2);
-
-/**
- * Same as mm_bufmgr_create.
- *
- * Buffer will be release when the manager is destroyed.
- */
-struct pb_manager *
-mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2);
-
-
-/**
- * Fenced buffer manager.
- *
- * This manager is just meant for convenience. It wraps the buffers returned
- * by another manager in fenced buffers, so that
- *
- * NOTE: the buffer manager that provides the buffers will be destroyed
- * at the same time.
- */
-struct pb_manager *
-fenced_bufmgr_create(struct pb_manager *provider,
- struct pipe_winsys *winsys);
-
-
-#endif /*PB_BUFMGR_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
deleted file mode 100644
index c535d3276c..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-
-/**
- * \file
- * A buffer manager that wraps buffers in fenced buffers.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.dot.com>
- */
-
-
-#include "p_debug.h"
-#include "p_util.h"
-
-#include "pb_buffer.h"
-#include "pb_buffer_fenced.h"
-#include "pb_bufmgr.h"
-
-
-struct fenced_pb_manager
-{
- struct pb_manager base;
-
- struct pb_manager *provider;
-
- struct fenced_buffer_list *fenced_list;
-};
-
-
-static INLINE struct fenced_pb_manager *
-fenced_pb_manager(struct pb_manager *mgr)
-{
- assert(mgr);
- return (struct fenced_pb_manager *)mgr;
-}
-
-
-static struct pb_buffer *
-fenced_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
- const struct pb_desc *desc)
-{
- struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
- struct pb_buffer *buf;
- struct pb_buffer *fenced_buf;
-
- /* check for free buffers before allocating new ones */
- fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0);
-
- buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
- if(!buf) {
- /* try harder to get a buffer */
- fenced_buffer_list_check_free(fenced_mgr->fenced_list, 1);
-
- buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
- if(!buf) {
- /* give up */
- return NULL;
- }
- }
-
- fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
- if(!fenced_buf) {
- assert(buf->base.refcount == 1);
- pb_destroy(buf);
- }
-
- return fenced_buf;
-}
-
-
-static void
-fenced_bufmgr_destroy(struct pb_manager *mgr)
-{
- struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
-
- fenced_buffer_list_destroy(fenced_mgr->fenced_list);
-
- fenced_mgr->provider->destroy(fenced_mgr->provider);
-
- FREE(fenced_mgr);
-}
-
-
-struct pb_manager *
-fenced_bufmgr_create(struct pb_manager *provider,
- struct pipe_winsys *winsys)
-{
- struct fenced_pb_manager *fenced_mgr;
-
- fenced_mgr = (struct fenced_pb_manager *)CALLOC(1, sizeof(*fenced_mgr));
- if (!fenced_mgr)
- return NULL;
-
- fenced_mgr->base.destroy = fenced_bufmgr_destroy;
- fenced_mgr->base.create_buffer = fenced_bufmgr_create_buffer;
-
- fenced_mgr->provider = provider;
- fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
- if(!fenced_mgr->fenced_list) {
- FREE(fenced_mgr);
- return NULL;
- }
-
- return &fenced_mgr->base;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
deleted file mode 100644
index 8b1b51c0e2..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ /dev/null
@@ -1,593 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * Copyright 1999 Wittawat Yamwong
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * Buffer manager using the old texture memory manager.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include "linked_list.h"
-
-#include "p_defines.h"
-#include "p_debug.h"
-#include "p_thread.h"
-#include "p_util.h"
-#include "pb_buffer.h"
-#include "pb_bufmgr.h"
-
-
-/**
- * Convenience macro (type safe).
- */
-#define SUPER(__derived) (&(__derived)->base)
-
-
-struct mem_block
-{
- struct mem_block *next, *prev;
- struct mem_block *next_free, *prev_free;
- struct mem_block *heap;
- int ofs, size;
- unsigned int free:1;
- unsigned int reserved:1;
-};
-
-
-#ifdef DEBUG
-/**
- * For debugging purposes.
- */
-static void
-mmDumpMemInfo(const struct mem_block *heap)
-{
- debug_printf("Memory heap %p:\n", (void *)heap);
- if (heap == 0) {
- debug_printf(" heap == 0\n");
- } else {
- const struct mem_block *p;
-
- for(p = heap->next; p != heap; p = p->next) {
- debug_printf(" Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
- p->free ? 'F':'.',
- p->reserved ? 'R':'.');
- }
-
- debug_printf("\nFree list:\n");
-
- for(p = heap->next_free; p != heap; p = p->next_free) {
- debug_printf(" FREE Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
- p->free ? 'F':'.',
- p->reserved ? 'R':'.');
- }
-
- }
- debug_printf("End of memory blocks\n");
-}
-#endif
-
-
-/**
- * input: total size in bytes
- * return: a heap pointer if OK, NULL if error
- */
-static struct mem_block *
-mmInit(int ofs, int size)
-{
- struct mem_block *heap, *block;
-
- if (size <= 0)
- return NULL;
-
- heap = CALLOC_STRUCT(mem_block);
- if (!heap)
- return NULL;
-
- block = CALLOC_STRUCT(mem_block);
- if (!block) {
- FREE(heap);
- return NULL;
- }
-
- heap->next = block;
- heap->prev = block;
- heap->next_free = block;
- heap->prev_free = block;
-
- block->heap = heap;
- block->next = heap;
- block->prev = heap;
- block->next_free = heap;
- block->prev_free = heap;
-
- block->ofs = ofs;
- block->size = size;
- block->free = 1;
-
- return heap;
-}
-
-
-static struct mem_block *
-SliceBlock(struct mem_block *p,
- int startofs, int size,
- int reserved, int alignment)
-{
- struct mem_block *newblock;
-
- /* break left [p, newblock, p->next], then p = newblock */
- if (startofs > p->ofs) {
- newblock = CALLOC_STRUCT(mem_block);
- if (!newblock)
- return NULL;
- newblock->ofs = startofs;
- newblock->size = p->size - (startofs - p->ofs);
- newblock->free = 1;
- newblock->heap = p->heap;
-
- newblock->next = p->next;
- newblock->prev = p;
- p->next->prev = newblock;
- p->next = newblock;
-
- newblock->next_free = p->next_free;
- newblock->prev_free = p;
- p->next_free->prev_free = newblock;
- p->next_free = newblock;
-
- p->size -= newblock->size;
- p = newblock;
- }
-
- /* break right, also [p, newblock, p->next] */
- if (size < p->size) {
- newblock = CALLOC_STRUCT(mem_block);
- if (!newblock)
- return NULL;
- newblock->ofs = startofs + size;
- newblock->size = p->size - size;
- newblock->free = 1;
- newblock->heap = p->heap;
-
- newblock->next = p->next;
- newblock->prev = p;
- p->next->prev = newblock;
- p->next = newblock;
-
- newblock->next_free = p->next_free;
- newblock->prev_free = p;
- p->next_free->prev_free = newblock;
- p->next_free = newblock;
-
- p->size = size;
- }
-
- /* p = middle block */
- p->free = 0;
-
- /* Remove p from the free list:
- */
- p->next_free->prev_free = p->prev_free;
- p->prev_free->next_free = p->next_free;
-
- p->next_free = 0;
- p->prev_free = 0;
-
- p->reserved = reserved;
- return p;
-}
-
-
-/**
- * Allocate 'size' bytes with 2^align2 bytes alignment,
- * restrict the search to free memory after 'startSearch'
- * depth and back buffers should be in different 4mb banks
- * to get better page hits if possible
- * input: size = size of block
- * align2 = 2^align2 bytes alignment
- * startSearch = linear offset from start of heap to begin search
- * return: pointer to the allocated block, 0 if error
- */
-static struct mem_block *
-mmAllocMem(struct mem_block *heap, int size, int align2, int startSearch)
-{
- struct mem_block *p;
- const int mask = (1 << align2)-1;
- int startofs = 0;
- int endofs;
-
- if (!heap || align2 < 0 || size <= 0)
- return NULL;
-
- for (p = heap->next_free; p != heap; p = p->next_free) {
- assert(p->free);
-
- startofs = (p->ofs + mask) & ~mask;
- if ( startofs < startSearch ) {
- startofs = startSearch;
- }
- endofs = startofs+size;
- if (endofs <= (p->ofs+p->size))
- break;
- }
-
- if (p == heap)
- return NULL;
-
- assert(p->free);
- p = SliceBlock(p,startofs,size,0,mask+1);
-
- return p;
-}
-
-
-#if 0
-/**
- * Free block starts at offset
- * input: pointer to a heap, start offset
- * return: pointer to a block
- */
-static struct mem_block *
-mmFindBlock(struct mem_block *heap, int start)
-{
- struct mem_block *p;
-
- for (p = heap->next; p != heap; p = p->next) {
- if (p->ofs == start)
- return p;
- }
-
- return NULL;
-}
-#endif
-
-
-static INLINE int
-Join2Blocks(struct mem_block *p)
-{
- /* XXX there should be some assertions here */
-
- /* NOTE: heap->free == 0 */
-
- if (p->free && p->next->free) {
- struct mem_block *q = p->next;
-
- assert(p->ofs + p->size == q->ofs);
- p->size += q->size;
-
- p->next = q->next;
- q->next->prev = p;
-
- q->next_free->prev_free = q->prev_free;
- q->prev_free->next_free = q->next_free;
-
- FREE(q);
- return 1;
- }
- return 0;
-}
-
-
-/**
- * Free block starts at offset
- * input: pointer to a block
- * return: 0 if OK, -1 if error
- */
-static int
-mmFreeMem(struct mem_block *b)
-{
- if (!b)
- return 0;
-
- if (b->free) {
- debug_printf("block already free\n");
- return -1;
- }
- if (b->reserved) {
- debug_printf("block is reserved\n");
- return -1;
- }
-
- b->free = 1;
- b->next_free = b->heap->next_free;
- b->prev_free = b->heap;
- b->next_free->prev_free = b;
- b->prev_free->next_free = b;
-
- Join2Blocks(b);
- if (b->prev != b->heap)
- Join2Blocks(b->prev);
-
- return 0;
-}
-
-
-/**
- * destroy MM
- */
-static void
-mmDestroy(struct mem_block *heap)
-{
- struct mem_block *p;
-
- if (!heap)
- return;
-
- for (p = heap->next; p != heap; ) {
- struct mem_block *next = p->next;
- FREE(p);
- p = next;
- }
-
- FREE(heap);
-}
-
-
-struct mm_pb_manager
-{
- struct pb_manager base;
-
- _glthread_Mutex mutex;
-
- size_t size;
- struct mem_block *heap;
-
- size_t align2;
-
- struct pb_buffer *buffer;
- void *map;
-};
-
-
-static INLINE struct mm_pb_manager *
-mm_pb_manager(struct pb_manager *mgr)
-{
- assert(mgr);
- return (struct mm_pb_manager *)mgr;
-}
-
-
-struct mm_buffer
-{
- struct pb_buffer base;
-
- struct mm_pb_manager *mgr;
-
- struct mem_block *block;
-};
-
-
-static INLINE struct mm_buffer *
-mm_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- return (struct mm_buffer *)buf;
-}
-
-
-static void
-mm_buffer_destroy(struct pb_buffer *buf)
-{
- struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_pb_manager *mm = mm_buf->mgr;
-
- assert(buf->base.refcount == 0);
-
- _glthread_LOCK_MUTEX(mm->mutex);
- mmFreeMem(mm_buf->block);
- FREE(buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
-}
-
-
-static void *
-mm_buffer_map(struct pb_buffer *buf,
- unsigned flags)
-{
- struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_pb_manager *mm = mm_buf->mgr;
-
- return (unsigned char *) mm->map + mm_buf->block->ofs;
-}
-
-
-static void
-mm_buffer_unmap(struct pb_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-mm_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_pb_manager *mm = mm_buf->mgr;
- pb_get_base_buffer(mm->buffer, base_buf, offset);
- *offset += mm_buf->block->ofs;
-}
-
-
-static const struct pb_vtbl
-mm_buffer_vtbl = {
- mm_buffer_destroy,
- mm_buffer_map,
- mm_buffer_unmap,
- mm_buffer_get_base_buffer
-};
-
-
-static struct pb_buffer *
-mm_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
- const struct pb_desc *desc)
-{
- struct mm_pb_manager *mm = mm_pb_manager(mgr);
- struct mm_buffer *mm_buf;
-
- /* We don't handle alignments larger then the one initially setup */
- assert(desc->alignment % (1 << mm->align2) == 0);
- if(desc->alignment % (1 << mm->align2))
- return NULL;
-
- _glthread_LOCK_MUTEX(mm->mutex);
-
- mm_buf = CALLOC_STRUCT(mm_buffer);
- if (!mm_buf) {
- _glthread_UNLOCK_MUTEX(mm->mutex);
- return NULL;
- }
-
- mm_buf->base.base.refcount = 1;
- mm_buf->base.base.alignment = desc->alignment;
- mm_buf->base.base.usage = desc->usage;
- mm_buf->base.base.size = size;
-
- mm_buf->base.vtbl = &mm_buffer_vtbl;
-
- mm_buf->mgr = mm;
-
- mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
- if(!mm_buf->block) {
- debug_printf("warning: heap full\n");
-#if 0
- mmDumpMemInfo(mm->heap);
-#endif
-
- mm_buf->block = mmAllocMem(mm->heap, size, mm->align2, 0);
- if(!mm_buf->block) {
- assert(0);
- FREE(mm_buf);
- _glthread_UNLOCK_MUTEX(mm->mutex);
- return NULL;
- }
- }
-
- /* Some sanity checks */
- assert(0 <= mm_buf->block->ofs && mm_buf->block->ofs < mm->size);
- assert(size <= mm_buf->block->size && mm_buf->block->ofs + mm_buf->block->size <= mm->size);
-
- _glthread_UNLOCK_MUTEX(mm->mutex);
- return SUPER(mm_buf);
-}
-
-
-static void
-mm_bufmgr_destroy(struct pb_manager *mgr)
-{
- struct mm_pb_manager *mm = mm_pb_manager(mgr);
-
- _glthread_LOCK_MUTEX(mm->mutex);
-
- mmDestroy(mm->heap);
-
- pb_unmap(mm->buffer);
- pb_reference(&mm->buffer, NULL);
-
- _glthread_UNLOCK_MUTEX(mm->mutex);
-
- FREE(mgr);
-}
-
-
-struct pb_manager *
-mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2)
-{
- struct mm_pb_manager *mm;
-
- if(!buffer)
- return NULL;
-
- mm = CALLOC_STRUCT(mm_pb_manager);
- if (!mm)
- return NULL;
-
- mm->base.create_buffer = mm_bufmgr_create_buffer;
- mm->base.destroy = mm_bufmgr_destroy;
-
- mm->size = size;
- mm->align2 = align2; /* 64-byte alignment */
-
- _glthread_INIT_MUTEX(mm->mutex);
-
- mm->buffer = buffer;
-
- mm->map = pb_map(mm->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if(!mm->map)
- goto failure;
-
- mm->heap = mmInit(0, size);
- if (!mm->heap)
- goto failure;
-
- return SUPER(mm);
-
-failure:
-if(mm->heap)
- mmDestroy(mm->heap);
- if(mm->map)
- pb_unmap(mm->buffer);
- if(mm)
- FREE(mm);
- return NULL;
-}
-
-
-struct pb_manager *
-mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2)
-{
- struct pb_buffer *buffer;
- struct pb_manager *mgr;
- struct pb_desc desc;
-
- assert(provider);
- assert(provider->create_buffer);
-
- memset(&desc, 0, sizeof(desc));
- desc.alignment = 1 << align2;
-
- buffer = provider->create_buffer(provider, size, &desc);
- if (!buffer)
- return NULL;
-
- mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
- if (!mgr) {
- pb_reference(&buffer, NULL);
- return NULL;
- }
-
- return mgr;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
deleted file mode 100644
index 04477a865a..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-
-/**
- * \file
- * Batch buffer pool management.
- *
- * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
- * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-
-#include "linked_list.h"
-
-#include "p_compiler.h"
-#include "p_debug.h"
-#include "p_thread.h"
-#include "p_defines.h"
-#include "p_util.h"
-
-#include "pb_buffer.h"
-#include "pb_bufmgr.h"
-
-
-/**
- * Convenience macro (type safe).
- */
-#define SUPER(__derived) (&(__derived)->base)
-
-
-struct pool_pb_manager
-{
- struct pb_manager base;
-
- _glthread_Mutex mutex;
-
- size_t bufSize;
- size_t bufAlign;
-
- size_t numFree;
- size_t numTot;
-
- struct list_head free;
-
- struct pb_buffer *buffer;
- void *map;
-
- struct pool_buffer *bufs;
-};
-
-
-static INLINE struct pool_pb_manager *
-pool_pb_manager(struct pb_manager *mgr)
-{
- assert(mgr);
- return (struct pool_pb_manager *)mgr;
-}
-
-
-struct pool_buffer
-{
- struct pb_buffer base;
-
- struct pool_pb_manager *mgr;
-
- struct list_head head;
-
- size_t start;
-};
-
-
-static INLINE struct pool_buffer *
-pool_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- return (struct pool_buffer *)buf;
-}
-
-
-
-static void
-pool_buffer_destroy(struct pb_buffer *buf)
-{
- struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_pb_manager *pool = pool_buf->mgr;
-
- assert(pool_buf->base.base.refcount == 0);
-
- _glthread_LOCK_MUTEX(pool->mutex);
- LIST_ADD(&pool_buf->head, &pool->free);
- pool->numFree++;
- _glthread_UNLOCK_MUTEX(pool->mutex);
-}
-
-
-static void *
-pool_buffer_map(struct pb_buffer *buf, unsigned flags)
-{
- struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_pb_manager *pool = pool_buf->mgr;
- void *map;
-
- _glthread_LOCK_MUTEX(pool->mutex);
- map = (unsigned char *) pool->map + pool_buf->start;
- _glthread_UNLOCK_MUTEX(pool->mutex);
- return map;
-}
-
-
-static void
-pool_buffer_unmap(struct pb_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-pool_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_pb_manager *pool = pool_buf->mgr;
- pb_get_base_buffer(pool->buffer, base_buf, offset);
- *offset += pool_buf->start;
-}
-
-
-static const struct pb_vtbl
-pool_buffer_vtbl = {
- pool_buffer_destroy,
- pool_buffer_map,
- pool_buffer_unmap,
- pool_buffer_get_base_buffer
-};
-
-
-static struct pb_buffer *
-pool_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
- const struct pb_desc *desc)
-{
- struct pool_pb_manager *pool = pool_pb_manager(mgr);
- struct pool_buffer *pool_buf;
- struct list_head *item;
-
- assert(size == pool->bufSize);
- assert(pool->bufAlign % desc->alignment == 0);
-
- _glthread_LOCK_MUTEX(pool->mutex);
-
- if (pool->numFree == 0) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
- debug_printf("warning: out of fixed size buffer objects\n");
- return NULL;
- }
-
- item = pool->free.next;
-
- if (item == &pool->free) {
- _glthread_UNLOCK_MUTEX(pool->mutex);
- debug_printf("error: fixed size buffer pool corruption\n");
- return NULL;
- }
-
- LIST_DEL(item);
- --pool->numFree;
-
- _glthread_UNLOCK_MUTEX(pool->mutex);
-
- pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
- assert(pool_buf->base.base.refcount == 0);
- pool_buf->base.base.refcount = 1;
- pool_buf->base.base.alignment = desc->alignment;
- pool_buf->base.base.usage = desc->usage;
-
- return SUPER(pool_buf);
-}
-
-
-static void
-pool_bufmgr_destroy(struct pb_manager *mgr)
-{
- struct pool_pb_manager *pool = pool_pb_manager(mgr);
- _glthread_LOCK_MUTEX(pool->mutex);
-
- FREE(pool->bufs);
-
- pb_unmap(pool->buffer);
- pb_reference(&pool->buffer, NULL);
-
- _glthread_UNLOCK_MUTEX(pool->mutex);
-
- FREE(mgr);
-}
-
-
-struct pb_manager *
-pool_bufmgr_create(struct pb_manager *provider,
- size_t numBufs,
- size_t bufSize,
- const struct pb_desc *desc)
-{
- struct pool_pb_manager *pool;
- struct pool_buffer *pool_buf;
- size_t i;
-
- pool = (struct pool_pb_manager *)CALLOC(1, sizeof(*pool));
- if (!pool)
- return NULL;
-
- pool->base.destroy = pool_bufmgr_destroy;
- pool->base.create_buffer = pool_bufmgr_create_buffer;
-
- LIST_INITHEAD(&pool->free);
-
- pool->numTot = numBufs;
- pool->numFree = numBufs;
- pool->bufSize = bufSize;
- pool->bufAlign = desc->alignment;
-
- _glthread_INIT_MUTEX(pool->mutex);
-
- pool->buffer = provider->create_buffer(provider, numBufs*bufSize, desc);
- if (!pool->buffer)
- goto failure;
-
- pool->map = pb_map(pool->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if(!pool->map)
- goto failure;
-
- pool->bufs = (struct pool_buffer *)CALLOC(numBufs, sizeof(*pool->bufs));
- if (!pool->bufs)
- goto failure;
-
- pool_buf = pool->bufs;
- for (i = 0; i < numBufs; ++i) {
- pool_buf->base.base.refcount = 0;
- pool_buf->base.base.alignment = 0;
- pool_buf->base.base.usage = 0;
- pool_buf->base.base.size = bufSize;
- pool_buf->base.vtbl = &pool_buffer_vtbl;
- pool_buf->mgr = pool;
- pool_buf->start = i * bufSize;
- LIST_ADDTAIL(&pool_buf->head, &pool->free);
- pool_buf++;
- }
-
- return SUPER(pool);
-
-failure:
- if(pool->bufs)
- FREE(pool->bufs);
- if(pool->map)
- pb_unmap(pool->buffer);
- if(pool->buffer)
- pb_reference(&pool->buffer, NULL);
- if(pool)
- FREE(pool);
- return NULL;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_winsys.c b/src/mesa/pipe/pipebuffer/pb_winsys.c
deleted file mode 100644
index 978944091f..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_winsys.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * Implementation of client buffer (also designated as "user buffers"), which
- * are just state-tracker owned data masqueraded as buffers.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-
-#include "pb_buffer.h"
-
-
-/**
- * User buffers are special buffers that initially reference memory
- * held by the user but which may if necessary copy that memory into
- * device memory behind the scenes, for submission to hardware.
- *
- * These are particularly useful when the referenced data is never
- * submitted to hardware at all, in the particular case of software
- * vertex processing.
- */
-struct pb_user_buffer
-{
- struct pb_buffer base;
- void *data;
-};
-
-
-extern const struct pb_vtbl pb_user_buffer_vtbl;
-
-
-static INLINE struct pb_user_buffer *
-pb_user_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- assert(buf->vtbl == &pb_user_buffer_vtbl);
- return (struct pb_user_buffer *)buf;
-}
-
-
-static void
-pb_user_buffer_destroy(struct pb_buffer *buf)
-{
- assert(buf);
- FREE(buf);
-}
-
-
-static void *
-pb_user_buffer_map(struct pb_buffer *buf,
- unsigned flags)
-{
- return pb_user_buffer(buf)->data;
-}
-
-
-static void
-pb_user_buffer_unmap(struct pb_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-pb_user_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-const struct pb_vtbl
-pb_user_buffer_vtbl = {
- pb_user_buffer_destroy,
- pb_user_buffer_map,
- pb_user_buffer_unmap,
- pb_user_buffer_get_base_buffer
-};
-
-
-static struct pipe_buffer *
-pb_winsys_user_buffer_create(struct pipe_winsys *winsys,
- void *data,
- unsigned bytes)
-{
- struct pb_user_buffer *buf = CALLOC_STRUCT(pb_user_buffer);
-
- if(!buf)
- return NULL;
-
- buf->base.base.refcount = 1;
- buf->base.base.size = bytes;
- buf->base.base.alignment = 0;
- buf->base.base.usage = 0;
-
- buf->base.vtbl = &pb_user_buffer_vtbl;
- buf->data = data;
-
- return &buf->base.base;
-}
-
-
-static void *
-pb_winsys_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- (void)winsys;
- return pb_map(pb_buffer(buf), flags);
-}
-
-
-static void
-pb_winsys_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- (void)winsys;
- pb_unmap(pb_buffer(buf));
-}
-
-
-static void
-pb_winsys_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- (void)winsys;
- pb_destroy(pb_buffer(buf));
-}
-
-
-void
-pb_init_winsys(struct pipe_winsys *winsys)
-{
- winsys->user_buffer_create = pb_winsys_user_buffer_create;
- winsys->buffer_map = pb_winsys_buffer_map;
- winsys->buffer_unmap = pb_winsys_buffer_unmap;
- winsys->buffer_destroy = pb_winsys_buffer_destroy;
-}
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
deleted file mode 100644
index 304632abb2..0000000000
--- a/src/mesa/pipe/softpipe/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-
-TOP = ../../../..
-include $(TOP)/configs/current
-
-LIBNAME = softpipe
-
-DRIVER_SOURCES = \
- sp_fs_exec.c \
- sp_fs_sse.c \
- sp_fs_llvm.c \
- sp_clear.c \
- sp_flush.c \
- sp_query.c \
- sp_context.c \
- sp_draw_arrays.c \
- sp_prim_setup.c \
- sp_prim_vbuf.c \
- sp_quad.c \
- sp_quad_alpha_test.c \
- sp_quad_blend.c \
- sp_quad_bufloop.c \
- sp_quad_colormask.c \
- sp_quad_coverage.c \
- sp_quad_depth_test.c \
- sp_quad_earlyz.c \
- sp_quad_fs.c \
- sp_quad_occlusion.c \
- sp_quad_output.c \
- sp_quad_stencil.c \
- sp_quad_stipple.c \
- sp_state_blend.c \
- sp_state_clip.c \
- sp_state_derived.c \
- sp_state_fs.c \
- sp_state_sampler.c \
- sp_state_rasterizer.c \
- sp_state_surface.c \
- sp_state_vertex.c \
- sp_texture.c \
- sp_tex_sample.c \
- sp_tile_cache.c \
- sp_surface.c
-
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-include ../Makefile.template
-
-symlinks:
-
diff --git a/src/mesa/pipe/softpipe/SConscript b/src/mesa/pipe/softpipe/SConscript
deleted file mode 100644
index d581ee8d3c..0000000000
--- a/src/mesa/pipe/softpipe/SConscript
+++ /dev/null
@@ -1,42 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-softpipe = env.ConvenienceLibrary(
- target = 'softpipe',
- source = [
- 'sp_clear.c',
- 'sp_context.c',
- 'sp_draw_arrays.c',
- 'sp_flush.c',
- 'sp_prim_setup.c',
- 'sp_prim_vbuf.c',
- 'sp_quad_alpha_test.c',
- 'sp_quad_blend.c',
- 'sp_quad_bufloop.c',
- 'sp_quad.c',
- 'sp_quad_colormask.c',
- 'sp_quad_coverage.c',
- 'sp_quad_depth_test.c',
- 'sp_quad_earlyz.c',
- 'sp_quad_fs.c',
- 'sp_quad_occlusion.c',
- 'sp_quad_output.c',
- 'sp_quad_stencil.c',
- 'sp_quad_stipple.c',
- 'sp_query.c',
- 'sp_state_blend.c',
- 'sp_state_clip.c',
- 'sp_state_derived.c',
- 'sp_state_fs.c',
- 'sp_state_rasterizer.c',
- 'sp_state_sampler.c',
- 'sp_state_surface.c',
- 'sp_state_vertex.c',
- 'sp_surface.c',
- 'sp_tex_sample.c',
- 'sp_texture.c',
- 'sp_tile_cache.c',
- ])
-
-Export('softpipe') \ No newline at end of file
diff --git a/src/mesa/pipe/softpipe/sp_clear.c b/src/mesa/pipe/softpipe/sp_clear.c
deleted file mode 100644
index 8d295a30ca..0000000000
--- a/src/mesa/pipe/softpipe/sp_clear.c
+++ /dev/null
@@ -1,73 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- */
-
-
-#include "pipe/p_defines.h"
-#include "sp_clear.h"
-#include "sp_context.h"
-#include "sp_surface.h"
-#include "sp_state.h"
-#include "sp_tile_cache.h"
-
-
-/**
- * Clear the given surface to the specified value.
- * No masking, no scissor (clear entire buffer).
- */
-void
-softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- uint i;
-
-#if 0
- softpipe_update_derived(softpipe); /* not needed?? */
-#endif
-
- if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) {
- sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue);
-#if TILE_CLEAR_OPTIMIZATION
- return;
-#endif
- }
-
- 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);
- }
- }
-
-#if !TILE_CLEAR_OPTIMIZATION
- /* non-cached surface */
- pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
-#endif
-}
diff --git a/src/mesa/pipe/softpipe/sp_clear.h b/src/mesa/pipe/softpipe/sp_clear.h
deleted file mode 100644
index a8ed1c4ecc..0000000000
--- a/src/mesa/pipe/softpipe/sp_clear.h
+++ /dev/null
@@ -1,43 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- */
-
-#ifndef SP_CLEAR_H
-#define SP_CLEAR_H
-
-#include "pipe/p_state.h"
-struct pipe_context;
-
-extern void
-softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
- unsigned clearValue);
-
-
-#endif /* SP_CLEAR_H */
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
deleted file mode 100644
index cea6b90104..0000000000
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ /dev/null
@@ -1,333 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
-#include "sp_clear.h"
-#include "sp_context.h"
-#include "sp_flush.h"
-#include "sp_prim_setup.h"
-#include "sp_prim_vbuf.h"
-#include "sp_state.h"
-#include "sp_surface.h"
-#include "sp_tile_cache.h"
-#include "sp_texture.h"
-#include "sp_winsys.h"
-#include "sp_query.h"
-
-
-
-/**
- * Query format support for creating a texture, drawing surface, etc.
- * \param format the format to test
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
- */
-static boolean
-softpipe_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- switch (type) {
- case PIPE_TEXTURE:
- /* softpipe supports all texture formats */
- return TRUE;
- case PIPE_SURFACE:
- /* softpipe supports all (off-screen) surface formats */
- return TRUE;
- default:
- assert(0);
- return FALSE;
- }
-}
-
-
-/**
- * Map any drawing surfaces which aren't already mapped
- */
-void
-softpipe_map_surfaces(struct softpipe_context *sp)
-{
- unsigned i;
-
- for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
- sp_tile_cache_map_surfaces(sp->cbuf_cache[i]);
- }
-
- sp_tile_cache_map_surfaces(sp->zsbuf_cache);
-}
-
-
-/**
- * Unmap any mapped drawing surfaces
- */
-void
-softpipe_unmap_surfaces(struct softpipe_context *sp)
-{
- uint i;
-
- for (i = 0; i < sp->framebuffer.num_cbufs; i++)
- sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
- sp_flush_tile_cache(sp, sp->zsbuf_cache);
-
- for (i = 0; i < sp->framebuffer.num_cbufs; i++) {
- sp_tile_cache_unmap_surfaces(sp->cbuf_cache[i]);
- }
- sp_tile_cache_unmap_surfaces(sp->zsbuf_cache);
-}
-
-
-static void softpipe_destroy( struct pipe_context *pipe )
-{
- struct softpipe_context *softpipe = softpipe_context( pipe );
- struct pipe_winsys *ws = pipe->winsys;
- uint i;
-
- 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.bufloop->destroy( softpipe->quad.bufloop );
- 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 < PIPE_MAX_COLOR_BUFS; i++)
- sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
- sp_destroy_tile_cache(softpipe->zsbuf_cache);
-
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
- sp_destroy_tile_cache(softpipe->tex_cache[i]);
-
- for (i = 0; i < Elements(softpipe->constants); i++) {
- if (softpipe->constants[i].buffer) {
- pipe_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
- }
- }
-
- FREE( softpipe );
-}
-
-
-static const char *softpipe_get_name( struct pipe_context *pipe )
-{
- return "softpipe";
-}
-
-static const char *softpipe_get_vendor( struct pipe_context *pipe )
-{
- return "Tungsten Graphics, Inc.";
-}
-
-static int softpipe_get_param(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
- return 8;
- case PIPE_CAP_NPOT_TEXTURES:
- return 1;
- case PIPE_CAP_TWO_SIDED_STENCIL:
- return 1;
- case PIPE_CAP_GLSL:
- return 1;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 1;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 1;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 12; /* max 2Kx2K */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 12; /* max 2Kx2K */
- default:
- return 0;
- }
-}
-
-static float softpipe_get_paramf(struct pipe_context *pipe, int param)
-{
- switch (param) {
- case PIPE_CAP_MAX_LINE_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_LINE_WIDTH_AA:
- return 255.0; /* arbitrary */
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0; /* arbitrary */
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 0.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0; /* arbitrary */
-
- default:
- return 0;
- }
-}
-
-struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
- struct softpipe_winsys *softpipe_winsys )
-{
- struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
- uint i;
-
-#if defined(__i386__) || defined(__386__)
- softpipe->use_sse = GETENV( "GALLIUM_NOSSE" ) == NULL;
-#else
- softpipe->use_sse = FALSE;
-#endif
-
- softpipe->dump_fs = GETENV( "GALLIUM_DUMP_FS" ) != NULL;
-
- softpipe->pipe.winsys = pipe_winsys;
- softpipe->pipe.destroy = softpipe_destroy;
-
- /* queries */
- softpipe->pipe.is_format_supported = softpipe_is_format_supported;
- softpipe->pipe.get_name = softpipe_get_name;
- softpipe->pipe.get_vendor = softpipe_get_vendor;
- softpipe->pipe.get_param = softpipe_get_param;
- softpipe->pipe.get_paramf = softpipe_get_paramf;
-
- /* state setters */
- softpipe->pipe.create_blend_state = softpipe_create_blend_state;
- softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
- softpipe->pipe.delete_blend_state = softpipe_delete_blend_state;
-
- softpipe->pipe.create_sampler_state = softpipe_create_sampler_state;
- softpipe->pipe.bind_sampler_state = softpipe_bind_sampler_state;
- softpipe->pipe.delete_sampler_state = softpipe_delete_sampler_state;
-
- softpipe->pipe.create_depth_stencil_alpha_state = softpipe_create_depth_stencil_state;
- softpipe->pipe.bind_depth_stencil_alpha_state = softpipe_bind_depth_stencil_state;
- softpipe->pipe.delete_depth_stencil_alpha_state = softpipe_delete_depth_stencil_state;
-
- softpipe->pipe.create_rasterizer_state = softpipe_create_rasterizer_state;
- softpipe->pipe.bind_rasterizer_state = softpipe_bind_rasterizer_state;
- softpipe->pipe.delete_rasterizer_state = softpipe_delete_rasterizer_state;
-
- softpipe->pipe.create_fs_state = softpipe_create_fs_state;
- softpipe->pipe.bind_fs_state = softpipe_bind_fs_state;
- softpipe->pipe.delete_fs_state = softpipe_delete_fs_state;
-
- softpipe->pipe.create_vs_state = softpipe_create_vs_state;
- softpipe->pipe.bind_vs_state = softpipe_bind_vs_state;
- softpipe->pipe.delete_vs_state = softpipe_delete_vs_state;
-
- softpipe->pipe.set_blend_color = softpipe_set_blend_color;
- softpipe->pipe.set_clip_state = softpipe_set_clip_state;
- softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
- softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
- softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
- softpipe->pipe.set_scissor_state = softpipe_set_scissor_state;
- softpipe->pipe.set_sampler_texture = softpipe_set_sampler_texture;
- softpipe->pipe.set_viewport_state = softpipe_set_viewport_state;
-
- softpipe->pipe.set_vertex_buffer = softpipe_set_vertex_buffer;
- softpipe->pipe.set_vertex_element = softpipe_set_vertex_element;
-
- softpipe->pipe.draw_arrays = softpipe_draw_arrays;
- softpipe->pipe.draw_elements = softpipe_draw_elements;
-
- softpipe->pipe.clear = softpipe_clear;
- softpipe->pipe.flush = softpipe_flush;
-
- softpipe_init_query_funcs( softpipe );
-
- /* textures */
- softpipe->pipe.texture_create = softpipe_texture_create;
- softpipe->pipe.texture_release = softpipe_texture_release;
- softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
-
- /*
- * Alloc caches for accessing drawing surfaces and textures.
- * Must be before quad stage setup!
- */
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
- softpipe->cbuf_cache[i] = sp_create_tile_cache();
- softpipe->zsbuf_cache = sp_create_tile_cache();
-
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
- softpipe->tex_cache[i] = sp_create_tile_cache();
-
-
- /* 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.bufloop = sp_quad_bufloop_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);
-
- softpipe->winsys = softpipe_winsys;
-
- /*
- * Create drawing context and plug our rendering stage into it.
- */
- softpipe->draw = draw_create();
- assert(softpipe->draw);
- softpipe->setup = sp_draw_render_stage(softpipe);
-
- if (GETENV( "SP_VBUF" ) != NULL) {
- sp_init_vbuf(softpipe);
- }
- else {
- draw_set_rasterize_stage(softpipe->draw, softpipe->setup);
- }
-
- sp_init_surface_functions(softpipe);
-
- return &softpipe->pipe;
-}
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
deleted file mode 100644
index 5e24baf938..0000000000
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_CONTEXT_H
-#define SP_CONTEXT_H
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-
-#include "pipe/draw/draw_vertex.h"
-
-#include "sp_quad.h"
-
-
-struct softpipe_winsys;
-struct softpipe_vbuf_render;
-struct draw_context;
-struct draw_stage;
-struct softpipe_tile_cache;
-struct sp_fragment_shader;
-struct sp_vertex_shader;
-
-
-struct softpipe_context {
- struct pipe_context pipe; /**< base class */
- struct softpipe_winsys *winsys; /**< window system interface */
-
-
- /* The most recent drawing state as set by the driver:
- */
- const struct pipe_blend_state *blend;
- const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct pipe_depth_stencil_alpha_state *depth_stencil;
- const struct pipe_rasterizer_state *rasterizer;
- const struct sp_fragment_shader *fs;
- const struct sp_vertex_shader *vs;
-
- struct pipe_blend_color blend_color;
- struct pipe_clip_state clip;
- struct pipe_constant_buffer constants[2];
- struct pipe_framebuffer_state framebuffer;
- struct pipe_poly_stipple poly_stipple;
- struct pipe_scissor_state scissor;
- struct softpipe_texture *texture[PIPE_MAX_SAMPLERS];
- struct pipe_viewport_state viewport;
- struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
- struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
- unsigned dirty;
-
- /* Counter for occlusion queries. Note this supports overlapping
- * queries.
- */
- uint64 occlusion_count;
-
- /*
- * Mapped vertex buffers
- */
- ubyte *mapped_vbuffer[PIPE_ATTRIB_MAX];
-
- /** Mapped constant buffers */
- void *mapped_constants[PIPE_SHADER_TYPES];
-
- /** Vertex format */
- struct vertex_info vertex_info;
- struct vertex_info vertex_info_vbuf;
-
- int psize_slot;
-
-#if 0
- /* Stipple derived state:
- */
- ubyte stipple_masks[16][16];
-#endif
-
- /** Derived from scissor and surface bounds: */
- struct pipe_scissor_state cliprect;
-
- unsigned line_stipple_counter;
-
- /** Software quad rendering pipeline */
- struct {
- struct quad_stage *polygon_stipple;
- struct quad_stage *earlyz;
- struct quad_stage *shade;
- struct quad_stage *alpha_test;
- struct quad_stage *stencil_test;
- struct quad_stage *depth_test;
- struct quad_stage *occlusion;
- struct quad_stage *coverage;
- struct quad_stage *bufloop;
- struct quad_stage *blend;
- struct quad_stage *colormask;
- struct quad_stage *output;
-
- struct quad_stage *first; /**< points to one of the above stages */
- } quad;
-
- /** The primitive drawing context */
- struct draw_context *draw;
- struct draw_stage *setup;
- struct draw_stage *vbuf;
- struct softpipe_vbuf_render *vbuf_render;
-
- uint current_cbuf; /**< current color buffer being written to */
-
- struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS];
- struct softpipe_tile_cache *zsbuf_cache;
-
- struct softpipe_tile_cache *tex_cache[PIPE_MAX_SAMPLERS];
-
- int use_sse : 1;
- int dump_fs : 1;
-};
-
-
-
-
-static INLINE struct softpipe_context *
-softpipe_context( struct pipe_context *pipe )
-{
- return (struct softpipe_context *)pipe;
-}
-
-
-#endif /* SP_CONTEXT_H */
diff --git a/src/mesa/pipe/softpipe/sp_draw_arrays.c b/src/mesa/pipe/softpipe/sp_draw_arrays.c
deleted file mode 100644
index 71a303a8b5..0000000000
--- a/src/mesa/pipe/softpipe/sp_draw_arrays.c
+++ /dev/null
@@ -1,164 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Brian Paul
- * Keith Whitwell
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-#include "pipe/p_winsys.h"
-
-#include "sp_context.h"
-#include "sp_state.h"
-
-#include "pipe/draw/draw_context.h"
-
-
-
-static void
-softpipe_map_constant_buffers(struct softpipe_context *sp)
-{
- struct pipe_winsys *ws = sp->pipe.winsys;
- uint i;
- for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
- sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- }
-
- draw_set_mapped_constant_buffer(sp->draw,
- sp->mapped_constants[PIPE_SHADER_VERTEX]);
-}
-
-static void
-softpipe_unmap_constant_buffers(struct softpipe_context *sp)
-{
- struct pipe_winsys *ws = sp->pipe.winsys;
- uint i;
- for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
- ws->buffer_unmap(ws, sp->constants[i].buffer);
- sp->mapped_constants[i] = NULL;
- }
-}
-
-
-boolean
-softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count)
-{
- return softpipe_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-
-
-/**
- * Draw vertex arrays, with optional indexing.
- * Basically, map the vertex buffers (and drawing surfaces), then hand off
- * the drawing to the 'draw' module.
- *
- * XXX should the element buffer be specified/bound with a separate function?
- */
-boolean
-softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count)
-{
- struct softpipe_context *sp = softpipe_context(pipe);
- struct draw_context *draw = sp->draw;
- unsigned i;
-
- /* first, check that the primitive is not malformed. It is the
- * state tracker's responsibility to do send only correctly formed
- * primitives down. It currently isn't doing that though...
- */
-#if 1
- count = draw_trim_prim( mode, count );
-#else
- if (!draw_validate_prim( mode, count ))
- assert(0);
-#endif
-
-
- if (sp->dirty)
- softpipe_update_derived( sp );
-
- softpipe_map_surfaces(sp);
- softpipe_map_constant_buffers(sp);
-
- /*
- * Map vertex buffers
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (sp->vertex_buffer[i].buffer) {
- void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
- sp->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_vertex_buffer(draw, i, buf);
- }
- }
- /* Map index buffer, if present */
- if (indexBuffer) {
- void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
- }
- else {
- /* no index/element buffer */
- draw_set_mapped_element_buffer(draw, 0, NULL);
- }
-
-
- /* draw! */
- draw_arrays(draw, mode, start, count);
-
- /*
- * unmap vertex/index buffers - will cause draw module to flush
- */
- for (i = 0; i < PIPE_ATTRIB_MAX; i++) {
- if (sp->vertex_buffer[i].buffer) {
- draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
- }
- }
- if (indexBuffer) {
- draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
- }
-
-
- /* Note: leave drawing surfaces mapped */
- softpipe_unmap_constant_buffers(sp);
-
- return TRUE;
-}
diff --git a/src/mesa/pipe/softpipe/sp_flush.c b/src/mesa/pipe/softpipe/sp_flush.c
deleted file mode 100644
index ec6bb4a0dc..0000000000
--- a/src/mesa/pipe/softpipe/sp_flush.c
+++ /dev/null
@@ -1,73 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "pipe/p_defines.h"
-#include "sp_flush.h"
-#include "sp_context.h"
-#include "sp_surface.h"
-#include "sp_state.h"
-#include "sp_tile_cache.h"
-#include "sp_winsys.h"
-
-
-/* There will be actual work to do here. In future we may want a
- * fence-like interface instead of finish, and perhaps flush will take
- * flags to indicate what type of flush is required.
- */
-void
-softpipe_flush( struct pipe_context *pipe,
- unsigned flags )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- uint i;
-
- /* - flush the quad pipeline
- * - flush the texture cache
- * - flush the render cache
- */
-
- for (i = 0; i < softpipe->framebuffer.num_cbufs; i++)
- if (softpipe->cbuf_cache[i])
- sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
-
- if (softpipe->zsbuf_cache)
- sp_flush_tile_cache(softpipe, softpipe->zsbuf_cache);
-
- /* Need this call for hardware buffers before swapbuffers.
- *
- * there should probably be another/different flush-type function
- * that's called before swapbuffers because we don't always want
- * to unmap surfaces when flushing.
- */
- softpipe_unmap_surfaces(softpipe);
-}
-
diff --git a/src/mesa/pipe/softpipe/sp_flush.h b/src/mesa/pipe/softpipe/sp_flush.h
deleted file mode 100644
index 34ec617866..0000000000
--- a/src/mesa/pipe/softpipe/sp_flush.h
+++ /dev/null
@@ -1,35 +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 SP_FLUSH_H
-#define SP_FLUSH_H
-
-struct pipe_context;
-
-void softpipe_flush(struct pipe_context *pipe, unsigned flags );
-
-#endif
diff --git a/src/mesa/pipe/softpipe/sp_fs_exec.c b/src/mesa/pipe/softpipe/sp_fs_exec.c
deleted file mode 100644
index b949492e09..0000000000
--- a/src/mesa/pipe/softpipe/sp_fs_exec.c
+++ /dev/null
@@ -1,112 +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.
- *
- **************************************************************************/
-
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_fs.h"
-#include "sp_headers.h"
-
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-
-struct sp_exec_fragment_shader {
- struct sp_fragment_shader base;
-};
-
-
-
-
-static void
-exec_prepare( struct sp_fragment_shader *base,
- struct tgsi_exec_machine *machine,
- struct tgsi_sampler *samplers )
-{
- tgsi_exec_machine_bind_shader( machine,
- base->shader.tokens,
- PIPE_MAX_SAMPLERS,
- samplers );
-}
-
-
-
-
-/* TODO: hide the machine struct in here somewhere, remove from this
- * interface:
- */
-static unsigned
-exec_run( struct sp_fragment_shader *base,
- struct tgsi_exec_machine *machine,
- struct quad_header *quad )
-{
-
- /* Compute X, Y, Z, W vals for this quad */
- sp_setup_pos_vector(quad->posCoef,
- (float)quad->x0, (float)quad->y0,
- &machine->QuadPos);
-
- return tgsi_exec_machine_run( machine );
-}
-
-
-
-static void
-exec_delete( struct sp_fragment_shader *base )
-{
- FREE(base);
-}
-
-
-
-
-
-struct sp_fragment_shader *
-softpipe_create_fs_exec(struct softpipe_context *softpipe,
- const struct pipe_shader_state *templ)
-{
- struct sp_exec_fragment_shader *shader;
-
- /* Decide whether we'll be codegenerating this shader and if so do
- * that now.
- */
-
- shader = CALLOC_STRUCT(sp_exec_fragment_shader);
- if (!shader)
- return NULL;
-
- shader->base.shader = *templ;
- shader->base.prepare = exec_prepare;
- shader->base.run = exec_run;
- shader->base.delete = exec_delete;
-
- return &shader->base;
-}
-
diff --git a/src/mesa/pipe/softpipe/sp_fs_llvm.c b/src/mesa/pipe/softpipe/sp_fs_llvm.c
deleted file mode 100644
index 9237c1fbda..0000000000
--- a/src/mesa/pipe/softpipe/sp_fs_llvm.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors:
- * Zack Rusin
- */
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_fs.h"
-
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/tgsi/exec/tgsi_sse2.h"
-
-#if 0
-
-struct sp_llvm_fragment_shader {
- struct sp_fragment_shader base;
- struct gallivm_prog *llvm_prog;
-};
-
-static void
-shade_quad_llvm(struct quad_stage *qs,
- struct quad_header *quad)
-{
- struct quad_shade_stage *qss = quad_shade_stage(qs);
- struct softpipe_context *softpipe = qs->softpipe;
- float dests[4][16][4] ALIGN16_ATTRIB;
- float inputs[4][16][4] ALIGN16_ATTRIB;
- const float fx = (float) quad->x0;
- const float fy = (float) quad->y0;
- struct gallivm_prog *llvm = qss->llvm_prog;
-
- inputs[0][0][0] = fx;
- inputs[1][0][0] = fx + 1.0f;
- inputs[2][0][0] = fx;
- inputs[3][0][0] = fx + 1.0f;
-
- inputs[0][0][1] = fy;
- inputs[1][0][1] = fy;
- inputs[2][0][1] = fy + 1.0f;
- inputs[3][0][1] = fy + 1.0f;
-
-
- gallivm_prog_inputs_interpolate(llvm, inputs, quad->coef);
-
-#if DLLVM
- debug_printf("MASK = %d\n", quad->mask);
- for (int i = 0; i < 4; ++i) {
- for (int j = 0; j < 2; ++j) {
- debug_printf("IN(%d,%d) [%f %f %f %f]\n", i, j,
- inputs[i][j][0], inputs[i][j][1], inputs[i][j][2], inputs[i][j][3]);
- }
- }
-#endif
-
- quad->mask &=
- gallivm_fragment_shader_exec(llvm, fx, fy, dests, inputs,
- softpipe->mapped_constants[PIPE_SHADER_FRAGMENT],
- qss->samplers);
-#if DLLVM
- debug_printf("OUT LLVM = 1[%f %f %f %f], 2[%f %f %f %f]\n",
- dests[0][0][0], dests[0][0][1], dests[0][0][2], dests[0][0][3],
- dests[0][1][0], dests[0][1][1], dests[0][1][2], dests[0][1][3]);
-#endif
-
- /* store result color */
- if (qss->colorOutSlot >= 0) {
- unsigned i;
- /* XXX need to handle multiple color outputs someday */
- allvmrt(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
- == TGSI_SEMANTIC_COLOR);
- for (i = 0; i < QUAD_SIZE; ++i) {
- quad->outputs.color[0][i] = dests[i][qss->colorOutSlot][0];
- quad->outputs.color[1][i] = dests[i][qss->colorOutSlot][1];
- quad->outputs.color[2][i] = dests[i][qss->colorOutSlot][2];
- quad->outputs.color[3][i] = dests[i][qss->colorOutSlot][3];
- }
- }
-#if DLLVM
- for (int i = 0; i < QUAD_SIZE; ++i) {
- debug_printf("QLLVM%d(%d) [%f, %f, %f, %f]\n", i, qss->colorOutSlot,
- quad->outputs.color[0][i],
- quad->outputs.color[1][i],
- quad->outputs.color[2][i],
- quad->outputs.color[3][i]);
- }
-#endif
-
- /* store result Z */
- if (qss->depthOutSlot >= 0) {
- /* output[slot] is new Z */
- uint i;
- for (i = 0; i < 4; i++) {
- quad->outputs.depth[i] = dests[i][0][2];
- }
- }
- else {
- /* copy input Z (which was interpolated by the executor) to output Z */
- uint i;
- for (i = 0; i < 4; i++) {
- quad->outputs.depth[i] = inputs[i][0][2];
- }
- }
-#if DLLVM
- debug_printf("D [%f, %f, %f, %f] mask = %d\n",
- quad->outputs.depth[0],
- quad->outputs.depth[1],
- quad->outputs.depth[2],
- quad->outputs.depth[3], quad->mask);
-#endif
-
- /* shader may cull fragments */
- if( quad->mask ) {
- qs->next->run( qs->next, quad );
- }
-}
-
-
-unsigned
-run_llvm_fs( struct sp_fragment_shader *base,
- struct foo *machine )
-{
-}
-
-
-void
-delete_llvm_fs( struct sp_fragment_shader *base )
-{
- FREE(base);
-}
-
-
-struct sp_fragment_shader *
-softpipe_create_fs_llvm(struct softpipe_context *softpipe,
- const struct pipe_shader_state *templ)
-{
- struct sp_llvm_fragment_shader *shader = NULL;
-
- /* LLVM fragment shaders currently disabled:
- */
- state = CALLOC_STRUCT(sp_llvm_shader_state);
- if (!state)
- return NULL;
-
- state->llvm_prog = 0;
-
- if (!gallivm_global_cpu_engine()) {
- gallivm_cpu_engine_create(state->llvm_prog);
- }
- else
- gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog);
-
- if (shader) {
- shader->base.run = run_llvm_fs;
- shader->base.delete = delete_llvm_fs;
- }
-
- return shader;
-}
-
-
-#else
-
-struct sp_fragment_shader *
-softpipe_create_fs_llvm(struct softpipe_context *softpipe,
- const struct pipe_shader_state *templ)
-{
- return NULL;
-}
-
-#endif
diff --git a/src/mesa/pipe/softpipe/sp_fs_sse.c b/src/mesa/pipe/softpipe/sp_fs_sse.c
deleted file mode 100644
index 713ece369e..0000000000
--- a/src/mesa/pipe/softpipe/sp_fs_sse.c
+++ /dev/null
@@ -1,192 +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.
- *
- **************************************************************************/
-
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_fs.h"
-#include "sp_headers.h"
-
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-#include "pipe/tgsi/exec/tgsi_sse2.h"
-
-
-#if defined(__i386__) || defined(__386__)
-
-#include "x86/rtasm/x86sse.h"
-
-/* Surely this should be defined somewhere in a tgsi header:
- */
-typedef void (XSTDCALL *codegen_function)(
- const struct tgsi_exec_vector *input,
- struct tgsi_exec_vector *output,
- float (*constant)[4],
- struct tgsi_exec_vector *temporary,
- const struct tgsi_interp_coef *coef
- //, const struct tgsi_exec_vector *quadPos
- );
-
-
-struct sp_sse_fragment_shader {
- struct sp_fragment_shader base;
- struct x86_function sse2_program;
- codegen_function func;
-};
-
-
-/**
- * Compute quad X,Y,Z,W for the four fragments in a quad.
- *
- * This should really be part of the compiled shader.
- */
-void
-sp_setup_pos_vector(const struct tgsi_interp_coef *coef,
- float x, float y,
- struct tgsi_exec_vector *quadpos)
-{
- uint chan;
- /* do X */
- quadpos->xyzw[0].f[0] = x;
- quadpos->xyzw[0].f[1] = x + 1;
- quadpos->xyzw[0].f[2] = x;
- quadpos->xyzw[0].f[3] = x + 1;
-
- /* do Y */
- quadpos->xyzw[1].f[0] = y;
- quadpos->xyzw[1].f[1] = y;
- quadpos->xyzw[1].f[2] = y + 1;
- quadpos->xyzw[1].f[3] = y + 1;
-
- /* do Z and W for all fragments in the quad */
- for (chan = 2; chan < 4; chan++) {
- const float dadx = coef->dadx[chan];
- const float dady = coef->dady[chan];
- const float a0 = coef->a0[chan] + dadx * x + dady * y;
- quadpos->xyzw[chan].f[0] = a0;
- quadpos->xyzw[chan].f[1] = a0 + dadx;
- quadpos->xyzw[chan].f[2] = a0 + dady;
- quadpos->xyzw[chan].f[3] = a0 + dadx + dady;
- }
-}
-
-
-static void
-sse_prepare( struct sp_fragment_shader *base,
- struct tgsi_exec_machine *machine,
- struct tgsi_sampler *samplers )
-{
-}
-
-
-/* TODO: codegenerate the whole run function, skip this wrapper.
- * TODO: break dependency on tgsi_exec_machine struct
- * TODO: push Position calculation into the generated shader
- * TODO: process >1 quad at a time
- */
-static unsigned
-sse_run( struct sp_fragment_shader *base,
- struct tgsi_exec_machine *machine,
- struct quad_header *quad )
-{
- struct sp_sse_fragment_shader *shader = (struct sp_sse_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,
- machine->Temps);
-
- shader->func( machine->Inputs,
- machine->Outputs,
- machine->Consts,
- machine->Temps,
- machine->InterpCoefs
- // , &machine->QuadPos
- );
-
- return ~(machine->Temps[TGSI_EXEC_TEMP_KILMASK_I].xyzw[TGSI_EXEC_TEMP_KILMASK_C].u[0]);
-}
-
-
-static void
-sse_delete( struct sp_fragment_shader *base )
-{
- struct sp_sse_fragment_shader *shader = (struct sp_sse_fragment_shader *) base;
-
- x86_release_func( &shader->sse2_program );
- FREE(shader);
-}
-
-
-struct sp_fragment_shader *
-softpipe_create_fs_sse(struct softpipe_context *softpipe,
- const struct pipe_shader_state *templ)
-{
- struct sp_sse_fragment_shader *shader;
-
- if (!softpipe->use_sse)
- return NULL;
-
- shader = CALLOC_STRUCT(sp_sse_fragment_shader);
- if (!shader)
- return NULL;
-
- x86_init_func( &shader->sse2_program );
-
- if (!tgsi_emit_sse2_fs( templ->tokens, &shader->sse2_program )) {
- FREE(shader);
- return NULL;
- }
-
- shader->func = (codegen_function) x86_get_func( &shader->sse2_program );
- assert(shader->func);
-
- shader->base.shader = *templ;
- shader->base.prepare = sse_prepare;
- shader->base.run = sse_run;
- shader->base.delete = sse_delete;
-
- return &shader->base;
-}
-
-
-#else
-
-/* Maybe put this varient in the header file.
- */
-struct sp_fragment_shader *
-softpipe_create_fs_sse(struct softpipe_context *softpipe,
- const struct pipe_shader_state *templ)
-{
- return NULL;
-}
-
-#endif
diff --git a/src/mesa/pipe/softpipe/sp_headers.h b/src/mesa/pipe/softpipe/sp_headers.h
deleted file mode 100644
index 0ae31d8796..0000000000
--- a/src/mesa/pipe/softpipe/sp_headers.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_HEADERS_H
-#define SP_HEADERS_H
-
-#include "pipe/tgsi/exec/tgsi_exec.h"
-
-#define PRIM_POINT 1
-#define PRIM_LINE 2
-#define PRIM_TRI 3
-
-
-/* The rasterizer generates 2x2 quads of fragment and feeds them to
- * the current fp_machine (see below).
- * Remember that Y=0=top with Y increasing down the window.
- */
-#define QUAD_TOP_LEFT 0
-#define QUAD_TOP_RIGHT 1
-#define QUAD_BOTTOM_LEFT 2
-#define QUAD_BOTTOM_RIGHT 3
-
-#define MASK_TOP_LEFT (1 << QUAD_TOP_LEFT)
-#define MASK_TOP_RIGHT (1 << QUAD_TOP_RIGHT)
-#define MASK_BOTTOM_LEFT (1 << QUAD_BOTTOM_LEFT)
-#define MASK_BOTTOM_RIGHT (1 << QUAD_BOTTOM_RIGHT)
-#define MASK_ALL 0xf
-
-
-/**
- * Encodes everything we need to know about a 2x2 pixel block. Uses
- * "Channel-Serial" or "SoA" layout.
- */
-struct quad_header {
- int x0;
- int y0;
- unsigned mask:4;
- unsigned facing:1; /**< Front (0) or back (1) facing? */
- unsigned prim:2; /**< PRIM_POINT, LINE, TRI */
-
- struct {
- float color[NUM_CHANNELS][QUAD_SIZE]; /* rrrr, gggg, bbbb, aaaa */
- float depth[QUAD_SIZE];
- } outputs;
-
- float coverage[QUAD_SIZE]; /** fragment coverage for antialiasing */
-
- const struct tgsi_interp_coef *coef;
- const struct tgsi_interp_coef *posCoef;
-
- unsigned nr_attrs;
-};
-
-
-#endif /* SP_HEADERS_H */
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.c b/src/mesa/pipe/softpipe/sp_prim_setup.c
deleted file mode 100644
index 7478b2336b..0000000000
--- a/src/mesa/pipe/softpipe/sp_prim_setup.c
+++ /dev/null
@@ -1,1244 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Primitive rasterization/rendering (points, lines, triangles)
- *
- * \author Keith Whitwell <keith@tungstengraphics.com>
- * \author Brian Paul
- */
-
-
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-#include "sp_state.h"
-#include "sp_prim_setup.h"
-#include "pipe/draw/draw_private.h"
-#include "pipe/draw/draw_vertex.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-
-#define DEBUG_VERTS 0
-
-/**
- * Triangle edge info
- */
-struct edge {
- float dx; /**< X(v1) - X(v0), used only during setup */
- float dy; /**< Y(v1) - Y(v0), used only during setup */
- float dxdy; /**< dx/dy */
- float sx, sy; /**< first sample point coord */
- int lines; /**< number of lines on this edge */
-};
-
-
-/**
- * Triangle setup info (derived from draw_stage).
- * Also used for line drawing (taking some liberties).
- */
-struct setup_stage {
- struct draw_stage stage; /**< This must be first (base class) */
-
- struct softpipe_context *softpipe;
-
- /* Vertices are just an array of floats making up each attribute in
- * turn. Currently fixed at 4 floats, but should change in time.
- * Codegen will help cope with this.
- */
- const struct vertex_header *vmax;
- const struct vertex_header *vmid;
- const struct vertex_header *vmin;
- const struct vertex_header *vprovoke;
-
- struct edge ebot;
- struct edge etop;
- struct edge emaj;
-
- float oneoverarea;
-
- struct tgsi_interp_coef coef[PIPE_MAX_SHADER_INPUTS];
- struct tgsi_interp_coef posCoef; /* For Z, W */
- struct quad_header quad;
-
- struct {
- int left[2]; /**< [0] = row0, [1] = row1 */
- int right[2];
- int y;
- unsigned y_flags;
- unsigned mask; /**< mask of MASK_BOTTOM/TOP_LEFT/RIGHT bits */
- } span;
-};
-
-
-
-/**
- * Basically a cast wrapper.
- */
-static INLINE struct setup_stage *setup_stage( struct draw_stage *stage )
-{
- return (struct setup_stage *)stage;
-}
-
-
-/**
- * Clip setup->quad against the scissor/surface bounds.
- */
-static INLINE void
-quad_clip(struct setup_stage *setup)
-{
- const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect;
- const int minx = (int) cliprect->minx;
- const int maxx = (int) cliprect->maxx;
- 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) {
- /* totally clipped */
- setup->quad.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);
-}
-
-
-/**
- * Emit a quad (pass to next stage) with clipping.
- */
-static INLINE void
-clip_emit_quad(struct setup_stage *setup)
-{
- quad_clip(setup);
- if (setup->quad.mask) {
- struct softpipe_context *sp = setup->softpipe;
- sp->quad.first->run(sp->quad.first, &setup->quad);
- }
-}
-
-
-/**
- * Emit a quad (pass to next stage). No clipping is done.
- */
-static INLINE void
-emit_quad( struct setup_stage *setup, int x, int y, unsigned mask )
-{
- struct softpipe_context *sp = setup->softpipe;
- setup->quad.x0 = x;
- setup->quad.y0 = y;
- setup->quad.mask = mask;
- sp->quad.first->run(sp->quad.first, &setup->quad);
-}
-
-
-/**
- * Given an X or Y coordinate, return the block/quad coordinate that it
- * belongs to.
- */
-static INLINE int block( int x )
-{
- return x & ~1;
-}
-
-
-/**
- * Compute mask which indicates which pixels in the 2x2 quad are actually inside
- * the triangle's bounds.
- *
- * this is pretty nasty... may need to rework flush_spans again to
- * fix it, if possible.
- */
-static unsigned calculate_mask( struct setup_stage *setup, int x )
-{
- unsigned mask = 0x0;
-
- if (x >= setup->span.left[0] && x < setup->span.right[0])
- mask |= MASK_TOP_LEFT;
-
- if (x >= setup->span.left[1] && x < setup->span.right[1])
- mask |= MASK_BOTTOM_LEFT;
-
- if (x+1 >= setup->span.left[0] && x+1 < setup->span.right[0])
- mask |= MASK_TOP_RIGHT;
-
- if (x+1 >= setup->span.left[1] && x+1 < setup->span.right[1])
- mask |= MASK_BOTTOM_RIGHT;
-
- return mask;
-}
-
-
-/**
- * Render a horizontal span of quads
- */
-static void flush_spans( struct setup_stage *setup )
-{
- int minleft, maxright;
- int x;
-
- switch (setup->span.y_flags) {
- case 0x3:
- /* both odd and even lines written (both quad rows) */
- minleft = MIN2(setup->span.left[0], setup->span.left[1]);
- maxright = MAX2(setup->span.right[0], setup->span.right[1]);
- break;
-
- case 0x1:
- /* only even line written (quad top row) */
- minleft = setup->span.left[0];
- maxright = setup->span.right[0];
- break;
-
- case 0x2:
- /* only odd line written (quad bottom row) */
- minleft = setup->span.left[1];
- maxright = setup->span.right[1];
- break;
-
- default:
- return;
- }
-
- /* XXX this loop could be moved into the above switch cases and
- * calculate_mask() could be simplified a bit...
- */
- for (x = block(minleft); x <= block(maxright); x += 2) {
- emit_quad( setup, x, setup->span.y,
- calculate_mask( setup, x ) );
- }
-
- setup->span.y = 0;
- setup->span.y_flags = 0;
- setup->span.right[0] = 0;
- setup->span.right[1] = 0;
-}
-
-#if DEBUG_VERTS
-static void print_vertex(const struct setup_stage *setup,
- const struct vertex_header *v)
-{
- int i;
- debug_printf("Vertex: (%p)\n", v);
- for (i = 0; i < setup->quad.nr_attrs; i++) {
- debug_printf(" %d: %f %f %f %f\n", i,
- v->data[i][0], v->data[i][1], v->data[i][2], v->data[i][3]);
- }
-}
-#endif
-
-static boolean setup_sort_vertices( struct setup_stage *setup,
- const struct prim_header *prim )
-{
- const struct vertex_header *v0 = prim->v[0];
- const struct vertex_header *v1 = prim->v[1];
- const struct vertex_header *v2 = prim->v[2];
-
-#if DEBUG_VERTS
- debug_printf("Triangle:\n");
- print_vertex(setup, v0);
- print_vertex(setup, v1);
- print_vertex(setup, v2);
-#endif
-
- setup->vprovoke = v2;
-
- /* determine bottom to top order of vertices */
- {
- float y0 = v0->data[0][1];
- float y1 = v1->data[0][1];
- float y2 = v2->data[0][1];
- if (y0 <= y1) {
- if (y1 <= y2) {
- /* y0<=y1<=y2 */
- setup->vmin = v0;
- setup->vmid = v1;
- setup->vmax = v2;
- }
- else if (y2 <= y0) {
- /* y2<=y0<=y1 */
- setup->vmin = v2;
- setup->vmid = v0;
- setup->vmax = v1;
- }
- else {
- /* y0<=y2<=y1 */
- setup->vmin = v0;
- setup->vmid = v2;
- setup->vmax = v1;
- }
- }
- else {
- if (y0 <= y2) {
- /* y1<=y0<=y2 */
- setup->vmin = v1;
- setup->vmid = v0;
- setup->vmax = v2;
- }
- else if (y2 <= y1) {
- /* y2<=y1<=y0 */
- setup->vmin = v2;
- setup->vmid = v1;
- setup->vmax = v0;
- }
- else {
- /* y1<=y2<=y0 */
- setup->vmin = v1;
- setup->vmid = v2;
- setup->vmax = v0;
- }
- }
- }
-
- setup->ebot.dx = setup->vmid->data[0][0] - setup->vmin->data[0][0];
- setup->ebot.dy = setup->vmid->data[0][1] - setup->vmin->data[0][1];
- setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0];
- setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[0][1];
- setup->etop.dx = setup->vmax->data[0][0] - setup->vmid->data[0][0];
- setup->etop.dy = setup->vmax->data[0][1] - setup->vmid->data[0][1];
-
- /*
- * Compute triangle's area. Use 1/area to compute partial
- * derivatives of attributes later.
- *
- * The area will be the same as prim->det, but the sign may be
- * different depending on how the vertices get sorted above.
- *
- * To determine whether the primitive is front or back facing we
- * use the prim->det value because its sign is correct.
- */
- {
- const float area = (setup->emaj.dx * setup->ebot.dy -
- 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, prim->det );
- */
- }
-
- /* 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 = (prim->det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
-
- return TRUE;
-}
-
-
-/**
- * Compute a0 for a constant-valued coefficient (GL_FLAT shading).
- * The value value comes from vertex->data[slot][i].
- * The result will be put into setup->coef[slot].a0[i].
- * \param slot which attribute slot
- * \param i which component of the slot (0..3)
- */
-static void const_coeff( struct setup_stage *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- assert(i <= 3);
-
- coef->dadx[i] = 0;
- coef->dady[i] = 0;
-
- /* need provoking vertex info!
- */
- coef->a0[i] = setup->vprovoke->data[vertSlot][i];
-}
-
-
-/**
- * Compute a0, dadx and dady for a linearly interpolated coefficient,
- * for a triangle.
- */
-static void tri_linear_coeff( struct setup_stage *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- float botda = setup->vmid->data[vertSlot][i] - setup->vmin->data[vertSlot][i];
- float majda = setup->vmax->data[vertSlot][i] - setup->vmin->data[vertSlot][i];
- float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
- float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
- float dadx = a * setup->oneoverarea;
- float dady = b * setup->oneoverarea;
-
- assert(i <= 3);
-
- coef->dadx[i] = dadx;
- coef->dady[i] = dady;
-
- /* calculate a0 as the value which would be sampled for the
- * fragment at (0,0), taking into account that we want to sample at
- * pixel centers, in other words (0.5, 0.5).
- *
- * this is neat but unfortunately not a good way to do things for
- * triangles with very large values of dadx or dady as it will
- * result in the subtraction and re-addition from a0 of a very
- * large number, which means we'll end up loosing a lot of the
- * fractional bits and precision from a0. the way to fix this is
- * to define a0 as the sample at a pixel center somewhere near vmin
- * instead - i'll switch to this later.
- */
- coef->a0[i] = (setup->vmin->data[vertSlot][i] -
- (dadx * (setup->vmin->data[0][0] - 0.5f) +
- dady * (setup->vmin->data[0][1] - 0.5f)));
-
- /*
- debug_printf("attr[%d].%c: %f dx:%f dy:%f\n",
- slot, "xyzw"[i],
- setup->coef[slot].a0[i],
- setup->coef[slot].dadx[i],
- setup->coef[slot].dady[i]);
- */
-}
-
-
-/**
- * Compute a0, dadx and dady for a perspective-corrected interpolant,
- * for a triangle.
- * We basically multiply the vertex value by 1/w before computing
- * the plane coefficients (a0, dadx, dady).
- * Later, when we compute the value at a particular fragment position we'll
- * divide the interpolated value by the interpolated W at that fragment.
- */
-static void tri_persp_coeff( struct setup_stage *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- /* premultiply by 1/w (v->data[0][3] is always W):
- */
- float mina = setup->vmin->data[vertSlot][i] * setup->vmin->data[0][3];
- float mida = setup->vmid->data[vertSlot][i] * setup->vmid->data[0][3];
- float maxa = setup->vmax->data[vertSlot][i] * setup->vmax->data[0][3];
- float botda = mida - mina;
- float majda = maxa - mina;
- float a = setup->ebot.dy * majda - botda * setup->emaj.dy;
- float b = setup->emaj.dx * botda - majda * setup->ebot.dx;
- float dadx = a * setup->oneoverarea;
- float dady = b * setup->oneoverarea;
-
- /*
- debug_printf("tri persp %d,%d: %f %f %f\n", vertSlot, i,
- setup->vmin->data[vertSlot][i],
- setup->vmid->data[vertSlot][i],
- setup->vmax->data[vertSlot][i]
- );
- */
- assert(i <= 3);
-
- coef->dadx[i] = dadx;
- coef->dady[i] = dady;
- coef->a0[i] = (mina -
- (dadx * (setup->vmin->data[0][0] - 0.5f) +
- dady * (setup->vmin->data[0][1] - 0.5f)));
-}
-
-
-/**
- * Special coefficient setup for gl_FragCoord.
- * X and Y are trivial, though Y has to be inverted for OpenGL.
- * Z and W are copied from posCoef which should have already been computed.
- * We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
- */
-static void
-setup_fragcoord_coeff(struct setup_stage *setup)
-{
- /*X*/
- setup->coef[0].a0[0] = 0;
- setup->coef[0].dadx[0] = 1.0;
- setup->coef[0].dady[0] = 0.0;
- /*Y*/
- if (setup->softpipe->rasterizer->origin_lower_left) {
- /* y=0=bottom */
- const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height;
- setup->coef[0].a0[1] = (float) (winHeight - 1);
- setup->coef[0].dady[1] = -1.0;
- }
- else {
- /* y=0=top */
- setup->coef[0].a0[1] = 0.0;
- setup->coef[0].dady[1] = 1.0;
- }
- setup->coef[0].dadx[1] = 0.0;
- /*Z*/
- setup->coef[0].a0[2] = setup->posCoef.a0[2];
- setup->coef[0].dadx[2] = setup->posCoef.dadx[2];
- setup->coef[0].dady[2] = setup->posCoef.dady[2];
- /*w*/
- setup->coef[0].a0[3] = setup->posCoef.a0[3];
- setup->coef[0].dadx[3] = setup->posCoef.dadx[3];
- setup->coef[0].dady[3] = setup->posCoef.dady[3];
-}
-
-
-
-/**
- * Compute the setup->coef[] array dadx, dady, a0 values.
- * Must be called after setup->vmin,vmid,vmax,vprovoke are initialized.
- */
-static void setup_tri_coefficients( struct setup_stage *setup )
-{
- const struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
- uint fragSlot;
-
- /* z and w are done by linear interpolation:
- */
- tri_linear_coeff(setup, &setup->posCoef, 0, 2);
- tri_linear_coeff(setup, &setup->posCoef, 0, 3);
-
- /* setup interpolation for all the remaining attributes:
- */
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
- const uint vertSlot = softpipe->vertex_info.src_index[fragSlot];
- uint j;
-
- switch (softpipe->vertex_info.interp_mode[fragSlot]) {
- case INTERP_CONSTANT:
- for (j = 0; j < NUM_CHANNELS; j++)
- const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_LINEAR:
- for (j = 0; j < NUM_CHANNELS; j++)
- tri_linear_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_PERSPECTIVE:
- for (j = 0; j < NUM_CHANNELS; j++)
- tri_persp_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_POS:
- assert(fragSlot == 0);
- setup_fragcoord_coeff(setup);
- break;
- default:
- assert(0);
- }
-
- if (fs->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].dadx[1] = 0.0;
- setup->coef[fragSlot].dady[1] = 0.0;
- }
- }
-}
-
-
-
-static void setup_tri_edges( struct setup_stage *setup )
-{
- float vmin_x = setup->vmin->data[0][0] + 0.5f;
- float vmid_x = setup->vmid->data[0][0] + 0.5f;
-
- float vmin_y = setup->vmin->data[0][1] - 0.5f;
- float vmid_y = setup->vmid->data[0][1] - 0.5f;
- float vmax_y = setup->vmax->data[0][1] - 0.5f;
-
- 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.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.dxdy = setup->ebot.dx / setup->ebot.dy;
- setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
-}
-
-
-/**
- * Render the upper or lower half of a triangle.
- * Scissoring/cliprect is applied here too.
- */
-static void subtriangle( struct setup_stage *setup,
- struct edge *eleft,
- struct edge *eright,
- unsigned lines )
-{
- const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect;
- const int minx = (int) cliprect->minx;
- const int maxx = (int) cliprect->maxx;
- const int miny = (int) cliprect->miny;
- const int maxy = (int) cliprect->maxy;
- int y, start_y, finish_y;
- int sy = (int)eleft->sy;
-
- assert((int)eleft->sy == (int) eright->sy);
-
- /* clip top/bottom */
- start_y = sy;
- finish_y = sy + lines;
-
- if (start_y < miny)
- start_y = miny;
-
- if (finish_y > maxy)
- finish_y = maxy;
-
- start_y -= sy;
- finish_y -= sy;
-
- /*
- debug_printf("%s %d %d\n", __FUNCTION__, start_y, finish_y);
- */
-
- for (y = start_y; y < finish_y; y++) {
-
- /* avoid accumulating adds as floats don't have the precision to
- * accurately iterate large triangle edges that way. luckily we
- * can just multiply these days.
- *
- * this is all drowned out by the attribute interpolation anyway.
- */
- int left = (int)(eleft->sx + y * eleft->dxdy);
- int right = (int)(eright->sx + y * eright->dxdy);
-
- /* clip left/right */
- if (left < minx)
- left = minx;
- if (right > maxx)
- right = maxx;
-
- if (left < right) {
- int _y = sy + y;
- if (block(_y) != setup->span.y) {
- flush_spans(setup);
- setup->span.y = block(_y);
- }
-
- setup->span.left[_y&1] = left;
- setup->span.right[_y&1] = right;
- setup->span.y_flags |= 1<<(_y&1);
- }
- }
-
-
- /* save the values so that emaj can be restarted:
- */
- eleft->sx += lines * eleft->dxdy;
- eright->sx += lines * eright->dxdy;
- eleft->sy += lines;
- eright->sy += lines;
-}
-
-
-/**
- * Do setup for triangle rasterization, then render the triangle.
- */
-static void setup_tri( struct draw_stage *stage,
- struct prim_header *prim )
-{
- struct setup_stage *setup = setup_stage( stage );
-
- /*
- debug_printf("%s\n", __FUNCTION__ );
- */
-
- setup_sort_vertices( setup, prim );
- setup_tri_coefficients( setup );
- setup_tri_edges( setup );
-
- setup->quad.prim = PRIM_TRI;
-
- setup->span.y = 0;
- setup->span.y_flags = 0;
- setup->span.right[0] = 0;
- setup->span.right[1] = 0;
- /* setup->span.z_mode = tri_z_mode( setup->ctx ); */
-
- /* init_constant_attribs( setup ); */
-
- if (setup->oneoverarea < 0.0) {
- /* emaj on left:
- */
- subtriangle( setup, &setup->emaj, &setup->ebot, setup->ebot.lines );
- subtriangle( setup, &setup->emaj, &setup->etop, setup->etop.lines );
- }
- else {
- /* emaj on right:
- */
- subtriangle( setup, &setup->ebot, &setup->emaj, setup->ebot.lines );
- subtriangle( setup, &setup->etop, &setup->emaj, setup->etop.lines );
- }
-
- flush_spans( setup );
-}
-
-
-
-/**
- * Compute a0, dadx and dady for a linearly interpolated coefficient,
- * for a line.
- */
-static void
-line_linear_coeff(struct setup_stage *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- const float da = setup->vmax->data[vertSlot][i] - setup->vmin->data[vertSlot][i];
- const float dadx = da * setup->emaj.dx * setup->oneoverarea;
- const float dady = da * setup->emaj.dy * setup->oneoverarea;
- coef->dadx[i] = dadx;
- coef->dady[i] = dady;
- coef->a0[i] = (setup->vmin->data[vertSlot][i] -
- (dadx * (setup->vmin->data[0][0] - 0.5f) +
- dady * (setup->vmin->data[0][1] - 0.5f)));
-}
-
-
-/**
- * Compute a0, dadx and dady for a perspective-corrected interpolant,
- * for a line.
- */
-static void
-line_persp_coeff(struct setup_stage *setup,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- /* XXX double-check/verify this arithmetic */
- const float a0 = setup->vmin->data[vertSlot][i] * setup->vmin->data[0][3];
- const float a1 = setup->vmax->data[vertSlot][i] * setup->vmax->data[0][3];
- const float da = a1 - a0;
- const float dadx = da * setup->emaj.dx * setup->oneoverarea;
- const float dady = da * setup->emaj.dy * setup->oneoverarea;
- coef->dadx[i] = dadx;
- coef->dady[i] = dady;
- coef->a0[i] = (setup->vmin->data[vertSlot][i] -
- (dadx * (setup->vmin->data[0][0] - 0.5f) +
- dady * (setup->vmin->data[0][1] - 0.5f)));
-}
-
-
-/**
- * Compute the setup->coef[] array dadx, dady, a0 values.
- * Must be called after setup->vmin,vmax are initialized.
- */
-static INLINE void
-setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
-{
- const struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
- uint fragSlot;
-
- /* use setup->vmin, vmax to point to vertices */
- setup->vprovoke = prim->v[1];
- setup->vmin = prim->v[0];
- setup->vmax = prim->v[1];
-
- setup->emaj.dx = setup->vmax->data[0][0] - setup->vmin->data[0][0];
- setup->emaj.dy = setup->vmax->data[0][1] - setup->vmin->data[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);
-
- /* z and w are done by linear interpolation:
- */
- line_linear_coeff(setup, &setup->posCoef, 0, 2);
- line_linear_coeff(setup, &setup->posCoef, 0, 3);
-
- /* setup interpolation for all the remaining attributes:
- */
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
- const uint vertSlot = softpipe->vertex_info.src_index[fragSlot];
- uint j;
-
- switch (softpipe->vertex_info.interp_mode[fragSlot]) {
- case INTERP_CONSTANT:
- for (j = 0; j < NUM_CHANNELS; j++)
- const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_LINEAR:
- for (j = 0; j < NUM_CHANNELS; j++)
- line_linear_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_PERSPECTIVE:
- for (j = 0; j < NUM_CHANNELS; j++)
- line_persp_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_POS:
- assert(fragSlot == 0);
- assert(0); /* XXX fix this: */
- setup_fragcoord_coeff(setup);
- break;
- default:
- assert(0);
- }
-
- if (fs->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].dadx[1] = 0.0;
- setup->coef[fragSlot].dady[1] = 0.0;
- }
- }
-}
-
-
-/**
- * Plot a pixel in a line segment.
- */
-static INLINE void
-plot(struct setup_stage *setup, int x, int y)
-{
- const int iy = y & 1;
- const int ix = x & 1;
- const int quadX = x - ix;
- const int quadY = y - iy;
- const int mask = (1 << ix) << (2 * iy);
-
- if (quadX != setup->quad.x0 ||
- quadY != setup->quad.y0)
- {
- /* flush prev quad, start new quad */
-
- if (setup->quad.x0 != -1)
- clip_emit_quad(setup);
-
- setup->quad.x0 = quadX;
- setup->quad.y0 = quadY;
- setup->quad.mask = 0x0;
- }
-
- setup->quad.mask |= mask;
-}
-
-
-/**
- * Do setup for line rasterization, then render the line.
- * Single-pixel width, no stipple, etc. We rely on the 'draw' module
- * to handle stippling and wide lines.
- */
-static void
-setup_line(struct draw_stage *stage, struct prim_header *prim)
-{
- const struct vertex_header *v0 = prim->v[0];
- const struct vertex_header *v1 = prim->v[1];
- struct setup_stage *setup = setup_stage( stage );
- int x0 = (int) v0->data[0][0];
- int x1 = (int) v1->data[0][0];
- int y0 = (int) v0->data[0][1];
- int y1 = (int) v1->data[0][1];
- int dx = x1 - x0;
- int dy = y1 - y0;
- int xstep, ystep;
-
- if (dx == 0 && dy == 0)
- return;
-
- setup_line_coefficients(setup, prim);
-
- if (dx < 0) {
- dx = -dx; /* make positive */
- xstep = -1;
- }
- else {
- xstep = 1;
- }
-
- if (dy < 0) {
- dy = -dy; /* make positive */
- ystep = -1;
- }
- else {
- ystep = 1;
- }
-
- assert(dx >= 0);
- assert(dy >= 0);
-
- setup->quad.x0 = setup->quad.y0 = -1;
- setup->quad.mask = 0x0;
- setup->quad.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;
-
- if (dx > dy) {
- /*** X-major line ***/
- int i;
- const int errorInc = dy + dy;
- int error = errorInc - dx;
- const int errorDec = error - dx;
-
- for (i = 0; i < dx; i++) {
- plot(setup, x0, y0);
-
- x0 += xstep;
- if (error < 0) {
- error += errorInc;
- }
- else {
- error += errorDec;
- y0 += ystep;
- }
- }
- }
- else {
- /*** Y-major line ***/
- int i;
- const int errorInc = dx + dx;
- int error = errorInc - dy;
- const int errorDec = error - dy;
-
- for (i = 0; i < dy; i++) {
- plot(setup, x0, y0);
-
- y0 += ystep;
- if (error < 0) {
- error += errorInc;
- }
- else {
- error += errorDec;
- x0 += xstep;
- }
- }
- }
-
- /* draw final quad */
- if (setup->quad.mask) {
- clip_emit_quad(setup);
- }
-}
-
-
-static void
-point_persp_coeff(struct setup_stage *setup,
- const struct vertex_header *vert,
- struct tgsi_interp_coef *coef,
- uint vertSlot, uint i)
-{
- assert(i <= 3);
- coef->dadx[i] = 0.0F;
- coef->dady[i] = 0.0F;
- coef->a0[i] = vert->data[vertSlot][i] * vert->data[0][3];
-}
-
-
-/**
- * Do setup for point rasterization, then render the point.
- * Round or square points...
- * XXX could optimize a lot for 1-pixel points.
- */
-static void
-setup_point(struct draw_stage *stage, struct prim_header *prim)
-{
- struct setup_stage *setup = setup_stage( stage );
- struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
- const struct vertex_header *v0 = prim->v[0];
- const int sizeAttr = setup->softpipe->psize_slot;
- const float size
- = sizeAttr > 0 ? v0->data[sizeAttr][0]
- : setup->softpipe->rasterizer->point_size;
- const float halfSize = 0.5F * size;
- const boolean round = (boolean) setup->softpipe->rasterizer->point_smooth;
- const float x = v0->data[0][0]; /* Note: data[0] is always position */
- const float y = v0->data[0][1];
- uint fragSlot;
-
- /* For points, all interpolants are constant-valued.
- * However, for point sprites, we'll need to setup texcoords appropriately.
- * XXX: which coefficients are the texcoords???
- * We may do point sprites as textured quads...
- *
- * KW: We don't know which coefficients are texcoords - ultimately
- * the choice of what interpolation mode to use for each attribute
- * should be determined by the fragment program, using
- * per-attribute declaration statements that include interpolation
- * mode as a parameter. So either the fragment program will have
- * to be adjusted for pointsprite vs normal point behaviour, or
- * otherwise a special interpolation mode will have to be defined
- * which matches the required behaviour for point sprites. But -
- * the latter is not a feature of normal hardware, and as such
- * probably should be ruled out on that basis.
- */
- setup->vprovoke = prim->v[0];
-
- /* setup Z, W */
- const_coeff(setup, &setup->posCoef, 0, 2);
- const_coeff(setup, &setup->posCoef, 0, 3);
-
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
- const uint vertSlot = softpipe->vertex_info.src_index[fragSlot];
- uint j;
-
- switch (softpipe->vertex_info.interp_mode[fragSlot]) {
- case INTERP_CONSTANT:
- /* fall-through */
- case INTERP_LINEAR:
- for (j = 0; j < NUM_CHANNELS; j++)
- const_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_PERSPECTIVE:
- for (j = 0; j < NUM_CHANNELS; j++)
- point_persp_coeff(setup, setup->vprovoke,
- &setup->coef[fragSlot], vertSlot, j);
- break;
- case INTERP_POS:
- assert(fragSlot == 0);
- assert(0); /* XXX fix this: */
- setup_fragcoord_coeff(setup);
- break;
- default:
- assert(0);
- }
-
- if (fs->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].dadx[1] = 0.0;
- setup->coef[fragSlot].dady[1] = 0.0;
- }
- }
-
- setup->quad.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);
- }
- else {
- if (round) {
- /* rounded points */
- const int ixmin = block((int) (x - halfSize));
- const int ixmax = block((int) (x + halfSize));
- const int iymin = block((int) (y - halfSize));
- const int iymax = block((int) (y + halfSize));
- const float rmin = halfSize - 0.7071F; /* 0.7071 = sqrt(2)/2 */
- const float rmax = halfSize + 0.7071F;
- const float rmin2 = MAX2(0.0F, rmin * rmin);
- const float rmax2 = rmax * rmax;
- const float cscale = 1.0F / (rmax2 - rmin2);
- int ix, iy;
-
- for (iy = iymin; iy <= iymax; iy += 2) {
- for (ix = ixmin; ix <= ixmax; ix += 2) {
- float dx, dy, dist2, cover;
-
- setup->quad.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;
- }
-
- dx = (ix + 1.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_RIGHT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_TOP_RIGHT;
- }
-
- dx = (ix + 0.5f) - x;
- dy = (iy + 1.5f) - y;
- 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;
- }
-
- dx = (ix + 1.5f) - x;
- dy = (iy + 1.5f) - y;
- 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;
- }
-
- if (setup->quad.mask) {
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
- }
- }
- }
- }
- else {
- /* square points */
- const int xmin = (int) (x + 0.75 - halfSize);
- const int ymin = (int) (y + 0.25 - halfSize);
- const int xmax = xmin + (int) size;
- const int ymax = ymin + (int) size;
- /* XXX could apply scissor to xmin,ymin,xmax,ymax now */
- const int ixmin = block(xmin);
- const int ixmax = block(xmax - 1);
- const int iymin = block(ymin);
- const int iymax = block(ymax - 1);
- int ix, iy;
-
- /*
- debug_printf("(%f, %f) -> X:%d..%d Y:%d..%d\n", x, y, xmin, xmax,ymin,ymax);
- */
- for (iy = iymin; iy <= iymax; iy += 2) {
- uint rowMask = 0xf;
- if (iy < ymin) {
- /* above the top edge */
- rowMask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
- }
- if (iy + 1 >= ymax) {
- /* below the bottom edge */
- rowMask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
- }
-
- for (ix = ixmin; ix <= ixmax; ix += 2) {
- uint mask = rowMask;
-
- if (ix < xmin) {
- /* fragment is past left edge of point, turn off left bits */
- mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
- }
- if (ix + 1 >= xmax) {
- /* past the right edge */
- mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
- }
-
- setup->quad.mask = mask;
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
- }
- }
- }
- }
-}
-
-
-
-static void setup_begin( struct draw_stage *stage )
-{
- struct setup_stage *setup = setup_stage(stage);
- struct softpipe_context *sp = setup->softpipe;
- const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
-
- setup->quad.nr_attrs = fs->num_inputs;
-
- sp->quad.first->begin(sp->quad.first);
-
- stage->point = setup_point;
- stage->line = setup_line;
- stage->tri = setup_tri;
-}
-
-
-static void setup_first_point( struct draw_stage *stage,
- struct prim_header *header )
-{
- setup_begin(stage);
- stage->point( stage, header );
-}
-
-static void setup_first_line( struct draw_stage *stage,
- struct prim_header *header )
-{
- setup_begin(stage);
- stage->line( stage, header );
-}
-
-
-static void setup_first_tri( struct draw_stage *stage,
- struct prim_header *header )
-{
- setup_begin(stage);
- stage->tri( stage, header );
-}
-
-
-
-static void setup_flush( struct draw_stage *stage,
- unsigned flags )
-{
- stage->point = setup_first_point;
- stage->line = setup_first_line;
- stage->tri = setup_first_tri;
-}
-
-
-static void reset_stipple_counter( struct draw_stage *stage )
-{
-}
-
-
-static void render_destroy( struct draw_stage *stage )
-{
- FREE( stage );
-}
-
-
-/**
- * Create a new primitive setup/render stage.
- */
-struct draw_stage *sp_draw_render_stage( struct softpipe_context *softpipe )
-{
- struct setup_stage *setup = CALLOC_STRUCT(setup_stage);
-
- setup->softpipe = softpipe;
- setup->stage.draw = softpipe->draw;
- setup->stage.point = setup_first_point;
- setup->stage.line = setup_first_line;
- setup->stage.tri = setup_first_tri;
- setup->stage.flush = setup_flush;
- setup->stage.reset_stipple_counter = reset_stipple_counter;
- setup->stage.destroy = render_destroy;
-
- setup->quad.coef = setup->coef;
- setup->quad.posCoef = &setup->posCoef;
-
- return &setup->stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_prim_setup.h b/src/mesa/pipe/softpipe/sp_prim_setup.h
deleted file mode 100644
index f3e8a79dd9..0000000000
--- a/src/mesa/pipe/softpipe/sp_prim_setup.h
+++ /dev/null
@@ -1,79 +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 SP_PRIM_SETUP_H
-#define SP_PRIM_SETUP_H
-
-
-/**
- * vbuf is a special stage to gather the stream of triangles, lines, points
- * together and reconstruct vertex buffers for hardware upload.
- *
- * First attempt, work in progress.
- *
- * TODO:
- * - separate out vertex buffer building and primitive emit, ie >1 draw per vb.
- * - tell vbuf stage how to build hw vertices directly
- * - pass vbuf stage a buffer pointer for direct emit to agp/vram.
- *
- *
- *
- * Vertices are just an array of floats, with all the attributes
- * packed. We currently assume a layout like:
- *
- * attr[0][0..3] - window position
- * attr[1..n][0..3] - remaining attributes.
- *
- * Attributes are assumed to be 4 floats wide but are packed so that
- * all the enabled attributes run contiguously.
- */
-
-
-struct draw_stage;
-struct softpipe_context;
-
-
-typedef void (*vbuf_draw_func)( struct pipe_context *pipe,
- unsigned prim,
- const ushort *elements,
- unsigned nr_elements,
- const void *vertex_buffer,
- unsigned nr_vertices );
-
-
-extern struct draw_stage *
-sp_draw_render_stage( struct softpipe_context *softpipe );
-
-
-extern struct draw_stage *
-sp_draw_vbuf_stage( struct draw_context *draw_context,
- struct pipe_context *pipe,
- vbuf_draw_func draw );
-
-
-#endif /* SP_PRIM_SETUP_H */
diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.c b/src/mesa/pipe/softpipe/sp_prim_vbuf.c
deleted file mode 100644
index c9089e7eb2..0000000000
--- a/src/mesa/pipe/softpipe/sp_prim_vbuf.c
+++ /dev/null
@@ -1,222 +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.
- *
- **************************************************************************/
-
-/**
- * Post-transform vertex buffering. This is an optional part of the
- * softpipe rendering pipeline.
- * Probably not desired in general, but useful for testing/debuggin.
- * Enabled/Disabled with SP_VBUF env var.
- *
- * Authors
- * Brian Paul
- */
-
-
-#include "sp_context.h"
-#include "sp_prim_vbuf.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.h"
-#include "pipe/draw/draw_vbuf.h"
-
-
-#define SP_MAX_VBUF_INDEXES 1024
-#define SP_MAX_VBUF_SIZE 4096
-
-
-/**
- * Subclass of vbuf_render.
- */
-struct softpipe_vbuf_render
-{
- struct vbuf_render base;
- struct softpipe_context *softpipe;
- uint prim;
- uint vertex_size;
- void *vertex_buffer;
-};
-
-
-/** cast wrapper */
-static struct softpipe_vbuf_render *
-softpipe_vbuf_render(struct vbuf_render *vbr)
-{
- return (struct softpipe_vbuf_render *) vbr;
-}
-
-
-
-static const struct vertex_info *
-sp_vbuf_get_vertex_info(struct vbuf_render *vbr)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- /* XXX check for state changes? */
- assert(!cvbr->softpipe->dirty );
- return &cvbr->softpipe->vertex_info_vbuf;
-}
-
-
-static void *
-sp_vbuf_allocate_vertices(struct vbuf_render *vbr,
- ushort vertex_size, ushort nr_vertices)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- assert(!cvbr->vertex_buffer);
- cvbr->vertex_buffer = align_malloc(vertex_size * nr_vertices, 16);
- cvbr->vertex_size = vertex_size;
- return cvbr->vertex_buffer;
-}
-
-
-static void
-sp_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
- unsigned vertex_size, unsigned vertices_used)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- align_free(vertices);
- assert(vertices == cvbr->vertex_buffer);
- cvbr->vertex_buffer = NULL;
-}
-
-
-static void
-sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- cvbr->prim = prim;
-}
-
-
-/**
- * Recalculate prim's determinant.
- * XXX is this needed?
- */
-static void
-calc_det(struct prim_header *header)
-{
- /* Window coords: */
- const float *v0 = header->v[0]->data[0];
- const float *v1 = header->v[1]->data[0];
- const float *v2 = header->v[2]->data[0];
-
- /* edge vectors e = v0 - v2, f = v1 - v2 */
- const float ex = v0[0] - v2[0];
- const float ey = v0[1] - v2[1];
- const float fx = v1[0] - v2[0];
- const float fy = v1[1] - v2[1];
-
- /* det = cross(e,f).z */
- header->det = ex * fy - ey * fx;
-}
-
-
-static void
-sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr_indices)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- struct softpipe_context *softpipe = cvbr->softpipe;
- struct draw_stage *setup = softpipe->setup;
- struct prim_header prim;
- unsigned vertex_size = softpipe->vertex_info_vbuf.size * sizeof(float);
- unsigned i, j;
- void *vertex_buffer = cvbr->vertex_buffer;
-
- prim.det = 0;
- prim.reset_line_stipple = 0;
- prim.edgeflags = 0;
- prim.pad = 0;
-
- switch (cvbr->prim) {
- case PIPE_PRIM_TRIANGLES:
- for (i = 0; i < nr_indices; i += 3) {
- for (j = 0; j < 3; j++)
- prim.v[j] = (struct vertex_header *)((char *)vertex_buffer +
- indices[i+j] * vertex_size);
-
- calc_det(&prim);
- setup->tri( setup, &prim );
- }
- break;
-
- case PIPE_PRIM_LINES:
- for (i = 0; i < nr_indices; i += 2) {
- for (j = 0; j < 2; j++)
- prim.v[j] = (struct vertex_header *)((char *)vertex_buffer +
- indices[i+j] * vertex_size);
-
- setup->line( setup, &prim );
- }
- break;
-
- case PIPE_PRIM_POINTS:
- for (i = 0; i < nr_indices; i++) {
- prim.v[0] = (struct vertex_header *)((char *)vertex_buffer +
- indices[i] * vertex_size);
- setup->point( setup, &prim );
- }
- break;
- }
-
- setup->flush( setup, 0 );
-}
-
-
-static void
-sp_vbuf_destroy(struct vbuf_render *vbr)
-{
- struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
- cvbr->softpipe->vbuf_render = NULL;
- FREE(cvbr);
-}
-
-
-/**
- * Initialize the post-transform vertex buffer information for the given
- * context.
- */
-void
-sp_init_vbuf(struct softpipe_context *sp)
-{
- assert(sp->draw);
-
- sp->vbuf_render = CALLOC_STRUCT(softpipe_vbuf_render);
-
- sp->vbuf_render->base.max_indices = SP_MAX_VBUF_INDEXES;
- sp->vbuf_render->base.max_vertex_buffer_bytes = SP_MAX_VBUF_SIZE;
-
- sp->vbuf_render->base.get_vertex_info = sp_vbuf_get_vertex_info;
- sp->vbuf_render->base.allocate_vertices = sp_vbuf_allocate_vertices;
- sp->vbuf_render->base.set_primitive = sp_vbuf_set_primitive;
- sp->vbuf_render->base.draw = sp_vbuf_draw;
- sp->vbuf_render->base.release_vertices = sp_vbuf_release_vertices;
- sp->vbuf_render->base.destroy = sp_vbuf_destroy;
-
- sp->vbuf_render->softpipe = sp;
-
- sp->vbuf = draw_vbuf_stage(sp->draw, &sp->vbuf_render->base);
-
- draw_set_rasterize_stage(sp->draw, sp->vbuf);
-}
diff --git a/src/mesa/pipe/softpipe/sp_prim_vbuf.h b/src/mesa/pipe/softpipe/sp_prim_vbuf.h
deleted file mode 100644
index 1de9cc2a89..0000000000
--- a/src/mesa/pipe/softpipe/sp_prim_vbuf.h
+++ /dev/null
@@ -1,38 +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 SP_VBUF_H
-#define SP_VBUF_H
-
-
-struct softpipe_context;
-
-extern void
-sp_init_vbuf(struct softpipe_context *softpipe);
-
-
-#endif /* SP_VBUF_H */
diff --git a/src/mesa/pipe/softpipe/sp_quad.c b/src/mesa/pipe/softpipe/sp_quad.c
deleted file mode 100644
index 6bd468a51c..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad.c
+++ /dev/null
@@ -1,118 +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.
- *
- **************************************************************************/
-
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "pipe/p_shader_tokens.h"
-
-static void
-sp_push_quad_first(
- struct softpipe_context *sp,
- struct quad_stage *quad )
-{
- quad->next = sp->quad.first;
- sp->quad.first = quad;
-}
-
-static void
-sp_build_depth_stencil(
- struct softpipe_context *sp )
-{
- if (sp->depth_stencil->stencil[0].enabled ||
- sp->depth_stencil->stencil[1].enabled) {
- sp_push_quad_first( sp, sp->quad.stencil_test );
- }
- else if (sp->depth_stencil->depth.enabled &&
- sp->framebuffer.zsbuf) {
- sp_push_quad_first( sp, sp->quad.depth_test );
- }
-}
-
-void
-sp_build_quad_pipeline(struct softpipe_context *sp)
-{
- boolean early_depth_test =
- sp->depth_stencil->depth.enabled &&
- sp->framebuffer.zsbuf &&
- !sp->depth_stencil->alpha.enabled &&
- sp->fs->shader.output_semantic_name[0] != TGSI_SEMANTIC_POSITION;
-
- /* 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->framebuffer.num_cbufs == 1) {
- /* the usual case: write to exactly one colorbuf */
- sp->current_cbuf = 0;
- }
- else {
- /* insert bufloop stage */
- sp_push_quad_first( sp, sp->quad.bufloop );
- }
-
- 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 );
- }
-
- if (sp->rasterizer->poly_stipple_enable) {
- sp_push_quad_first( sp, sp->quad.polygon_stipple );
- }
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad.h b/src/mesa/pipe/softpipe/sp_quad.h
deleted file mode 100644
index f1e0281764..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_QUAD_H
-#define SP_QUAD_H
-
-
-struct softpipe_context;
-struct quad_header;
-
-
-struct quad_stage {
- struct softpipe_context *softpipe;
-
- struct quad_stage *next;
-
- void (*begin)(struct quad_stage *qs);
-
- /** the stage action */
- void (*run)(struct quad_stage *qs, struct quad_header *quad);
-
- void (*destroy)(struct quad_stage *qs);
-};
-
-
-struct quad_stage *sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_earlyz_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_alpha_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_occlusion_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_coverage_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_bufloop_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe );
-struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe );
-
-void sp_build_quad_pipeline(struct softpipe_context *sp);
-
-void sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad);
-
-#endif /* SP_QUAD_H */
diff --git a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c b/src/mesa/pipe/softpipe/sp_quad_alpha_test.c
deleted file mode 100644
index 4ffeac35e1..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_alpha_test.c
+++ /dev/null
@@ -1,108 +0,0 @@
-
-/**
- * quad alpha test
- */
-
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-
-
-static void
-alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- const float ref = softpipe->depth_stencil->alpha.ref;
- unsigned passMask = 0x0, j;
- const float *aaaa = quad->outputs.color[3];
-
- switch (softpipe->depth_stencil->alpha.func) {
- case PIPE_FUNC_NEVER:
- quad->mask = 0x0;
- break;
- case PIPE_FUNC_LESS:
- /*
- * If mask were an array [4] we could do this SIMD-style:
- * passMask = (quad->outputs.color[3] <= vec4(ref));
- */
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] < ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_EQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] == ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_LEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] <= ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_GREATER:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] > ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_NOTEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] != ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_GEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (aaaa[j] >= ref) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_ALWAYS:
- passMask = MASK_ALL;
- break;
- default:
- abort();
- }
-
- quad->mask &= passMask;
-
- if (quad->mask)
- qs->next->run(qs->next, quad);
-}
-
-
-static void alpha_test_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void alpha_test_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *
-sp_quad_alpha_test_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = alpha_test_begin;
- stage->run = alpha_test_quad;
- stage->destroy = alpha_test_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_blend.c b/src/mesa/pipe/softpipe/sp_quad_blend.c
deleted file mode 100644
index 17f3ecd0b8..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_blend.c
+++ /dev/null
@@ -1,749 +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.
- *
- **************************************************************************/
-
-/**
- * quad blending
- * \author Brian Paul
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_tile_cache.h"
-#include "sp_quad.h"
-
-
-#define VEC4_COPY(DST, SRC) \
-do { \
- DST[0] = SRC[0]; \
- DST[1] = SRC[1]; \
- DST[2] = SRC[2]; \
- DST[3] = SRC[3]; \
-} while(0)
-
-#define VEC4_SCALAR(DST, SRC) \
-do { \
- DST[0] = SRC; \
- DST[1] = SRC; \
- DST[2] = SRC; \
- DST[3] = SRC; \
-} while(0)
-
-#define VEC4_ADD(R, A, B) \
-do { \
- R[0] = A[0] + B[0]; \
- R[1] = A[1] + B[1]; \
- R[2] = A[2] + B[2]; \
- R[3] = A[3] + B[3]; \
-} while (0)
-
-#define VEC4_SUB(R, A, B) \
-do { \
- R[0] = A[0] - B[0]; \
- R[1] = A[1] - B[1]; \
- R[2] = A[2] - B[2]; \
- R[3] = A[3] - B[3]; \
-} while (0)
-
-#define VEC4_MUL(R, A, B) \
-do { \
- R[0] = A[0] * B[0]; \
- R[1] = A[1] * B[1]; \
- R[2] = A[2] * B[2]; \
- R[3] = A[3] * B[3]; \
-} while (0)
-
-#define VEC4_MIN(R, A, B) \
-do { \
- R[0] = (A[0] < B[0]) ? A[0] : B[0]; \
- R[1] = (A[1] < B[1]) ? A[1] : B[1]; \
- R[2] = (A[2] < B[2]) ? A[2] : B[2]; \
- R[3] = (A[3] < B[3]) ? A[3] : B[3]; \
-} while (0)
-
-#define VEC4_MAX(R, A, B) \
-do { \
- R[0] = (A[0] > B[0]) ? A[0] : B[0]; \
- R[1] = (A[1] > B[1]) ? A[1] : B[1]; \
- R[2] = (A[2] > B[2]) ? A[2] : B[2]; \
- R[3] = (A[3] > B[3]) ? A[3] : B[3]; \
-} while (0)
-
-
-
-static void
-logicop_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- float dest[4][QUAD_SIZE];
- ubyte src[4][4], dst[4][4], res[4][4];
- uint *src4 = (uint *) src;
- uint *dst4 = (uint *) dst;
- uint *res4 = (uint *) res;
- struct softpipe_cached_tile *
- tile = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[softpipe->current_cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color;
- 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);
- for (i = 0; i < 4; i++) {
- dest[i][j] = tile->data.color[y][x][i];
- }
- }
-
- /* 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 */
- }
-
- switch (softpipe->blend->logicop_func) {
- case PIPE_LOGICOP_CLEAR:
- for (j = 0; j < 4; j++)
- res4[j] = 0;
- break;
- case PIPE_LOGICOP_NOR:
- for (j = 0; j < 4; j++)
- res4[j] = ~(src4[j] | dst4[j]);
- break;
- case PIPE_LOGICOP_AND_INVERTED:
- for (j = 0; j < 4; j++)
- res4[j] = ~src4[j] & dst4[j];
- break;
- case PIPE_LOGICOP_COPY_INVERTED:
- for (j = 0; j < 4; j++)
- res4[j] = ~src4[j];
- break;
- case PIPE_LOGICOP_AND_REVERSE:
- for (j = 0; j < 4; j++)
- res4[j] = src4[j] & ~dst4[j];
- break;
- case PIPE_LOGICOP_INVERT:
- for (j = 0; j < 4; j++)
- res4[j] = ~dst4[j];
- break;
- case PIPE_LOGICOP_XOR:
- for (j = 0; j < 4; j++)
- res4[j] = dst4[j] ^ src4[j];
- break;
- case PIPE_LOGICOP_NAND:
- for (j = 0; j < 4; j++)
- res4[j] = ~(src4[j] & dst4[j]);
- break;
- case PIPE_LOGICOP_AND:
- for (j = 0; j < 4; j++)
- res4[j] = src4[j] & dst4[j];
- break;
- case PIPE_LOGICOP_EQUIV:
- for (j = 0; j < 4; j++)
- res4[j] = ~(src4[j] ^ dst4[j]);
- break;
- case PIPE_LOGICOP_NOOP:
- for (j = 0; j < 4; j++)
- res4[j] = dst4[j];
- break;
- case PIPE_LOGICOP_OR_INVERTED:
- for (j = 0; j < 4; j++)
- res4[j] = ~src4[j] | dst4[j];
- break;
- case PIPE_LOGICOP_COPY:
- for (j = 0; j < 4; j++)
- res4[j] = src4[j];
- break;
- case PIPE_LOGICOP_OR_REVERSE:
- for (j = 0; j < 4; j++)
- res4[j] = src4[j] | ~dst4[j];
- break;
- case PIPE_LOGICOP_OR:
- for (j = 0; j < 4; j++)
- res4[j] = src4[j] | dst4[j];
- break;
- case PIPE_LOGICOP_SET:
- for (j = 0; j < 4; j++)
- res4[j] = ~0;
- break;
- default:
- assert(0);
- }
-
- 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]);
- }
-
- /* pass quad to next stage */
- qs->next->run(qs->next, quad);
-}
-
-
-
-
-static void
-blend_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- static const float zero[4] = { 0, 0, 0, 0 };
- static const float one[4] = { 1, 1, 1, 1 };
- float source[4][QUAD_SIZE], dest[4][QUAD_SIZE];
- struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[softpipe->current_cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color;
- uint i, j;
-
- if (softpipe->blend->logicop_enable) {
- logicop_quad(qs, quad);
- return;
- }
-
- /* 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);
- for (i = 0; i < 4; i++) {
- dest[i][j] = tile->data.color[y][x][i];
- }
- }
-
- /*
- * Compute src/first term RGB
- */
- switch (softpipe->blend->rgb_src_factor) {
- case PIPE_BLENDFACTOR_ONE:
- VEC4_COPY(source[0], quadColor[0]); /* R */
- VEC4_COPY(source[1], quadColor[1]); /* G */
- VEC4_COPY(source[2], quadColor[2]); /* B */
- break;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- VEC4_MUL(source[0], quadColor[0], quadColor[0]); /* R */
- VEC4_MUL(source[1], quadColor[1], quadColor[1]); /* G */
- VEC4_MUL(source[2], quadColor[2], quadColor[2]); /* B */
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- {
- const float *alpha = quadColor[3];
- VEC4_MUL(source[0], quadColor[0], alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_DST_COLOR:
- VEC4_MUL(source[0], quadColor[0], dest[0]); /* R */
- VEC4_MUL(source[1], quadColor[1], dest[1]); /* G */
- VEC4_MUL(source[2], quadColor[2], dest[2]); /* B */
- break;
- case PIPE_BLENDFACTOR_DST_ALPHA:
- {
- const float *alpha = dest[3];
- VEC4_MUL(source[0], quadColor[0], alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- {
- const float *alpha = quadColor[3];
- float diff[4];
- VEC4_SUB(diff, one, dest[3]);
- VEC4_MIN(source[0], alpha, diff); /* R */
- VEC4_MIN(source[1], alpha, diff); /* G */
- VEC4_MIN(source[2], alpha, diff); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- {
- float comp[4];
- VEC4_SCALAR(comp, softpipe->blend_color.color[0]); /* R */
- VEC4_MUL(source[0], quadColor[0], comp); /* R */
- VEC4_SCALAR(comp, softpipe->blend_color.color[1]); /* G */
- VEC4_MUL(source[1], quadColor[1], comp); /* G */
- VEC4_SCALAR(comp, softpipe->blend_color.color[2]); /* B */
- VEC4_MUL(source[2], quadColor[2], comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- {
- float alpha[4];
- VEC4_SCALAR(alpha, softpipe->blend_color.color[3]);
- VEC4_MUL(source[0], quadColor[0], alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_SRC1_COLOR:
- assert(0); /* to do */
- break;
- case PIPE_BLENDFACTOR_SRC1_ALPHA:
- assert(0); /* to do */
- break;
- case PIPE_BLENDFACTOR_ZERO:
- VEC4_COPY(source[0], zero); /* R */
- VEC4_COPY(source[1], zero); /* G */
- VEC4_COPY(source[2], zero); /* B */
- break;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, quadColor[0]); /* R */
- VEC4_MUL(source[0], quadColor[0], inv_comp); /* R */
- VEC4_SUB(inv_comp, one, quadColor[1]); /* G */
- VEC4_MUL(source[1], quadColor[1], inv_comp); /* G */
- VEC4_SUB(inv_comp, one, quadColor[2]); /* B */
- VEC4_MUL(source[2], quadColor[2], inv_comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- {
- float inv_alpha[4];
- VEC4_SUB(inv_alpha, one, quadColor[3]);
- VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- {
- float inv_alpha[4];
- VEC4_SUB(inv_alpha, one, dest[3]);
- VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, dest[0]); /* R */
- VEC4_MUL(source[0], quadColor[0], inv_comp); /* R */
- VEC4_SUB(inv_comp, one, dest[1]); /* G */
- VEC4_MUL(source[1], quadColor[1], inv_comp); /* G */
- VEC4_SUB(inv_comp, one, dest[2]); /* B */
- VEC4_MUL(source[2], quadColor[2], inv_comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- {
- float inv_comp[4];
- /* R */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[0]);
- VEC4_MUL(source[0], quadColor[0], inv_comp);
- /* G */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[1]);
- VEC4_MUL(source[1], quadColor[1], inv_comp);
- /* B */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[2]);
- VEC4_MUL(source[2], quadColor[2], inv_comp);
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- {
- float inv_alpha[4];
- VEC4_SCALAR(inv_alpha, 1.0f - softpipe->blend_color.color[3]);
- VEC4_MUL(source[0], quadColor[0], inv_alpha); /* R */
- VEC4_MUL(source[1], quadColor[1], inv_alpha); /* G */
- VEC4_MUL(source[2], quadColor[2], inv_alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
- assert(0); /* to do */
- break;
- case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
- assert(0); /* to do */
- break;
- default:
- abort();
- }
-
- /*
- * Compute src/first term A
- */
- switch (softpipe->blend->alpha_src_factor) {
- case PIPE_BLENDFACTOR_ONE:
- VEC4_COPY(source[3], quadColor[3]); /* A */
- break;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- {
- const float *alpha = quadColor[3];
- VEC4_MUL(source[3], quadColor[3], alpha); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_DST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_DST_ALPHA:
- VEC4_MUL(source[3], quadColor[3], dest[3]); /* A */
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- {
- const float *alpha = quadColor[3];
- float diff[4];
- VEC4_SUB(diff, one, dest[3]);
- VEC4_MIN(source[3], alpha, diff); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- {
- float comp[4];
- VEC4_SCALAR(comp, softpipe->blend_color.color[3]); /* A */
- VEC4_MUL(source[3], quadColor[3], comp); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_ZERO:
- VEC4_COPY(source[3], zero); /* A */
- break;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- {
- float inv_alpha[4];
- VEC4_SUB(inv_alpha, one, quadColor[3]);
- VEC4_MUL(source[3], quadColor[3], inv_alpha); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- {
- float inv_alpha[4];
- VEC4_SUB(inv_alpha, one, dest[3]);
- VEC4_MUL(source[3], quadColor[3], inv_alpha); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- {
- float inv_comp[4];
- /* A */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[3]);
- VEC4_MUL(source[3], quadColor[3], inv_comp);
- }
- break;
- default:
- abort();
- }
-
-
- /*
- * Compute dest/second term RGB
- */
- switch (softpipe->blend->rgb_dst_factor) {
- case PIPE_BLENDFACTOR_ONE:
- /* dest = dest * 1 NO-OP, leave dest as-is */
- break;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- VEC4_MUL(dest[0], dest[0], quadColor[0]); /* R */
- VEC4_MUL(dest[1], dest[1], quadColor[1]); /* G */
- VEC4_MUL(dest[2], dest[2], quadColor[2]); /* B */
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- VEC4_MUL(dest[0], dest[0], quadColor[3]); /* R * A */
- VEC4_MUL(dest[1], dest[1], quadColor[3]); /* G * A */
- VEC4_MUL(dest[2], dest[2], quadColor[3]); /* B * A */
- break;
- case PIPE_BLENDFACTOR_DST_ALPHA:
- VEC4_MUL(dest[0], dest[0], dest[3]); /* R * A */
- VEC4_MUL(dest[1], dest[1], dest[3]); /* G * A */
- VEC4_MUL(dest[2], dest[2], dest[3]); /* B * A */
- break;
- case PIPE_BLENDFACTOR_DST_COLOR:
- VEC4_MUL(dest[0], dest[0], dest[0]); /* R */
- VEC4_MUL(dest[1], dest[1], dest[1]); /* G */
- VEC4_MUL(dest[2], dest[2], dest[2]); /* B */
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- assert(0); /* illegal */
- break;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- {
- float comp[4];
- VEC4_SCALAR(comp, softpipe->blend_color.color[0]); /* R */
- VEC4_MUL(dest[0], dest[0], comp); /* R */
- VEC4_SCALAR(comp, softpipe->blend_color.color[1]); /* G */
- VEC4_MUL(dest[1], dest[1], comp); /* G */
- VEC4_SCALAR(comp, softpipe->blend_color.color[2]); /* B */
- VEC4_MUL(dest[2], dest[2], comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- {
- float comp[4];
- VEC4_SCALAR(comp, softpipe->blend_color.color[3]); /* A */
- VEC4_MUL(dest[0], dest[0], comp); /* R */
- VEC4_MUL(dest[1], dest[1], comp); /* G */
- VEC4_MUL(dest[2], dest[2], comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_ZERO:
- VEC4_COPY(dest[0], zero); /* R */
- VEC4_COPY(dest[1], zero); /* G */
- VEC4_COPY(dest[2], zero); /* B */
- break;
- case PIPE_BLENDFACTOR_SRC1_COLOR:
- case PIPE_BLENDFACTOR_SRC1_ALPHA:
- /* XXX what are these? */
- assert(0);
- break;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, quadColor[0]); /* R */
- VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */
- VEC4_SUB(inv_comp, one, quadColor[1]); /* G */
- VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */
- VEC4_SUB(inv_comp, one, quadColor[2]); /* B */
- VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- {
- float one_minus_alpha[QUAD_SIZE];
- VEC4_SUB(one_minus_alpha, one, quadColor[3]);
- VEC4_MUL(dest[0], dest[0], one_minus_alpha); /* R */
- VEC4_MUL(dest[1], dest[1], one_minus_alpha); /* G */
- VEC4_MUL(dest[2], dest[2], one_minus_alpha); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, quadColor[3]); /* A */
- VEC4_MUL(dest[0], inv_comp, dest[0]); /* R */
- VEC4_MUL(dest[1], inv_comp, dest[1]); /* G */
- VEC4_MUL(dest[2], inv_comp, dest[2]); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, dest[0]); /* R */
- VEC4_MUL(dest[0], dest[0], inv_comp); /* R */
- VEC4_SUB(inv_comp, one, dest[1]); /* G */
- VEC4_MUL(dest[1], dest[1], inv_comp); /* G */
- VEC4_SUB(inv_comp, one, dest[2]); /* B */
- VEC4_MUL(dest[2], dest[2], inv_comp); /* B */
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- {
- float inv_comp[4];
- /* R */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[0]);
- VEC4_MUL(dest[0], dest[0], inv_comp);
- /* G */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[1]);
- VEC4_MUL(dest[1], dest[1], inv_comp);
- /* B */
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[2]);
- VEC4_MUL(dest[2], dest[2], inv_comp);
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- {
- float inv_comp[4];
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[3]);
- VEC4_MUL(dest[0], dest[0], inv_comp);
- VEC4_MUL(dest[1], dest[1], inv_comp);
- VEC4_MUL(dest[2], dest[2], inv_comp);
- }
- break;
- case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
- case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
- /* XXX what are these? */
- assert(0);
- break;
- default:
- assert(0);
- }
-
- /*
- * Compute dest/second term A
- */
- switch (softpipe->blend->alpha_dst_factor) {
- case PIPE_BLENDFACTOR_ONE:
- /* dest = dest * 1 NO-OP, leave dest as-is */
- break;
- case PIPE_BLENDFACTOR_SRC_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_SRC_ALPHA:
- VEC4_MUL(dest[3], dest[3], quadColor[3]); /* A * A */
- break;
- case PIPE_BLENDFACTOR_DST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_DST_ALPHA:
- VEC4_MUL(dest[3], dest[3], dest[3]); /* A */
- break;
- case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
- assert(0); /* illegal */
- break;
- case PIPE_BLENDFACTOR_CONST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_CONST_ALPHA:
- {
- float comp[4];
- VEC4_SCALAR(comp, softpipe->blend_color.color[3]); /* A */
- VEC4_MUL(dest[3], dest[3], comp); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_ZERO:
- VEC4_COPY(dest[3], zero); /* A */
- break;
- case PIPE_BLENDFACTOR_INV_SRC_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
- {
- float one_minus_alpha[QUAD_SIZE];
- VEC4_SUB(one_minus_alpha, one, quadColor[3]);
- VEC4_MUL(dest[3], dest[3], one_minus_alpha); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_INV_DST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_DST_ALPHA:
- {
- float inv_comp[4];
- VEC4_SUB(inv_comp, one, dest[3]); /* A */
- VEC4_MUL(dest[3], inv_comp, dest[3]); /* A */
- }
- break;
- case PIPE_BLENDFACTOR_INV_CONST_COLOR:
- /* fall-through */
- case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
- {
- float inv_comp[4];
- VEC4_SCALAR(inv_comp, 1.0f - softpipe->blend_color.color[3]);
- VEC4_MUL(dest[3], dest[3], inv_comp);
- }
- break;
- default:
- assert(0);
- }
-
- /*
- * Combine RGB terms
- */
- switch (softpipe->blend->rgb_func) {
- case PIPE_BLEND_ADD:
- VEC4_ADD(quadColor[0], source[0], dest[0]); /* R */
- VEC4_ADD(quadColor[1], source[1], dest[1]); /* G */
- VEC4_ADD(quadColor[2], source[2], dest[2]); /* B */
- break;
- case PIPE_BLEND_SUBTRACT:
- VEC4_SUB(quadColor[0], source[0], dest[0]); /* R */
- VEC4_SUB(quadColor[1], source[1], dest[1]); /* G */
- VEC4_SUB(quadColor[2], source[2], dest[2]); /* B */
- break;
- case PIPE_BLEND_REVERSE_SUBTRACT:
- VEC4_SUB(quadColor[0], dest[0], source[0]); /* R */
- VEC4_SUB(quadColor[1], dest[1], source[1]); /* G */
- VEC4_SUB(quadColor[2], dest[2], source[2]); /* B */
- break;
- case PIPE_BLEND_MIN:
- VEC4_MIN(quadColor[0], source[0], dest[0]); /* R */
- VEC4_MIN(quadColor[1], source[1], dest[1]); /* G */
- VEC4_MIN(quadColor[2], source[2], dest[2]); /* B */
- break;
- case PIPE_BLEND_MAX:
- VEC4_MAX(quadColor[0], source[0], dest[0]); /* R */
- VEC4_MAX(quadColor[1], source[1], dest[1]); /* G */
- VEC4_MAX(quadColor[2], source[2], dest[2]); /* B */
- break;
- default:
- assert(0);
- }
-
- /*
- * Combine A terms
- */
- switch (softpipe->blend->alpha_func) {
- case PIPE_BLEND_ADD:
- VEC4_ADD(quadColor[3], source[3], dest[3]); /* A */
- break;
- case PIPE_BLEND_SUBTRACT:
- VEC4_SUB(quadColor[3], source[3], dest[3]); /* A */
- break;
- case PIPE_BLEND_REVERSE_SUBTRACT:
- VEC4_SUB(quadColor[3], dest[3], source[3]); /* A */
- break;
- case PIPE_BLEND_MIN:
- VEC4_MIN(quadColor[3], source[3], dest[3]); /* A */
- break;
- case PIPE_BLEND_MAX:
- VEC4_MAX(quadColor[3], source[3], dest[3]); /* A */
- break;
- default:
- abort();
- }
-
- /* pass blended quad to next stage */
- qs->next->run(qs->next, quad);
-}
-
-
-static void blend_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void blend_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_blend_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = blend_begin;
- stage->run = blend_quad;
- stage->destroy = blend_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_bufloop.c b/src/mesa/pipe/softpipe/sp_quad_bufloop.c
deleted file mode 100644
index 2ae4e22a7d..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_bufloop.c
+++ /dev/null
@@ -1,72 +0,0 @@
-
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_quad.h"
-
-
-/**
- * Loop over colorbuffers, passing quad to next stage each time.
- */
-static void
-cbuf_loop_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- float tmp[4][QUAD_SIZE];
- unsigned i;
-
- assert(sizeof(quad->outputs.color) == sizeof(tmp));
- assert(softpipe->framebuffer.num_cbufs <= PIPE_MAX_COLOR_BUFS);
-
- /* make copy of original colors since they can get modified
- * by blending and masking.
- * XXX we won't have to do this if the fragment program actually emits
- * N separate colors and we're drawing to N color buffers (MRT).
- * But if we emitted one color and glDrawBuffer(GL_FRONT_AND_BACK) is
- * in effect, we need to save/restore colors like this.
- */
- memcpy(tmp, quad->outputs.color, sizeof(tmp));
-
- for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
- /* set current cbuffer */
- softpipe->current_cbuf = i;
-
- /* pass blended quad to next stage */
- qs->next->run(qs->next, quad);
-
- /* restore quad's colors for next buffer */
- memcpy(quad->outputs.color, tmp, sizeof(tmp));
- }
-}
-
-
-static void cbuf_loop_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void cbuf_loop_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-/**
- * Create the colorbuffer loop stage.
- * This is used to implement multiple render targets and GL_FRONT_AND_BACK
- * rendering.
- */
-struct quad_stage *sp_quad_bufloop_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = cbuf_loop_begin;
- stage->run = cbuf_loop_quad;
- stage->destroy = cbuf_loop_destroy;
-
- return stage;
-}
-
diff --git a/src/mesa/pipe/softpipe/sp_quad_colormask.c b/src/mesa/pipe/softpipe/sp_quad_colormask.c
deleted file mode 100644
index 1f09d900ca..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_colormask.c
+++ /dev/null
@@ -1,110 +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.
- *
- **************************************************************************/
-
-/**
- * \brief quad colormask stage
- * \author Brian Paul
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_quad.h"
-#include "sp_tile_cache.h"
-
-
-
-/**
- * XXX colormask could be rolled into blending...
- */
-static void
-colormask_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- float dest[4][QUAD_SIZE];
- struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[softpipe->current_cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color;
- 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);
- for (i = 0; i < 4; i++) {
- dest[i][j] = tile->data.color[y][x][i];
- }
- }
-
- /* R */
- if (!(softpipe->blend->colormask & PIPE_MASK_R))
- COPY_4V(quadColor[0], dest[0]);
-
- /* G */
- if (!(softpipe->blend->colormask & PIPE_MASK_G))
- COPY_4V(quadColor[1], dest[1]);
-
- /* B */
- if (!(softpipe->blend->colormask & PIPE_MASK_B))
- COPY_4V(quadColor[2], dest[2]);
-
- /* A */
- if (!(softpipe->blend->colormask & PIPE_MASK_A))
- COPY_4V(quadColor[3], dest[3]);
-
- /* pass quad to next stage */
- qs->next->run(qs->next, quad);
-}
-
-
-static void colormask_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void colormask_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_colormask_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = colormask_begin;
- stage->run = colormask_quad;
- stage->destroy = colormask_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_coverage.c b/src/mesa/pipe/softpipe/sp_quad_coverage.c
deleted file mode 100644
index b3d3fae22f..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_coverage.c
+++ /dev/null
@@ -1,88 +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.
- *
- **************************************************************************/
-
-
-/**
- * \brief Apply AA coverage to quad alpha valus
- * \author Brian Paul
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-
-
-/**
- * Multiply quad's alpha values by the fragment coverage.
- */
-static void
-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)) {
- float (*quadColor)[4] = quad->outputs.color;
- 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];
- }
- }
-
- qs->next->run(qs->next, quad);
-}
-
-
-static void coverage_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void coverage_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_coverage_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = coverage_begin;
- stage->run = coverage_quad;
- stage->destroy = coverage_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_depth_test.c b/src/mesa/pipe/softpipe/sp_quad_depth_test.c
deleted file mode 100644
index a9a0754f27..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_depth_test.c
+++ /dev/null
@@ -1,276 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Quad depth testing
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_quad.h"
-#include "sp_tile_cache.h"
-
-
-/**
- * Do depth testing for a quad.
- * Not static since it's used by the stencil code.
- */
-
-/*
- * To increase efficiency, we should probably have multiple versions
- * of this function that are specifically for Z16, Z32 and FP Z buffers.
- * Try to effectively do that with codegen...
- */
-
-void
-sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
- const enum pipe_format format = ps->format;
- unsigned bzzzz[QUAD_SIZE]; /**< Z values fetched from depth buffer */
- unsigned qzzzz[QUAD_SIZE]; /**< Z values from the quad */
- unsigned zmask = 0;
- unsigned j;
- struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
-
- assert(ps); /* shouldn't get here if there's no zbuffer */
-
- /*
- * Convert quad's float depth values to int depth values (qzzzz).
- * If the Z buffer stores integer values, we _have_ to do the depth
- * compares with integers (not floats). Otherwise, the float->int->float
- * conversion of Z values (which isn't an identity function) will cause
- * Z-fighting errors.
- *
- * Also, get the zbuffer values (bzzzz) from the cached tile.
- */
- switch (format) {
- case PIPE_FORMAT_Z16_UNORM:
- {
- float scale = 65535.0;
-
- for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.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);
- bzzzz[j] = tile->data.depth16[y][x];
- }
- }
- break;
- case PIPE_FORMAT_Z32_UNORM:
- {
- double scale = (double) (uint) ~0UL;
-
- for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.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);
- bzzzz[j] = tile->data.depth32[y][x];
- }
- }
- break;
- case PIPE_FORMAT_S8Z24_UNORM:
- {
- float scale = (float) ((1 << 24) - 1);
-
- for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.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);
- bzzzz[j] = tile->data.depth32[y][x] & 0xffffff;
- }
- }
- break;
- case PIPE_FORMAT_Z24S8_UNORM:
- {
- float scale = (float) ((1 << 24) - 1);
-
- for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.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);
- bzzzz[j] = tile->data.depth32[y][x] >> 8;
- }
- }
- break;
- default:
- assert(0);
- }
-
- switch (softpipe->depth_stencil->depth.func) {
- case PIPE_FUNC_NEVER:
- /* zmask = 0 */
- break;
- case PIPE_FUNC_LESS:
- /* Note this is pretty much a single sse or cell instruction.
- * Like this: quad->mask &= (quad->outputs.depth < zzzz);
- */
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] < bzzzz[j])
- zmask |= 1 << j;
- }
- break;
- case PIPE_FUNC_EQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] == bzzzz[j])
- zmask |= 1 << j;
- }
- break;
- case PIPE_FUNC_LEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] <= bzzzz[j])
- zmask |= (1 << j);
- }
- break;
- case PIPE_FUNC_GREATER:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] > bzzzz[j])
- zmask |= (1 << j);
- }
- break;
- case PIPE_FUNC_NOTEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] != bzzzz[j])
- zmask |= (1 << j);
- }
- break;
- case PIPE_FUNC_GEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (qzzzz[j] >= bzzzz[j])
- zmask |= (1 << j);
- }
- break;
- case PIPE_FUNC_ALWAYS:
- zmask = MASK_ALL;
- break;
- default:
- abort();
- }
-
- quad->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)) {
- bzzzz[j] = qzzzz[j];
- }
- }
-
- /* put updated Z values back into cached tile */
- 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);
- tile->data.depth16[y][x] = (ushort) bzzzz[j];
- }
- break;
- 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);
- 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);
- uint s8z24 = tile->data.depth32[y][x];
- s8z24 = (s8z24 & 0xff000000) | bzzzz[j];
- tile->data.depth32[y][x] = s8z24;
- }
- 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);
- uint z24s8 = tile->data.depth32[y][x];
- z24s8 = (z24s8 & 0xff) | (bzzzz[j] << 24);
- tile->data.depth32[y][x] = z24s8;
- }
- break;
- default:
- assert(0);
- }
- }
-}
-
-
-static void
-depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- sp_depth_test_quad(qs, quad);
-
- if (quad->mask)
- qs->next->run(qs->next, quad);
-}
-
-
-static void depth_test_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void depth_test_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = depth_test_begin;
- stage->run = depth_test_quad;
- stage->destroy = depth_test_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_earlyz.c b/src/mesa/pipe/softpipe/sp_quad_earlyz.c
deleted file mode 100644
index 22ea99049f..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_earlyz.c
+++ /dev/null
@@ -1,88 +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.
- *
- **************************************************************************/
-
-/**
- * \brief Quad early-z testing
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-
-
-/**
- * All this stage does is compute the quad's Z values (which is normally
- * done by the shading stage).
- * The next stage will do the actual depth test.
- */
-static void
-earlyz_quad(
- struct quad_stage *qs,
- struct quad_header *quad )
-{
- const float fx = (float) quad->x0;
- const float fy = (float) quad->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;
-
- qs->next->run( qs->next, quad );
-}
-
-static void
-earlyz_begin(
- struct quad_stage *qs )
-{
- qs->next->begin( qs->next );
-}
-
-static void
-earlyz_destroy(
- struct quad_stage *qs )
-{
- FREE( qs );
-}
-
-struct quad_stage *
-sp_quad_earlyz_stage(
- struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT( quad_stage );
-
- stage->softpipe = softpipe;
- stage->begin = earlyz_begin;
- stage->run = earlyz_quad;
- stage->destroy = earlyz_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
deleted file mode 100644
index cf1b1eff75..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ /dev/null
@@ -1,208 +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.
- *
- **************************************************************************/
-
-/* Vertices are just an array of floats, with all the attributes
- * packed. We currently assume a layout like:
- *
- * attr[0][0..3] - window position
- * attr[1..n][0..3] - remaining attributes.
- *
- * Attributes are assumed to be 4 floats wide but are packed so that
- * all the enabled attributes run contiguously.
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-#include "sp_texture.h"
-#include "sp_tex_sample.h"
-
-
-struct quad_shade_stage
-{
- struct quad_stage stage;
- struct tgsi_sampler samplers[PIPE_MAX_SAMPLERS];
- struct tgsi_exec_machine machine;
- struct tgsi_exec_vector *inputs, *outputs;
- int colorOutSlot, depthOutSlot;
-};
-
-
-/** cast wrapper */
-static INLINE struct quad_shade_stage *
-quad_shade_stage(struct quad_stage *qs)
-{
- return (struct quad_shade_stage *) qs;
-}
-
-
-
-/**
- * Execute fragment shader for the four fragments in the quad.
- */
-static void
-shade_quad(
- struct quad_stage *qs,
- struct quad_header *quad )
-{
- struct quad_shade_stage *qss = quad_shade_stage( qs );
- struct softpipe_context *softpipe = qs->softpipe;
- struct tgsi_exec_machine *machine = &qss->machine;
-
- /* Consts do not require 16 byte alignment. */
- machine->Consts = softpipe->mapped_constants[PIPE_SHADER_FRAGMENT];
-
- machine->InterpCoefs = quad->coef;
-
- /* run shader */
- quad->mask &= softpipe->fs->run( softpipe->fs,
- &qss->machine,
- quad );
-
- /* store result color */
- if (qss->colorOutSlot >= 0) {
- /* XXX need to handle multiple color outputs someday */
- assert(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
- == TGSI_SEMANTIC_COLOR);
- memcpy(
- quad->outputs.color,
- &machine->Outputs[qss->colorOutSlot].xyzw[0].f[0],
- sizeof( quad->outputs.color ) );
- }
-
- /*
- * XXX the following code for updating quad->outputs.depth
- * isn't really needed if we did early z testing.
- */
-
- /* store result Z */
- if (qss->depthOutSlot >= 0) {
- /* output[slot] is new Z */
- uint i;
- for (i = 0; i < 4; i++) {
- quad->outputs.depth[i] = machine->Outputs[0].xyzw[2].f[i];
- }
- }
- else {
- /* copy input Z (which was interpolated by the executor) to output Z */
- uint i;
- for (i = 0; i < 4; i++) {
- quad->outputs.depth[i] = machine->Inputs[0].xyzw[2].f[i];
- /* XXX not sure the above line is always correct. The following
- * might be better:
- quad->outputs.depth[i] = machine->QuadPos.xyzw[2].f[i];
- */
- }
- }
-
- /* shader may cull fragments */
- if( quad->mask ) {
- qs->next->run( qs->next, quad );
- }
-}
-
-/**
- * Per-primitive (or per-begin?) setup
- */
-static void shade_begin(struct quad_stage *qs)
-{
- struct quad_shade_stage *qss = quad_shade_stage(qs);
- struct softpipe_context *softpipe = qs->softpipe;
- unsigned i;
-
- /* set TGSI sampler state that varies */
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- qss->samplers[i].state = softpipe->sampler[i];
- qss->samplers[i].texture = &softpipe->texture[i]->base;
- }
-
- /* find output slots for depth, color */
- qss->colorOutSlot = -1;
- qss->depthOutSlot = -1;
- for (i = 0; i < qss->stage.softpipe->fs->shader.num_outputs; i++) {
- switch (qss->stage.softpipe->fs->shader.output_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- qss->depthOutSlot = i;
- break;
- case TGSI_SEMANTIC_COLOR:
- qss->colorOutSlot = i;
- break;
- }
- }
-
- softpipe->fs->prepare( softpipe->fs,
- &qss->machine,
- qss->samplers );
-
- qs->next->begin(qs->next);
-}
-
-
-static void shade_destroy(struct quad_stage *qs)
-{
- struct quad_shade_stage *qss = (struct quad_shade_stage *) qs;
-
- tgsi_exec_machine_free_data(&qss->machine);
- FREE( qss->inputs );
- FREE( qss->outputs );
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe )
-{
- struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage);
- uint i;
-
- /* allocate storage for program inputs/outputs, aligned to 16 bytes */
- qss->inputs = MALLOC(PIPE_ATTRIB_MAX * sizeof(*qss->inputs) + 16);
- qss->outputs = MALLOC(PIPE_ATTRIB_MAX * sizeof(*qss->outputs) + 16);
- qss->machine.Inputs = align16(qss->inputs);
- qss->machine.Outputs = align16(qss->outputs);
-
- qss->stage.softpipe = softpipe;
- qss->stage.begin = shade_begin;
- qss->stage.run = shade_quad;
- qss->stage.destroy = shade_destroy;
-
- /* set TGSI sampler state that's constant */
- for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
- assert(softpipe->tex_cache[i]);
- qss->samplers[i].get_samples = sp_get_samples;
- qss->samplers[i].pipe = &softpipe->pipe;
- qss->samplers[i].cache = softpipe->tex_cache[i];
- }
-
- tgsi_exec_machine_init( &qss->machine );
-
- return &qss->stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_occlusion.c b/src/mesa/pipe/softpipe/sp_quad_occlusion.c
deleted file mode 100644
index 54254df1f1..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_occlusion.c
+++ /dev/null
@@ -1,85 +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.
- *
- **************************************************************************/
-
-
-/**
- * \brief Quad occlusion counter stage
- * \author Brian Paul
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_quad.h"
-
-static unsigned count_bits( unsigned val )
-{
- unsigned i;
-
- for (i = 0; val ; val >>= 1)
- i += (val & 1);
-
- return i;
-}
-
-static void
-occlusion_count_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
-
- softpipe->occlusion_count += count_bits(quad->mask);
-
- qs->next->run(qs->next, quad);
-}
-
-
-static void occlusion_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void occlusion_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_occlusion_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = occlusion_begin;
- stage->run = occlusion_count_quad;
- stage->destroy = occlusion_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_output.c b/src/mesa/pipe/softpipe/sp_quad_output.c
deleted file mode 100644
index cfe8f11808..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_output.c
+++ /dev/null
@@ -1,90 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_quad.h"
-#include "sp_tile_cache.h"
-
-
-/**
- * Write quad to framebuffer, taking mask into account.
- *
- * Note that surfaces support only full quad reads and writes.
- */
-static void
-output_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe,
- softpipe->cbuf_cache[softpipe->current_cbuf],
- quad->x0, quad->y0);
- /* in-tile pos: */
- const int itx = quad->x0 % TILE_SIZE;
- const int ity = quad->y0 % TILE_SIZE;
- float (*quadColor)[4] = quad->outputs.color;
- int i, j;
-
- /* get/swizzle dest colors */
- for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->mask & (1 << j)) {
- int x = itx + (j & 1);
- int y = ity + (j >> 1);
- for (i = 0; i < 4; i++) { /* loop over color chans */
- tile->data.color[y][x][i] = quadColor[i][j];
- }
- }
- }
-}
-
-
-static void output_begin(struct quad_stage *qs)
-{
- assert(qs->next == NULL);
-}
-
-
-static void output_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_output_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = output_begin;
- stage->run = output_quad;
- stage->destroy = output_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c
deleted file mode 100644
index 92a0da0083..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_stencil.c
+++ /dev/null
@@ -1,352 +0,0 @@
-
-/**
- * \brief Quad stencil testing
- */
-
-
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_tile_cache.h"
-#include "sp_quad.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-
-
-/** Only 8-bit stencil supported */
-#define STENCIL_MAX 0xff
-
-
-/**
- * Do the basic stencil test (compare stencil buffer values against the
- * reference value.
- *
- * \param stencilVals the stencil values from the stencil buffer
- * \param func the stencil func (PIPE_FUNC_x)
- * \param ref the stencil reference value
- * \param valMask the stencil value mask indicating which bits of the stencil
- * values and ref value are to be used.
- * \return mask indicating which pixels passed the stencil test
- */
-static unsigned
-do_stencil_test(const ubyte stencilVals[QUAD_SIZE], unsigned func,
- unsigned ref, unsigned valMask)
-{
- unsigned passMask = 0x0;
- unsigned j;
-
- ref &= valMask;
-
- switch (func) {
- case PIPE_FUNC_NEVER:
- /* passMask = 0x0 */
- break;
- case PIPE_FUNC_LESS:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref < (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_EQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref == (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_LEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref <= (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_GREATER:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref > (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_NOTEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref != (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_GEQUAL:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (ref >= (stencilVals[j] & valMask)) {
- passMask |= (1 << j);
- }
- }
- break;
- case PIPE_FUNC_ALWAYS:
- passMask = MASK_ALL;
- break;
- default:
- assert(0);
- }
-
- return passMask;
-}
-
-
-/**
- * Apply the stencil operator to stencil values.
- *
- * \param stencilVals the stencil buffer values (read and written)
- * \param mask indicates which pixels to update
- * \param op the stencil operator (PIPE_STENCIL_OP_x)
- * \param ref the stencil reference value
- * \param wrtMask writemask controlling which bits are changed in the
- * stencil values
- */
-static void
-apply_stencil_op(ubyte stencilVals[QUAD_SIZE],
- unsigned mask, unsigned op, ubyte ref, ubyte wrtMask)
-{
- unsigned j;
- ubyte newstencil[QUAD_SIZE];
-
- for (j = 0; j < QUAD_SIZE; j++) {
- newstencil[j] = stencilVals[j];
- }
-
- switch (op) {
- case PIPE_STENCIL_OP_KEEP:
- /* no-op */
- break;
- case PIPE_STENCIL_OP_ZERO:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- newstencil[j] = 0;
- }
- }
- break;
- case PIPE_STENCIL_OP_REPLACE:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- newstencil[j] = ref;
- }
- }
- break;
- case PIPE_STENCIL_OP_INCR:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- if (stencilVals[j] < STENCIL_MAX) {
- newstencil[j] = stencilVals[j] + 1;
- }
- }
- }
- break;
- case PIPE_STENCIL_OP_DECR:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- if (stencilVals[j] > 0) {
- newstencil[j] = stencilVals[j] - 1;
- }
- }
- }
- break;
- case PIPE_STENCIL_OP_INCR_WRAP:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- newstencil[j] = stencilVals[j] + 1;
- }
- }
- break;
- case PIPE_STENCIL_OP_DECR_WRAP:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- newstencil[j] = stencilVals[j] - 1;
- }
- }
- break;
- case PIPE_STENCIL_OP_INVERT:
- for (j = 0; j < QUAD_SIZE; j++) {
- if (mask & (1 << j)) {
- newstencil[j] = ~stencilVals[j];
- }
- }
- break;
- default:
- assert(0);
- }
-
- /*
- * update the stencil values
- */
- if (wrtMask != STENCIL_MAX) {
- /* apply bit-wise stencil buffer writemask */
- for (j = 0; j < QUAD_SIZE; j++) {
- stencilVals[j] = (wrtMask & newstencil[j]) | (~wrtMask & stencilVals[j]);
- }
- }
- else {
- for (j = 0; j < QUAD_SIZE; j++) {
- stencilVals[j] = newstencil[j];
- }
- }
-}
-
-
-/**
- * Do stencil (and depth) testing. Stenciling depends on the outcome of
- * depth testing.
- */
-static void
-stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
-{
- struct softpipe_context *softpipe = qs->softpipe;
- struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
- unsigned func, zFailOp, zPassOp, failOp;
- 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);
- uint j;
- uint face = quad->facing;
-
- if (!softpipe->depth_stencil->stencil[1].enabled) {
- /* single-sided stencil test, use front (face=0) state */
- face = 0;
- }
-
- /* choose front or back face function, operator, etc */
- /* XXX we could do these initializations once per primitive */
- func = softpipe->depth_stencil->stencil[face].func;
- failOp = softpipe->depth_stencil->stencil[face].fail_op;
- zFailOp = softpipe->depth_stencil->stencil[face].zfail_op;
- zPassOp = softpipe->depth_stencil->stencil[face].zpass_op;
- ref = softpipe->depth_stencil->stencil[face].ref_value;
- wrtMask = softpipe->depth_stencil->stencil[face].write_mask;
- valMask = softpipe->depth_stencil->stencil[face].value_mask;
-
- assert(ps); /* shouldn't get here if there's no stencil buffer */
-
- /* get stencil values from cached tile */
- 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);
- 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);
- stencilVals[j] = tile->data.depth32[y][x] & 0xff;
- }
- break;
- case PIPE_FORMAT_U_S8:
- for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
- stencilVals[j] = tile->data.stencil8[y][x];
- }
- break;
- default:
- assert(0);
- }
-
- /* do the stencil test first */
- {
- unsigned passMask, failMask;
- passMask = do_stencil_test(stencilVals, func, ref, valMask);
- failMask = quad->mask & ~passMask;
- quad->mask &= passMask;
-
- if (failOp != PIPE_STENCIL_OP_KEEP) {
- apply_stencil_op(stencilVals, failMask, failOp, ref, wrtMask);
- }
- }
-
- if (quad->mask) {
- /* now the pixels that passed the stencil test are depth tested */
- if (softpipe->depth_stencil->depth.enabled) {
- const unsigned origMask = quad->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;
- apply_stencil_op(stencilVals, failMask, zFailOp, ref, wrtMask);
- }
-
- if (zPassOp != PIPE_STENCIL_OP_KEEP) {
- const unsigned passMask = origMask & quad->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);
- }
-
- }
-
- /* put new stencil values into cached tile */
- 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);
- uint s8z24 = tile->data.depth32[y][x];
- s8z24 = (stencilVals[j] << 24) | (s8z24 & 0xffffff);
- tile->data.depth32[y][x] = s8z24;
- }
- 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);
- uint z24s8 = tile->data.depth32[y][x];
- z24s8 = (z24s8 & 0xffffff00) | stencilVals[j];
- tile->data.depth32[y][x] = z24s8;
- }
- break;
- case PIPE_FORMAT_U_S8:
- for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
- tile->data.stencil8[y][x] = stencilVals[j];
- }
- break;
- default:
- assert(0);
- }
-
- if (quad->mask)
- qs->next->run(qs->next, quad);
-}
-
-
-static void stencil_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void stencil_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *sp_quad_stencil_test_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = stencil_begin;
- stage->run = stencil_test_quad;
- stage->destroy = stencil_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_quad_stipple.c b/src/mesa/pipe/softpipe/sp_quad_stipple.c
deleted file mode 100644
index 8660432259..0000000000
--- a/src/mesa/pipe/softpipe/sp_quad_stipple.c
+++ /dev/null
@@ -1,94 +0,0 @@
-
-/**
- * quad polygon stipple stage
- */
-
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_quad.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-
-
-/**
- * Apply polygon stipple to quads produced by triangle rasterization
- */
-static void
-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) {
- 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.cbufs[0]->height - 1 - quad->y0;
- y1 = y0 - 1;
- }
- else {
- y0 = quad->y0;
- y1 = y0 + 1;
- }
- stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
- stipple1 = softpipe->poly_stipple.stipple[y1 % 32];
-
-#if 1
- {
- const int col0 = quad->x0 % 32;
- if ((stipple0 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_LEFT;
-
- if ((stipple0 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_RIGHT;
-
- if ((stipple1 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_LEFT;
-
- if ((stipple1 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_RIGHT;
- }
-#else
- /* We'd like to use this code, but we'd need to redefine
- * MASK_TOP_LEFT to be (1 << 1) and MASK_TOP_RIGHT to be (1 << 0),
- * and similarly for the BOTTOM bits. But that may have undesirable
- * side effects elsewhere.
- */
- const int col0 = 30 - (quad->x0 % 32);
- quad->mask &= (((stipple0 >> col0) & 0x3) |
- (((stipple1 >> col0) & 0x3) << 2));
-#endif
- if (!quad->mask)
- return;
- }
-
- qs->next->run(qs->next, quad);
-}
-
-
-static void stipple_begin(struct quad_stage *qs)
-{
- qs->next->begin(qs->next);
-}
-
-
-static void stipple_destroy(struct quad_stage *qs)
-{
- FREE( qs );
-}
-
-
-struct quad_stage *
-sp_quad_polygon_stipple_stage( struct softpipe_context *softpipe )
-{
- struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
-
- stage->softpipe = softpipe;
- stage->begin = stipple_begin;
- stage->run = stipple_quad;
- stage->destroy = stipple_destroy;
-
- return stage;
-}
diff --git a/src/mesa/pipe/softpipe/sp_query.c b/src/mesa/pipe/softpipe/sp_query.c
deleted file mode 100644
index 6a8a43aeda..0000000000
--- a/src/mesa/pipe/softpipe/sp_query.c
+++ /dev/null
@@ -1,107 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/draw/draw_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_query.h"
-
-struct softpipe_query {
- uint64 start;
- uint64 end;
-};
-
-
-static struct softpipe_query *softpipe_query( struct pipe_query *p )
-{
- return (struct softpipe_query *)p;
-}
-
-static struct pipe_query *
-softpipe_create_query(struct pipe_context *pipe,
- unsigned type)
-{
- assert(type == PIPE_QUERY_OCCLUSION_COUNTER);
- return (struct pipe_query *)CALLOC_STRUCT( softpipe_query );
-}
-
-
-static void
-softpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
-{
- FREE(q);
-}
-
-
-static void
-softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
-{
- struct softpipe_context *softpipe = softpipe_context( pipe );
- struct softpipe_query *sq = softpipe_query(q);
-
- sq->start = softpipe->occlusion_count;
-}
-
-
-static void
-softpipe_end_query(struct pipe_context *pipe, struct pipe_query *q)
-{
- struct softpipe_context *softpipe = softpipe_context( pipe );
- struct softpipe_query *sq = softpipe_query(q);
-
- sq->end = softpipe->occlusion_count;
-}
-
-
-static boolean
-softpipe_get_query_result(struct pipe_context *pipe,
- struct pipe_query *q,
- boolean wait,
- uint64 *result )
-{
- struct softpipe_query *sq = softpipe_query(q);
- *result = sq->end - sq->start;
- return TRUE;
-}
-
-
-void softpipe_init_query_funcs(struct softpipe_context *softpipe )
-{
- softpipe->pipe.create_query = softpipe_create_query;
- softpipe->pipe.destroy_query = softpipe_destroy_query;
- softpipe->pipe.begin_query = softpipe_begin_query;
- softpipe->pipe.end_query = softpipe_end_query;
- softpipe->pipe.get_query_result = softpipe_get_query_result;
-}
-
-
diff --git a/src/mesa/pipe/softpipe/sp_query.h b/src/mesa/pipe/softpipe/sp_query.h
deleted file mode 100644
index 05060a4575..0000000000
--- a/src/mesa/pipe/softpipe/sp_query.h
+++ /dev/null
@@ -1,39 +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.
- *
- **************************************************************************/
-
-/* Author:
- * Keith Whitwell
- */
-
-#ifndef SP_QUERY_H
-#define SP_QUERY_H
-
-struct softpipe_context;
-extern void softpipe_init_query_funcs(struct softpipe_context * );
-
-
-#endif /* SP_QUERY_H */
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
deleted file mode 100644
index 431952f1aa..0000000000
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_STATE_H
-#define SP_STATE_H
-
-#include "pipe/p_state.h"
-
-
-#define SP_NEW_VIEWPORT 0x1
-#define SP_NEW_RASTERIZER 0x2
-#define SP_NEW_FS 0x4
-#define SP_NEW_BLEND 0x8
-#define SP_NEW_CLIP 0x10
-#define SP_NEW_SCISSOR 0x20
-#define SP_NEW_STIPPLE 0x40
-#define SP_NEW_FRAMEBUFFER 0x80
-#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
-#define SP_NEW_CONSTANTS 0x200
-#define SP_NEW_SAMPLER 0x400
-#define SP_NEW_TEXTURE 0x800
-#define SP_NEW_VERTEX 0x1000
-#define SP_NEW_VS 0x2000
-#define SP_NEW_QUERY 0x4000
-
-
-struct tgsi_sampler;
-struct tgsi_interp_coef;
-struct tgsi_exec_machine;
-
-
-/** Subclass of pipe_shader_state (though it doesn't really need to be).
- *
- * This is starting to look an awful lot like a quad pipeline stage...
- */
-struct sp_fragment_shader {
- struct pipe_shader_state shader;
-
- void (*prepare)( struct sp_fragment_shader *shader,
- struct tgsi_exec_machine *machine,
- struct tgsi_sampler *samplers);
-
- /* Run the shader - this interface will get cleaned up in the
- * future:
- */
- unsigned (*run)( struct sp_fragment_shader *shader,
- struct tgsi_exec_machine *machine,
- struct quad_header *quad );
-
-
- void (*delete)( struct sp_fragment_shader * );
-};
-
-
-/** Subclass of pipe_shader_state */
-struct sp_vertex_shader {
- struct pipe_shader_state shader;
- struct draw_vertex_shader *draw_data;
-};
-
-
-
-void *
-softpipe_create_blend_state(struct pipe_context *,
- const struct pipe_blend_state *);
-void softpipe_bind_blend_state(struct pipe_context *,
- void *);
-void softpipe_delete_blend_state(struct pipe_context *,
- void *);
-
-void *
-softpipe_create_sampler_state(struct pipe_context *,
- const struct pipe_sampler_state *);
-void softpipe_bind_sampler_state(struct pipe_context *, unsigned, void *);
-void softpipe_delete_sampler_state(struct pipe_context *, void *);
-
-void *
-softpipe_create_depth_stencil_state(struct pipe_context *,
- const struct pipe_depth_stencil_alpha_state *);
-void softpipe_bind_depth_stencil_state(struct pipe_context *, void *);
-void softpipe_delete_depth_stencil_state(struct pipe_context *, void *);
-
-void *
-softpipe_create_rasterizer_state(struct pipe_context *,
- const struct pipe_rasterizer_state *);
-void softpipe_bind_rasterizer_state(struct pipe_context *, void *);
-void softpipe_delete_rasterizer_state(struct pipe_context *, void *);
-
-void softpipe_set_framebuffer_state( struct pipe_context *,
- const struct pipe_framebuffer_state * );
-
-void softpipe_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color );
-
-void softpipe_set_clip_state( struct pipe_context *,
- const struct pipe_clip_state * );
-
-void softpipe_set_constant_buffer(struct pipe_context *,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf);
-
-void *softpipe_create_fs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void softpipe_bind_fs_state(struct pipe_context *, void *);
-void softpipe_delete_fs_state(struct pipe_context *, void *);
-void *softpipe_create_vs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void softpipe_bind_vs_state(struct pipe_context *, void *);
-void softpipe_delete_vs_state(struct pipe_context *, void *);
-
-void softpipe_set_polygon_stipple( struct pipe_context *,
- const struct pipe_poly_stipple * );
-
-void softpipe_set_scissor_state( struct pipe_context *,
- const struct pipe_scissor_state * );
-
-void softpipe_set_sampler_texture( struct pipe_context *,
- unsigned unit,
- struct pipe_texture * );
-
-void softpipe_set_viewport_state( struct pipe_context *,
- const struct pipe_viewport_state * );
-
-void softpipe_set_vertex_element(struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_element *);
-
-void softpipe_set_vertex_buffer(struct pipe_context *,
- unsigned index,
- const struct pipe_vertex_buffer *);
-
-
-void softpipe_update_derived( struct softpipe_context *softpipe );
-
-
-boolean softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count);
-
-boolean softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count);
-
-
-void
-softpipe_map_surfaces(struct softpipe_context *sp);
-
-void
-softpipe_unmap_surfaces(struct softpipe_context *sp);
-
-void
-softpipe_map_texture_surfaces(struct softpipe_context *sp);
-
-void
-softpipe_unmap_texture_surfaces(struct softpipe_context *sp);
-
-#endif
diff --git a/src/mesa/pipe/softpipe/sp_state_blend.c b/src/mesa/pipe/softpipe/sp_state_blend.c
deleted file mode 100644
index 2d40d6bd8f..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_blend.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_state.h"
-
-
-void *
-softpipe_create_blend_state(struct pipe_context *pipe,
- const struct pipe_blend_state *blend)
-{
- return mem_dup(blend, sizeof(*blend));
-}
-
-void softpipe_bind_blend_state( struct pipe_context *pipe,
- void *blend )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->blend = (const struct pipe_blend_state *)blend;
-
- softpipe->dirty |= SP_NEW_BLEND;
-}
-
-void softpipe_delete_blend_state(struct pipe_context *pipe,
- void *blend)
-{
- FREE( blend );
-}
-
-
-void softpipe_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->blend_color = *blend_color;
-
- softpipe->dirty |= SP_NEW_BLEND;
-}
-
-
-/** XXX move someday? Or consolidate all these simple state setters
- * into one file.
- */
-
-
-void *
-softpipe_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
-{
- return mem_dup(depth_stencil, sizeof(*depth_stencil));
-}
-
-void
-softpipe_bind_depth_stencil_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil;
-
- softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;
-}
-
-void
-softpipe_delete_depth_stencil_state(struct pipe_context *pipe, void *depth)
-{
- FREE( depth );
-}
diff --git a/src/mesa/pipe/softpipe/sp_state_clip.c b/src/mesa/pipe/softpipe/sp_state_clip.c
deleted file mode 100644
index 08c5f06d05..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_clip.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-#include "sp_context.h"
-#include "sp_state.h"
-#include "pipe/draw/draw_context.h"
-
-
-void softpipe_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- /* pass the clip state to the draw module */
- draw_set_clip_state(softpipe->draw, clip);
-}
-
-
-
-/* Called when driver state tracker notices changes to the viewport
- * matrix:
- */
-void softpipe_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->viewport = *viewport; /* struct copy */
- softpipe->dirty |= SP_NEW_VIEWPORT;
-
- /* pass the viewport info to the draw module */
- draw_set_viewport_state(softpipe->draw, viewport);
-
- /* Using tnl/ and vf/ modules is temporary while getting started.
- * Full pipe will have vertex shader, vertex fetch of its own.
- */
-}
-
-
-void softpipe_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- memcpy( &softpipe->scissor, scissor, sizeof(*scissor) );
- softpipe->dirty |= SP_NEW_SCISSOR;
-}
-
-
-void softpipe_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- memcpy( &softpipe->poly_stipple, stipple, sizeof(*stipple) );
- softpipe->dirty |= SP_NEW_STIPPLE;
-}
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
deleted file mode 100644
index 39c3e1afe1..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_vertex.h"
-#include "pipe/draw/draw_private.h"
-#include "sp_context.h"
-#include "sp_state.h"
-
-
-static int
-find_vs_output(const struct pipe_shader_state *vs,
- uint semantic_name,
- uint semantic_index)
-{
- uint i;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == semantic_name &&
- vs->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
- * coefficients from the post-transform vertex attributes.
- */
-static void calculate_vertex_layout( struct softpipe_context *softpipe )
-{
- const struct pipe_shader_state *vs = &softpipe->vs->shader;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
- const enum interp_mode colorInterp
- = softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
- struct vertex_info *vinfo = &softpipe->vertex_info;
- uint i;
-
- if (softpipe->vbuf) {
- /* if using the post-transform vertex buffer, tell draw_vbuf to
- * simply emit the whole post-xform vertex as-is:
- */
- struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
- vinfo_vbuf->num_attribs = 0;
- draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0);
- vinfo_vbuf->size = 4 * vs->num_outputs + sizeof(struct vertex_header)/4;
- }
-
- /*
- * Loop over fragment shader inputs, searching for the matching output
- * from the vertex shader.
- */
- vinfo->num_attribs = 0;
- for (i = 0; i < fs->num_inputs; i++) {
- int src;
- switch (fs->input_semantic_name[i]) {
- case TGSI_SEMANTIC_POSITION:
- src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
- break;
-
- case TGSI_SEMANTIC_COLOR:
- src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
- fs->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);
-#if 1
- if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
- src = 0;
-#endif
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- break;
-
- case TGSI_SEMANTIC_GENERIC:
- /* this includes texcoords and varying vars */
- src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
- fs->input_semantic_index[i]);
- assert(src >= 0);
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
- break;
-
- default:
- assert(0);
- }
- }
-
- softpipe->psize_slot = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0);
- if (softpipe->psize_slot >= 0) {
- draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
- softpipe->psize_slot);
- }
-
- draw_compute_vertex_size(vinfo);
-}
-
-
-/**
- * Recompute cliprect from scissor bounds, scissor enable and surface size.
- */
-static void
-compute_cliprect(struct softpipe_context *sp)
-{
- unsigned surfWidth, surfHeight;
-
- if (sp->framebuffer.num_cbufs > 0) {
- surfWidth = sp->framebuffer.cbufs[0]->width;
- surfHeight = sp->framebuffer.cbufs[0]->height;
- }
- else {
- /* no surface? */
- surfWidth = sp->scissor.maxx;
- surfHeight = sp->scissor.maxy;
- }
-
- if (sp->rasterizer->scissor) {
- /* clip to scissor rect */
- sp->cliprect.minx = MAX2(sp->scissor.minx, 0);
- sp->cliprect.miny = MAX2(sp->scissor.miny, 0);
- sp->cliprect.maxx = MIN2(sp->scissor.maxx, surfWidth);
- sp->cliprect.maxy = MIN2(sp->scissor.maxy, surfHeight);
- }
- else {
- /* clip to surface bounds */
- sp->cliprect.minx = 0;
- sp->cliprect.miny = 0;
- sp->cliprect.maxx = surfWidth;
- sp->cliprect.maxy = surfHeight;
- }
-}
-
-
-/* Hopefully this will remain quite simple, otherwise need to pull in
- * something like the state tracker mechanism.
- */
-void softpipe_update_derived( struct softpipe_context *softpipe )
-{
- if (softpipe->dirty & (SP_NEW_RASTERIZER |
- SP_NEW_FS |
- SP_NEW_VS))
- calculate_vertex_layout( softpipe );
-
- if (softpipe->dirty & (SP_NEW_SCISSOR |
- SP_NEW_DEPTH_STENCIL_ALPHA |
- SP_NEW_FRAMEBUFFER))
- compute_cliprect(softpipe);
-
- if (softpipe->dirty & (SP_NEW_BLEND |
- SP_NEW_DEPTH_STENCIL_ALPHA |
- SP_NEW_FRAMEBUFFER |
- SP_NEW_RASTERIZER |
- SP_NEW_FS |
- SP_NEW_QUERY))
- sp_build_quad_pipeline(softpipe);
-
- softpipe->dirty = 0;
-}
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
deleted file mode 100644
index c43f28583e..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ /dev/null
@@ -1,156 +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.
- *
- **************************************************************************/
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_fs.h"
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
-
-
-void *
-softpipe_create_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_fragment_shader *state;
-
- if (softpipe->dump_fs)
- tgsi_dump(templ->tokens, 0);
-
- state = softpipe_create_fs_llvm( softpipe, templ );
- if (state)
- return state;
-
- state = softpipe_create_fs_sse( softpipe, templ );
- if (state)
- return state;
-
- state = softpipe_create_fs_exec( softpipe, templ );
-
- assert(state);
- return state;
-}
-
-
-void
-softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->fs = (struct sp_fragment_shader *) fs;
-
- softpipe->dirty |= SP_NEW_FS;
-}
-
-
-void
-softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
-{
- struct sp_fragment_shader *state = fs;
-
- state->delete( state );
-}
-
-
-void *
-softpipe_create_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *templ)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- struct sp_vertex_shader *state;
-
- state = CALLOC_STRUCT(sp_vertex_shader);
- if (state == NULL ) {
- return NULL;
- }
-
- state->shader = *templ;
-
- state->draw_data = draw_create_vertex_shader(softpipe->draw,
- &state->shader);
- if (state->draw_data == NULL) {
- FREE( state );
- return NULL;
- }
-
- return state;
-}
-
-
-void
-softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->vs = (const struct sp_vertex_shader *)vs;
-
- draw_bind_vertex_shader(softpipe->draw, softpipe->vs->draw_data);
-
- softpipe->dirty |= SP_NEW_VS;
-}
-
-
-void
-softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- struct sp_vertex_shader *state =
- (struct sp_vertex_shader *)vs;
-
- draw_delete_vertex_shader(softpipe->draw, state->draw_data);
- FREE( state );
-}
-
-
-
-void
-softpipe_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- struct pipe_winsys *ws = pipe->winsys;
-
- assert(shader < PIPE_SHADER_TYPES);
- assert(index == 0);
-
- /* note: reference counting */
- pipe_buffer_reference(ws,
- &softpipe->constants[shader].buffer,
- buf->buffer);
- softpipe->constants[shader].size = buf->size;
-
- softpipe->dirty |= SP_NEW_CONSTANTS;
-}
diff --git a/src/mesa/pipe/softpipe/sp_state_rasterizer.c b/src/mesa/pipe/softpipe/sp_state_rasterizer.c
deleted file mode 100644
index 53755099dd..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_rasterizer.c
+++ /dev/null
@@ -1,62 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_state.h"
-#include "pipe/draw/draw_context.h"
-
-
-
-void *
-softpipe_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *rast)
-{
- return mem_dup(rast, sizeof(*rast));
-}
-
-void softpipe_bind_rasterizer_state(struct pipe_context *pipe,
- void *setup)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- /* pass-through to draw module */
- draw_set_rasterizer_state(softpipe->draw, setup);
-
- softpipe->rasterizer = (struct pipe_rasterizer_state *)setup;
-
- softpipe->dirty |= SP_NEW_RASTERIZER;
-}
-
-void softpipe_delete_rasterizer_state(struct pipe_context *pipe,
- void *rasterizer)
-{
- FREE( rasterizer );
-}
-
-
diff --git a/src/mesa/pipe/softpipe/sp_state_sampler.c b/src/mesa/pipe/softpipe/sp_state_sampler.c
deleted file mode 100644
index 6a5a643c89..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_sampler.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors:
- * Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_texture.h"
-#include "sp_tile_cache.h"
-#include "pipe/draw/draw_context.h"
-
-
-
-void *
-softpipe_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
-{
- return mem_dup(sampler, sizeof(*sampler));
-}
-
-void
-softpipe_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- draw_flush(softpipe->draw);
-
- assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->sampler[unit] = (struct pipe_sampler_state *)sampler;
-
- softpipe->dirty |= SP_NEW_SAMPLER;
-}
-
-
-void
-softpipe_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
-{
- FREE( sampler );
-}
-
-
-void
-softpipe_set_sampler_texture(struct pipe_context *pipe,
- unsigned unit,
- struct pipe_texture *texture)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- draw_flush(softpipe->draw);
-
- assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
-
- sp_tile_cache_set_texture(softpipe->tex_cache[unit], texture);
-
- softpipe->dirty |= SP_NEW_TEXTURE;
-}
-
-
-
diff --git a/src/mesa/pipe/softpipe/sp_state_surface.c b/src/mesa/pipe/softpipe/sp_state_surface.c
deleted file mode 100644
index e2c6893e9f..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_surface.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-#include "p_inlines.h"
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_surface.h"
-#include "sp_tile_cache.h"
-
-
-/**
- * XXX this might get moved someday
- * Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.
- * Here, we flush the old surfaces and update the tile cache to point to the new
- * surfaces.
- */
-void
-softpipe_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct softpipe_context *sp = softpipe_context(pipe);
- uint i;
-
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- /* check if changing cbuf */
- if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) {
- /* flush old */
- sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
-
- /* assign new */
- sp->framebuffer.cbufs[i] = fb->cbufs[i];
-
- /* update cache */
- sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]);
- }
- }
-
- sp->framebuffer.num_cbufs = fb->num_cbufs;
-
- /* zbuf changing? */
- if (sp->framebuffer.zsbuf != fb->zsbuf) {
- /* flush old */
- sp_flush_tile_cache(sp, sp->zsbuf_cache);
-
- /* assign new */
- sp->framebuffer.zsbuf = fb->zsbuf;
-
- /* update cache */
- sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);
- }
-
-#if 0
- /* XXX combined depth/stencil here */
-
- /* sbuf changing? */
- if (sp->framebuffer.sbuf != fb->sbuf) {
- /* flush old */
- sp_flush_tile_cache(sp, sp->sbuf_cache_sep);
-
- /* assign new */
- sp->framebuffer.sbuf = fb->sbuf;
-
- /* update cache */
- if (fb->sbuf != fb->zbuf) {
- /* separate stencil buf */
- sp->sbuf_cache = sp->sbuf_cache_sep;
- sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
- }
- else {
- /* combined depth/stencil */
- sp->sbuf_cache = sp->zbuf_cache;
- sp_tile_cache_set_surface(sp->sbuf_cache, fb->sbuf);
- }
- }
-#endif
-
- sp->dirty |= SP_NEW_FRAMEBUFFER;
-}
-
-
-
-
diff --git a/src/mesa/pipe/softpipe/sp_state_vertex.c b/src/mesa/pipe/softpipe/sp_state_vertex.c
deleted file mode 100644
index 09ff540ccf..0000000000
--- a/src/mesa/pipe/softpipe/sp_state_vertex.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "sp_context.h"
-#include "sp_state.h"
-#include "sp_surface.h"
-
-#include "pipe/draw/draw_context.h"
-
-
-void
-softpipe_set_vertex_element(struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_element *attrib)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- assert(index < PIPE_ATTRIB_MAX);
- softpipe->vertex_element[index] = *attrib; /* struct copy */
- softpipe->dirty |= SP_NEW_VERTEX;
-
- draw_set_vertex_element(softpipe->draw, index, attrib);
-}
-
-
-void
-softpipe_set_vertex_buffer(struct pipe_context *pipe,
- unsigned index,
- const struct pipe_vertex_buffer *buffer)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- assert(index < PIPE_ATTRIB_MAX);
- softpipe->vertex_buffer[index] = *buffer; /* struct copy */
- softpipe->dirty |= SP_NEW_VERTEX;
-
- draw_set_vertex_buffer(softpipe->draw, index, buffer);
-}
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
deleted file mode 100644
index 5c6ed3b8d9..0000000000
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ /dev/null
@@ -1,159 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "pipe/util/p_tile.h"
-#include "sp_context.h"
-#include "sp_surface.h"
-
-
-
-/* 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,
- unsigned 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->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- do_flip ? -src->pitch : src->pitch,
- srcx, do_flip ? 1 - srcy - height : 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->pitch + x) * dst->cpp;
-}
-
-
-#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_surface_map(dst);
-
- assert(dst->pitch > 0);
- assert(width <= dst->pitch);
-
-
- switch (dst->cpp) {
- case 1:
- {
- ubyte *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
- case 2:
- {
- ushort *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
- case 4:
- {
- unsigned *row = get_pointer(dst, dst_map, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
- 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->pitch * 4;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe_surface_unmap( dst );
-}
-
-
-void
-sp_init_surface_functions(struct softpipe_context *sp)
-{
- sp->pipe.surface_copy = sp_surface_copy;
- sp->pipe.surface_fill = sp_surface_fill;
-}
diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h
deleted file mode 100644
index 22de3ba43f..0000000000
--- a/src/mesa/pipe/softpipe/sp_surface.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef SP_SURFACE_H
-#define SP_SURFACE_H
-
-
-struct softpipe_context;
-
-
-extern void
-sp_init_surface_functions(struct softpipe_context *sp);
-
-
-#endif /* SP_SURFACE_H */
diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.c b/src/mesa/pipe/softpipe/sp_tex_sample.c
deleted file mode 100644
index 325bdb86da..0000000000
--- a/src/mesa/pipe/softpipe/sp_tex_sample.c
+++ /dev/null
@@ -1,916 +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.
- *
- **************************************************************************/
-
-/**
- * Texture sampling
- *
- * Authors:
- * Brian Paul
- */
-
-#include "sp_context.h"
-#include "sp_headers.h"
-#include "sp_surface.h"
-#include "sp_tex_sample.h"
-#include "sp_tile_cache.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/tgsi/exec/tgsi_exec.h"
-
-
-/*
- * Note, the FRAC macro has to work perfectly. Otherwise you'll sometimes
- * see 1-pixel bands of improperly weighted linear-filtered textures.
- * The tests/texwrap.c demo is a good test.
- * 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))
-
-
-/**
- * Linear interpolation macro
- */
-#define LERP(T, A, B) ( (A) + (T) * ((B) - (A)) )
-
-
-/**
- * Do 2D/biliner interpolation of float values.
- * v00, v10, v01 and v11 are typically four texture samples in a square/box.
- * a and b are the horizontal and vertical interpolants.
- * It's important that this function is inlined when compiled with
- * optimization! If we find that's not true on some systems, convert
- * to a macro.
- */
-static INLINE float
-lerp_2d(float a, float b,
- float v00, float v10, float v01, float v11)
-{
- const float temp0 = LERP(a, v00, v10);
- const float temp1 = LERP(a, v01, v11);
- return LERP(b, temp0, temp1);
-}
-
-
-/**
- * If A is a signed integer, A % B doesn't give the right value for A < 0
- * (in terms of texture repeat). Just casting to unsigned fixes that.
- */
-#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B))
-
-
-/**
- * Apply texture coord wrapping mode and return integer texture index.
- * \param wrapMode PIPE_TEX_WRAP_x
- * \param s the texcoord
- * \param size the texture image size
- * \return integer texture index
- */
-static INLINE int
-nearest_texcoord(unsigned wrapMode, float s, unsigned size)
-{
- int i;
- switch (wrapMode) {
- case PIPE_TEX_WRAP_REPEAT:
- /* s limited to [0,1) */
- /* i limited to [0,size-1] */
- i = ifloor(s * size);
- i = REMAINDER(i, size);
- return i;
- case PIPE_TEX_WRAP_CLAMP:
- /* s limited to [0,1] */
- /* i limited to [0,size-1] */
- if (s <= 0.0F)
- i = 0;
- else if (s >= 1.0F)
- i = size - 1;
- else
- i = ifloor(s * size);
- return i;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- {
- /* s limited to [min,max] */
- /* i limited to [0, size-1] */
- const float min = 1.0F / (2.0F * size);
- const float max = 1.0F - min;
- if (s < min)
- i = 0;
- else if (s > max)
- i = size - 1;
- else
- i = ifloor(s * size);
- }
- return i;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- {
- /* s limited to [min,max] */
- /* i limited to [-1, size] */
- const float min = -1.0F / (2.0F * size);
- const float max = 1.0F - min;
- if (s <= min)
- i = -1;
- else if (s >= max)
- i = size;
- else
- i = 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);
- float u;
- if (flr & 1)
- u = 1.0F - (s - (float) flr);
- else
- u = s - (float) flr;
- if (u < min)
- i = 0;
- else if (u > max)
- i = size - 1;
- else
- i = 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);
- if (u <= 0.0F)
- i = 0;
- else if (u >= 1.0F)
- i = size - 1;
- else
- i = ifloor(u * size);
- }
- return i;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- {
- /* s limited to [min,max] */
- /* 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);
- if (u < min)
- i = 0;
- else if (u > max)
- i = size - 1;
- else
- i = ifloor(u * size);
- }
- return i;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- {
- /* s limited to [min,max] */
- /* 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);
- if (u < min)
- i = -1;
- else if (u > max)
- i = size;
- else
- i = ifloor(u * size);
- }
- return i;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-/**
- * Used to compute texel locations for linear sampling.
- * \param wrapMode PIPE_TEX_WRAP_x
- * \param s the texcoord
- * \param size the texture image size
- * \param i0 returns first texture index
- * \param i1 returns second texture index (usually *i0 + 1)
- * \param a returns blend factor/weight between texture indexes
- */
-static INLINE void
-linear_texcoord(unsigned wrapMode, float s, unsigned size,
- int *i0, int *i1, float *a)
-{
- float u;
- switch (wrapMode) {
- case PIPE_TEX_WRAP_REPEAT:
- u = s * size - 0.5F;
- *i0 = REMAINDER(ifloor(u), size);
- *i1 = REMAINDER(*i0 + 1, size);
- break;
- case PIPE_TEX_WRAP_CLAMP:
- if (s <= 0.0F)
- u = 0.0F;
- else if (s >= 1.0F)
- u = (float) size;
- else
- u = s * size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
- if (s <= 0.0F)
- u = 0.0F;
- else if (s >= 1.0F)
- u = (float) size;
- else
- u = s * size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- if (*i0 < 0)
- *i0 = 0;
- if (*i1 >= (int) size)
- *i1 = size - 1;
- break;
- case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
- {
- const float min = -1.0F / (2.0F * size);
- const float max = 1.0F - min;
- if (s <= min)
- u = min * size;
- else if (s >= max)
- u = max * size;
- else
- u = s * size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- }
- break;
- case PIPE_TEX_WRAP_MIRROR_REPEAT:
- {
- const int flr = ifloor(s);
- if (flr & 1)
- u = 1.0F - (s - (float) flr);
- else
- u = s - (float) flr;
- u = (u * size) - 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- if (*i0 < 0)
- *i0 = 0;
- if (*i1 >= (int) size)
- *i1 = size - 1;
- }
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP:
- u = FABSF(s);
- if (u >= 1.0F)
- u = (float) size;
- else
- u *= size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- u = FABSF(s);
- if (u >= 1.0F)
- u = (float) size;
- else
- u *= size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- if (*i0 < 0)
- *i0 = 0;
- if (*i1 >= (int) size)
- *i1 = size - 1;
- break;
- case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
- {
- const float min = -1.0F / (2.0F * size);
- const float max = 1.0F - min;
- u = FABSF(s);
- if (u <= min)
- u = min * size;
- else if (u >= max)
- u = max * size;
- else
- u *= size;
- u -= 0.5F;
- *i0 = ifloor(u);
- *i1 = *i0 + 1;
- }
- break;
- default:
- assert(0);
- }
- *a = FRAC(u);
-}
-
-
-static unsigned
-choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
-{
- /*
- major axis
- direction target sc tc ma
- ---------- ------------------------------- --- --- ---
- +rx TEXTURE_CUBE_MAP_POSITIVE_X_EXT -rz -ry rx
- -rx TEXTURE_CUBE_MAP_NEGATIVE_X_EXT +rz -ry rx
- +ry TEXTURE_CUBE_MAP_POSITIVE_Y_EXT +rx +rz ry
- -ry TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT +rx -rz ry
- +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);
- unsigned face;
- float sc, tc, ma;
-
- if (arx > ary && arx > arz) {
- if (rx >= 0.0F) {
- face = PIPE_TEX_FACE_POS_X;
- sc = -rz;
- tc = -ry;
- ma = arx;
- }
- else {
- face = PIPE_TEX_FACE_NEG_X;
- sc = rz;
- tc = -ry;
- ma = arx;
- }
- }
- else if (ary > arx && ary > arz) {
- if (ry >= 0.0F) {
- face = PIPE_TEX_FACE_POS_Y;
- sc = rx;
- tc = rz;
- ma = ary;
- }
- else {
- face = PIPE_TEX_FACE_NEG_Y;
- sc = rx;
- tc = -rz;
- ma = ary;
- }
- }
- else {
- if (rz > 0.0F) {
- face = PIPE_TEX_FACE_POS_Z;
- sc = rx;
- tc = -ry;
- ma = arz;
- }
- else {
- face = PIPE_TEX_FACE_NEG_Z;
- sc = -rx;
- tc = -ry;
- ma = arz;
- }
- }
-
- *newS = ( sc / ma + 1.0F ) * 0.5F;
- *newT = ( tc / ma + 1.0F ) * 0.5F;
-
- return face;
-}
-
-
-/**
- * Examine the quad's texture coordinates to compute the partial
- * derivatives w.r.t X and Y, then compute lambda (level of detail).
- *
- * This is only done for fragment shaders, not vertex shaders.
- */
-static float
-compute_lambda(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias)
-{
- float rho, lambda;
-
- assert(s);
- {
- 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);
- rho = MAX2(dsdx, dsdy);
- if (sampler->state->normalized_coords)
- rho *= 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);
- max = MAX2(dtdx, dtdy);
- if (sampler->state->normalized_coords)
- max *= sampler->texture->height[0];
- rho = MAX2(rho, max);
- }
- if (p) {
- 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);
- max = MAX2(dpdx, dpdy);
- if (sampler->state->normalized_coords)
- max *= sampler->texture->depth[0];
- rho = MAX2(rho, max);
- }
-
- lambda = LOG2(rho);
- lambda += lodbias + sampler->state->lod_bias;
- lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
-
- return lambda;
-}
-
-
-/**
- * Do several things here:
- * 1. Compute lambda from the texcoords, if needed
- * 2. Determine if we're minifying or magnifying
- * 3. If minifying, choose mipmap levels
- * 4. Return image filter to use within mipmap images
- */
-static void
-choose_mipmap_levels(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- unsigned *level0, unsigned *level1, float *levelBlend,
- unsigned *imgFilter)
-{
- if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE) {
- /* no mipmap selection needed */
- *imgFilter = sampler->state->mag_img_filter;
- *level0 = *level1 = (int) sampler->state->min_lod;
- }
- else {
- float lambda;
-
- if (1)
- /* fragment shader */
- lambda = compute_lambda(sampler, s, t, p, lodbias);
- else
- /* vertex shader */
- lambda = lodbias; /* not really a bias, but absolute LOD */
-
- if (lambda < 0.0) { /* XXX threshold depends on the filter */
- /* magnifying */
- *imgFilter = sampler->state->mag_img_filter;
- *level0 = *level1 = 0;
- }
- else {
- /* minifying */
- *imgFilter = sampler->state->min_img_filter;
-
- /* choose mipmap level(s) and compute the blend factor between them */
- if (sampler->state->min_mip_filter == PIPE_TEX_MIPFILTER_NEAREST) {
- /* Nearest mipmap level */
- const int lvl = (int) (lambda + 0.5);
- *level0 =
- *level1 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
- }
- else {
- /* Linear interpolation between mipmap levels */
- const int lvl = (int) lambda;
- *level0 = CLAMP(lvl, 0, (int) sampler->texture->last_level);
- *level1 = CLAMP(lvl + 1, 0, (int) sampler->texture->last_level);
- *levelBlend = FRAC(lambda); /* blending weight between levels */
- }
- }
- }
-}
-
-
-/**
- * Get a texel from a texture, using the texture tile cache.
- *
- * \param face the cube face in 0..5
- * \param level the mipmap level
- * \param x the x coord of texel within 2D image
- * \param y the y coord of texel within 2D image
- * \param z which slice of a 3D texture
- * \param rgba the quad to put the texel/color into
- * \param j which element of the rgba quad to write to
- *
- * XXX maybe move this into sp_tile_cache.c and merge with the
- * sp_get_cached_tile_tex() function. Also, get 4 texels instead of 1...
- */
-static void
-get_texel(struct tgsi_sampler *sampler,
- unsigned face, unsigned level, int x, int y, int z,
- float rgba[NUM_CHANNELS][QUAD_SIZE], unsigned j)
-{
- const int tx = x % TILE_SIZE;
- const int ty = y % TILE_SIZE;
- const struct softpipe_cached_tile *tile
- = sp_get_cached_tile_tex(sampler->pipe, sampler->cache,
- x, y, z, face, level);
- rgba[0][j] = tile->data.color[ty][tx][0];
- rgba[1][j] = tile->data.color[ty][tx][1];
- rgba[2][j] = tile->data.color[ty][tx][2];
- rgba[3][j] = tile->data.color[ty][tx][3];
-}
-
-
-/**
- * Compare texcoord 'p' (aka R) against texture value 'rgba[0]'
- * When we sampled the depth texture, the depth value was put into all
- * RGBA channels. We look at the red channel here.
- */
-static INLINE void
-shadow_compare(uint compare_func,
- float rgba[NUM_CHANNELS][QUAD_SIZE],
- const float p[QUAD_SIZE],
- uint j)
-{
- int k;
- switch (compare_func) {
- case PIPE_FUNC_LESS:
- k = p[j] < rgba[0][j];
- break;
- case PIPE_FUNC_LEQUAL:
- k = p[j] <= rgba[0][j];
- break;
- case PIPE_FUNC_GREATER:
- k = p[j] > rgba[0][j];
- break;
- case PIPE_FUNC_GEQUAL:
- k = p[j] >= rgba[0][j];
- break;
- case PIPE_FUNC_EQUAL:
- k = p[j] == rgba[0][j];
- break;
- case PIPE_FUNC_NOTEQUAL:
- k = p[j] != rgba[0][j];
- break;
- case PIPE_FUNC_ALWAYS:
- k = 1;
- break;
- case PIPE_FUNC_NEVER:
- k = 0;
- break;
- default:
- assert(0);
- }
-
- rgba[0][j] = rgba[1][j] = rgba[2][j] = (float) k;
-}
-
-
-/**
- * Common code for sampling 1D/2D/cube textures.
- * Could probably extend for 3D...
- */
-static void
-sp_get_samples_2d_common(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE],
- const unsigned faces[4])
-{
- const uint compare_func = sampler->state->compare_func;
- unsigned level0, level1, j, imgFilter;
- int width, height;
- float levelBlend;
-
- choose_mipmap_levels(sampler, s, t, p, lodbias,
- &level0, &level1, &levelBlend, &imgFilter);
-
- if (sampler->state->normalized_coords) {
- width = sampler->texture->width[level0];
- height = sampler->texture->height[level0];
- }
- else {
- width = height = 1;
- }
-
- assert(width > 0);
-
- switch (imgFilter) {
- case PIPE_TEX_FILTER_NEAREST:
- for (j = 0; j < QUAD_SIZE; j++) {
- int x = nearest_texcoord(sampler->state->wrap_s, s[j], width);
- int y = nearest_texcoord(sampler->state->wrap_t, t[j], height);
- get_texel(sampler, faces[j], level0, x, y, 0, rgba, j);
- if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- shadow_compare(compare_func, rgba, p, j);
- }
-
- if (level0 != level1) {
- /* get texels from second mipmap level and blend */
- float rgba2[4][4];
- unsigned c;
- x = x / 2;
- y = y / 2;
- get_texel(sampler, faces[j], level1, x, y, 0, rgba2, j);
- if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE){
- shadow_compare(compare_func, rgba2, p, j);
- }
-
- for (c = 0; c < NUM_CHANNELS; c++) {
- rgba[c][j] = LERP(levelBlend, rgba[c][j], rgba2[c][j]);
- }
- }
- }
- break;
- case PIPE_TEX_FILTER_LINEAR:
- for (j = 0; j < QUAD_SIZE; j++) {
- float tx[4][4], a, b;
- int x0, y0, x1, y1, c;
- linear_texcoord(sampler->state->wrap_s, s[j], width, &x0, &x1, &a);
- linear_texcoord(sampler->state->wrap_t, t[j], height, &y0, &y1, &b);
- get_texel(sampler, faces[j], level0, x0, y0, 0, tx, 0);
- get_texel(sampler, faces[j], level0, x1, y0, 0, tx, 1);
- get_texel(sampler, faces[j], level0, x0, y1, 0, tx, 2);
- get_texel(sampler, faces[j], level0, x1, y1, 0, tx, 3);
- if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
- shadow_compare(compare_func, tx, p, 0);
- shadow_compare(compare_func, tx, p, 1);
- shadow_compare(compare_func, tx, p, 2);
- shadow_compare(compare_func, tx, p, 3);
- }
-
- for (c = 0; c < 4; c++) {
- rgba[c][j] = lerp_2d(a, b, tx[c][0], tx[c][1], tx[c][2], tx[c][3]);
- }
-
- if (level0 != level1) {
- /* get texels from second mipmap level and blend */
- float rgba2[4][4];
- x0 = x0 / 2;
- y0 = y0 / 2;
- x1 = x1 / 2;
- y1 = y1 / 2;
- get_texel(sampler, faces[j], level1, x0, y0, 0, tx, 0);
- get_texel(sampler, faces[j], level1, x1, y0, 0, tx, 1);
- get_texel(sampler, faces[j], level1, x0, y1, 0, tx, 2);
- get_texel(sampler, faces[j], level1, x1, y1, 0, tx, 3);
- if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE){
- shadow_compare(compare_func, tx, p, 0);
- shadow_compare(compare_func, tx, p, 1);
- shadow_compare(compare_func, tx, p, 2);
- shadow_compare(compare_func, tx, p, 3);
- }
-
- for (c = 0; c < 4; c++) {
- rgba2[c][j] = lerp_2d(a, b,
- tx[c][0], tx[c][1], tx[c][2], tx[c][3]);
- }
-
- for (c = 0; c < NUM_CHANNELS; c++) {
- rgba[c][j] = LERP(levelBlend, rgba[c][j], rgba2[c][j]);
- }
- }
- }
- break;
- default:
- assert(0);
- }
-}
-
-
-static void
-sp_get_samples_1d(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE])
-{
- static const unsigned faces[4] = {0, 0, 0, 0};
- static const float tzero[4] = {0, 0, 0, 0};
- sp_get_samples_2d_common(sampler, s, tzero, NULL, lodbias, rgba, faces);
-}
-
-
-static void
-sp_get_samples_2d(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE])
-{
- static const unsigned faces[4] = {0, 0, 0, 0};
- sp_get_samples_2d_common(sampler, s, t, p, lodbias, rgba, faces);
-}
-
-
-static void
-sp_get_samples_3d(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE])
-{
- /* get/map pipe_surfaces corresponding to 3D tex slices */
- unsigned level0, level1, j, imgFilter;
- int width, height, depth;
- float levelBlend;
- const uint face = 0;
-
- choose_mipmap_levels(sampler, s, t, p, lodbias,
- &level0, &level1, &levelBlend, &imgFilter);
-
- if (sampler->state->normalized_coords) {
- width = sampler->texture->width[level0];
- height = sampler->texture->height[level0];
- depth = sampler->texture->depth[level0];
- }
- else {
- width = height = depth = 1;
- }
-
- assert(width > 0);
- assert(height > 0);
- assert(depth > 0);
-
- switch (imgFilter) {
- case PIPE_TEX_FILTER_NEAREST:
- for (j = 0; j < QUAD_SIZE; j++) {
- int x = nearest_texcoord(sampler->state->wrap_s, s[j], width);
- int y = nearest_texcoord(sampler->state->wrap_t, t[j], height);
- int z = nearest_texcoord(sampler->state->wrap_r, p[j], depth);
- get_texel(sampler, face, level0, x, y, z, rgba, j);
-
- if (level0 != level1) {
- /* get texels from second mipmap level and blend */
- float rgba2[4][4];
- unsigned c;
- x /= 2;
- y /= 2;
- z /= 2;
- get_texel(sampler, face, level1, x, y, z, rgba2, j);
- for (c = 0; c < NUM_CHANNELS; c++) {
- rgba[c][j] = LERP(levelBlend, rgba2[c][j], rgba[c][j]);
- }
- }
- }
- break;
- case PIPE_TEX_FILTER_LINEAR:
- for (j = 0; j < QUAD_SIZE; j++) {
- float texel0[4][4], texel1[4][4];
- float xw, yw, zw; /* interpolation weights */
- int x0, x1, y0, y1, z0, z1, c;
- linear_texcoord(sampler->state->wrap_s, s[j], width, &x0, &x1, &xw);
- linear_texcoord(sampler->state->wrap_t, t[j], height, &y0, &y1, &yw);
- linear_texcoord(sampler->state->wrap_r, p[j], depth, &z0, &z1, &zw);
- get_texel(sampler, face, level0, x0, y0, z0, texel0, 0);
- get_texel(sampler, face, level0, x1, y0, z0, texel0, 1);
- get_texel(sampler, face, level0, x0, y1, z0, texel0, 2);
- get_texel(sampler, face, level0, x1, y1, z0, texel0, 3);
- get_texel(sampler, face, level0, x0, y0, z1, texel1, 0);
- get_texel(sampler, face, level0, x1, y0, z1, texel1, 1);
- get_texel(sampler, face, level0, x0, y1, z1, texel1, 2);
- get_texel(sampler, face, level0, x1, y1, z1, texel1, 3);
-
- /* 3D lerp */
- for (c = 0; c < 4; c++) {
- float ctemp0[4][4], ctemp1[4][4];
- ctemp0[c][j] = lerp_2d(xw, yw,
- texel0[c][0], texel0[c][1],
- texel0[c][2], texel0[c][3]);
- ctemp1[c][j] = lerp_2d(xw, yw,
- texel1[c][0], texel1[c][1],
- texel1[c][2], texel1[c][3]);
- rgba[c][j] = LERP(zw, ctemp0[c][j], ctemp1[c][j]);
- }
-
- if (level0 != level1) {
- /* get texels from second mipmap level and blend */
- float rgba2[4][4];
- x0 /= 2;
- y0 /= 2;
- z0 /= 2;
- x1 /= 2;
- y1 /= 2;
- z1 /= 2;
- get_texel(sampler, face, level1, x0, y0, z0, texel0, 0);
- get_texel(sampler, face, level1, x1, y0, z0, texel0, 1);
- get_texel(sampler, face, level1, x0, y1, z0, texel0, 2);
- get_texel(sampler, face, level1, x1, y1, z0, texel0, 3);
- get_texel(sampler, face, level1, x0, y0, z1, texel1, 0);
- get_texel(sampler, face, level1, x1, y0, z1, texel1, 1);
- get_texel(sampler, face, level1, x0, y1, z1, texel1, 2);
- get_texel(sampler, face, level1, x1, y1, z1, texel1, 3);
-
- /* 3D lerp */
- for (c = 0; c < 4; c++) {
- float ctemp0[4][4], ctemp1[4][4];
- ctemp0[c][j] = lerp_2d(xw, yw,
- texel0[c][0], texel0[c][1],
- texel0[c][2], texel0[c][3]);
- ctemp1[c][j] = lerp_2d(xw, yw,
- texel1[c][0], texel1[c][1],
- texel1[c][2], texel1[c][3]);
- rgba2[c][j] = LERP(zw, ctemp0[c][j], ctemp1[c][j]);
- }
-
- /* blend mipmap levels */
- for (c = 0; c < NUM_CHANNELS; c++) {
- rgba[c][j] = LERP(levelBlend, rgba[c][j], rgba2[c][j]);
- }
- }
- }
- break;
- default:
- assert(0);
- }
-}
-
-
-static void
-sp_get_samples_cube(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE])
-{
- unsigned faces[QUAD_SIZE], j;
- float ssss[4], tttt[4];
- for (j = 0; j < QUAD_SIZE; j++) {
- faces[j] = choose_cube_face(s[j], t[j], p[j], ssss + j, tttt + j);
- }
- sp_get_samples_2d_common(sampler, ssss, tttt, NULL, lodbias, rgba, faces);
-}
-
-
-/**
- * Called via tgsi_sampler::get_samples()
- * Use the sampler's state setting to get a filtered RGBA value
- * from the sampler's texture.
- *
- * XXX we can implement many versions of this function, each
- * tightly coded for a specific combination of sampler state
- * (nearest + repeat), (bilinear mipmap + clamp), etc.
- *
- * The update_samplers() function in st_atom_sampler.c could create
- * a new tgsi_sampler object for each state combo it finds....
- */
-void
-sp_get_samples(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE])
-{
- if (!sampler->texture)
- return;
-
- switch (sampler->texture->target) {
- case PIPE_TEXTURE_1D:
- sp_get_samples_1d(sampler, s, t, p, lodbias, rgba);
- break;
- case PIPE_TEXTURE_2D:
- sp_get_samples_2d(sampler, s, t, p, lodbias, rgba);
- break;
- case PIPE_TEXTURE_3D:
- sp_get_samples_3d(sampler, s, t, p, lodbias, rgba);
- break;
- case PIPE_TEXTURE_CUBE:
- sp_get_samples_cube(sampler, s, t, p, lodbias, rgba);
- break;
- default:
- assert(0);
- }
-}
-
diff --git a/src/mesa/pipe/softpipe/sp_tex_sample.h b/src/mesa/pipe/softpipe/sp_tex_sample.h
deleted file mode 100644
index 404bfd0c36..0000000000
--- a/src/mesa/pipe/softpipe/sp_tex_sample.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef SP_TEX_SAMPLE_H
-#define SP_TEX_SAMPLE_H
-
-
-struct tgsi_sampler;
-
-
-extern void
-sp_get_samples(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE]);
-
-
-#endif /* SP_TEX_SAMPLE_H */
diff --git a/src/mesa/pipe/softpipe/sp_texture.c b/src/mesa/pipe/softpipe/sp_texture.c
deleted file mode 100644
index 6de7a9b543..0000000000
--- a/src/mesa/pipe/softpipe/sp_texture.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Michel Dänzer <michel@tungstengraphics.com>
- */
-
-#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 "sp_context.h"
-#include "sp_state.h"
-#include "sp_texture.h"
-
-
-/* Simple, maximally packed layout.
- */
-
-static unsigned minify( unsigned d )
-{
- return MAX2(1, d>>1);
-}
-
-
-static void
-softpipe_texture_layout(struct softpipe_texture * spt)
-{
- struct pipe_texture *pt = &spt->base;
- unsigned level;
- unsigned width = pt->width[0];
- unsigned height = pt->height[0];
- unsigned depth = pt->depth[0];
-
- spt->buffer_size = 0;
-
- for (level = 0; level <= pt->last_level; level++) {
- pt->width[level] = width;
- pt->height[level] = height;
- pt->depth[level] = depth;
-
- spt->level_offset[level] = spt->buffer_size;
-
- spt->buffer_size += ((pt->compressed) ? MAX2(1, height/4) : height) *
- ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
- width * pt->cpp;
-
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
- }
-}
-
-
-struct pipe_texture *
-softpipe_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
-{
- struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
- if (!spt)
- return NULL;
-
- spt->base = *templat;
-
- softpipe_texture_layout(spt);
-
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
- if (!spt->buffer) {
- FREE(spt);
- return NULL;
- }
-
- return &spt->base;
-}
-
-
-void
-softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
-{
- if (!*pt)
- return;
-
- /*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
- */
- if (--(*pt)->refcount <= 0) {
- struct softpipe_texture *spt = softpipe_texture(*pt);
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
- */
-
- pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
-
- FREE(spt);
- }
- *pt = NULL;
-}
-
-
-/**
- * Called via pipe->get_tex_surface()
- */
-struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
-{
- struct softpipe_texture *spt = softpipe_texture(pt);
- struct pipe_surface *ps;
-
- assert(level <= pt->last_level);
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->refcount);
- assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = ps->width;
- ps->offset = spt->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
- ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
- (pt->compressed ? ps->height/4 : ps->height) *
- ps->width * ps->cpp;
- } else {
- assert(face == 0);
- assert(zslice == 0);
- }
- }
- return ps;
-}
diff --git a/src/mesa/pipe/softpipe/sp_texture.h b/src/mesa/pipe/softpipe/sp_texture.h
deleted file mode 100644
index fa646c0de9..0000000000
--- a/src/mesa/pipe/softpipe/sp_texture.h
+++ /dev/null
@@ -1,71 +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 SP_TEXTURE_H
-#define SP_TEXTURE_H
-
-
-struct pipe_context;
-struct pipe_texture;
-
-
-struct softpipe_texture
-{
- struct pipe_texture base;
-
- unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
-
- /* The data is held here:
- */
- struct pipe_buffer *buffer;
- unsigned long buffer_size;
-};
-
-
-/** cast wrapper */
-static INLINE struct softpipe_texture *
-softpipe_texture(struct pipe_texture *pt)
-{
- return (struct softpipe_texture *) pt;
-}
-
-
-
-extern struct pipe_texture *
-softpipe_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
-extern void
-softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-extern struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice);
-
-
-#endif /* SP_TEXTURE */
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
deleted file mode 100644
index 1597361b82..0000000000
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ /dev/null
@@ -1,585 +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.
- *
- **************************************************************************/
-
-/**
- * Framebuffer/surface tile caching.
- *
- * Author:
- * Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/util/p_tile.h"
-#include "sp_context.h"
-#include "sp_surface.h"
-#include "sp_tile_cache.h"
-
-#define NUM_ENTRIES 30
-
-
-/** XXX move these */
-#define MAX_WIDTH 2048
-#define MAX_HEIGHT 2048
-
-
-struct softpipe_tile_cache
-{
- struct pipe_surface *surface; /**< the surface we're caching */
- void *surface_map;
- struct pipe_texture *texture; /**< if caching a texture */
- struct softpipe_cached_tile entries[NUM_ENTRIES];
- uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32];
- float clear_color[4];
- uint clear_val;
- boolean depth_stencil; /** Is the surface a depth/stencil format? */
-
- struct pipe_surface *tex_surf;
- void *tex_surf_map;
- int tex_face, tex_level, tex_z;
-
- struct softpipe_cached_tile tile; /**< scratch tile for clears */
-};
-
-
-/**
- * Return the position in the cache for the tile that contains win pos (x,y).
- * We currently use a direct mapped cache so this is like a hack key.
- * At some point we should investige something more sophisticated, like
- * a LRU replacement policy.
- */
-#define CACHE_POS(x, y) \
- (((x) / TILE_SIZE + ((y) / TILE_SIZE) * 5) % NUM_ENTRIES)
-
-
-
-/**
- * Is the tile at (x,y) in cleared state?
- */
-static INLINE uint
-is_clear_flag_set(const uint *bitvec, int x, int y)
-{
- int pos, bit;
- x /= TILE_SIZE;
- y /= TILE_SIZE;
- pos = y * (MAX_WIDTH / TILE_SIZE) + x;
- assert(pos / 32 < (MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32);
- bit = bitvec[pos / 32] & (1 << (pos & 31));
- return bit;
-}
-
-
-/**
- * Mark the tile at (x,y) as not cleared.
- */
-static INLINE void
-clear_clear_flag(uint *bitvec, int x, int y)
-{
- int pos;
- x /= TILE_SIZE;
- y /= TILE_SIZE;
- pos = y * (MAX_WIDTH / TILE_SIZE) + x;
- assert(pos / 32 < (MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32);
- bitvec[pos / 32] &= ~(1 << (pos & 31));
-}
-
-
-struct softpipe_tile_cache *
-sp_create_tile_cache(void)
-{
- struct softpipe_tile_cache *tc;
- uint pos;
-
- tc = CALLOC_STRUCT( softpipe_tile_cache );
- if (tc) {
- for (pos = 0; pos < NUM_ENTRIES; pos++) {
- tc->entries[pos].x =
- tc->entries[pos].y = -1;
- }
- }
- return tc;
-}
-
-
-void
-sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
-{
- uint pos;
-
- for (pos = 0; pos < NUM_ENTRIES; pos++) {
- //assert(tc->entries[pos].x < 0);
- }
- if (tc->surface) {
- pipe_surface_reference(&tc->surface, NULL);
- }
- if (tc->tex_surf) {
- pipe_surface_reference(&tc->tex_surf, NULL);
- }
-
- FREE( tc );
-}
-
-
-/**
- * Specify the surface to cache.
- */
-void
-sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
- struct pipe_surface *ps)
-{
- assert(!tc->texture);
-
- if (tc->surface_map) {
- /*assert(tc->surface != ps);*/
- pipe_surface_unmap(tc->surface);
- }
-
- pipe_surface_reference(&tc->surface, ps);
-
- if (ps) {
- if (tc->surface_map)
- tc->surface_map = pipe_surface_map(ps);
-
- tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
- ps->format == PIPE_FORMAT_Z16_UNORM ||
- ps->format == PIPE_FORMAT_Z32_UNORM ||
- ps->format == PIPE_FORMAT_U_S8);
- }
-}
-
-
-/**
- * Return the surface being cached.
- */
-struct pipe_surface *
-sp_tile_cache_get_surface(struct softpipe_tile_cache *tc)
-{
- return tc->surface;
-}
-
-
-void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc)
-{
- if (tc->surface && !tc->surface_map)
- tc->surface_map = pipe_surface_map(tc->surface);
-
- if (tc->tex_surf && !tc->tex_surf_map)
- tc->tex_surf_map = pipe_surface_map(tc->tex_surf);
-}
-
-
-void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc)
-{
- if (tc->surface_map) {
- pipe_surface_unmap(tc->surface);
- tc->surface_map = NULL;
- }
-
- if (tc->tex_surf_map) {
- pipe_surface_unmap(tc->tex_surf);
- tc->tex_surf_map = NULL;
- }
-}
-
-
-/**
- * Specify the texture to cache.
- */
-void
-sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
- struct pipe_texture *texture)
-{
- uint i;
-
- assert(!tc->surface);
-
- tc->texture = texture;
-
- if (tc->tex_surf_map) {
- pipe_surface_unmap(tc->tex_surf);
- tc->tex_surf_map = NULL;
- }
- pipe_surface_reference(&tc->tex_surf, NULL);
-
- /* mark as entries as invalid/empty */
- /* XXX we should try to avoid this when the teximage hasn't changed */
- for (i = 0; i < NUM_ENTRIES; i++) {
- tc->entries[i].x = -1;
- }
-
- tc->tex_face = -1; /* any invalid value here */
-}
-
-
-/**
- * Set pixels in a tile to the given clear color/value, float.
- */
-static void
-clear_tile_rgba(struct softpipe_cached_tile *tile,
- enum pipe_format format,
- const float clear_value[4])
-{
- if (clear_value[0] == 0.0 &&
- clear_value[1] == 0.0 &&
- clear_value[2] == 0.0 &&
- clear_value[3] == 0.0) {
- memset(tile->data.color, 0, sizeof(tile->data.color));
- }
- else {
- uint i, j;
- for (i = 0; i < TILE_SIZE; i++) {
- for (j = 0; j < TILE_SIZE; j++) {
- tile->data.color[i][j][0] = clear_value[0];
- tile->data.color[i][j][1] = clear_value[1];
- tile->data.color[i][j][2] = clear_value[2];
- tile->data.color[i][j][3] = clear_value[3];
- }
- }
- }
-}
-
-
-/**
- * Set a tile to a solid value/color.
- */
-static void
-clear_tile(struct softpipe_cached_tile *tile,
- enum pipe_format format,
- uint clear_value)
-{
- uint i, j;
-
- switch (pf_get_size(format)) {
- case 1:
- memset(tile->data.any, 0, TILE_SIZE * TILE_SIZE);
- break;
- case 2:
- if (clear_value == 0) {
- memset(tile->data.any, 0, 2 * TILE_SIZE * TILE_SIZE);
- }
- else {
- for (i = 0; i < TILE_SIZE; i++) {
- for (j = 0; j < TILE_SIZE; j++) {
- tile->data.depth16[i][j] = (ushort) clear_value;
- }
- }
- }
- break;
- case 4:
- if (clear_value == 0) {
- memset(tile->data.any, 0, 4 * TILE_SIZE * TILE_SIZE);
- }
- else {
- for (i = 0; i < TILE_SIZE; i++) {
- for (j = 0; j < TILE_SIZE; j++) {
- tile->data.color32[i][j] = clear_value;
- }
- }
- }
- break;
- default:
- assert(0);
- }
-}
-
-
-/**
- * Actually clear the tiles which were flagged as being in a clear state.
- */
-static void
-sp_tile_cache_flush_clear(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc)
-{
- struct pipe_surface *ps = tc->surface;
- const uint w = tc->surface->width;
- const uint h = tc->surface->height;
- uint x, y;
- uint numCleared = 0;
-
- /* clear the scratch tile to the clear value */
- clear_tile(&tc->tile, ps->format, tc->clear_val);
-
- /* push the tile to all positions marked as clear */
- for (y = 0; y < h; y += TILE_SIZE) {
- for (x = 0; x < w; x += TILE_SIZE) {
- if (is_clear_flag_set(tc->clear_flags, x, y)) {
- pipe_put_tile_raw(pipe, ps,
- x, y, TILE_SIZE, TILE_SIZE,
- tc->tile.data.color32, 0/*STRIDE*/);
-
- /* do this? */
- clear_clear_flag(tc->clear_flags, x, y);
-
- numCleared++;
- }
- }
- }
-#if 0
- debug_printf("num cleared: %u\n", numCleared);
-#endif
-}
-
-
-/**
- * Flush the tile cache: write all dirty tiles back to the surface.
- * any tiles "flagged" as cleared will be "really" cleared.
- */
-void
-sp_flush_tile_cache(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc)
-{
- struct pipe_context *pipe = &softpipe->pipe;
- struct pipe_surface *ps = tc->surface;
- int inuse = 0, pos;
-
- if (!ps || !ps->buffer)
- return;
-
- for (pos = 0; pos < NUM_ENTRIES; pos++) {
- struct softpipe_cached_tile *tile = tc->entries + pos;
- if (tile->x >= 0) {
- if (tc->depth_stencil) {
- pipe_put_tile_raw(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32, 0/*STRIDE*/);
- }
- else {
- pipe_put_tile_rgba(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
- }
- tile->x = tile->y = -1; /* mark as empty */
- inuse++;
- }
- }
-
-#if TILE_CLEAR_OPTIMIZATION
- sp_tile_cache_flush_clear(&softpipe->pipe, tc);
-#endif
-
-#if 0
- debug_printf("flushed tiles in use: %d\n", inuse);
-#endif
-}
-
-
-/**
- * Get a tile from the cache.
- * \param x, y position of tile, in pixels
- */
-struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc, int x, int y)
-{
- struct pipe_context *pipe = &softpipe->pipe;
- struct pipe_surface *ps = tc->surface;
-
- /* tile pos in framebuffer: */
- const int tile_x = x & ~(TILE_SIZE - 1);
- const int tile_y = y & ~(TILE_SIZE - 1);
-
- /* cache pos/entry: */
- const int pos = CACHE_POS(x, y);
- struct softpipe_cached_tile *tile = tc->entries + pos;
-
- if (tile_x != tile->x ||
- tile_y != tile->y) {
-
- if (tile->x != -1) {
- /* put dirty tile back in framebuffer */
- if (tc->depth_stencil) {
- pipe_put_tile_raw(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32, 0/*STRIDE*/);
- }
- else {
- pipe_put_tile_rgba(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
- }
- }
-
- tile->x = tile_x;
- tile->y = tile_y;
-
- if (is_clear_flag_set(tc->clear_flags, x, y)) {
- /* don't get tile from framebuffer, just clear it */
- if (tc->depth_stencil) {
- clear_tile(tile, ps->format, tc->clear_val);
- }
- else {
- clear_tile_rgba(tile, ps->format, tc->clear_color);
- }
- clear_clear_flag(tc->clear_flags, x, y);
- }
- else {
- /* get new tile data from surface */
- if (tc->depth_stencil) {
- pipe_get_tile_raw(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32, 0/*STRIDE*/);
- }
- else {
- pipe_get_tile_rgba(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
- }
- }
- }
-
- return tile;
-}
-
-
-/**
- * Given the texture face, level, zslice, x and y values, compute
- * the cache entry position/index where we'd hope to find the
- * cached texture tile.
- * This is basically a direct-map cache.
- * XXX There's probably lots of ways in which we can improve this.
- */
-static INLINE uint
-tex_cache_pos(int x, int y, int z, int face, int level)
-{
- uint entry = x + y * 5 + z * 4 + face + level;
- return entry % NUM_ENTRIES;
-}
-
-
-/**
- * Similar to sp_get_cached_tile() but for textures.
- * Tiles are read-only and indexed with more params.
- */
-const struct softpipe_cached_tile *
-sp_get_cached_tile_tex(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc, int x, int y, int z,
- int face, int level)
-{
- /* tile pos in framebuffer: */
- const int tile_x = x & ~(TILE_SIZE - 1);
- const int tile_y = y & ~(TILE_SIZE - 1);
- /* cache pos/entry: */
- const uint pos = tex_cache_pos(x / TILE_SIZE, y / TILE_SIZE, z,
- face, level);
- struct softpipe_cached_tile *tile = tc->entries + pos;
-
- if (tile_x != tile->x ||
- tile_y != tile->y ||
- z != tile->z ||
- face != tile->face ||
- level != tile->level) {
- /* cache miss */
-
- /* check if we need to get a new surface */
- if (!tc->tex_surf ||
- tc->tex_face != face ||
- tc->tex_level != level ||
- tc->tex_z != z) {
- /* get new surface (view into texture) */
-
- if (tc->tex_surf_map)
- pipe_surface_unmap(tc->tex_surf);
-
- tc->tex_surf = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
- tc->tex_surf_map = pipe_surface_map(tc->tex_surf);
-
- tc->tex_face = face;
- tc->tex_level = level;
- tc->tex_z = z;
- }
-
- /* get tile from the surface (view into texture) */
- pipe_get_tile_rgba(pipe, tc->tex_surf,
- tile_x, tile_y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
- tile->x = tile_x;
- tile->y = tile_y;
- tile->z = z;
- tile->face = face;
- tile->level = level;
- }
-
- return tile;
-}
-
-
-/**
- * When a whole surface is being cleared to a value we can avoid
- * fetching tiles above.
- * Save the color and set a 'clearflag' for each tile of the screen.
- */
-void
-sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue)
-{
- uint r, g, b, a;
- uint pos;
-
- tc->clear_val = clearValue;
-
- switch (tc->surface->format) {
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- r = (clearValue >> 24) & 0xff;
- g = (clearValue >> 16) & 0xff;
- b = (clearValue >> 8) & 0xff;
- a = (clearValue ) & 0xff;
- break;
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- r = (clearValue >> 16) & 0xff;
- g = (clearValue >> 8) & 0xff;
- b = (clearValue ) & 0xff;
- a = (clearValue >> 24) & 0xff;
- break;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- r = (clearValue >> 8) & 0xff;
- g = (clearValue >> 16) & 0xff;
- b = (clearValue >> 24) & 0xff;
- a = (clearValue ) & 0xff;
- break;
- default:
- r = g = b = a = 0;
- }
-
- tc->clear_color[0] = r / 255.0f;
- tc->clear_color[1] = g / 255.0f;
- tc->clear_color[2] = b / 255.0f;
- tc->clear_color[3] = a / 255.0f;
-
-#if TILE_CLEAR_OPTIMIZATION
- /* set flags to indicate all the tiles are cleared */
- memset(tc->clear_flags, 255, sizeof(tc->clear_flags));
-#else
- /* disable the optimization */
- memset(tc->clear_flags, 0, sizeof(tc->clear_flags));
-#endif
-
- for (pos = 0; pos < NUM_ENTRIES; pos++) {
- struct softpipe_cached_tile *tile = tc->entries + pos;
- tile->x = tile->y = -1;
- }
-}
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.h b/src/mesa/pipe/softpipe/sp_tile_cache.h
deleted file mode 100644
index 7fd1081286..0000000000
--- a/src/mesa/pipe/softpipe/sp_tile_cache.h
+++ /dev/null
@@ -1,104 +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 SP_TILE_CACHE_H
-#define SP_TILE_CACHE_H
-
-#define TILE_CLEAR_OPTIMIZATION 1
-
-
-#include "pipe/p_compiler.h"
-
-
-struct softpipe_context;
-struct softpipe_tile_cache;
-
-
-/**
- * Cache tile size (width and height). This needs to be a power of two.
- */
-#define TILE_SIZE 64
-
-
-
-struct softpipe_cached_tile
-{
- int x, y; /**< pos of tile in window coords */
- int z, face, level; /**< Extra texture indexes */
- union {
- float color[TILE_SIZE][TILE_SIZE][4];
- uint color32[TILE_SIZE][TILE_SIZE];
- uint depth32[TILE_SIZE][TILE_SIZE];
- ushort depth16[TILE_SIZE][TILE_SIZE];
- ubyte stencil8[TILE_SIZE][TILE_SIZE];
- ubyte any[1];
- } data;
-};
-
-
-extern struct softpipe_tile_cache *
-sp_create_tile_cache(void);
-
-extern void
-sp_destroy_tile_cache(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
- struct pipe_surface *sps);
-
-extern struct pipe_surface *
-sp_tile_cache_get_surface(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_map_surfaces(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
- struct pipe_texture *texture);
-
-extern void
-sp_flush_tile_cache(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc);
-
-extern void
-sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue);
-
-extern struct softpipe_cached_tile *
-sp_get_cached_tile(struct softpipe_context *softpipe,
- struct softpipe_tile_cache *tc, int x, int y);
-
-extern const struct softpipe_cached_tile *
-sp_get_cached_tile_tex(struct pipe_context *pipe,
- struct softpipe_tile_cache *tc, int x, int y, int z,
- int face, int level);
-
-
-#endif /* SP_TILE_CACHE_H */
-
diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h
deleted file mode 100644
index d6b379f58c..0000000000
--- a/src/mesa/pipe/softpipe/sp_winsys.h
+++ /dev/null
@@ -1,57 +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.
- *
- **************************************************************************/
-
-/* This is the interface that softpipe requires any window system
- * hosting it to implement. This is the only include file in softpipe
- * which is public.
- */
-
-
-#ifndef SP_WINSYS_H
-#define SP_WINSYS_H
-
-
-#include "pipe/p_compiler.h" /* for boolean */
-
-enum pipe_format;
-
-struct softpipe_winsys {
- /** test if the given format is supported for front/back color bufs */
- boolean (*is_format_supported)( struct softpipe_winsys *sws,
- enum pipe_format format );
-
-};
-
-struct pipe_winsys;
-struct pipe_context;
-
-
-struct pipe_context *softpipe_create( struct pipe_winsys *,
- struct softpipe_winsys * );
-
-
-#endif /* SP_WINSYS_H */
diff --git a/src/mesa/pipe/tgsi/Makefile b/src/mesa/pipe/tgsi/Makefile
deleted file mode 100644
index 12a8bd0409..0000000000
--- a/src/mesa/pipe/tgsi/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-default:
- cd ../.. ; make
-
diff --git a/src/mesa/pipe/tgsi/exec/Makefile b/src/mesa/pipe/tgsi/exec/Makefile
deleted file mode 100644
index eb8b14e0e8..0000000000
--- a/src/mesa/pipe/tgsi/exec/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-default:
- cd ../../.. ; make
-
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
deleted file mode 100644
index 92a6fd4d62..0000000000
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c
+++ /dev/null
@@ -1,2465 +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.
- *
- **************************************************************************/
-
-/**
- * TGSI interpretor/executor.
- *
- * Flow control information:
- *
- * Since we operate on 'quads' (4 pixels or 4 vertices in parallel)
- * flow control statements (IF/ELSE/ENDIF, LOOP/ENDLOOP) require special
- * care since a condition may be true for some quad components but false
- * for other components.
- *
- * We basically execute all statements (even if they're in the part of
- * an IF/ELSE clause that's "not taken") and use a special mask to
- * control writing to destination registers. This is the ExecMask.
- * See store_dest().
- *
- * The ExecMask is computed from three other masks (CondMask, LoopMask and
- * ContMask) which are controlled by the flow control instructions (namely:
- * (IF/ELSE/ENDIF, LOOP/ENDLOOP and CONT).
- *
- *
- * Authors:
- * Michal Krol
- * Brian Paul
- */
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-#include "pipe/tgsi/util/tgsi_util.h"
-#include "tgsi_exec.h"
-
-#define TILE_TOP_LEFT 0
-#define TILE_TOP_RIGHT 1
-#define TILE_BOTTOM_LEFT 2
-#define TILE_BOTTOM_RIGHT 3
-
-/*
- * Shorthand locations of various utility registers (_I = Index, _C = Channel)
- */
-#define TEMP_0_I TGSI_EXEC_TEMP_00000000_I
-#define TEMP_0_C TGSI_EXEC_TEMP_00000000_C
-#define TEMP_7F_I TGSI_EXEC_TEMP_7FFFFFFF_I
-#define TEMP_7F_C TGSI_EXEC_TEMP_7FFFFFFF_C
-#define TEMP_80_I TGSI_EXEC_TEMP_80000000_I
-#define TEMP_80_C TGSI_EXEC_TEMP_80000000_C
-#define TEMP_FF_I TGSI_EXEC_TEMP_FFFFFFFF_I
-#define TEMP_FF_C TGSI_EXEC_TEMP_FFFFFFFF_C
-#define TEMP_1_I TGSI_EXEC_TEMP_ONE_I
-#define TEMP_1_C TGSI_EXEC_TEMP_ONE_C
-#define TEMP_2_I TGSI_EXEC_TEMP_TWO_I
-#define TEMP_2_C TGSI_EXEC_TEMP_TWO_C
-#define TEMP_128_I TGSI_EXEC_TEMP_128_I
-#define TEMP_128_C TGSI_EXEC_TEMP_128_C
-#define TEMP_M128_I TGSI_EXEC_TEMP_MINUS_128_I
-#define TEMP_M128_C TGSI_EXEC_TEMP_MINUS_128_C
-#define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I
-#define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C
-#define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I
-#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_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)))
-
-#define IS_CHANNEL_ENABLED2(INST, CHAN)\
- ((INST).FullDstRegisters[1].DstRegister.WriteMask & (1 << (CHAN)))
-
-#define FOR_EACH_ENABLED_CHANNEL(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
- if (IS_CHANNEL_ENABLED( INST, CHAN ))
-
-#define FOR_EACH_ENABLED_CHANNEL2(INST, CHAN)\
- FOR_EACH_CHANNEL( CHAN )\
- if (IS_CHANNEL_ENABLED2( INST, CHAN ))
-
-
-/** The execution mask depends on the conditional mask and the loop mask */
-#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.
- * After this, we can call tgsi_exec_machine_run() many times.
- */
-void
-tgsi_exec_machine_bind_shader(
- struct tgsi_exec_machine *mach,
- const struct tgsi_token *tokens,
- uint numSamplers,
- struct tgsi_sampler *samplers)
-{
- uint k;
- struct tgsi_parse_context parse;
- struct tgsi_exec_labels *labels = &mach->Labels;
- struct tgsi_full_instruction *instructions;
- struct tgsi_full_declaration *declarations;
- uint maxInstructions = 10, numInstructions = 0;
- uint maxDeclarations = 10, numDeclarations = 0;
- uint instno = 0;
-
-#if 0
- tgsi_dump(tokens, 0);
-#endif
-
- mach->Tokens = tokens;
- mach->Samplers = samplers;
-
- k = tgsi_parse_init (&parse, mach->Tokens);
- if (k != TGSI_PARSE_OK) {
- debug_printf( "Problem parsing!\n" );
- return;
- }
-
- mach->Processor = parse.FullHeader.Processor.Processor;
- mach->ImmLimit = 0;
- labels->count = 0;
-
- declarations = (struct tgsi_full_declaration *)
- MALLOC( maxDeclarations * sizeof(struct tgsi_full_declaration) );
-
- instructions = (struct tgsi_full_instruction *)
- MALLOC( maxInstructions * sizeof(struct tgsi_full_instruction) );
-
-
- while( !tgsi_parse_end_of_tokens( &parse ) ) {
- uint pointer = parse.Position;
- uint i;
-
- tgsi_parse_token( &parse );
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- /* save expanded declaration */
- if (numDeclarations == maxDeclarations) {
- declarations = REALLOC(declarations,
- maxDeclarations
- * sizeof(struct tgsi_full_instruction),
- (maxDeclarations + 10)
- * sizeof(struct tgsi_full_instruction));
- maxDeclarations += 10;
- }
- memcpy(declarations + numDeclarations,
- &parse.FullToken.FullInstruction,
- sizeof(declarations[0]));
- numDeclarations++;
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- {
- uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
- assert( size % 4 == 0 );
- assert( mach->ImmLimit + size / 4 <= TGSI_EXEC_NUM_IMMEDIATES );
-
- for( i = 0; i < size; i++ ) {
- mach->Imms[mach->ImmLimit + i / 4][i % 4] =
- parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float;
- }
- mach->ImmLimit += size / 4;
- }
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- assert( labels->count < 128 );
-
- labels->labels[labels->count][0] = instno;
- labels->labels[labels->count][1] = pointer;
- labels->count++;
-
- /* save expanded instruction */
- if (numInstructions == maxInstructions) {
- instructions = REALLOC(instructions,
- maxInstructions
- * sizeof(struct tgsi_full_instruction),
- (maxInstructions + 10)
- * sizeof(struct tgsi_full_instruction));
- maxInstructions += 10;
- }
- memcpy(instructions + numInstructions,
- &parse.FullToken.FullInstruction,
- sizeof(instructions[0]));
- numInstructions++;
- break;
-
- default:
- assert( 0 );
- }
- }
- tgsi_parse_free (&parse);
-
- if (mach->Declarations) {
- FREE( mach->Declarations );
- }
- mach->Declarations = declarations;
- mach->NumDeclarations = numDeclarations;
-
- if (mach->Instructions) {
- FREE( mach->Instructions );
- }
- mach->Instructions = instructions;
- mach->NumInstructions = numInstructions;
-}
-
-
-void
-tgsi_exec_machine_init(
- struct tgsi_exec_machine *mach )
-{
- uint i;
-
- mach->Temps = (struct tgsi_exec_vector *) tgsi_align_128bit( mach->_Temps);
- mach->Addrs = &mach->Temps[TGSI_EXEC_NUM_TEMPS];
-
- /* Setup constants. */
- for( i = 0; i < 4; i++ ) {
- mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000;
- mach->Temps[TEMP_7F_I].xyzw[TEMP_7F_C].u[i] = 0x7FFFFFFF;
- mach->Temps[TEMP_80_I].xyzw[TEMP_80_C].u[i] = 0x80000000;
- mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].u[i] = 0xFFFFFFFF;
- mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].f[i] = 1.0f;
- mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].f[i] = 2.0f;
- mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].f[i] = 128.0f;
- mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].f[i] = -128.0f;
- }
-}
-
-
-void
-tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach)
-{
- if (mach->Instructions) {
- FREE(mach->Instructions);
- mach->Instructions = NULL;
- mach->NumInstructions = 0;
- }
- if (mach->Declarations) {
- FREE(mach->Declarations);
- mach->Declarations = NULL;
- mach->NumDeclarations = 0;
- }
-}
-
-
-static void
-micro_abs(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) fabs( (double) src->f[0] );
- dst->f[1] = (float) fabs( (double) src->f[1] );
- dst->f[2] = (float) fabs( (double) src->f[2] );
- dst->f[3] = (float) fabs( (double) src->f[3] );
-}
-
-static void
-micro_add(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] + src1->f[0];
- dst->f[1] = src0->f[1] + src1->f[1];
- dst->f[2] = src0->f[2] + src1->f[2];
- dst->f[3] = src0->f[3] + src1->f[3];
-}
-
-static void
-micro_iadd(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] + src1->i[0];
- dst->i[1] = src0->i[1] + src1->i[1];
- dst->i[2] = src0->i[2] + src1->i[2];
- dst->i[3] = src0->i[3] + src1->i[3];
-}
-
-static void
-micro_and(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] & src1->u[0];
- dst->u[1] = src0->u[1] & src1->u[1];
- dst->u[2] = src0->u[2] & src1->u[2];
- dst->u[3] = src0->u[3] & src1->u[3];
-}
-
-static void
-micro_ceil(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) ceil( (double) src->f[0] );
- dst->f[1] = (float) ceil( (double) src->f[1] );
- dst->f[2] = (float) ceil( (double) src->f[2] );
- dst->f[3] = (float) ceil( (double) src->f[3] );
-}
-
-static void
-micro_cos(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) cos( (double) src->f[0] );
- dst->f[1] = (float) cos( (double) src->f[1] );
- dst->f[2] = (float) cos( (double) src->f[2] );
- dst->f[3] = (float) cos( (double) src->f[3] );
-}
-
-static void
-micro_ddx(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] =
- dst->f[1] =
- dst->f[2] =
- dst->f[3] = src->f[TILE_BOTTOM_RIGHT] - src->f[TILE_BOTTOM_LEFT];
-}
-
-static void
-micro_ddy(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] =
- dst->f[1] =
- dst->f[2] =
- dst->f[3] = src->f[TILE_TOP_LEFT] - src->f[TILE_BOTTOM_LEFT];
-}
-
-static void
-micro_div(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] / src1->f[0];
- dst->f[1] = src0->f[1] / src1->f[1];
- dst->f[2] = src0->f[2] / src1->f[2];
- dst->f[3] = src0->f[3] / src1->f[3];
-}
-
-static void
-micro_udiv(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] / src1->u[0];
- dst->u[1] = src0->u[1] / src1->u[1];
- dst->u[2] = src0->u[2] / src1->u[2];
- dst->u[3] = src0->u[3] / src1->u[3];
-}
-
-static void
-micro_eq(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] == src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] == src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] == src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] == src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
-micro_ieq(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->i[0] = src0->i[0] == src1->i[0] ? src2->i[0] : src3->i[0];
- dst->i[1] = src0->i[1] == src1->i[1] ? src2->i[1] : src3->i[1];
- dst->i[2] = src0->i[2] == src1->i[2] ? src2->i[2] : src3->i[2];
- dst->i[3] = src0->i[3] == src1->i[3] ? src2->i[3] : src3->i[3];
-}
-
-static void
-micro_exp2(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src)
-{
- dst->f[0] = (float) pow( 2.0, (double) src->f[0] );
- dst->f[1] = (float) pow( 2.0, (double) src->f[1] );
- dst->f[2] = (float) pow( 2.0, (double) src->f[2] );
- dst->f[3] = (float) pow( 2.0, (double) src->f[3] );
-}
-
-static void
-micro_f2it(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->i[0] = (int) src->f[0];
- dst->i[1] = (int) src->f[1];
- dst->i[2] = (int) src->f[2];
- dst->i[3] = (int) src->f[3];
-}
-
-static void
-micro_f2ut(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->u[0] = (uint) src->f[0];
- dst->u[1] = (uint) src->f[1];
- dst->u[2] = (uint) src->f[2];
- dst->u[3] = (uint) src->f[3];
-}
-
-static void
-micro_flr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) floor( (double) src->f[0] );
- dst->f[1] = (float) floor( (double) src->f[1] );
- dst->f[2] = (float) floor( (double) src->f[2] );
- dst->f[3] = (float) floor( (double) src->f[3] );
-}
-
-static void
-micro_frc(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = src->f[0] - (float) floor( (double) src->f[0] );
- dst->f[1] = src->f[1] - (float) floor( (double) src->f[1] );
- dst->f[2] = src->f[2] - (float) floor( (double) src->f[2] );
- dst->f[3] = src->f[3] - (float) floor( (double) src->f[3] );
-}
-
-static void
-micro_ge(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] >= src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] >= src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] >= src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] >= src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
-micro_i2f(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) src->i[0];
- dst->f[1] = (float) src->i[1];
- dst->f[2] = (float) src->i[2];
- dst->f[3] = (float) src->i[3];
-}
-
-static void
-micro_lg2(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) log( (double) src->f[0] ) * 1.442695f;
- dst->f[1] = (float) log( (double) src->f[1] ) * 1.442695f;
- dst->f[2] = (float) log( (double) src->f[2] ) * 1.442695f;
- dst->f[3] = (float) log( (double) src->f[3] ) * 1.442695f;
-}
-
-static void
-micro_lt(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->f[0] = src0->f[0] < src1->f[0] ? src2->f[0] : src3->f[0];
- dst->f[1] = src0->f[1] < src1->f[1] ? src2->f[1] : src3->f[1];
- dst->f[2] = src0->f[2] < src1->f[2] ? src2->f[2] : src3->f[2];
- dst->f[3] = src0->f[3] < src1->f[3] ? src2->f[3] : src3->f[3];
-}
-
-static void
-micro_ilt(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->i[0] = src0->i[0] < src1->i[0] ? src2->i[0] : src3->i[0];
- dst->i[1] = src0->i[1] < src1->i[1] ? src2->i[1] : src3->i[1];
- dst->i[2] = src0->i[2] < src1->i[2] ? src2->i[2] : src3->i[2];
- dst->i[3] = src0->i[3] < src1->i[3] ? src2->i[3] : src3->i[3];
-}
-
-static void
-micro_ult(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2,
- const union tgsi_exec_channel *src3 )
-{
- dst->u[0] = src0->u[0] < src1->u[0] ? src2->u[0] : src3->u[0];
- dst->u[1] = src0->u[1] < src1->u[1] ? src2->u[1] : src3->u[1];
- dst->u[2] = src0->u[2] < src1->u[2] ? src2->u[2] : src3->u[2];
- dst->u[3] = src0->u[3] < src1->u[3] ? src2->u[3] : src3->u[3];
-}
-
-static void
-micro_max(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] > src1->f[0] ? src0->f[0] : src1->f[0];
- dst->f[1] = src0->f[1] > src1->f[1] ? src0->f[1] : src1->f[1];
- dst->f[2] = src0->f[2] > src1->f[2] ? src0->f[2] : src1->f[2];
- dst->f[3] = src0->f[3] > src1->f[3] ? src0->f[3] : src1->f[3];
-}
-
-static void
-micro_imax(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] > src1->i[0] ? src0->i[0] : src1->i[0];
- dst->i[1] = src0->i[1] > src1->i[1] ? src0->i[1] : src1->i[1];
- dst->i[2] = src0->i[2] > src1->i[2] ? src0->i[2] : src1->i[2];
- dst->i[3] = src0->i[3] > src1->i[3] ? src0->i[3] : src1->i[3];
-}
-
-static void
-micro_umax(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] > src1->u[0] ? src0->u[0] : src1->u[0];
- dst->u[1] = src0->u[1] > src1->u[1] ? src0->u[1] : src1->u[1];
- dst->u[2] = src0->u[2] > src1->u[2] ? src0->u[2] : src1->u[2];
- dst->u[3] = src0->u[3] > src1->u[3] ? src0->u[3] : src1->u[3];
-}
-
-static void
-micro_min(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] < src1->f[0] ? src0->f[0] : src1->f[0];
- dst->f[1] = src0->f[1] < src1->f[1] ? src0->f[1] : src1->f[1];
- dst->f[2] = src0->f[2] < src1->f[2] ? src0->f[2] : src1->f[2];
- dst->f[3] = src0->f[3] < src1->f[3] ? src0->f[3] : src1->f[3];
-}
-
-static void
-micro_imin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] < src1->i[0] ? src0->i[0] : src1->i[0];
- dst->i[1] = src0->i[1] < src1->i[1] ? src0->i[1] : src1->i[1];
- dst->i[2] = src0->i[2] < src1->i[2] ? src0->i[2] : src1->i[2];
- dst->i[3] = src0->i[3] < src1->i[3] ? src0->i[3] : src1->i[3];
-}
-
-static void
-micro_umin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] < src1->u[0] ? src0->u[0] : src1->u[0];
- dst->u[1] = src0->u[1] < src1->u[1] ? src0->u[1] : src1->u[1];
- dst->u[2] = src0->u[2] < src1->u[2] ? src0->u[2] : src1->u[2];
- dst->u[3] = src0->u[3] < src1->u[3] ? src0->u[3] : src1->u[3];
-}
-
-static void
-micro_umod(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] % src1->u[0];
- dst->u[1] = src0->u[1] % src1->u[1];
- dst->u[2] = src0->u[2] % src1->u[2];
- dst->u[3] = src0->u[3] % src1->u[3];
-}
-
-static void
-micro_mul(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] * src1->f[0];
- dst->f[1] = src0->f[1] * src1->f[1];
- dst->f[2] = src0->f[2] * src1->f[2];
- dst->f[3] = src0->f[3] * src1->f[3];
-}
-
-static void
-micro_imul(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] * src1->i[0];
- dst->i[1] = src0->i[1] * src1->i[1];
- dst->i[2] = src0->i[2] * src1->i[2];
- dst->i[3] = src0->i[3] * src1->i[3];
-}
-
-static void
-micro_imul64(
- union tgsi_exec_channel *dst0,
- union tgsi_exec_channel *dst1,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst1->i[0] = src0->i[0] * src1->i[0];
- dst1->i[1] = src0->i[1] * src1->i[1];
- dst1->i[2] = src0->i[2] * src1->i[2];
- dst1->i[3] = src0->i[3] * src1->i[3];
- dst0->i[0] = 0;
- dst0->i[1] = 0;
- dst0->i[2] = 0;
- dst0->i[3] = 0;
-}
-
-static void
-micro_umul64(
- union tgsi_exec_channel *dst0,
- union tgsi_exec_channel *dst1,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst1->u[0] = src0->u[0] * src1->u[0];
- dst1->u[1] = src0->u[1] * src1->u[1];
- dst1->u[2] = src0->u[2] * src1->u[2];
- dst1->u[3] = src0->u[3] * src1->u[3];
- dst0->u[0] = 0;
- dst0->u[1] = 0;
- dst0->u[2] = 0;
- dst0->u[3] = 0;
-}
-
-static void
-micro_movc(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1,
- const union tgsi_exec_channel *src2 )
-{
- dst->u[0] = src0->u[0] ? src1->u[0] : src2->u[0];
- dst->u[1] = src0->u[1] ? src1->u[1] : src2->u[1];
- dst->u[2] = src0->u[2] ? src1->u[2] : src2->u[2];
- dst->u[3] = src0->u[3] ? src1->u[3] : src2->u[3];
-}
-
-static void
-micro_neg(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = -src->f[0];
- dst->f[1] = -src->f[1];
- dst->f[2] = -src->f[2];
- dst->f[3] = -src->f[3];
-}
-
-static void
-micro_ineg(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->i[0] = -src->i[0];
- dst->i[1] = -src->i[1];
- dst->i[2] = -src->i[2];
- dst->i[3] = -src->i[3];
-}
-
-static void
-micro_not(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->u[0] = ~src->u[0];
- dst->u[1] = ~src->u[1];
- dst->u[2] = ~src->u[2];
- dst->u[3] = ~src->u[3];
-}
-
-static void
-micro_or(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] | src1->u[0];
- dst->u[1] = src0->u[1] | src1->u[1];
- dst->u[2] = src0->u[2] | src1->u[2];
- dst->u[3] = src0->u[3] | src1->u[3];
-}
-
-static void
-micro_pow(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = (float) pow( (double) src0->f[0], (double) src1->f[0] );
- dst->f[1] = (float) pow( (double) src0->f[1], (double) src1->f[1] );
- dst->f[2] = (float) pow( (double) src0->f[2], (double) src1->f[2] );
- dst->f[3] = (float) pow( (double) src0->f[3], (double) src1->f[3] );
-}
-
-static void
-micro_rnd(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) floor( (double) (src->f[0] + 0.5f) );
- dst->f[1] = (float) floor( (double) (src->f[1] + 0.5f) );
- dst->f[2] = (float) floor( (double) (src->f[2] + 0.5f) );
- dst->f[3] = (float) floor( (double) (src->f[3] + 0.5f) );
-}
-
-static void
-micro_shl(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] << src1->i[0];
- dst->i[1] = src0->i[1] << src1->i[1];
- dst->i[2] = src0->i[2] << src1->i[2];
- dst->i[3] = src0->i[3] << src1->i[3];
-}
-
-static void
-micro_ishr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->i[0] = src0->i[0] >> src1->i[0];
- dst->i[1] = src0->i[1] >> src1->i[1];
- dst->i[2] = src0->i[2] >> src1->i[2];
- dst->i[3] = src0->i[3] >> src1->i[3];
-}
-
-static void
-micro_trunc(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0 )
-{
- dst->f[0] = (float) (int) src0->f[0];
- dst->f[1] = (float) (int) src0->f[1];
- dst->f[2] = (float) (int) src0->f[2];
- dst->f[3] = (float) (int) src0->f[3];
-}
-
-static void
-micro_ushr(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] >> src1->u[0];
- dst->u[1] = src0->u[1] >> src1->u[1];
- dst->u[2] = src0->u[2] >> src1->u[2];
- dst->u[3] = src0->u[3] >> src1->u[3];
-}
-
-static void
-micro_sin(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) sin( (double) src->f[0] );
- dst->f[1] = (float) sin( (double) src->f[1] );
- dst->f[2] = (float) sin( (double) src->f[2] );
- dst->f[3] = (float) sin( (double) src->f[3] );
-}
-
-static void
-micro_sqrt( union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) sqrt( (double) src->f[0] );
- dst->f[1] = (float) sqrt( (double) src->f[1] );
- dst->f[2] = (float) sqrt( (double) src->f[2] );
- dst->f[3] = (float) sqrt( (double) src->f[3] );
-}
-
-static void
-micro_sub(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->f[0] = src0->f[0] - src1->f[0];
- dst->f[1] = src0->f[1] - src1->f[1];
- dst->f[2] = src0->f[2] - src1->f[2];
- dst->f[3] = src0->f[3] - src1->f[3];
-}
-
-static void
-micro_u2f(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src )
-{
- dst->f[0] = (float) src->u[0];
- dst->f[1] = (float) src->u[1];
- dst->f[2] = (float) src->u[2];
- dst->f[3] = (float) src->u[3];
-}
-
-static void
-micro_xor(
- union tgsi_exec_channel *dst,
- const union tgsi_exec_channel *src0,
- const union tgsi_exec_channel *src1 )
-{
- dst->u[0] = src0->u[0] ^ src1->u[0];
- dst->u[1] = src0->u[1] ^ src1->u[1];
- dst->u[2] = src0->u[2] ^ src1->u[2];
- dst->u[3] = src0->u[3] ^ src1->u[3];
-}
-
-static void
-fetch_src_file_channel(
- const struct tgsi_exec_machine *mach,
- const uint file,
- const uint swizzle,
- const union tgsi_exec_channel *index,
- union tgsi_exec_channel *chan )
-{
- switch( swizzle ) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- switch( file ) {
- case TGSI_FILE_CONSTANT:
- 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];
- chan->f[3] = mach->Consts[index->i[3]][swizzle];
- break;
-
- case TGSI_FILE_INPUT:
- chan->u[0] = mach->Inputs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Inputs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Inputs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Inputs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- case TGSI_FILE_TEMPORARY:
- chan->u[0] = mach->Temps[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Temps[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Temps[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Temps[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- case TGSI_FILE_IMMEDIATE:
- assert( index->i[0] < (int) mach->ImmLimit );
- chan->f[0] = mach->Imms[index->i[0]][swizzle];
- assert( index->i[1] < (int) mach->ImmLimit );
- chan->f[1] = mach->Imms[index->i[1]][swizzle];
- assert( index->i[2] < (int) mach->ImmLimit );
- chan->f[2] = mach->Imms[index->i[2]][swizzle];
- assert( index->i[3] < (int) mach->ImmLimit );
- chan->f[3] = mach->Imms[index->i[3]][swizzle];
- break;
-
- case TGSI_FILE_ADDRESS:
- chan->u[0] = mach->Addrs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Addrs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Addrs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Addrs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- case TGSI_FILE_OUTPUT:
- /* vertex/fragment output vars can be read too */
- chan->u[0] = mach->Outputs[index->i[0]].xyzw[swizzle].u[0];
- chan->u[1] = mach->Outputs[index->i[1]].xyzw[swizzle].u[1];
- chan->u[2] = mach->Outputs[index->i[2]].xyzw[swizzle].u[2];
- chan->u[3] = mach->Outputs[index->i[3]].xyzw[swizzle].u[3];
- break;
-
- default:
- assert( 0 );
- }
- break;
-
- case TGSI_EXTSWIZZLE_ZERO:
- *chan = mach->Temps[TEMP_0_I].xyzw[TEMP_0_C];
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- *chan = mach->Temps[TEMP_1_I].xyzw[TEMP_1_C];
- break;
-
- default:
- assert( 0 );
- }
-}
-
-static void
-fetch_source(
- const struct tgsi_exec_machine *mach,
- union tgsi_exec_channel *chan,
- const struct tgsi_full_src_register *reg,
- const uint chan_index )
-{
- union tgsi_exec_channel index;
- uint swizzle;
-
- index.i[0] =
- index.i[1] =
- index.i[2] =
- index.i[3] = reg->SrcRegister.Index;
-
- if (reg->SrcRegister.Indirect) {
- union tgsi_exec_channel index2;
- union tgsi_exec_channel indir_index;
-
- index2.i[0] =
- index2.i[1] =
- index2.i[2] =
- index2.i[3] = reg->SrcRegisterInd.Index;
-
- swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterInd, CHAN_X );
- fetch_src_file_channel(
- mach,
- reg->SrcRegisterInd.File,
- swizzle,
- &index2,
- &indir_index );
-
- index.i[0] += indir_index.i[0];
- index.i[1] += indir_index.i[1];
- index.i[2] += indir_index.i[2];
- index.i[3] += indir_index.i[3];
- }
-
- if( reg->SrcRegister.Dimension ) {
- switch( reg->SrcRegister.File ) {
- case TGSI_FILE_INPUT:
- index.i[0] *= 17;
- index.i[1] *= 17;
- index.i[2] *= 17;
- index.i[3] *= 17;
- break;
- case TGSI_FILE_CONSTANT:
- index.i[0] *= 4096;
- index.i[1] *= 4096;
- index.i[2] *= 4096;
- index.i[3] *= 4096;
- break;
- default:
- assert( 0 );
- }
-
- index.i[0] += reg->SrcRegisterDim.Index;
- index.i[1] += reg->SrcRegisterDim.Index;
- index.i[2] += reg->SrcRegisterDim.Index;
- index.i[3] += reg->SrcRegisterDim.Index;
-
- if (reg->SrcRegisterDim.Indirect) {
- union tgsi_exec_channel index2;
- union tgsi_exec_channel indir_index;
-
- index2.i[0] =
- index2.i[1] =
- index2.i[2] =
- index2.i[3] = reg->SrcRegisterDimInd.Index;
-
- swizzle = tgsi_util_get_src_register_swizzle( &reg->SrcRegisterDimInd, CHAN_X );
- fetch_src_file_channel(
- mach,
- reg->SrcRegisterDimInd.File,
- swizzle,
- &index2,
- &indir_index );
-
- index.i[0] += indir_index.i[0];
- index.i[1] += indir_index.i[1];
- index.i[2] += indir_index.i[2];
- index.i[3] += indir_index.i[3];
- }
- }
-
- swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
- fetch_src_file_channel(
- mach,
- reg->SrcRegister.File,
- swizzle,
- &index,
- chan );
-
- switch (tgsi_util_get_full_src_register_sign_mode( reg, chan_index )) {
- case TGSI_UTIL_SIGN_CLEAR:
- micro_abs( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_SET:
- micro_abs( chan, chan );
- micro_neg( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_TOGGLE:
- micro_neg( chan, chan );
- break;
-
- case TGSI_UTIL_SIGN_KEEP:
- break;
- }
-
- if (reg->SrcRegisterExtMod.Complement) {
- micro_sub( chan, &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], chan );
- }
-}
-
-static void
-store_dest(
- struct tgsi_exec_machine *mach,
- const union tgsi_exec_channel *chan,
- const struct tgsi_full_dst_register *reg,
- const struct tgsi_full_instruction *inst,
- uint chan_index )
-{
- union tgsi_exec_channel *dst;
-
- switch( reg->DstRegister.File ) {
- case TGSI_FILE_NULL:
- return;
-
- case TGSI_FILE_OUTPUT:
- dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
- + reg->DstRegister.Index].xyzw[chan_index];
- break;
-
- case TGSI_FILE_TEMPORARY:
- dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index];
- break;
-
- case TGSI_FILE_ADDRESS:
- dst = &mach->Addrs[reg->DstRegister.Index].xyzw[chan_index];
- 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];
- 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]);
- break;
-
- case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
- break;
-
- default:
- assert( 0 );
- }
-}
-
-#define FETCH(VAL,INDEX,CHAN)\
- fetch_source (mach, VAL, &inst->FullSrcRegisters[INDEX], CHAN)
-
-#define STORE(VAL,INDEX,CHAN)\
- store_dest (mach, VAL, &inst->FullDstRegisters[INDEX], inst, CHAN )
-
-
-/**
- * Execute ARB-style KIL which is predicated by a src register.
- * Kill fragment if any of the four values is less than zero.
- */
-static void
-exec_kilp(struct tgsi_exec_machine *mach,
- const struct tgsi_full_instruction *inst)
-{
- uint uniquemask;
- uint chan_index;
- uint kilmask = 0; /* bit 0 = pixel 0, bit 1 = pixel 1, etc */
- union tgsi_exec_channel r[1];
-
- /* This mask stores component bits that were already tested. Note that
- * we test if the value is less than zero, so 1.0 and 0.0 need not to be
- * tested. */
- uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
-
- for (chan_index = 0; chan_index < 4; chan_index++)
- {
- uint swizzle;
- uint i;
-
- /* unswizzle channel */
- swizzle = tgsi_util_get_full_src_register_extswizzle (
- &inst->FullSrcRegisters[0],
- chan_index);
-
- /* check if the component has not been already tested */
- if (uniquemask & (1 << swizzle))
- continue;
- uniquemask |= 1 << swizzle;
-
- FETCH(&r[0], 0, chan_index);
- for (i = 0; i < 4; i++)
- if (r[0].f[i] < 0.0f)
- kilmask |= 1 << i;
- }
-
- mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= kilmask;
-}
-
-
-/*
- * Fetch a texel using STR texture coordinates.
- */
-static void
-fetch_texel( struct tgsi_sampler *sampler,
- const union tgsi_exec_channel *s,
- const union tgsi_exec_channel *t,
- const union tgsi_exec_channel *p,
- float lodbias, /* XXX should be float[4] */
- union tgsi_exec_channel *r,
- union tgsi_exec_channel *g,
- union tgsi_exec_channel *b,
- union tgsi_exec_channel *a )
-{
- uint j;
- float rgba[NUM_CHANNELS][QUAD_SIZE];
-
- sampler->get_samples(sampler, s->f, t->f, p->f, lodbias, rgba);
-
- for (j = 0; j < 4; j++) {
- r->f[j] = rgba[0][j];
- g->f[j] = rgba[1][j];
- b->f[j] = rgba[2][j];
- a->f[j] = rgba[3][j];
- }
-}
-
-
-static void
-exec_tex(struct tgsi_exec_machine *mach,
- const struct tgsi_full_instruction *inst,
- boolean biasLod)
-{
- const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
- union tgsi_exec_channel r[8];
- uint chan_index;
- float lodBias;
-
- /* debug_printf("Sampler %u unit %u\n", sampler, unit); */
-
- switch (inst->InstructionExtTexture.Texture) {
- case TGSI_TEXTURE_1D:
-
- FETCH(&r[0], 0, CHAN_X);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[1], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[1] );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[1], 0, CHAN_W);
- lodBias = r[2].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */
- &r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
- break;
-
- case TGSI_TEXTURE_2D:
- case TGSI_TEXTURE_RECT:
-
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[3], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[3] );
- micro_div( &r[1], &r[1], &r[3] );
- micro_div( &r[2], &r[2], &r[3] );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias, /* inputs */
- &r[0], &r[1], &r[2], &r[3]); /* outputs */
- break;
-
- case TGSI_TEXTURE_3D:
- case TGSI_TEXTURE_CUBE:
-
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- switch (inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtDivide) {
- case TGSI_EXTSWIZZLE_W:
- FETCH(&r[3], 0, CHAN_W);
- micro_div( &r[0], &r[0], &r[3] );
- micro_div( &r[1], &r[1], &r[3] );
- micro_div( &r[2], &r[2], &r[3] );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- break;
-
- default:
- assert (0);
- }
-
- if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
- lodBias = r[3].f[0];
- }
- else
- lodBias = 0.0;
-
- fetch_texel(&mach->Samplers[unit],
- &r[0], &r[1], &r[2], lodBias,
- &r[0], &r[1], &r[2], &r[3]);
- break;
-
- default:
- assert (0);
- }
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[chan_index], 0, chan_index );
- }
-}
-
-
-
-static void
-constant_interpolation(
- struct tgsi_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- unsigned i;
-
- for( i = 0; i < QUAD_SIZE; i++ ) {
- mach->Inputs[attrib].xyzw[chan].f[i] = mach->InterpCoefs[attrib].a0[chan];
- }
-}
-
-static void
-linear_interpolation(
- struct tgsi_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- const float x = mach->QuadPos.xyzw[0].f[0];
- const float y = mach->QuadPos.xyzw[1].f[0];
- const float dadx = mach->InterpCoefs[attrib].dadx[chan];
- const float dady = mach->InterpCoefs[attrib].dady[chan];
- const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
- mach->Inputs[attrib].xyzw[chan].f[0] = a0;
- mach->Inputs[attrib].xyzw[chan].f[1] = a0 + dadx;
- mach->Inputs[attrib].xyzw[chan].f[2] = a0 + dady;
- mach->Inputs[attrib].xyzw[chan].f[3] = a0 + dadx + dady;
-}
-
-static void
-perspective_interpolation(
- struct tgsi_exec_machine *mach,
- unsigned attrib,
- unsigned chan )
-{
- const float x = mach->QuadPos.xyzw[0].f[0];
- const float y = mach->QuadPos.xyzw[1].f[0];
- const float dadx = mach->InterpCoefs[attrib].dadx[chan];
- const float dady = mach->InterpCoefs[attrib].dady[chan];
- const float a0 = mach->InterpCoefs[attrib].a0[chan] + dadx * x + dady * y;
- const float *w = mach->QuadPos.xyzw[3].f;
- /* divide by W here */
- mach->Inputs[attrib].xyzw[chan].f[0] = a0 / w[0];
- mach->Inputs[attrib].xyzw[chan].f[1] = (a0 + dadx) / w[1];
- mach->Inputs[attrib].xyzw[chan].f[2] = (a0 + dady) / w[2];
- mach->Inputs[attrib].xyzw[chan].f[3] = (a0 + dadx + dady) / w[3];
-}
-
-
-typedef void (* interpolation_func)(
- struct tgsi_exec_machine *mach,
- unsigned attrib,
- unsigned chan );
-
-static void
-exec_declaration(
- struct tgsi_exec_machine *mach,
- const struct tgsi_full_declaration *decl )
-{
- if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
- unsigned first, last, mask;
- interpolation_func interp;
-
- assert( decl->Declaration.Declare == TGSI_DECLARE_RANGE );
-
- first = decl->u.DeclarationRange.First;
- last = decl->u.DeclarationRange.Last;
- mask = decl->Declaration.UsageMask;
-
- switch( decl->Interpolation.Interpolate ) {
- case TGSI_INTERPOLATE_CONSTANT:
- interp = constant_interpolation;
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- interp = linear_interpolation;
- break;
-
- case TGSI_INTERPOLATE_PERSPECTIVE:
- interp = perspective_interpolation;
- break;
-
- default:
- assert( 0 );
- }
-
- if( mask == TGSI_WRITEMASK_XYZW ) {
- unsigned i, j;
-
- for( i = first; i <= last; i++ ) {
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- interp( mach, i, j );
- }
- }
- }
- else {
- unsigned i, j;
-
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- if( mask & (1 << j) ) {
- for( i = first; i <= last; i++ ) {
- interp( mach, i, j );
- }
- }
- }
- }
- }
- }
-}
-
-static void
-exec_instruction(
- struct tgsi_exec_machine *mach,
- const struct tgsi_full_instruction *inst,
- int *pc )
-{
- uint chan_index;
- union tgsi_exec_channel r[8];
-
- (*pc)++;
-
- 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 );
- }
- break;
-
- case TGSI_OPCODE_MOV:
- /* TGSI_OPCODE_SWZ */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LIT:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y ) || IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_X );
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- micro_max( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Y );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[1], 0, CHAN_Y );
- micro_max( &r[1], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
-
- FETCH( &r[2], 0, CHAN_W );
- micro_min( &r[2], &r[2], &mach->Temps[TEMP_128_I].xyzw[TEMP_128_C] );
- micro_max( &r[2], &r[2], &mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C] );
- micro_pow( &r[1], &r[1], &r[2] );
- micro_lt( &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, CHAN_Z );
- }
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_RCP:
- /* TGSI_OPCODE_RECIP */
- FETCH( &r[0], 0, CHAN_X );
- micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_RSQ:
- /* TGSI_OPCODE_RECIPSQRT */
- FETCH( &r[0], 0, CHAN_X );
- micro_sqrt( &r[0], &r[0] );
- micro_div( &r[0], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_EXP:
- assert (0);
- break;
-
- case TGSI_OPCODE_LOG:
- assert (0);
- break;
-
- case TGSI_OPCODE_MUL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index )
- {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_ADD:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_add( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP3:
- /* TGSI_OPCODE_DOT3 */
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Z );
- FETCH( &r[2], 1, CHAN_Z );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP4:
- /* TGSI_OPCODE_DOT4 */
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_W);
- FETCH(&r[2], 1, CHAN_W);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DST:
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_X );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- FETCH( &r[0], 0, CHAN_Y );
- FETCH( &r[1], 1, CHAN_Y);
- micro_mul( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, CHAN_Y );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- FETCH( &r[0], 0, CHAN_Z );
- STORE( &r[0], 0, CHAN_Z );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- FETCH( &r[0], 1, CHAN_W );
- STORE( &r[0], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MIN:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- /* XXX use micro_min()?? */
- micro_lt( &r[0], &r[0], &r[1], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_MAX:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- /* XXX use micro_max()?? */
- micro_lt( &r[0], &r[0], &r[1], &r[1], &r[0] );
-
- STORE(&r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLT:
- /* TGSI_OPCODE_SETLT */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_lt( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SGE:
- /* TGSI_OPCODE_SETGE */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_ge( &r[0], &r[0], &r[1], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MAD:
- /* TGSI_OPCODE_MADD */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_mul( &r[0], &r[0], &r[1] );
- FETCH( &r[1], 2, chan_index );
- micro_add( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SUB:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
-
- micro_sub( &r[0], &r[0], &r[1] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_LERP:
- /* TGSI_OPCODE_LRP */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
- FETCH(&r[2], 2, chan_index);
-
- micro_sub( &r[1], &r[1], &r[2] );
- micro_mul( &r[0], &r[0], &r[1] );
- micro_add( &r[0], &r[0], &r[2] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_CND:
- assert (0);
- break;
-
- case TGSI_OPCODE_CND0:
- assert (0);
- break;
-
- case TGSI_OPCODE_DOT2ADD:
- /* TGSI_OPCODE_DP2A */
- assert (0);
- break;
-
- case TGSI_OPCODE_INDEX:
- assert (0);
- break;
-
- case TGSI_OPCODE_NEGATE:
- assert (0);
- break;
-
- case TGSI_OPCODE_FRAC:
- /* TGSI_OPCODE_FRC */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_frc( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CLAMP:
- assert (0);
- break;
-
- case TGSI_OPCODE_FLOOR:
- /* TGSI_OPCODE_FLR */
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_flr( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_ROUND:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_rnd( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_EXPBASE2:
- /* TGSI_OPCODE_EX2 */
- FETCH(&r[0], 0, CHAN_X);
-
- micro_pow( &r[0], &mach->Temps[TEMP_2_I].xyzw[TEMP_2_C], &r[0] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LOGBASE2:
- /* TGSI_OPCODE_LG2 */
- FETCH( &r[0], 0, CHAN_X );
- micro_lg2( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_POWER:
- /* TGSI_OPCODE_POW */
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- micro_pow( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CROSSPRODUCT:
- /* TGSI_OPCODE_XPD */
- FETCH(&r[0], 0, CHAN_Y);
- FETCH(&r[1], 1, CHAN_Z);
-
- micro_mul( &r[2], &r[0], &r[1] );
-
- FETCH(&r[3], 0, CHAN_Z);
- FETCH(&r[4], 1, CHAN_Y);
-
- micro_mul( &r[5], &r[3], &r[4] );
- micro_sub( &r[2], &r[2], &r[5] );
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
- STORE( &r[2], 0, CHAN_X );
- }
-
- FETCH(&r[2], 1, CHAN_X);
-
- micro_mul( &r[3], &r[3], &r[2] );
-
- FETCH(&r[5], 0, CHAN_X);
-
- micro_mul( &r[1], &r[1], &r[5] );
- micro_sub( &r[3], &r[3], &r[1] );
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
- STORE( &r[3], 0, CHAN_Y );
- }
-
- micro_mul( &r[5], &r[5], &r[4] );
- micro_mul( &r[0], &r[0], &r[2] );
- micro_sub( &r[5], &r[5], &r[0] );
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
- STORE( &r[5], 0, CHAN_Z );
- }
-
- if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MULTIPLYMATRIX:
- assert (0);
- break;
-
- case TGSI_OPCODE_ABS:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
-
- micro_abs( &r[0], &r[0] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_RCC:
- assert (0);
- break;
-
- case TGSI_OPCODE_DPH:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 1, CHAN_X);
-
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Y);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 0, CHAN_Z);
- FETCH(&r[2], 1, CHAN_Z);
-
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FETCH(&r[1], 1, CHAN_W);
-
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_COS:
- FETCH(&r[0], 0, CHAN_X);
-
- micro_cos( &r[0], &r[0] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DDX:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ddx( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DDY:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ddy( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_KILP:
- exec_kilp (mach, inst);
- break;
-
- case TGSI_OPCODE_KIL:
- /* for enabled ExecMask bits, set the killed bit */
- mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] |= mach->ExecMask;
- break;
-
- case TGSI_OPCODE_PK2H:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK2US:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK4B:
- assert (0);
- break;
-
- case TGSI_OPCODE_PK4UB:
- assert (0);
- break;
-
- case TGSI_OPCODE_RFL:
- assert (0);
- break;
-
- case TGSI_OPCODE_SEQ:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_eq( &r[0], &r[0], &r[1],
- &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C],
- &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SFL:
- assert (0);
- break;
-
- case TGSI_OPCODE_SGT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_lt( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SIN:
- FETCH( &r[0], 0, CHAN_X );
- micro_sin( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_ge( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SNE:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_eq( &r[0], &r[0], &r[1], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_STR:
- assert (0);
- break;
-
- case TGSI_OPCODE_TEX:
- /* simple texture lookup */
- /* src[0] = texcoord */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, FALSE);
- break;
-
- case TGSI_OPCODE_TXB:
- /* Texture lookup with lod bias */
- /* src[0] = texcoord (src[0].w = LOD bias) */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE);
- break;
-
- case TGSI_OPCODE_TXD:
- /* Texture lookup with explict partial derivatives */
- /* src[0] = texcoord */
- /* src[1] = d[strq]/dx */
- /* src[2] = d[strq]/dy */
- /* src[3] = sampler unit */
- assert (0);
- break;
-
- case TGSI_OPCODE_TXL:
- /* Texture lookup with explit LOD */
- /* src[0] = texcoord (src[0].w = LOD) */
- /* src[1] = sampler unit */
- exec_tex(mach, inst, TRUE);
- break;
-
- case TGSI_OPCODE_UP2H:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP2US:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP4B:
- assert (0);
- break;
-
- case TGSI_OPCODE_UP4UB:
- assert (0);
- break;
-
- case TGSI_OPCODE_X2D:
- assert (0);
- break;
-
- case TGSI_OPCODE_ARA:
- assert (0);
- break;
-
- case TGSI_OPCODE_ARR:
- assert (0);
- break;
-
- case TGSI_OPCODE_BRA:
- assert (0);
- break;
-
- case TGSI_OPCODE_CAL:
- /* skip the call if no execution channels are enabled */
- if (mach->ExecMask) {
- /* do the call */
-
- /* push the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
- mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
-
- assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
- mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
-
- /* note that PC was already incremented above */
- mach->CallStack[mach->CallStackTop++] = *pc;
- *pc = inst->InstructionExtLabel.Label;
- }
- break;
-
- case TGSI_OPCODE_RET:
- mach->FuncMask &= ~mach->ExecMask;
- UPDATE_EXEC_MASK(mach);
-
- if (mach->ExecMask == 0x0) {
- /* really return now (otherwise, keep executing */
-
- if (mach->CallStackTop == 0) {
- /* returning from main() */
- *pc = -1;
- return;
- }
- *pc = mach->CallStack[--mach->CallStackTop];
-
- /* pop the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop > 0);
- mach->CondMask = mach->CondStack[--mach->CondStackTop];
- assert(mach->LoopStackTop > 0);
- mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[--mach->ContStackTop];
- assert(mach->FuncStackTop > 0);
- mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
-
- UPDATE_EXEC_MASK(mach);
- }
- break;
-
- case TGSI_OPCODE_SSG:
- assert (0);
- break;
-
- case TGSI_OPCODE_CMP:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH(&r[0], 0, chan_index);
- FETCH(&r[1], 1, chan_index);
- FETCH(&r[2], 2, chan_index);
-
- micro_lt( &r[0], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2] );
-
- STORE(&r[0], 0, chan_index);
- }
- break;
-
- case TGSI_OPCODE_SCS:
- if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) || IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- FETCH( &r[0], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
- micro_cos( &r[1], &r[0] );
- STORE( &r[1], 0, CHAN_X );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- micro_sin( &r[1], &r[0] );
- STORE( &r[1], 0, CHAN_Y );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- STORE( &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], 0, CHAN_Z );
- }
- if( IS_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
- STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_NRM:
- assert (0);
- break;
-
- case TGSI_OPCODE_DIV:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_DP2:
- FETCH( &r[0], 0, CHAN_X );
- FETCH( &r[1], 1, CHAN_X );
- micro_mul( &r[0], &r[0], &r[1] );
-
- FETCH( &r[1], 0, CHAN_Y );
- FETCH( &r[2], 1, CHAN_Y );
- micro_mul( &r[1], &r[1], &r[2] );
- micro_add( &r[0], &r[0], &r[1] );
-
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_IF:
- /* push CondMask */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
- mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- FETCH( &r[0], 0, CHAN_X );
- /* update CondMask */
- if( ! r[0].u[0] ) {
- mach->CondMask &= ~0x1;
- }
- if( ! r[0].u[1] ) {
- mach->CondMask &= ~0x2;
- }
- if( ! r[0].u[2] ) {
- mach->CondMask &= ~0x4;
- }
- if( ! r[0].u[3] ) {
- mach->CondMask &= ~0x8;
- }
- UPDATE_EXEC_MASK(mach);
- /* Todo: If CondMask==0, jump to ELSE */
- break;
-
- case TGSI_OPCODE_ELSE:
- /* invert CondMask wrt previous mask */
- {
- uint prevMask;
- assert(mach->CondStackTop > 0);
- prevMask = mach->CondStack[mach->CondStackTop - 1];
- mach->CondMask = ~mach->CondMask & prevMask;
- UPDATE_EXEC_MASK(mach);
- /* Todo: If CondMask==0, jump to ENDIF */
- }
- break;
-
- case TGSI_OPCODE_ENDIF:
- /* pop CondMask */
- assert(mach->CondStackTop > 0);
- mach->CondMask = mach->CondStack[--mach->CondStackTop];
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_END:
- /* halt execution */
- *pc = -1;
- break;
-
- case TGSI_OPCODE_REP:
- assert (0);
- break;
-
- case TGSI_OPCODE_ENDREP:
- assert (0);
- break;
-
- case TGSI_OPCODE_PUSHA:
- assert (0);
- break;
-
- case TGSI_OPCODE_POPA:
- assert (0);
- break;
-
- case TGSI_OPCODE_CEIL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_ceil( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_I2F:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_i2f( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_NOT:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_not( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_TRUNC:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- micro_trunc( &r[0], &r[0] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SHL:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_shl( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SHR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_ishr( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_AND:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_and( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_OR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_or( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MOD:
- assert (0);
- break;
-
- case TGSI_OPCODE_XOR:
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( &r[0], 0, chan_index );
- FETCH( &r[1], 1, chan_index );
- micro_xor( &r[0], &r[0], &r[1] );
- STORE( &r[0], 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SAD:
- assert (0);
- break;
-
- case TGSI_OPCODE_TXF:
- assert (0);
- break;
-
- case TGSI_OPCODE_TXQ:
- assert (0);
- break;
-
- case TGSI_OPCODE_EMIT:
- mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += 16;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
- break;
-
- case TGSI_OPCODE_ENDPRIM:
- mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]++;
- mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0;
- break;
-
- case TGSI_OPCODE_LOOP:
- /* fall-through (for now) */
- case TGSI_OPCODE_BGNLOOP2:
- /* push LoopMask and ContMasks */
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
- mach->ContStack[mach->ContStackTop++] = mach->ContMask;
- break;
-
- case TGSI_OPCODE_ENDLOOP:
- /* fall-through (for now at least) */
- case TGSI_OPCODE_ENDLOOP2:
- /* Restore ContMask, but don't pop */
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
- if (mach->LoopMask) {
- /* repeat loop: jump to instruction just past BGNLOOP */
- *pc = inst->InstructionExtLabel.Label + 1;
- }
- else {
- /* exit loop: pop LoopMask */
- assert(mach->LoopStackTop > 0);
- mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- /* pop ContMask */
- assert(mach->ContStackTop > 0);
- mach->ContMask = mach->ContStack[--mach->ContStackTop];
- }
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_BRK:
- /* turn off loop channels for each enabled exec channel */
- mach->LoopMask &= ~mach->ExecMask;
- /* Todo: if mach->LoopMask == 0, jump to end of loop */
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_CONT:
- /* turn off cont channels for each enabled exec channel */
- mach->ContMask &= ~mach->ExecMask;
- /* Todo: if mach->LoopMask == 0, jump to end of loop */
- UPDATE_EXEC_MASK(mach);
- break;
-
- case TGSI_OPCODE_BGNSUB:
- /* no-op */
- break;
-
- case TGSI_OPCODE_ENDSUB:
- /* no-op */
- break;
-
- case TGSI_OPCODE_NOISE1:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE2:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE3:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOISE4:
- assert( 0 );
- break;
-
- case TGSI_OPCODE_NOP:
- break;
-
- default:
- assert( 0 );
- }
-}
-
-
-/**
- * Run TGSI interpreter.
- * \return bitmask of "alive" quad components
- */
-uint
-tgsi_exec_machine_run( struct tgsi_exec_machine *mach )
-{
- uint i;
- int pc = 0;
-
- mach->CondMask = 0xf;
- mach->LoopMask = 0xf;
- mach->ContMask = 0xf;
- 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->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
- mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
-
- if( mach->Processor == TGSI_PROCESSOR_GEOMETRY ) {
- mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0] = 0;
- mach->Primitives[0] = 0;
- }
-
-
- /* execute declarations (interpolants) */
- for (i = 0; i < mach->NumDeclarations; i++) {
- exec_declaration( mach, mach->Declarations+i );
- }
-
- /* execute instructions, until pc is set to -1 */
- while (pc != -1) {
- assert(pc < mach->NumInstructions);
- exec_instruction( mach, mach->Instructions + pc, &pc );
- }
-
-#if 0
- /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */
- if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
- /*
- * Scale back depth component.
- */
- for (i = 0; i < 4; i++)
- mach->Outputs[0].xyzw[2].f[i] *= ctx->DrawBuffer->_DepthMaxF;
- }
-#endif
-
- return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
-}
-
-
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.h b/src/mesa/pipe/tgsi/exec/tgsi_exec.h
deleted file mode 100644
index 45c49dd007..0000000000
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.h
+++ /dev/null
@@ -1,243 +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.
- *
- **************************************************************************/
-
-#if !defined TGSI_EXEC_H
-#define TGSI_EXEC_H
-
-#include "pipe/p_compiler.h"
-
-#if defined __cplusplus
-extern "C" {
-#endif
-
-#define NUM_CHANNELS 4 /* R,G,B,A */
-#define QUAD_SIZE 4 /* 4 pixel/quad */
-
-/**
- * Registers may be treated as float, signed int or unsigned int.
- */
-union tgsi_exec_channel
-{
- float f[QUAD_SIZE];
- int i[QUAD_SIZE];
- unsigned u[QUAD_SIZE];
-};
-
-/**
- * A vector[RGBA] of channels[4 pixels]
- */
-struct tgsi_exec_vector
-{
- union tgsi_exec_channel xyzw[NUM_CHANNELS];
-};
-
-/**
- * For fragment programs, information for computing fragment input
- * values from plane equation of the triangle/line.
- */
-struct tgsi_interp_coef
-{
- float a0[NUM_CHANNELS]; /* in an xyzw layout */
- float dadx[NUM_CHANNELS];
- float dady[NUM_CHANNELS];
-};
-
-
-struct softpipe_tile_cache; /**< Opaque to TGSI */
-
-/**
- * Information for sampling textures, which must be implemented
- * by code outside the TGSI executor.
- */
-struct tgsi_sampler
-{
- const struct pipe_sampler_state *state;
- struct pipe_texture *texture;
- /** Get samples for four fragments in a quad */
- void (*get_samples)(struct tgsi_sampler *sampler,
- const float s[QUAD_SIZE],
- const float t[QUAD_SIZE],
- const float p[QUAD_SIZE],
- float lodbias,
- float rgba[NUM_CHANNELS][QUAD_SIZE]);
- void *pipe; /*XXX temporary*/
- struct softpipe_tile_cache *cache;
-};
-
-/**
- * For branching/calling subroutines.
- */
-struct tgsi_exec_labels
-{
- unsigned labels[128][2];
- unsigned count;
-};
-
-/*
- * Locations of various utility registers (_I = Index, _C = Channel)
- */
-#define TGSI_EXEC_TEMP_00000000_I 32
-#define TGSI_EXEC_TEMP_00000000_C 0
-
-#define TGSI_EXEC_TEMP_7FFFFFFF_I 32
-#define TGSI_EXEC_TEMP_7FFFFFFF_C 1
-
-#define TGSI_EXEC_TEMP_80000000_I 32
-#define TGSI_EXEC_TEMP_80000000_C 2
-
-#define TGSI_EXEC_TEMP_FFFFFFFF_I 32
-#define TGSI_EXEC_TEMP_FFFFFFFF_C 3
-
-#define TGSI_EXEC_TEMP_ONE_I 33
-#define TGSI_EXEC_TEMP_ONE_C 0
-
-#define TGSI_EXEC_TEMP_TWO_I 33
-#define TGSI_EXEC_TEMP_TWO_C 1
-
-#define TGSI_EXEC_TEMP_128_I 33
-#define TGSI_EXEC_TEMP_128_C 2
-
-#define TGSI_EXEC_TEMP_MINUS_128_I 33
-#define TGSI_EXEC_TEMP_MINUS_128_C 3
-
-#define TGSI_EXEC_TEMP_KILMASK_I 34
-#define TGSI_EXEC_TEMP_KILMASK_C 0
-
-#define TGSI_EXEC_TEMP_OUTPUT_I 34
-#define TGSI_EXEC_TEMP_OUTPUT_C 1
-
-#define TGSI_EXEC_TEMP_PRIMITIVE_I 34
-#define TGSI_EXEC_TEMP_PRIMITIVE_C 2
-
-#define TGSI_EXEC_TEMP_R0 35
-
-#define TGSI_EXEC_NUM_TEMPS (32 + 4)
-#define TGSI_EXEC_NUM_ADDRS 1
-#define TGSI_EXEC_NUM_IMMEDIATES 256
-
-#define TGSI_EXEC_MAX_COND_NESTING 10
-#define TGSI_EXEC_MAX_LOOP_NESTING 10
-#define TGSI_EXEC_MAX_CALL_NESTING 10
-
-/**
- * Run-time virtual machine state for executing TGSI shader.
- */
-struct tgsi_exec_machine
-{
- /*
- * 32 program temporaries
- * 4 internal temporaries
- * 1 address
- * 1 temporary of padding to align to 16 bytes
- */
- struct tgsi_exec_vector _Temps[TGSI_EXEC_NUM_TEMPS + TGSI_EXEC_NUM_ADDRS + 1];
-
- /*
- * This will point to _Temps after aligning to 16B boundary.
- */
- struct tgsi_exec_vector *Temps;
- struct tgsi_exec_vector *Addrs;
-
- struct tgsi_sampler *Samplers;
-
- float Imms[TGSI_EXEC_NUM_IMMEDIATES][4];
- unsigned ImmLimit;
- float (*Consts)[4];
- struct tgsi_exec_vector *Inputs;
- struct tgsi_exec_vector *Outputs;
- const struct tgsi_token *Tokens;
- unsigned Processor;
-
- /* GEOMETRY processor only. */
- unsigned *Primitives;
-
- /* FRAGMENT processor only. */
- const struct tgsi_interp_coef *InterpCoefs;
- struct tgsi_exec_vector QuadPos;
-
- /* Conditional execution masks */
- uint CondMask; /**< For IF/ELSE/ENDIF */
- uint LoopMask; /**< For BGNLOOP/ENDLOOP */
- uint ContMask; /**< For loop CONT statements */
- uint FuncMask; /**< For function calls */
- uint ExecMask; /**< = CondMask & LoopMask */
-
- /** Condition mask stack (for nested conditionals) */
- uint CondStack[TGSI_EXEC_MAX_COND_NESTING];
- int CondStackTop;
-
- /** Loop mask stack (for nested loops) */
- uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING];
- int LoopStackTop;
-
- /** Loop continue mask stack (see comments in tgsi_exec.c) */
- uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING];
- int ContStackTop;
-
- /** Function execution mask stack (for executing subroutine code) */
- uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING];
- int FuncStackTop;
-
- /** Function call stack for saving/restoring the program counter */
- uint CallStack[TGSI_EXEC_MAX_CALL_NESTING];
- int CallStackTop;
-
- struct tgsi_full_instruction *Instructions;
- uint NumInstructions;
-
- struct tgsi_full_declaration *Declarations;
- uint NumDeclarations;
-
- struct tgsi_exec_labels Labels;
-};
-
-void
-tgsi_exec_machine_init(
- struct tgsi_exec_machine *mach );
-
-
-void
-tgsi_exec_machine_bind_shader(
- struct tgsi_exec_machine *mach,
- const struct tgsi_token *tokens,
- uint numSamplers,
- struct tgsi_sampler *samplers);
-
-uint
-tgsi_exec_machine_run(
- struct tgsi_exec_machine *mach );
-
-
-void
-tgsi_exec_machine_free_data(struct tgsi_exec_machine *mach);
-
-
-#if defined __cplusplus
-} /* extern "C" */
-#endif
-
-#endif /* TGSI_EXEC_H */
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c b/src/mesa/pipe/tgsi/exec/tgsi_sse2.c
deleted file mode 100755
index 9bc9483e3b..0000000000
--- a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c
+++ /dev/null
@@ -1,2377 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-#include "pipe/tgsi/util/tgsi_util.h"
-#include "tgsi_exec.h"
-#include "tgsi_sse2.h"
-
-#include "x86/rtasm/x86sse.h"
-
-#if defined(__i386__) || defined(__386__)
-
-#define DUMP_SSE 0
-
-#if DUMP_SSE
-
-static void
-_print_reg(
- struct x86_reg reg )
-{
- if (reg.mod != mod_REG)
- debug_printf( "[" );
-
- switch( reg.file ) {
- case file_REG32:
- switch( reg.idx ) {
- case reg_AX:
- debug_printf( "EAX" );
- break;
- case reg_CX:
- debug_printf( "ECX" );
- break;
- case reg_DX:
- debug_printf( "EDX" );
- break;
- case reg_BX:
- debug_printf( "EBX" );
- break;
- case reg_SP:
- debug_printf( "ESP" );
- break;
- case reg_BP:
- debug_printf( "EBP" );
- break;
- case reg_SI:
- debug_printf( "ESI" );
- break;
- case reg_DI:
- debug_printf( "EDI" );
- break;
- }
- break;
- case file_MMX:
- assert( 0 );
- break;
- case file_XMM:
- debug_printf( "XMM%u", reg.idx );
- break;
- case file_x87:
- assert( 0 );
- break;
- }
-
- if (reg.mod == mod_DISP8 ||
- reg.mod == mod_DISP32)
- debug_printf("+%d", reg.disp);
-
- if (reg.mod != mod_REG)
- debug_printf( "]" );
-}
-
-static void
-_fill(
- const char *op )
-{
- unsigned count = 10 - strlen( op );
-
- while( count-- ) {
- debug_printf( " " );
- }
-}
-
-#define DUMP_START() debug_printf( "\nsse-dump start ----------------" )
-#define DUMP_END() debug_printf( "\nsse-dump end ----------------\n" )
-#define DUMP( OP ) debug_printf( "\n%s", OP )
-#define DUMP_I( OP, I ) do {\
- debug_printf( "\n%s", OP );\
- _fill( OP );\
- debug_printf( "%u", I ); } while( 0 )
-#define DUMP_R( OP, R0 ) do {\
- debug_printf( "\n%s", OP );\
- _fill( OP );\
- _print_reg( R0 ); } while( 0 )
-#define DUMP_RR( OP, R0, R1 ) do {\
- debug_printf( "\n%s", OP );\
- _fill( OP );\
- _print_reg( R0 );\
- debug_printf( ", " );\
- _print_reg( R1 ); } while( 0 )
-#define DUMP_RRI( OP, R0, R1, I ) do {\
- debug_printf( "\n%s", OP );\
- _fill( OP );\
- _print_reg( R0 );\
- debug_printf( ", " );\
- _print_reg( R1 );\
- debug_printf( ", " );\
- debug_printf( "%u", I ); } while( 0 )
-
-#else
-
-#define DUMP_START()
-#define DUMP_END()
-#define DUMP( OP )
-#define DUMP_I( OP, I )
-#define DUMP_R( OP, R0 )
-#define DUMP_RR( OP, R0, R1 )
-#define DUMP_RRI( OP, R0, R1, I )
-
-#endif
-
-#define FOR_EACH_CHANNEL( CHAN )\
- for( CHAN = 0; CHAN < 4; 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 ))
-
-#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
- FOR_EACH_CHANNEL( CHAN )\
- IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
-
-#define CHAN_X 0
-#define CHAN_Y 1
-#define CHAN_Z 2
-#define CHAN_W 3
-
-#define TEMP_R0 TGSI_EXEC_TEMP_R0
-
-/**
- * X86 utility functions.
- */
-
-static struct x86_reg
-make_xmm(
- unsigned xmm )
-{
- return x86_make_reg(
- file_XMM,
- (enum x86_reg_name) xmm );
-}
-
-/**
- * X86 register mapping helpers.
- */
-
-static struct x86_reg
-get_const_base( void )
-{
- return x86_make_reg(
- file_REG32,
- reg_CX );
-}
-
-static struct x86_reg
-get_input_base( void )
-{
- return x86_make_reg(
- file_REG32,
- reg_AX );
-}
-
-static struct x86_reg
-get_output_base( void )
-{
- return x86_make_reg(
- file_REG32,
- reg_DX );
-}
-
-static struct x86_reg
-get_temp_base( void )
-{
-#ifdef WIN32
- return x86_make_reg(
- file_REG32,
- reg_BX );
-#else
- return x86_make_reg(
- file_REG32,
- reg_SI );
-#endif
-}
-
-static struct x86_reg
-get_coef_base( void )
-{
- return get_output_base();
-}
-
-/**
- * Data access helpers.
- */
-
-static struct x86_reg
-get_argument(
- unsigned index )
-{
- return x86_make_disp(
- x86_make_reg( file_REG32, reg_SP ),
- (index + 1) * 4 );
-}
-
-static struct x86_reg
-get_const(
- unsigned vec,
- unsigned chan )
-{
- return x86_make_disp(
- get_const_base(),
- (vec * 4 + chan) * 4 );
-}
-
-static struct x86_reg
-get_input(
- unsigned vec,
- unsigned chan )
-{
- return x86_make_disp(
- get_input_base(),
- (vec * 4 + chan) * 16 );
-}
-
-static struct x86_reg
-get_output(
- unsigned vec,
- unsigned chan )
-{
- return x86_make_disp(
- get_output_base(),
- (vec * 4 + chan) * 16 );
-}
-
-static struct x86_reg
-get_temp(
- unsigned vec,
- unsigned chan )
-{
- return x86_make_disp(
- get_temp_base(),
- (vec * 4 + chan) * 16 );
-}
-
-static struct x86_reg
-get_coef(
- unsigned vec,
- unsigned chan,
- unsigned member )
-{
- return x86_make_disp(
- get_coef_base(),
- ((vec * 3 + member) * 4 + chan) * 4 );
-}
-
-/**
- * X86 rtasm wrappers.
- */
-
-static void
-emit_addps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "ADDPS", dst, src );
- sse_addps( func, dst, src );
-}
-
-static void
-emit_andnps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "ANDNPS", dst, src );
- sse_andnps( func, dst, src );
-}
-
-static void
-emit_andps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "ANDPS", dst, src );
- sse_andps( func, dst, src );
-}
-
-static void
-emit_call(
- struct x86_function *func,
- void (* addr)() )
-{
- struct x86_reg ecx = x86_make_reg( file_REG32, reg_CX );
-
- DUMP_I( "CALL", addr );
- x86_mov_reg_imm( func, ecx, (unsigned long) addr );
- x86_call( func, ecx );
-}
-
-static void
-emit_cmpps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src,
- enum sse_cc cc )
-{
- DUMP_RRI( "CMPPS", dst, src, cc );
- sse_cmpps( func, dst, src, cc );
-}
-
-static void
-emit_cvttps2dq(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "CVTTPS2DQ", dst, src );
- sse2_cvttps2dq( func, dst, src );
-}
-
-static void
-emit_maxps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MAXPS", dst, src );
- sse_maxps( func, dst, src );
-}
-
-static void
-emit_minps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MINPS", dst, src );
- sse_minps( func, dst, src );
-}
-
-static void
-emit_mov(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MOV", dst, src );
- x86_mov( func, dst, src );
-}
-
-static void
-emit_movaps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MOVAPS", dst, src );
- sse_movaps( func, dst, src );
-}
-
-static void
-emit_movss(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MOVSS", dst, src );
- sse_movss( func, dst, src );
-}
-
-static void
-emit_movups(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MOVUPS", dst, src );
- sse_movups( func, dst, src );
-}
-
-static void
-emit_mulps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "MULPS", dst, src );
- sse_mulps( func, dst, src );
-}
-
-static void
-emit_or(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "OR", dst, src );
- x86_or( func, dst, src );
-}
-
-static void
-emit_orps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "ORPS", dst, src );
- sse_orps( func, dst, src );
-}
-
-static void
-emit_pmovmskb(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "PMOVMSKB", dst, src );
- sse_pmovmskb( func, dst, src );
-}
-
-static void
-emit_pop(
- struct x86_function *func,
- struct x86_reg dst )
-{
- DUMP_R( "POP", dst );
- x86_pop( func, dst );
-}
-
-static void
-emit_push(
- struct x86_function *func,
- struct x86_reg dst )
-{
- DUMP_R( "PUSH", dst );
- x86_push( func, dst );
-}
-
-static void
-emit_rcpps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "RCPPS", dst, src );
- sse2_rcpps( func, dst, src );
-}
-
-#ifdef WIN32
-static void
-emit_retw(
- struct x86_function *func,
- unsigned size )
-{
- DUMP_I( "RET", size );
- x86_retw( func, size );
-}
-#else
-static void
-emit_ret(
- struct x86_function *func )
-{
- DUMP( "RET" );
- x86_ret( func );
-}
-#endif
-
-static void
-emit_rsqrtps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "RSQRTPS", dst, src );
- sse_rsqrtps( func, dst, src );
-}
-
-static void
-emit_shufps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src,
- unsigned char shuf )
-{
- DUMP_RRI( "SHUFPS", dst, src, shuf );
- sse_shufps( func, dst, src, shuf );
-}
-
-static void
-emit_subps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "SUBPS", dst, src );
- sse_subps( func, dst, src );
-}
-
-static void
-emit_xorps(
- struct x86_function *func,
- struct x86_reg dst,
- struct x86_reg src )
-{
- DUMP_RR( "XORPS", dst, src );
- sse_xorps( func, dst, src );
-}
-
-/**
- * Data fetch helpers.
- */
-
-static void
-emit_const(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movss(
- func,
- make_xmm( xmm ),
- get_const( vec, chan ) );
- emit_shufps(
- func,
- make_xmm( xmm ),
- make_xmm( xmm ),
- SHUF( 0, 0, 0, 0 ) );
-}
-
-static void
-emit_inputf(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movups(
- func,
- make_xmm( xmm ),
- get_input( vec, chan ) );
-}
-
-static void
-emit_output(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movups(
- func,
- get_output( vec, chan ),
- make_xmm( xmm ) );
-}
-
-static void
-emit_tempf(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movaps(
- func,
- make_xmm( xmm ),
- get_temp( vec, chan ) );
-}
-
-static void
-emit_coef(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan,
- unsigned member )
-{
- emit_movss(
- func,
- make_xmm( xmm ),
- get_coef( vec, chan, member ) );
- emit_shufps(
- func,
- make_xmm( xmm ),
- make_xmm( xmm ),
- SHUF( 0, 0, 0, 0 ) );
-}
-
-/**
- * Data store helpers.
- */
-
-static void
-emit_inputs(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movups(
- func,
- get_input( vec, chan ),
- make_xmm( xmm ) );
-}
-
-static void
-emit_temps(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_movaps(
- func,
- get_temp( vec, chan ),
- make_xmm( xmm ) );
-}
-
-static void
-emit_addrs(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_temps(
- func,
- xmm,
- vec + TGSI_EXEC_NUM_TEMPS,
- chan );
-}
-
-/**
- * Coefficent fetch helpers.
- */
-
-static void
-emit_coef_a0(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_coef(
- func,
- xmm,
- vec,
- chan,
- 0 );
-}
-
-static void
-emit_coef_dadx(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_coef(
- func,
- xmm,
- vec,
- chan,
- 1 );
-}
-
-static void
-emit_coef_dady(
- struct x86_function *func,
- unsigned xmm,
- unsigned vec,
- unsigned chan )
-{
- emit_coef(
- func,
- xmm,
- vec,
- chan,
- 2 );
-}
-
-/**
- * Function call helpers.
- */
-
-static void
-emit_push_gp(
- struct x86_function *func )
-{
- emit_push(
- func,
- get_const_base() );
- emit_push(
- func,
- get_input_base() );
- emit_push(
- func,
- get_output_base() );
-
- /* It is important on non-win32 platforms that temp base is pushed last.
- */
- emit_push(
- func,
- get_temp_base() );
-}
-
-static void
-emit_pop_gp(
- struct x86_function *func )
-{
- /* Restore GP registers in a reverse order.
- */
- emit_pop(
- func,
- get_temp_base() );
- emit_pop(
- func,
- get_output_base() );
- emit_pop(
- func,
- get_input_base() );
- emit_pop(
- func,
- get_const_base() );
-}
-
-static void
-emit_func_call_dst(
- struct x86_function *func,
- unsigned xmm_dst,
- void (*code)() )
-{
- emit_movaps(
- func,
- get_temp( TEMP_R0, 0 ),
- make_xmm( xmm_dst ) );
-
- emit_push_gp(
- func );
-
-#ifdef WIN32
- emit_push(
- func,
- get_temp( TEMP_R0, 0 ) );
-#endif
-
- emit_call(
- func,
- code );
-
- emit_pop_gp(
- func );
-
- emit_movaps(
- func,
- make_xmm( xmm_dst ),
- get_temp( TEMP_R0, 0 ) );
-}
-
-static void
-emit_func_call_dst_src(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src,
- void (*code)() )
-{
- emit_movaps(
- func,
- get_temp( TEMP_R0, 1 ),
- make_xmm( xmm_src ) );
-
- emit_func_call_dst(
- func,
- xmm_dst,
- code );
-}
-
-/**
- * Low-level instruction translators.
- */
-
-static void
-emit_abs(
- struct x86_function *func,
- unsigned xmm )
-{
- emit_andps(
- func,
- make_xmm( xmm ),
- get_temp(
- TGSI_EXEC_TEMP_7FFFFFFF_I,
- TGSI_EXEC_TEMP_7FFFFFFF_C ) );
-}
-
-static void
-emit_add(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_addps(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-static void XSTDCALL
-cos4f(
- float *store )
-{
-#ifdef WIN32
- store[0] = (float) cos( (double) store[0] );
- store[1] = (float) cos( (double) store[1] );
- store[2] = (float) cos( (double) store[2] );
- store[3] = (float) cos( (double) store[3] );
-#else
- const unsigned X = TEMP_R0 * 16;
- 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] );
-#endif
-}
-
-static void
-emit_cos(
- struct x86_function *func,
- unsigned xmm_dst )
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- cos4f );
-}
-
-static void XSTDCALL
-ex24f(
- float *store )
-{
-#ifdef WIN32
- store[0] = (float) pow( 2.0, (double) store[0] );
- store[1] = (float) pow( 2.0, (double) store[1] );
- store[2] = (float) pow( 2.0, (double) store[2] );
- store[3] = (float) pow( 2.0, (double) store[3] );
-#else
- const unsigned X = TEMP_R0 * 16;
- 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] );
-#endif
-}
-
-static void
-emit_ex2(
- struct x86_function *func,
- unsigned xmm_dst )
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- ex24f );
-}
-
-static void
-emit_f2it(
- struct x86_function *func,
- unsigned xmm )
-{
- emit_cvttps2dq(
- func,
- make_xmm( xmm ),
- make_xmm( xmm ) );
-}
-
-static void XSTDCALL
-flr4f(
- float *store )
-{
-#ifdef WIN32
- const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
- store[X + 0] = (float) floor( (double) store[X + 0] );
- store[X + 1] = (float) floor( (double) store[X + 1] );
- store[X + 2] = (float) floor( (double) store[X + 2] );
- store[X + 3] = (float) floor( (double) store[X + 3] );
-}
-
-static void
-emit_flr(
- struct x86_function *func,
- unsigned xmm_dst )
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- flr4f );
-}
-
-static void XSTDCALL
-frc4f(
- float *store )
-{
-#ifdef WIN32
- const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
- store[X + 0] -= (float) floor( (double) store[X + 0] );
- store[X + 1] -= (float) floor( (double) store[X + 1] );
- store[X + 2] -= (float) floor( (double) store[X + 2] );
- store[X + 3] -= (float) floor( (double) store[X + 3] );
-}
-
-static void
-emit_frc(
- struct x86_function *func,
- unsigned xmm_dst )
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- frc4f );
-}
-
-static void XSTDCALL
-lg24f(
- float *store )
-{
-#ifdef WIN32
- const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
- 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] );
-}
-
-static void
-emit_lg2(
- struct x86_function *func,
- unsigned xmm_dst )
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- lg24f );
-}
-
-static void
-emit_MOV(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_movups(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-static void
-emit_mul (struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src)
-{
- emit_mulps(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-static void
-emit_neg(
- struct x86_function *func,
- unsigned xmm )
-{
- emit_xorps(
- func,
- make_xmm( xmm ),
- get_temp(
- TGSI_EXEC_TEMP_80000000_I,
- TGSI_EXEC_TEMP_80000000_C ) );
-}
-
-static void XSTDCALL
-pow4f(
- float *store )
-{
-#ifdef WIN32
- store[0] = (float) pow( (double) store[0], (double) store[4] );
- store[1] = (float) pow( (double) store[1], (double) store[5] );
- store[2] = (float) pow( (double) store[2], (double) store[6] );
- store[3] = (float) pow( (double) store[3], (double) store[7] );
-#else
- const unsigned X = TEMP_R0 * 16;
- 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] );
-#endif
-}
-
-static void
-emit_pow(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_func_call_dst_src(
- func,
- xmm_dst,
- xmm_src,
- pow4f );
-}
-
-static void
-emit_rcp (
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_rcpps(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-static void
-emit_rsqrt(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_rsqrtps(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-static void
-emit_setsign(
- struct x86_function *func,
- unsigned xmm )
-{
- emit_orps(
- func,
- make_xmm( xmm ),
- get_temp(
- TGSI_EXEC_TEMP_80000000_I,
- TGSI_EXEC_TEMP_80000000_C ) );
-}
-
-static void XSTDCALL
-sin4f(
- float *store )
-{
-#ifdef WIN32
- store[0] = (float) sin( (double) store[0] );
- store[1] = (float) sin( (double) store[1] );
- store[2] = (float) sin( (double) store[2] );
- store[3] = (float) sin( (double) store[3] );
-#else
- const unsigned X = TEMP_R0 * 16;
- 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] );
-#endif
-}
-
-static void
-emit_sin (struct x86_function *func,
- unsigned xmm_dst)
-{
- emit_func_call_dst(
- func,
- xmm_dst,
- sin4f );
-}
-
-static void
-emit_sub(
- struct x86_function *func,
- unsigned xmm_dst,
- unsigned xmm_src )
-{
- emit_subps(
- func,
- make_xmm( xmm_dst ),
- make_xmm( xmm_src ) );
-}
-
-/**
- * Register fetch.
- */
-
-static void
-emit_fetch(
- struct x86_function *func,
- unsigned xmm,
- const struct tgsi_full_src_register *reg,
- const unsigned chan_index )
-{
- unsigned swizzle = tgsi_util_get_full_src_register_extswizzle( reg, chan_index );
-
- switch( swizzle ) {
- case TGSI_EXTSWIZZLE_X:
- case TGSI_EXTSWIZZLE_Y:
- case TGSI_EXTSWIZZLE_Z:
- case TGSI_EXTSWIZZLE_W:
- switch( reg->SrcRegister.File ) {
- case TGSI_FILE_CONSTANT:
- emit_const(
- func,
- xmm,
- reg->SrcRegister.Index,
- swizzle );
- break;
-
- case TGSI_FILE_INPUT:
- emit_inputf(
- func,
- xmm,
- reg->SrcRegister.Index,
- swizzle );
- break;
-
- case TGSI_FILE_TEMPORARY:
- emit_tempf(
- func,
- xmm,
- reg->SrcRegister.Index,
- swizzle );
- break;
-
- default:
- assert( 0 );
- }
- break;
-
- case TGSI_EXTSWIZZLE_ZERO:
- emit_tempf(
- func,
- xmm,
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C );
- break;
-
- case TGSI_EXTSWIZZLE_ONE:
- emit_tempf(
- func,
- xmm,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
- break;
-
- default:
- assert( 0 );
- }
-
- switch( tgsi_util_get_full_src_register_sign_mode( reg, chan_index ) ) {
- case TGSI_UTIL_SIGN_CLEAR:
- emit_abs( func, xmm );
- break;
-
- case TGSI_UTIL_SIGN_SET:
- emit_setsign( func, xmm );
- break;
-
- case TGSI_UTIL_SIGN_TOGGLE:
- emit_neg( func, xmm );
- break;
-
- case TGSI_UTIL_SIGN_KEEP:
- break;
- }
-}
-
-#define FETCH( FUNC, INST, XMM, INDEX, CHAN )\
- emit_fetch( FUNC, XMM, &(INST).FullSrcRegisters[INDEX], CHAN )
-
-/**
- * Register store.
- */
-
-static void
-emit_store(
- struct x86_function *func,
- unsigned xmm,
- const struct tgsi_full_dst_register *reg,
- const struct tgsi_full_instruction *inst,
- unsigned chan_index )
-{
- switch( reg->DstRegister.File ) {
- case TGSI_FILE_OUTPUT:
- emit_output(
- func,
- xmm,
- reg->DstRegister.Index,
- chan_index );
- break;
-
- case TGSI_FILE_TEMPORARY:
- emit_temps(
- func,
- xmm,
- reg->DstRegister.Index,
- chan_index );
- break;
-
- case TGSI_FILE_ADDRESS:
- emit_addrs(
- func,
- xmm,
- reg->DstRegister.Index,
- chan_index );
- break;
-
- default:
- assert( 0 );
- }
-
- switch( inst->Instruction.Saturate ) {
- case TGSI_SAT_NONE:
- break;
-
- case TGSI_SAT_ZERO_ONE:
-// assert( 0 );
- break;
-
- case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
- break;
- }
-}
-
-#define STORE( FUNC, INST, XMM, INDEX, CHAN )\
- emit_store( FUNC, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
-
-/**
- * High-level instruction translators.
- */
-
-static void
-emit_kil(
- struct x86_function *func,
- const struct tgsi_full_src_register *reg )
-{
- unsigned uniquemask;
- unsigned registers[4];
- unsigned nextregister = 0;
- unsigned firstchan = ~0;
- unsigned chan_index;
-
- /* This mask stores component bits that were already tested. Note that
- * we test if the value is less than zero, so 1.0 and 0.0 need not to be
- * tested. */
- uniquemask = (1 << TGSI_EXTSWIZZLE_ZERO) | (1 << TGSI_EXTSWIZZLE_ONE);
-
- FOR_EACH_CHANNEL( chan_index ) {
- unsigned swizzle;
-
- /* unswizzle channel */
- swizzle = tgsi_util_get_full_src_register_extswizzle(
- reg,
- chan_index );
-
- /* check if the component has not been already tested */
- if( !(uniquemask & (1 << swizzle)) ) {
- uniquemask |= 1 << swizzle;
-
- /* allocate register */
- registers[chan_index] = nextregister;
- emit_fetch(
- func,
- nextregister,
- reg,
- chan_index );
- nextregister++;
-
- /* mark the first channel used */
- if( firstchan == ~0 ) {
- firstchan = chan_index;
- }
- }
- }
-
- emit_push(
- func,
- x86_make_reg( file_REG32, reg_AX ) );
- emit_push(
- func,
- x86_make_reg( file_REG32, reg_DX ) );
-
- FOR_EACH_CHANNEL( chan_index ) {
- if( uniquemask & (1 << chan_index) ) {
- emit_cmpps(
- func,
- make_xmm( registers[chan_index] ),
- get_temp(
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C ),
- cc_LessThan );
-
- if( chan_index == firstchan ) {
- emit_pmovmskb(
- func,
- x86_make_reg( file_REG32, reg_AX ),
- make_xmm( registers[chan_index] ) );
- }
- else {
- emit_pmovmskb(
- func,
- x86_make_reg( file_REG32, reg_DX ),
- make_xmm( registers[chan_index] ) );
- emit_or(
- func,
- x86_make_reg( file_REG32, reg_AX ),
- x86_make_reg( file_REG32, reg_DX ) );
- }
- }
- }
-
- emit_or(
- func,
- get_temp(
- TGSI_EXEC_TEMP_KILMASK_I,
- TGSI_EXEC_TEMP_KILMASK_C ),
- x86_make_reg( file_REG32, reg_AX ) );
-
- emit_pop(
- func,
- x86_make_reg( file_REG32, reg_DX ) );
- emit_pop(
- func,
- x86_make_reg( file_REG32, reg_AX ) );
-}
-
-static void
-emit_setcc(
- struct x86_function *func,
- struct tgsi_full_instruction *inst,
- enum sse_cc cc )
-{
- unsigned chan_index;
-
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_cmpps(
- func,
- make_xmm( 0 ),
- make_xmm( 1 ),
- cc );
- emit_andps(
- func,
- make_xmm( 0 ),
- get_temp(
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C ) );
- STORE( func, *inst, 0, 0, chan_index );
- }
-}
-
-static void
-emit_cmp(
- struct x86_function *func,
- struct tgsi_full_instruction *inst )
-{
- unsigned chan_index;
-
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- FETCH( func, *inst, 2, 2, chan_index );
- emit_cmpps(
- func,
- make_xmm( 0 ),
- get_temp(
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C ),
- cc_LessThan );
- emit_andps(
- func,
- make_xmm( 1 ),
- make_xmm( 0 ) );
- emit_andnps(
- func,
- make_xmm( 0 ),
- make_xmm( 2 ) );
- emit_orps(
- func,
- make_xmm( 0 ),
- make_xmm( 1 ) );
- STORE( func, *inst, 0, 0, chan_index );
- }
-}
-
-static int
-emit_instruction(
- struct x86_function *func,
- struct tgsi_full_instruction *inst )
-{
- unsigned chan_index;
-
- switch( inst->Instruction.Opcode ) {
- case TGSI_OPCODE_ARL:
- 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 );
- }
- break;
-
- case TGSI_OPCODE_MOV:
- /* TGSI_OPCODE_SWZ */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LIT:
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
- IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
- emit_tempf(
- func,
- 0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C);
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ) {
- STORE( func, *inst, 0, 0, CHAN_X );
- }
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) ) {
- STORE( func, *inst, 0, 0, CHAN_W );
- }
- }
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
- IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_maxps(
- func,
- make_xmm( 0 ),
- get_temp(
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C ) );
- STORE( func, *inst, 0, 0, CHAN_Y );
- }
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- FETCH( func, *inst, 1, 0, CHAN_Y );
- emit_maxps(
- func,
- make_xmm( 1 ),
- get_temp(
- TGSI_EXEC_TEMP_00000000_I,
- TGSI_EXEC_TEMP_00000000_C ) );
- FETCH( func, *inst, 2, 0, CHAN_W );
- emit_minps(
- func,
- make_xmm( 2 ),
- get_temp(
- TGSI_EXEC_TEMP_128_I,
- TGSI_EXEC_TEMP_128_C ) );
- emit_maxps(
- func,
- make_xmm( 2 ),
- get_temp(
- TGSI_EXEC_TEMP_MINUS_128_I,
- TGSI_EXEC_TEMP_MINUS_128_C ) );
- emit_pow( func, 1, 2 );
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_xorps(
- func,
- make_xmm( 2 ),
- make_xmm( 2 ) );
- emit_cmpps(
- func,
- make_xmm( 2 ),
- make_xmm( 0 ),
- cc_LessThanEqual );
- emit_andps(
- func,
- make_xmm( 2 ),
- make_xmm( 1 ) );
- STORE( func, *inst, 2, 0, CHAN_Z );
- }
- }
- break;
-
- case TGSI_OPCODE_RCP:
- /* TGSI_OPCODE_RECIP */
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_rcp( func, 0, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_RSQ:
- /* TGSI_OPCODE_RECIPSQRT */
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_rsqrt( func, 0, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_EXP:
- return 0;
- break;
-
- case TGSI_OPCODE_LOG:
- return 0;
- break;
-
- case TGSI_OPCODE_MUL:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_mul( func, 0, 1 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_ADD:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_add( func, 0, 1 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP3:
- /* TGSI_OPCODE_DOT3 */
- FETCH( func, *inst, 0, 0, CHAN_X );
- FETCH( func, *inst, 1, 1, CHAN_X );
- emit_mul( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Y );
- FETCH( func, *inst, 2, 1, CHAN_Y );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Z );
- FETCH( func, *inst, 2, 1, CHAN_Z );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DP4:
- /* TGSI_OPCODE_DOT4 */
- FETCH( func, *inst, 0, 0, CHAN_X );
- FETCH( func, *inst, 1, 1, CHAN_X );
- emit_mul( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Y );
- FETCH( func, *inst, 2, 1, CHAN_Y );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Z );
- FETCH( func, *inst, 2, 1, CHAN_Z );
- emit_mul(func, 1, 2 );
- emit_add(func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_W );
- FETCH( func, *inst, 2, 1, CHAN_W );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DST:
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
- emit_tempf(
- func,
- 0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
- STORE( func, *inst, 0, 0, CHAN_X );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
- FETCH( func, *inst, 0, 0, CHAN_Y );
- FETCH( func, *inst, 1, 1, CHAN_Y );
- emit_mul( func, 0, 1 );
- STORE( func, *inst, 0, 0, CHAN_Y );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
- FETCH( func, *inst, 0, 0, CHAN_Z );
- STORE( func, *inst, 0, 0, CHAN_Z );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
- FETCH( func, *inst, 0, 1, CHAN_W );
- STORE( func, *inst, 0, 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MIN:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_minps(
- func,
- make_xmm( 0 ),
- make_xmm( 1 ) );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_MAX:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_maxps(
- func,
- make_xmm( 0 ),
- make_xmm( 1 ) );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLT:
- /* TGSI_OPCODE_SETLT */
- emit_setcc( func, inst, cc_LessThan );
- break;
-
- case TGSI_OPCODE_SGE:
- /* TGSI_OPCODE_SETGE */
- emit_setcc( func, inst, cc_NotLessThan );
- break;
-
- case TGSI_OPCODE_MAD:
- /* TGSI_OPCODE_MADD */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- FETCH( func, *inst, 2, 2, chan_index );
- emit_mul( func, 0, 1 );
- emit_add( func, 0, 2 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SUB:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- emit_sub( func, 0, 1 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LERP:
- /* TGSI_OPCODE_LRP */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- FETCH( func, *inst, 1, 1, chan_index );
- FETCH( func, *inst, 2, 2, chan_index );
- emit_sub( func, 1, 2 );
- emit_mul( func, 0, 1 );
- emit_add( func, 0, 2 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CND:
- return 0;
- break;
-
- case TGSI_OPCODE_CND0:
- return 0;
- break;
-
- case TGSI_OPCODE_DOT2ADD:
- /* TGSI_OPCODE_DP2A */
- return 0;
- break;
-
- case TGSI_OPCODE_INDEX:
- return 0;
- break;
-
- case TGSI_OPCODE_NEGATE:
- return 0;
- break;
-
- case TGSI_OPCODE_FRAC:
- /* TGSI_OPCODE_FRC */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- emit_frc( func, 0 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CLAMP:
- return 0;
- break;
-
- case TGSI_OPCODE_FLOOR:
- /* TGSI_OPCODE_FLR */
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- emit_flr( func, 0 );
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_ROUND:
- return 0;
- break;
-
- case TGSI_OPCODE_EXPBASE2:
- /* TGSI_OPCODE_EX2 */
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_ex2( func, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_LOGBASE2:
- /* TGSI_OPCODE_LG2 */
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_lg2( func, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_POWER:
- /* TGSI_OPCODE_POW */
- FETCH( func, *inst, 0, 0, CHAN_X );
- FETCH( func, *inst, 1, 1, CHAN_X );
- emit_pow( func, 0, 1 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_CROSSPRODUCT:
- /* TGSI_OPCODE_XPD */
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
- IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
- FETCH( func, *inst, 1, 1, CHAN_Z );
- FETCH( func, *inst, 3, 0, CHAN_Z );
- }
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
- IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- FETCH( func, *inst, 0, 0, CHAN_Y );
- FETCH( func, *inst, 4, 1, CHAN_Y );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
- emit_MOV( func, 2, 0 );
- emit_mul( func, 2, 1 );
- emit_MOV( func, 5, 3 );
- emit_mul( func, 5, 4 );
- emit_sub( func, 2, 5 );
- STORE( func, *inst, 2, 0, CHAN_X );
- }
- if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
- IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
- FETCH( func, *inst, 2, 1, CHAN_X );
- FETCH( func, *inst, 5, 0, CHAN_X );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
- emit_mul( func, 3, 2 );
- emit_mul( func, 1, 5 );
- emit_sub( func, 3, 1 );
- STORE( func, *inst, 3, 0, CHAN_Y );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
- emit_mul( func, 5, 4 );
- emit_mul( func, 0, 2 );
- emit_sub( func, 5, 0 );
- STORE( func, *inst, 5, 0, CHAN_Z );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
- FETCH( func, *inst, 0, TGSI_EXEC_TEMP_ONE_I, TGSI_EXEC_TEMP_ONE_C );
- STORE( func, *inst, 0, 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_MULTIPLYMATRIX:
- return 0;
- break;
-
- case TGSI_OPCODE_ABS:
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- FETCH( func, *inst, 0, 0, chan_index );
- emit_abs( func, 0) ;
-
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_RCC:
- return 0;
- break;
-
- case TGSI_OPCODE_DPH:
- FETCH( func, *inst, 0, 0, CHAN_X );
- FETCH( func, *inst, 1, 1, CHAN_X );
- emit_mul( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Y );
- FETCH( func, *inst, 2, 1, CHAN_Y );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FETCH( func, *inst, 1, 0, CHAN_Z );
- FETCH( func, *inst, 2, 1, CHAN_Z );
- emit_mul( func, 1, 2 );
- emit_add( func, 0, 1 );
- FETCH( func, *inst, 1, 1, CHAN_W );
- emit_add( func, 0, 1 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_COS:
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_cos( func, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_DDX:
- return 0;
- break;
-
- case TGSI_OPCODE_DDY:
- return 0;
- break;
-
- case TGSI_OPCODE_KIL:
- emit_kil( func, &inst->FullSrcRegisters[0] );
- break;
-
- case TGSI_OPCODE_PK2H:
- return 0;
- break;
-
- case TGSI_OPCODE_PK2US:
- return 0;
- break;
-
- case TGSI_OPCODE_PK4B:
- return 0;
- break;
-
- case TGSI_OPCODE_PK4UB:
- return 0;
- break;
-
- case TGSI_OPCODE_RFL:
- return 0;
- break;
-
- case TGSI_OPCODE_SEQ:
- return 0;
- break;
-
- case TGSI_OPCODE_SFL:
- return 0;
- break;
-
- case TGSI_OPCODE_SGT:
- return 0;
- break;
-
- case TGSI_OPCODE_SIN:
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_sin( func, 0 );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- break;
-
- case TGSI_OPCODE_SLE:
- return 0;
- break;
-
- case TGSI_OPCODE_SNE:
- return 0;
- break;
-
- case TGSI_OPCODE_STR:
- return 0;
- break;
-
- case TGSI_OPCODE_TEX:
- if (0) {
- /* Disable dummy texture code:
- */
- emit_tempf(
- func,
- 0,
- TGSI_EXEC_TEMP_ONE_I,
- TGSI_EXEC_TEMP_ONE_C );
- FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
- }
- }
- else {
- return 0;
- }
- break;
-
- case TGSI_OPCODE_TXD:
- return 0;
- break;
-
- case TGSI_OPCODE_UP2H:
- return 0;
- break;
-
- case TGSI_OPCODE_UP2US:
- return 0;
- break;
-
- case TGSI_OPCODE_UP4B:
- return 0;
- break;
-
- case TGSI_OPCODE_UP4UB:
- return 0;
- break;
-
- case TGSI_OPCODE_X2D:
- return 0;
- break;
-
- case TGSI_OPCODE_ARA:
- return 0;
- break;
-
- case TGSI_OPCODE_ARR:
- return 0;
- break;
-
- case TGSI_OPCODE_BRA:
- return 0;
- break;
-
- case TGSI_OPCODE_CAL:
- return 0;
- break;
-
- case TGSI_OPCODE_RET:
- case TGSI_OPCODE_END:
-#ifdef WIN32
- emit_retw( func, 16 );
-#else
- emit_ret( func );
-#endif
- break;
-
- case TGSI_OPCODE_SSG:
- return 0;
- break;
-
- case TGSI_OPCODE_CMP:
- emit_cmp (func, inst);
- break;
-
- case TGSI_OPCODE_SCS:
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
- FETCH( func, *inst, 0, 0, CHAN_X );
- emit_cos( func, 0 );
- STORE( func, *inst, 0, 0, CHAN_X );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
- FETCH( func, *inst, 0, 0, CHAN_Y );
- emit_sin( func, 0 );
- STORE( func, *inst, 0, 0, CHAN_Y );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
- FETCH( func, *inst, 0, TGSI_EXEC_TEMP_00000000_I, TGSI_EXEC_TEMP_00000000_C );
- STORE( func, *inst, 0, 0, CHAN_Z );
- }
- IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
- FETCH( func, *inst, 0, TGSI_EXEC_TEMP_ONE_I, TGSI_EXEC_TEMP_ONE_C );
- STORE( func, *inst, 0, 0, CHAN_W );
- }
- break;
-
- case TGSI_OPCODE_TXB:
- return 0;
- break;
-
- case TGSI_OPCODE_NRM:
- return 0;
- break;
-
- case TGSI_OPCODE_DIV:
- return 0;
- break;
-
- case TGSI_OPCODE_DP2:
- return 0;
- break;
-
- case TGSI_OPCODE_TXL:
- return 0;
- break;
-
- case TGSI_OPCODE_BRK:
- return 0;
- break;
-
- case TGSI_OPCODE_IF:
- return 0;
- break;
-
- case TGSI_OPCODE_LOOP:
- return 0;
- break;
-
- case TGSI_OPCODE_REP:
- return 0;
- break;
-
- case TGSI_OPCODE_ELSE:
- return 0;
- break;
-
- case TGSI_OPCODE_ENDIF:
- return 0;
- break;
-
- case TGSI_OPCODE_ENDLOOP:
- return 0;
- break;
-
- case TGSI_OPCODE_ENDREP:
- return 0;
- break;
-
- case TGSI_OPCODE_PUSHA:
- return 0;
- break;
-
- case TGSI_OPCODE_POPA:
- return 0;
- break;
-
- case TGSI_OPCODE_CEIL:
- return 0;
- break;
-
- case TGSI_OPCODE_I2F:
- return 0;
- break;
-
- case TGSI_OPCODE_NOT:
- return 0;
- break;
-
- case TGSI_OPCODE_TRUNC:
- return 0;
- break;
-
- case TGSI_OPCODE_SHL:
- return 0;
- break;
-
- case TGSI_OPCODE_SHR:
- return 0;
- break;
-
- case TGSI_OPCODE_AND:
- return 0;
- break;
-
- case TGSI_OPCODE_OR:
- return 0;
- break;
-
- case TGSI_OPCODE_MOD:
- return 0;
- break;
-
- case TGSI_OPCODE_XOR:
- return 0;
- break;
-
- case TGSI_OPCODE_SAD:
- return 0;
- break;
-
- case TGSI_OPCODE_TXF:
- return 0;
- break;
-
- case TGSI_OPCODE_TXQ:
- return 0;
- break;
-
- case TGSI_OPCODE_CONT:
- return 0;
- break;
-
- case TGSI_OPCODE_EMIT:
- return 0;
- break;
-
- case TGSI_OPCODE_ENDPRIM:
- return 0;
- break;
-
- default:
- return 0;
- }
-
- return 1;
-}
-
-static void
-emit_declaration(
- struct x86_function *func,
- struct tgsi_full_declaration *decl )
-{
- if( decl->Declaration.File == TGSI_FILE_INPUT ) {
- unsigned first, last, mask;
- unsigned i, j;
-
- assert( decl->Declaration.Declare == TGSI_DECLARE_RANGE );
-
- first = decl->u.DeclarationRange.First;
- last = decl->u.DeclarationRange.Last;
- mask = decl->Declaration.UsageMask;
-
- for( i = first; i <= last; i++ ) {
- for( j = 0; j < NUM_CHANNELS; j++ ) {
- if( mask & (1 << j) ) {
- switch( decl->Interpolation.Interpolate ) {
- case TGSI_INTERPOLATE_CONSTANT:
- emit_coef_a0( func, 0, i, j );
- emit_inputs( func, 0, i, j );
- break;
-
- case TGSI_INTERPOLATE_LINEAR:
- emit_tempf( func, 0, 0, TGSI_SWIZZLE_X );
- emit_coef_dadx( func, 1, i, j );
- emit_tempf( func, 2, 0, TGSI_SWIZZLE_Y );
- emit_coef_dady( func, 3, i, j );
- emit_mul( func, 0, 1 ); /* x * dadx */
- emit_coef_a0( func, 4, i, j );
- emit_mul( func, 2, 3 ); /* y * dady */
- emit_add( func, 0, 4 ); /* x * dadx + a0 */
- emit_add( func, 0, 2 ); /* x * dadx + y * dady + a0 */
- emit_inputs( func, 0, i, j );
- break;
-
- case TGSI_INTERPOLATE_PERSPECTIVE:
- emit_tempf( func, 0, 0, TGSI_SWIZZLE_X );
- emit_coef_dadx( func, 1, i, j );
- emit_tempf( func, 2, 0, TGSI_SWIZZLE_Y );
- emit_coef_dady( func, 3, i, j );
- emit_mul( func, 0, 1 ); /* x * dadx */
- emit_tempf( func, 4, 0, TGSI_SWIZZLE_W );
- emit_coef_a0( func, 5, i, j );
- emit_rcp( func, 4, 4 ); /* 1.0 / w */
- emit_mul( func, 2, 3 ); /* y * dady */
- emit_add( func, 0, 5 ); /* x * dadx + a0 */
- emit_add( func, 0, 2 ); /* x * dadx + y * dady + a0 */
- emit_mul( func, 0, 4 ); /* (x * dadx + y * dady + a0) / w */
- emit_inputs( func, 0, i, j );
- break;
-
- default:
- assert( 0 );
- break;
- }
- }
- }
- }
- }
-}
-
-unsigned
-tgsi_emit_sse2(
- struct tgsi_token *tokens,
- struct x86_function *func )
-{
- struct tgsi_parse_context parse;
- unsigned ok = 1;
-
- DUMP_START();
-
- func->csr = func->store;
-
- emit_mov(
- func,
- get_input_base(),
- get_argument( 0 ) );
- emit_mov(
- func,
- get_output_base(),
- get_argument( 1 ) );
- emit_mov(
- func,
- get_const_base(),
- get_argument( 2 ) );
- emit_mov(
- func,
- get_temp_base(),
- get_argument( 3 ) );
-
- tgsi_parse_init( &parse, tokens );
-
- while( !tgsi_parse_end_of_tokens( &parse ) && ok ) {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- ok = emit_instruction(
- func,
- &parse.FullToken.FullInstruction );
-
- if (!ok) {
- debug_printf("failed to translate tgsi opcode %d\n",
- parse.FullToken.FullInstruction.Instruction.Opcode );
- }
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- /* XXX implement this */
- ok = 0;
- debug_printf("failed to emit immediate value\n");
- break;
-
- default:
- assert( 0 );
- ok = 0;
- break;
- }
- }
-
- tgsi_parse_free( &parse );
-
- DUMP_END();
-
- return ok;
-}
-
-/**
- * Fragment shaders are responsible for interpolating shader inputs. Because on
- * x86 we have only 4 GP registers, and here we have 5 shader arguments (input,
- * output, const, temp and coef), the code is split into two phases --
- * DECLARATION and INSTRUCTION phase.
- * GP register holding the output argument is aliased with the coeff argument,
- * as outputs are not needed in the DECLARATION phase.
- */
-unsigned
-tgsi_emit_sse2_fs(
- struct tgsi_token *tokens,
- struct x86_function *func )
-{
- struct tgsi_parse_context parse;
- boolean instruction_phase = FALSE;
-
- DUMP_START();
-
- func->csr = func->store;
-
- /* DECLARATION phase, do not load output argument. */
- emit_mov(
- func,
- get_input_base(),
- get_argument( 0 ) );
- emit_mov(
- func,
- get_const_base(),
- get_argument( 2 ) );
- emit_mov(
- func,
- get_temp_base(),
- get_argument( 3 ) );
- emit_mov(
- func,
- get_coef_base(),
- get_argument( 4 ) );
-
- tgsi_parse_init( &parse, tokens );
-
- while( !tgsi_parse_end_of_tokens( &parse ) ) {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- emit_declaration(
- func,
- &parse.FullToken.FullDeclaration );
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- if( !instruction_phase ) {
- /* INSTRUCTION phase, overwrite coeff with output. */
- instruction_phase = TRUE;
- emit_mov(
- func,
- get_output_base(),
- get_argument( 1 ) );
- }
- emit_instruction(
- func,
- &parse.FullToken.FullInstruction );
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- /* XXX implement this */
- assert(0);
- break;
-
- default:
- assert( 0 );
- }
- }
-
- tgsi_parse_free( &parse );
-
- DUMP_END();
-
- return 1;
-}
-
-#endif /* i386 */
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_sse2.h b/src/mesa/pipe/tgsi/exec/tgsi_sse2.h
deleted file mode 100755
index 9bee371766..0000000000
--- a/src/mesa/pipe/tgsi/exec/tgsi_sse2.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#if !defined TGSI_SSE2_H
-#define TGSI_SSE2_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-struct tgsi_token;
-struct x86_function;
-
-unsigned
-tgsi_emit_sse2(
- struct tgsi_token *tokens,
- struct x86_function *function );
-
-unsigned
-tgsi_emit_sse2_fs(
- struct tgsi_token *tokens,
- struct x86_function *function );
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_SSE2_H
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_build.c b/src/mesa/pipe/tgsi/util/tgsi_build.c
deleted file mode 100644
index a00ff1c2a5..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_build.c
+++ /dev/null
@@ -1,1371 +0,0 @@
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "tgsi_build.h"
-#include "tgsi_parse.h"
-
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void )
-{
- struct tgsi_version version;
-
- version.MajorVersion = 1;
- version.MinorVersion = 1;
- version.Padding = 0;
-
- return version;
-}
-
-/*
- * header
- */
-
-struct tgsi_header
-tgsi_build_header( void )
-{
- struct tgsi_header header;
-
- header.HeaderSize = 1;
- header.BodySize = 0;
-
- return header;
-}
-
-static void
-header_headersize_grow( struct tgsi_header *header )
-{
- assert( header->HeaderSize < 0xFF );
- assert( header->BodySize == 0 );
-
- header->HeaderSize++;
-}
-
-static void
-header_bodysize_grow( struct tgsi_header *header )
-{
- assert( header->BodySize < 0xFFFFFF );
-
- header->BodySize++;
-}
-
-struct tgsi_processor
-tgsi_default_processor( void )
-{
- struct tgsi_processor processor;
-
- processor.Processor = TGSI_PROCESSOR_FRAGMENT;
- processor.Padding = 0;
-
- return processor;
-}
-
-struct tgsi_processor
-tgsi_build_processor(
- unsigned type,
- struct tgsi_header *header )
-{
- struct tgsi_processor processor;
-
- processor = tgsi_default_processor();
- processor.Processor = type;
-
- header_headersize_grow( header );
-
- return processor;
-}
-
-/*
- * declaration
- */
-
-struct tgsi_declaration
-tgsi_default_declaration( void )
-{
- struct tgsi_declaration declaration;
-
- declaration.Type = TGSI_TOKEN_TYPE_DECLARATION;
- declaration.Size = 1;
- declaration.File = TGSI_FILE_NULL;
- declaration.Declare = TGSI_DECLARE_RANGE;
- declaration.UsageMask = TGSI_WRITEMASK_XYZW;
- declaration.Interpolate = 0;
- declaration.Semantic = 0;
- declaration.Padding = 0;
- declaration.Extended = 0;
-
- return declaration;
-}
-
-struct tgsi_declaration
-tgsi_build_declaration(
- unsigned file,
- unsigned declare,
- unsigned usage_mask,
- unsigned interpolate,
- unsigned semantic,
- struct tgsi_header *header )
-{
- struct tgsi_declaration declaration;
-
- assert( file <= TGSI_FILE_IMMEDIATE );
- assert( declare <= TGSI_DECLARE_MASK );
-
- declaration = tgsi_default_declaration();
- declaration.File = file;
- declaration.Declare = declare;
- declaration.UsageMask = usage_mask;
- declaration.Interpolate = interpolate;
- declaration.Semantic = semantic;
-
- header_bodysize_grow( header );
-
- return declaration;
-}
-
-static void
-declaration_grow(
- struct tgsi_declaration *declaration,
- struct tgsi_header *header )
-{
- assert( declaration->Size < 0xFF );
-
- declaration->Size++;
-
- header_bodysize_grow( header );
-}
-
-struct tgsi_full_declaration
-tgsi_default_full_declaration( void )
-{
- struct tgsi_full_declaration full_declaration;
-
- full_declaration.Declaration = tgsi_default_declaration();
- full_declaration.Interpolation = tgsi_default_declaration_interpolation();
- full_declaration.Semantic = tgsi_default_declaration_semantic();
-
- return full_declaration;
-}
-
-unsigned
-tgsi_build_full_declaration(
- const struct tgsi_full_declaration *full_decl,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize )
-{
- unsigned size = 0;
- struct tgsi_declaration *declaration;
-
- if( maxsize <= size )
- return 0;
- declaration = (struct tgsi_declaration *) &tokens[size];
- size++;
-
- *declaration = tgsi_build_declaration(
- full_decl->Declaration.File,
- full_decl->Declaration.Declare,
- full_decl->Declaration.UsageMask,
- full_decl->Declaration.Interpolate,
- full_decl->Declaration.Semantic,
- header );
-
- switch( full_decl->Declaration.Declare ) {
- case TGSI_DECLARE_RANGE:
- {
- struct tgsi_declaration_range *dr;
-
- if( maxsize <= size )
- return 0;
- dr = (struct tgsi_declaration_range *) &tokens[size];
- size++;
-
- *dr = tgsi_build_declaration_range(
- full_decl->u.DeclarationRange.First,
- full_decl->u.DeclarationRange.Last,
- declaration,
- header );
- break;
- }
-
- case TGSI_DECLARE_MASK:
- {
- struct tgsi_declaration_mask *dm;
-
- if( maxsize <= size )
- return 0;
- dm = (struct tgsi_declaration_mask *) &tokens[size];
- size++;
-
- *dm = tgsi_build_declaration_mask(
- full_decl->u.DeclarationMask.Mask,
- declaration,
- header );
- break;
- }
-
- default:
- assert( 0 );
- }
-
- if( full_decl->Declaration.Interpolate ) {
- struct tgsi_declaration_interpolation *di;
-
- if( maxsize <= size )
- return 0;
- di = (struct tgsi_declaration_interpolation *) &tokens[size];
- size++;
-
- *di = tgsi_build_declaration_interpolation(
- full_decl->Interpolation.Interpolate,
- declaration,
- header );
- }
-
- if( full_decl->Declaration.Semantic ) {
- struct tgsi_declaration_semantic *ds;
-
- if( maxsize <= size )
- return 0;
- ds = (struct tgsi_declaration_semantic *) &tokens[size];
- size++;
-
- *ds = tgsi_build_declaration_semantic(
- full_decl->Semantic.SemanticName,
- full_decl->Semantic.SemanticIndex,
- declaration,
- header );
- }
-
- return size;
-}
-
-struct tgsi_declaration_range
-tgsi_build_declaration_range(
- unsigned first,
- unsigned last,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header )
-{
- struct tgsi_declaration_range declaration_range;
-
- assert( last >= first );
- assert( last <= 0xFFFF );
-
- declaration_range.First = first;
- declaration_range.Last = last;
-
- declaration_grow( declaration, header );
-
- return declaration_range;
-}
-
-struct tgsi_declaration_mask
-tgsi_build_declaration_mask(
- unsigned mask,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header )
-{
- struct tgsi_declaration_mask declaration_mask;
-
- declaration_mask.Mask = mask;
-
- declaration_grow( declaration, header );
-
- return declaration_mask;
-}
-
-struct tgsi_declaration_interpolation
-tgsi_default_declaration_interpolation( void )
-{
- struct tgsi_declaration_interpolation di;
-
- di.Interpolate = TGSI_INTERPOLATE_CONSTANT;
- di.Padding = 0;
-
- return di;
-}
-
-struct tgsi_declaration_interpolation
-tgsi_build_declaration_interpolation(
- unsigned interpolate,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header )
-{
- struct tgsi_declaration_interpolation di;
-
- assert( interpolate <= TGSI_INTERPOLATE_PERSPECTIVE );
-
- di = tgsi_default_declaration_interpolation();
- di.Interpolate = interpolate;
-
- declaration_grow( declaration, header );
-
- return di;
-}
-
-struct tgsi_declaration_semantic
-tgsi_default_declaration_semantic( void )
-{
- struct tgsi_declaration_semantic ds;
-
- ds.SemanticName = TGSI_SEMANTIC_POSITION;
- ds.SemanticIndex = 0;
- ds.Padding = 0;
-
- return ds;
-}
-
-struct tgsi_declaration_semantic
-tgsi_build_declaration_semantic(
- unsigned semantic_name,
- unsigned semantic_index,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header )
-{
- struct tgsi_declaration_semantic ds;
-
- assert( semantic_name <= TGSI_SEMANTIC_COUNT );
- assert( semantic_index <= 0xFFFF );
-
- ds = tgsi_default_declaration_semantic();
- ds.SemanticName = semantic_name;
- ds.SemanticIndex = semantic_index;
-
- declaration_grow( declaration, header );
-
- return ds;
-}
-
-/*
- * immediate
- */
-
-struct tgsi_immediate
-tgsi_default_immediate( void )
-{
- struct tgsi_immediate immediate;
-
- immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
- immediate.Size = 1;
- immediate.DataType = TGSI_IMM_FLOAT32;
- immediate.Padding = 0;
- immediate.Extended = 0;
-
- return immediate;
-}
-
-struct tgsi_immediate
-tgsi_build_immediate(
- struct tgsi_header *header )
-{
- struct tgsi_immediate immediate;
-
- immediate = tgsi_default_immediate();
-
- header_bodysize_grow( header );
-
- return immediate;
-}
-
-struct tgsi_full_immediate
-tgsi_default_full_immediate( void )
-{
- struct tgsi_full_immediate fullimm;
-
- fullimm.Immediate = tgsi_default_immediate();
- fullimm.u.Pointer = (void *) 0;
-
- return fullimm;
-}
-
-static void
-immediate_grow(
- struct tgsi_immediate *immediate,
- struct tgsi_header *header )
-{
- assert( immediate->Size < 0xFF );
-
- immediate->Size++;
-
- header_bodysize_grow( header );
-}
-
-struct tgsi_immediate_float32
-tgsi_build_immediate_float32(
- float value,
- struct tgsi_immediate *immediate,
- struct tgsi_header *header )
-{
- struct tgsi_immediate_float32 immediate_float32;
-
- immediate_float32.Float = value;
-
- immediate_grow( immediate, header );
-
- return immediate_float32;
-}
-
-unsigned
-tgsi_build_full_immediate(
- const struct tgsi_full_immediate *full_imm,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize )
-{
- unsigned size = 0, i;
- struct tgsi_immediate *immediate;
-
- if( maxsize <= size )
- return 0;
- immediate = (struct tgsi_immediate *) &tokens[size];
- size++;
-
- *immediate = tgsi_build_immediate( header );
-
- for( i = 0; i < full_imm->Immediate.Size - 1; i++ ) {
- struct tgsi_immediate_float32 *if32;
-
- if( maxsize <= size )
- return 0;
- if32 = (struct tgsi_immediate_float32 *) &tokens[size];
- size++;
-
- *if32 = tgsi_build_immediate_float32(
- full_imm->u.ImmediateFloat32[i].Float,
- immediate,
- header );
- }
-
- return size;
-}
-
-/*
- * instruction
- */
-
-struct tgsi_instruction
-tgsi_default_instruction( void )
-{
- struct tgsi_instruction instruction;
-
- instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
- instruction.Size = 1;
- instruction.Opcode = TGSI_OPCODE_MOV;
- instruction.Saturate = TGSI_SAT_NONE;
- instruction.NumDstRegs = 1;
- instruction.NumSrcRegs = 1;
- instruction.Padding = 0;
- instruction.Extended = 0;
-
- return instruction;
-}
-
-struct tgsi_instruction
-tgsi_build_instruction(
- unsigned opcode,
- unsigned saturate,
- unsigned num_dst_regs,
- unsigned num_src_regs,
- struct tgsi_header *header )
-{
- struct tgsi_instruction instruction;
-
- assert (opcode <= TGSI_OPCODE_LAST);
- assert (saturate <= TGSI_SAT_MINUS_PLUS_ONE);
- assert (num_dst_regs <= 3);
- assert (num_src_regs <= 15);
-
- instruction = tgsi_default_instruction();
- instruction.Opcode = opcode;
- instruction.Saturate = saturate;
- instruction.NumDstRegs = num_dst_regs;
- instruction.NumSrcRegs = num_src_regs;
-
- header_bodysize_grow( header );
-
- return instruction;
-}
-
-static void
-instruction_grow(
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- assert (instruction->Size < 0xFF);
-
- instruction->Size++;
-
- header_bodysize_grow( header );
-}
-
-struct tgsi_full_instruction
-tgsi_default_full_instruction( void )
-{
- struct tgsi_full_instruction full_instruction;
- unsigned i;
-
- full_instruction.Instruction = tgsi_default_instruction();
- full_instruction.InstructionExtNv = tgsi_default_instruction_ext_nv();
- full_instruction.InstructionExtLabel = tgsi_default_instruction_ext_label();
- full_instruction.InstructionExtTexture = tgsi_default_instruction_ext_texture();
- for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
- full_instruction.FullDstRegisters[i] = tgsi_default_full_dst_register();
- }
- for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) {
- full_instruction.FullSrcRegisters[i] = tgsi_default_full_src_register();
- }
-
- return full_instruction;
-}
-
-unsigned
-tgsi_build_full_instruction(
- const struct tgsi_full_instruction *full_inst,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize )
-{
- unsigned size = 0;
- unsigned i;
- struct tgsi_instruction *instruction;
- struct tgsi_token *prev_token;
-
- if( maxsize <= size )
- return 0;
- instruction = (struct tgsi_instruction *) &tokens[size];
- size++;
-
- *instruction = tgsi_build_instruction(
- full_inst->Instruction.Opcode,
- full_inst->Instruction.Saturate,
- full_inst->Instruction.NumDstRegs,
- full_inst->Instruction.NumSrcRegs,
- header );
- prev_token = (struct tgsi_token *) instruction;
-
- if( tgsi_compare_instruction_ext_nv(
- full_inst->InstructionExtNv,
- tgsi_default_instruction_ext_nv() ) ) {
- struct tgsi_instruction_ext_nv *instruction_ext_nv;
-
- if( maxsize <= size )
- return 0;
- instruction_ext_nv =
- (struct tgsi_instruction_ext_nv *) &tokens[size];
- size++;
-
- *instruction_ext_nv = tgsi_build_instruction_ext_nv(
- full_inst->InstructionExtNv.Precision,
- full_inst->InstructionExtNv.CondDstIndex,
- full_inst->InstructionExtNv.CondFlowIndex,
- full_inst->InstructionExtNv.CondMask,
- full_inst->InstructionExtNv.CondSwizzleX,
- full_inst->InstructionExtNv.CondSwizzleY,
- full_inst->InstructionExtNv.CondSwizzleZ,
- full_inst->InstructionExtNv.CondSwizzleW,
- full_inst->InstructionExtNv.CondDstUpdate,
- full_inst->InstructionExtNv.CondFlowEnable,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) instruction_ext_nv;
- }
-
- if( tgsi_compare_instruction_ext_label(
- full_inst->InstructionExtLabel,
- tgsi_default_instruction_ext_label() ) ) {
- struct tgsi_instruction_ext_label *instruction_ext_label;
-
- if( maxsize <= size )
- return 0;
- instruction_ext_label =
- (struct tgsi_instruction_ext_label *) &tokens[size];
- size++;
-
- *instruction_ext_label = tgsi_build_instruction_ext_label(
- full_inst->InstructionExtLabel.Label,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) instruction_ext_label;
- }
-
- if( tgsi_compare_instruction_ext_texture(
- full_inst->InstructionExtTexture,
- tgsi_default_instruction_ext_texture() ) ) {
- struct tgsi_instruction_ext_texture *instruction_ext_texture;
-
- if( maxsize <= size )
- return 0;
- instruction_ext_texture =
- (struct tgsi_instruction_ext_texture *) &tokens[size];
- size++;
-
- *instruction_ext_texture = tgsi_build_instruction_ext_texture(
- full_inst->InstructionExtTexture.Texture,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) instruction_ext_texture;
- }
-
- for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) {
- const struct tgsi_full_dst_register *reg = &full_inst->FullDstRegisters[i];
- struct tgsi_dst_register *dst_register;
- struct tgsi_token *prev_token;
-
- if( maxsize <= size )
- return 0;
- dst_register = (struct tgsi_dst_register *) &tokens[size];
- size++;
-
- *dst_register = tgsi_build_dst_register(
- reg->DstRegister.File,
- reg->DstRegister.WriteMask,
- reg->DstRegister.Index,
- instruction,
- header );
- prev_token = (struct tgsi_token *) dst_register;
-
- if( tgsi_compare_dst_register_ext_concode(
- reg->DstRegisterExtConcode,
- tgsi_default_dst_register_ext_concode() ) ) {
- struct tgsi_dst_register_ext_concode *dst_register_ext_concode;
-
- if( maxsize <= size )
- return 0;
- dst_register_ext_concode =
- (struct tgsi_dst_register_ext_concode *) &tokens[size];
- size++;
-
- *dst_register_ext_concode = tgsi_build_dst_register_ext_concode(
- reg->DstRegisterExtConcode.CondMask,
- reg->DstRegisterExtConcode.CondSwizzleX,
- reg->DstRegisterExtConcode.CondSwizzleY,
- reg->DstRegisterExtConcode.CondSwizzleZ,
- reg->DstRegisterExtConcode.CondSwizzleW,
- reg->DstRegisterExtConcode.CondSrcIndex,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) dst_register_ext_concode;
- }
-
- if( tgsi_compare_dst_register_ext_modulate(
- reg->DstRegisterExtModulate,
- tgsi_default_dst_register_ext_modulate() ) ) {
- struct tgsi_dst_register_ext_modulate *dst_register_ext_modulate;
-
- if( maxsize <= size )
- return 0;
- dst_register_ext_modulate =
- (struct tgsi_dst_register_ext_modulate *) &tokens[size];
- size++;
-
- *dst_register_ext_modulate = tgsi_build_dst_register_ext_modulate(
- reg->DstRegisterExtModulate.Modulate,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) dst_register_ext_modulate;
- }
- }
-
- for( i = 0; i < full_inst->Instruction.NumSrcRegs; i++ ) {
- const struct tgsi_full_src_register *reg = &full_inst->FullSrcRegisters[i];
- struct tgsi_src_register *src_register;
- struct tgsi_token *prev_token;
-
- if( maxsize <= size )
- return 0;
- src_register = (struct tgsi_src_register *) &tokens[size];
- size++;
-
- *src_register = tgsi_build_src_register(
- reg->SrcRegister.File,
- reg->SrcRegister.SwizzleX,
- reg->SrcRegister.SwizzleY,
- reg->SrcRegister.SwizzleZ,
- reg->SrcRegister.SwizzleW,
- reg->SrcRegister.Negate,
- reg->SrcRegister.Indirect,
- reg->SrcRegister.Dimension,
- reg->SrcRegister.Index,
- instruction,
- header );
- prev_token = (struct tgsi_token *) src_register;
-
- if( tgsi_compare_src_register_ext_swz(
- reg->SrcRegisterExtSwz,
- tgsi_default_src_register_ext_swz() ) ) {
- struct tgsi_src_register_ext_swz *src_register_ext_swz;
-
- if( maxsize <= size )
- return 0;
- src_register_ext_swz =
- (struct tgsi_src_register_ext_swz *) &tokens[size];
- size++;
-
- *src_register_ext_swz = tgsi_build_src_register_ext_swz(
- reg->SrcRegisterExtSwz.ExtSwizzleX,
- reg->SrcRegisterExtSwz.ExtSwizzleY,
- reg->SrcRegisterExtSwz.ExtSwizzleZ,
- reg->SrcRegisterExtSwz.ExtSwizzleW,
- reg->SrcRegisterExtSwz.NegateX,
- reg->SrcRegisterExtSwz.NegateY,
- reg->SrcRegisterExtSwz.NegateZ,
- reg->SrcRegisterExtSwz.NegateW,
- reg->SrcRegisterExtSwz.ExtDivide,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) src_register_ext_swz;
- }
-
- if( tgsi_compare_src_register_ext_mod(
- reg->SrcRegisterExtMod,
- tgsi_default_src_register_ext_mod() ) ) {
- struct tgsi_src_register_ext_mod *src_register_ext_mod;
-
- if( maxsize <= size )
- return 0;
- src_register_ext_mod =
- (struct tgsi_src_register_ext_mod *) &tokens[size];
- size++;
-
- *src_register_ext_mod = tgsi_build_src_register_ext_mod(
- reg->SrcRegisterExtMod.Complement,
- reg->SrcRegisterExtMod.Bias,
- reg->SrcRegisterExtMod.Scale2X,
- reg->SrcRegisterExtMod.Absolute,
- reg->SrcRegisterExtMod.Negate,
- prev_token,
- instruction,
- header );
- prev_token = (struct tgsi_token *) src_register_ext_mod;
- }
-
- if( reg->SrcRegister.Indirect ) {
- struct tgsi_src_register *ind;
-
- if( maxsize <= size )
- return 0;
- ind = (struct tgsi_src_register *) &tokens[size];
- size++;
-
- *ind = tgsi_build_src_register(
- reg->SrcRegisterInd.File,
- reg->SrcRegisterInd.SwizzleX,
- reg->SrcRegisterInd.SwizzleY,
- reg->SrcRegisterInd.SwizzleZ,
- reg->SrcRegisterInd.SwizzleW,
- reg->SrcRegisterInd.Negate,
- reg->SrcRegisterInd.Indirect,
- reg->SrcRegisterInd.Dimension,
- reg->SrcRegisterInd.Index,
- instruction,
- header );
- }
-
- if( reg->SrcRegister.Dimension ) {
- struct tgsi_dimension *dim;
-
- assert( !reg->SrcRegisterDim.Dimension );
-
- if( maxsize <= size )
- return 0;
- dim = (struct tgsi_dimension *) &tokens[size];
- size++;
-
- *dim = tgsi_build_dimension(
- reg->SrcRegisterDim.Indirect,
- reg->SrcRegisterDim.Index,
- instruction,
- header );
-
- if( reg->SrcRegisterDim.Indirect ) {
- struct tgsi_src_register *ind;
-
- if( maxsize <= size )
- return 0;
- ind = (struct tgsi_src_register *) &tokens[size];
- size++;
-
- *ind = tgsi_build_src_register(
- reg->SrcRegisterDimInd.File,
- reg->SrcRegisterDimInd.SwizzleX,
- reg->SrcRegisterDimInd.SwizzleY,
- reg->SrcRegisterDimInd.SwizzleZ,
- reg->SrcRegisterDimInd.SwizzleW,
- reg->SrcRegisterDimInd.Negate,
- reg->SrcRegisterDimInd.Indirect,
- reg->SrcRegisterDimInd.Dimension,
- reg->SrcRegisterDimInd.Index,
- instruction,
- header );
- }
- }
- }
-
- return size;
-}
-
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void )
-{
- struct tgsi_instruction_ext_nv instruction_ext_nv;
-
- instruction_ext_nv.Type = TGSI_INSTRUCTION_EXT_TYPE_NV;
- instruction_ext_nv.Precision = TGSI_PRECISION_DEFAULT;
- instruction_ext_nv.CondDstIndex = 0;
- instruction_ext_nv.CondFlowIndex = 0;
- instruction_ext_nv.CondMask = TGSI_CC_TR;
- instruction_ext_nv.CondSwizzleX = TGSI_SWIZZLE_X;
- instruction_ext_nv.CondSwizzleY = TGSI_SWIZZLE_Y;
- instruction_ext_nv.CondSwizzleZ = TGSI_SWIZZLE_Z;
- instruction_ext_nv.CondSwizzleW = TGSI_SWIZZLE_W;
- instruction_ext_nv.CondDstUpdate = 0;
- instruction_ext_nv.CondFlowEnable = 0;
- instruction_ext_nv.Padding = 0;
- instruction_ext_nv.Extended = 0;
-
- return instruction_ext_nv;
-}
-
-union token_u32
-{
- unsigned u32;
-};
-
-unsigned
-tgsi_compare_instruction_ext_nv(
- struct tgsi_instruction_ext_nv a,
- struct tgsi_instruction_ext_nv b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
- unsigned precision,
- unsigned cond_dst_index,
- unsigned cond_flow_index,
- unsigned cond_mask,
- unsigned cond_swizzle_x,
- unsigned cond_swizzle_y,
- unsigned cond_swizzle_z,
- unsigned cond_swizzle_w,
- unsigned cond_dst_update,
- unsigned cond_flow_update,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_instruction_ext_nv instruction_ext_nv;
-
- instruction_ext_nv = tgsi_default_instruction_ext_nv();
- instruction_ext_nv.Precision = precision;
- instruction_ext_nv.CondDstIndex = cond_dst_index;
- instruction_ext_nv.CondFlowIndex = cond_flow_index;
- instruction_ext_nv.CondMask = cond_mask;
- instruction_ext_nv.CondSwizzleX = cond_swizzle_x;
- instruction_ext_nv.CondSwizzleY = cond_swizzle_y;
- 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;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return instruction_ext_nv;
-}
-
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void )
-{
- struct tgsi_instruction_ext_label instruction_ext_label;
-
- instruction_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
- instruction_ext_label.Label = 0;
- instruction_ext_label.Padding = 0;
- instruction_ext_label.Extended = 0;
-
- return instruction_ext_label;
-}
-
-unsigned
-tgsi_compare_instruction_ext_label(
- struct tgsi_instruction_ext_label a,
- struct tgsi_instruction_ext_label b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
- unsigned label,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_instruction_ext_label instruction_ext_label;
-
- instruction_ext_label = tgsi_default_instruction_ext_label();
- instruction_ext_label.Label = label;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return instruction_ext_label;
-}
-
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void )
-{
- struct tgsi_instruction_ext_texture instruction_ext_texture;
-
- instruction_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
- instruction_ext_texture.Texture = TGSI_TEXTURE_UNKNOWN;
- instruction_ext_texture.Padding = 0;
- instruction_ext_texture.Extended = 0;
-
- return instruction_ext_texture;
-}
-
-unsigned
-tgsi_compare_instruction_ext_texture(
- struct tgsi_instruction_ext_texture a,
- struct tgsi_instruction_ext_texture b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
- unsigned texture,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_instruction_ext_texture instruction_ext_texture;
-
- instruction_ext_texture = tgsi_default_instruction_ext_texture();
- instruction_ext_texture.Texture = texture;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return instruction_ext_texture;
-}
-
-struct tgsi_src_register
-tgsi_default_src_register( void )
-{
- struct tgsi_src_register src_register;
-
- src_register.File = TGSI_FILE_NULL;
- src_register.SwizzleX = TGSI_SWIZZLE_X;
- src_register.SwizzleY = TGSI_SWIZZLE_Y;
- src_register.SwizzleZ = TGSI_SWIZZLE_Z;
- src_register.SwizzleW = TGSI_SWIZZLE_W;
- src_register.Negate = 0;
- src_register.Indirect = 0;
- src_register.Dimension = 0;
- src_register.Index = 0;
- src_register.Extended = 0;
-
- return src_register;
-}
-
-struct tgsi_src_register
-tgsi_build_src_register(
- unsigned file,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- unsigned negate,
- unsigned indirect,
- unsigned dimension,
- int index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_src_register src_register;
-
- assert( file <= TGSI_FILE_IMMEDIATE );
- assert( swizzle_x <= TGSI_SWIZZLE_W );
- assert( swizzle_y <= TGSI_SWIZZLE_W );
- assert( swizzle_z <= TGSI_SWIZZLE_W );
- assert( swizzle_w <= TGSI_SWIZZLE_W );
- assert( negate <= 1 );
- assert( index >= -0x8000 && index <= 0x7FFF );
-
- src_register = tgsi_default_src_register();
- src_register.File = file;
- src_register.SwizzleX = swizzle_x;
- src_register.SwizzleY = swizzle_y;
- src_register.SwizzleZ = swizzle_z;
- src_register.SwizzleW = swizzle_w;
- src_register.Negate = negate;
- src_register.Indirect = indirect;
- src_register.Dimension = dimension;
- src_register.Index = index;
-
- instruction_grow( instruction, header );
-
- return src_register;
-}
-
-struct tgsi_full_src_register
-tgsi_default_full_src_register( void )
-{
- struct tgsi_full_src_register full_src_register;
-
- full_src_register.SrcRegister = tgsi_default_src_register();
- full_src_register.SrcRegisterExtSwz = tgsi_default_src_register_ext_swz();
- full_src_register.SrcRegisterExtMod = tgsi_default_src_register_ext_mod();
- full_src_register.SrcRegisterInd = tgsi_default_src_register();
- full_src_register.SrcRegisterDim = tgsi_default_dimension();
- full_src_register.SrcRegisterDimInd = tgsi_default_src_register();
-
- return full_src_register;
-}
-
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void )
-{
- struct tgsi_src_register_ext_swz src_register_ext_swz;
-
- src_register_ext_swz.Type = TGSI_SRC_REGISTER_EXT_TYPE_SWZ;
- src_register_ext_swz.ExtSwizzleX = TGSI_EXTSWIZZLE_X;
- src_register_ext_swz.ExtSwizzleY = TGSI_EXTSWIZZLE_Y;
- src_register_ext_swz.ExtSwizzleZ = TGSI_EXTSWIZZLE_Z;
- src_register_ext_swz.ExtSwizzleW = TGSI_EXTSWIZZLE_W;
- src_register_ext_swz.NegateX = 0;
- src_register_ext_swz.NegateY = 0;
- src_register_ext_swz.NegateZ = 0;
- src_register_ext_swz.NegateW = 0;
- src_register_ext_swz.ExtDivide = TGSI_EXTSWIZZLE_ONE;
- src_register_ext_swz.Padding = 0;
- src_register_ext_swz.Extended = 0;
-
- return src_register_ext_swz;
-}
-
-unsigned
-tgsi_compare_src_register_ext_swz(
- struct tgsi_src_register_ext_swz a,
- struct tgsi_src_register_ext_swz b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
- unsigned ext_swizzle_x,
- unsigned ext_swizzle_y,
- unsigned ext_swizzle_z,
- unsigned ext_swizzle_w,
- unsigned negate_x,
- unsigned negate_y,
- unsigned negate_z,
- unsigned negate_w,
- unsigned ext_divide,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_src_register_ext_swz src_register_ext_swz;
-
- assert( ext_swizzle_x <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_y <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_z <= TGSI_EXTSWIZZLE_ONE );
- assert( ext_swizzle_w <= TGSI_EXTSWIZZLE_ONE );
- assert( negate_x <= 1 );
- assert( negate_y <= 1 );
- assert( negate_z <= 1 );
- assert( negate_w <= 1 );
- assert( ext_divide <= TGSI_EXTSWIZZLE_ONE );
-
- src_register_ext_swz = tgsi_default_src_register_ext_swz();
- src_register_ext_swz.ExtSwizzleX = ext_swizzle_x;
- src_register_ext_swz.ExtSwizzleY = ext_swizzle_y;
- src_register_ext_swz.ExtSwizzleZ = ext_swizzle_z;
- src_register_ext_swz.ExtSwizzleW = ext_swizzle_w;
- src_register_ext_swz.NegateX = negate_x;
- src_register_ext_swz.NegateY = negate_y;
- src_register_ext_swz.NegateZ = negate_z;
- src_register_ext_swz.NegateW = negate_w;
- src_register_ext_swz.ExtDivide = ext_divide;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return src_register_ext_swz;
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void )
-{
- struct tgsi_src_register_ext_mod src_register_ext_mod;
-
- src_register_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
- src_register_ext_mod.Complement = 0;
- src_register_ext_mod.Bias = 0;
- src_register_ext_mod.Scale2X = 0;
- src_register_ext_mod.Absolute = 0;
- src_register_ext_mod.Negate = 0;
- src_register_ext_mod.Padding = 0;
- src_register_ext_mod.Extended = 0;
-
- return src_register_ext_mod;
-}
-
-unsigned
-tgsi_compare_src_register_ext_mod(
- struct tgsi_src_register_ext_mod a,
- struct tgsi_src_register_ext_mod b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
- unsigned complement,
- unsigned bias,
- unsigned scale_2x,
- unsigned absolute,
- unsigned negate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_src_register_ext_mod src_register_ext_mod;
-
- assert( complement <= 1 );
- assert( bias <= 1 );
- assert( scale_2x <= 1 );
- assert( absolute <= 1 );
- assert( negate <= 1 );
-
- src_register_ext_mod = tgsi_default_src_register_ext_mod();
- src_register_ext_mod.Complement = complement;
- src_register_ext_mod.Bias = bias;
- src_register_ext_mod.Scale2X = scale_2x;
- src_register_ext_mod.Absolute = absolute;
- src_register_ext_mod.Negate = negate;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return src_register_ext_mod;
-}
-
-struct tgsi_dimension
-tgsi_default_dimension( void )
-{
- struct tgsi_dimension dimension;
-
- dimension.Indirect = 0;
- dimension.Dimension = 0;
- dimension.Padding = 0;
- dimension.Index = 0;
- dimension.Extended = 0;
-
- return dimension;
-}
-
-struct tgsi_dimension
-tgsi_build_dimension(
- unsigned indirect,
- unsigned index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_dimension dimension;
-
- dimension = tgsi_default_dimension();
- dimension.Indirect = indirect;
- dimension.Index = index;
-
- instruction_grow( instruction, header );
-
- return dimension;
-}
-
-struct tgsi_dst_register
-tgsi_default_dst_register( void )
-{
- struct tgsi_dst_register dst_register;
-
- dst_register.File = TGSI_FILE_NULL;
- dst_register.WriteMask = TGSI_WRITEMASK_XYZW;
- dst_register.Indirect = 0;
- dst_register.Dimension = 0;
- dst_register.Index = 0;
- dst_register.Padding = 0;
- dst_register.Extended = 0;
-
- return dst_register;
-}
-
-struct tgsi_dst_register
-tgsi_build_dst_register(
- unsigned file,
- unsigned mask,
- int index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_dst_register dst_register;
-
- assert( file <= TGSI_FILE_IMMEDIATE );
- assert( mask <= TGSI_WRITEMASK_XYZW );
- assert( index >= -32768 && index <= 32767 );
-
- dst_register = tgsi_default_dst_register();
- dst_register.File = file;
- dst_register.WriteMask = mask;
- dst_register.Index = index;
-
- instruction_grow( instruction, header );
-
- return dst_register;
-}
-
-struct tgsi_full_dst_register
-tgsi_default_full_dst_register( void )
-{
- struct tgsi_full_dst_register full_dst_register;
-
- full_dst_register.DstRegister = tgsi_default_dst_register();
- full_dst_register.DstRegisterExtConcode =
- tgsi_default_dst_register_ext_concode();
- full_dst_register.DstRegisterExtModulate =
- tgsi_default_dst_register_ext_modulate();
-
- return full_dst_register;
-}
-
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void )
-{
- struct tgsi_dst_register_ext_concode dst_register_ext_concode;
-
- dst_register_ext_concode.Type = TGSI_DST_REGISTER_EXT_TYPE_CONDCODE;
- dst_register_ext_concode.CondMask = TGSI_CC_TR;
- dst_register_ext_concode.CondSwizzleX = TGSI_SWIZZLE_X;
- dst_register_ext_concode.CondSwizzleY = TGSI_SWIZZLE_Y;
- dst_register_ext_concode.CondSwizzleZ = TGSI_SWIZZLE_Z;
- dst_register_ext_concode.CondSwizzleW = TGSI_SWIZZLE_W;
- dst_register_ext_concode.CondSrcIndex = 0;
- dst_register_ext_concode.Padding = 0;
- dst_register_ext_concode.Extended = 0;
-
- return dst_register_ext_concode;
-}
-
-unsigned
-tgsi_compare_dst_register_ext_concode(
- struct tgsi_dst_register_ext_concode a,
- struct tgsi_dst_register_ext_concode b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
- unsigned cc,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- int index,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_dst_register_ext_concode dst_register_ext_concode;
-
- assert( cc <= TGSI_CC_FL );
- assert( swizzle_x <= TGSI_SWIZZLE_W );
- assert( swizzle_y <= TGSI_SWIZZLE_W );
- assert( swizzle_z <= TGSI_SWIZZLE_W );
- assert( swizzle_w <= TGSI_SWIZZLE_W );
- assert( index >= -32768 && index <= 32767 );
-
- dst_register_ext_concode = tgsi_default_dst_register_ext_concode();
- dst_register_ext_concode.CondMask = cc;
- dst_register_ext_concode.CondSwizzleX = swizzle_x;
- dst_register_ext_concode.CondSwizzleY = swizzle_y;
- dst_register_ext_concode.CondSwizzleZ = swizzle_z;
- dst_register_ext_concode.CondSwizzleW = swizzle_w;
- dst_register_ext_concode.CondSrcIndex = index;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return dst_register_ext_concode;
-}
-
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void )
-{
- struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
-
- dst_register_ext_modulate.Type = TGSI_DST_REGISTER_EXT_TYPE_MODULATE;
- dst_register_ext_modulate.Modulate = TGSI_MODULATE_1X;
- dst_register_ext_modulate.Padding = 0;
- dst_register_ext_modulate.Extended = 0;
-
- return dst_register_ext_modulate;
-}
-
-unsigned
-tgsi_compare_dst_register_ext_modulate(
- struct tgsi_dst_register_ext_modulate a,
- struct tgsi_dst_register_ext_modulate b )
-{
- a.Padding = b.Padding = 0;
- a.Extended = b.Extended = 0;
- return ((union token_u32 *) &a)->u32 != ((union token_u32 *) &b)->u32;
-}
-
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
- unsigned modulate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header )
-{
- struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
-
- assert( modulate <= TGSI_MODULATE_EIGHTH );
-
- dst_register_ext_modulate = tgsi_default_dst_register_ext_modulate();
- dst_register_ext_modulate.Modulate = modulate;
-
- prev_token->Extended = 1;
- instruction_grow( instruction, header );
-
- return dst_register_ext_modulate;
-}
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_build.h b/src/mesa/pipe/tgsi/util/tgsi_build.h
deleted file mode 100644
index 116c78abf3..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_build.h
+++ /dev/null
@@ -1,320 +0,0 @@
-#if !defined TGSI_BUILD_H
-#define TGSI_BUILD_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-/*
- * version
- */
-
-struct tgsi_version
-tgsi_build_version( void );
-
-/*
- * header
- */
-
-struct tgsi_header
-tgsi_build_header( void );
-
-struct tgsi_processor
-tgsi_default_processor( void );
-
-struct tgsi_processor
-tgsi_build_processor(
- unsigned processor,
- struct tgsi_header *header );
-
-/*
- * declaration
- */
-
-struct tgsi_declaration
-tgsi_default_declaration( void );
-
-struct tgsi_declaration
-tgsi_build_declaration(
- unsigned file,
- unsigned declare,
- unsigned usage_mask,
- unsigned interpolate,
- unsigned semantic,
- struct tgsi_header *header );
-
-struct tgsi_full_declaration
-tgsi_default_full_declaration( void );
-
-unsigned
-tgsi_build_full_declaration(
- const struct tgsi_full_declaration *full_decl,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize );
-
-struct tgsi_declaration_range
-tgsi_build_declaration_range(
- unsigned first,
- unsigned last,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header );
-
-struct tgsi_declaration_mask
-tgsi_build_declaration_mask(
- unsigned mask,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header );
-
-struct tgsi_declaration_interpolation
-tgsi_default_declaration_interpolation( void );
-
-struct tgsi_declaration_interpolation
-tgsi_build_declaration_interpolation(
- unsigned interpolate,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header );
-
-struct tgsi_declaration_semantic
-tgsi_default_declaration_semantic( void );
-
-struct tgsi_declaration_semantic
-tgsi_build_declaration_semantic(
- unsigned semantic_name,
- unsigned semantic_index,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header );
-
-/*
- * immediate
- */
-
-struct tgsi_immediate
-tgsi_default_immediate( void );
-
-struct tgsi_immediate
-tgsi_build_immediate(
- struct tgsi_header *header );
-
-struct tgsi_full_immediate
-tgsi_default_full_immediate( void );
-
-struct tgsi_immediate_float32
-tgsi_build_immediate_float32(
- float value,
- struct tgsi_immediate *immediate,
- struct tgsi_header *header );
-
-unsigned
-tgsi_build_full_immediate(
- const struct tgsi_full_immediate *full_imm,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize );
-
-/*
- * instruction
- */
-
-struct tgsi_instruction
-tgsi_default_instruction( void );
-
-struct tgsi_instruction
-tgsi_build_instruction(
- unsigned opcode,
- unsigned saturate,
- unsigned num_dst_regs,
- unsigned num_src_regs,
- struct tgsi_header *header );
-
-struct tgsi_full_instruction
-tgsi_default_full_instruction( void );
-
-unsigned
-tgsi_build_full_instruction(
- const struct tgsi_full_instruction *full_inst,
- struct tgsi_token *tokens,
- struct tgsi_header *header,
- unsigned maxsize );
-
-struct tgsi_instruction_ext_nv
-tgsi_default_instruction_ext_nv( void );
-
-unsigned
-tgsi_compare_instruction_ext_nv(
- struct tgsi_instruction_ext_nv a,
- struct tgsi_instruction_ext_nv b );
-
-struct tgsi_instruction_ext_nv
-tgsi_build_instruction_ext_nv(
- unsigned precision,
- unsigned cond_dst_index,
- unsigned cond_flow_index,
- unsigned cond_mask,
- unsigned cond_swizzle_x,
- unsigned cond_swizzle_y,
- unsigned cond_swizzle_z,
- unsigned cond_swizzle_w,
- unsigned cond_dst_update,
- unsigned cond_flow_update,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_instruction_ext_label
-tgsi_default_instruction_ext_label( void );
-
-unsigned
-tgsi_compare_instruction_ext_label(
- struct tgsi_instruction_ext_label a,
- struct tgsi_instruction_ext_label b );
-
-struct tgsi_instruction_ext_label
-tgsi_build_instruction_ext_label(
- unsigned label,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_instruction_ext_texture
-tgsi_default_instruction_ext_texture( void );
-
-unsigned
-tgsi_compare_instruction_ext_texture(
- struct tgsi_instruction_ext_texture a,
- struct tgsi_instruction_ext_texture b );
-
-struct tgsi_instruction_ext_texture
-tgsi_build_instruction_ext_texture(
- unsigned texture,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_src_register
-tgsi_default_src_register( void );
-
-struct tgsi_src_register
-tgsi_build_src_register(
- unsigned file,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- unsigned negate,
- unsigned indirect,
- unsigned dimension,
- int index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_full_src_register
-tgsi_default_full_src_register( void );
-
-struct tgsi_src_register_ext_swz
-tgsi_default_src_register_ext_swz( void );
-
-unsigned
-tgsi_compare_src_register_ext_swz(
- struct tgsi_src_register_ext_swz a,
- struct tgsi_src_register_ext_swz b );
-
-struct tgsi_src_register_ext_swz
-tgsi_build_src_register_ext_swz(
- unsigned ext_swizzle_x,
- unsigned ext_swizzle_y,
- unsigned ext_swizzle_z,
- unsigned ext_swizzle_w,
- unsigned negate_x,
- unsigned negate_y,
- unsigned negate_z,
- unsigned negate_w,
- unsigned ext_divide,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_src_register_ext_mod
-tgsi_default_src_register_ext_mod( void );
-
-unsigned
-tgsi_compare_src_register_ext_mod(
- struct tgsi_src_register_ext_mod a,
- struct tgsi_src_register_ext_mod b );
-
-struct tgsi_src_register_ext_mod
-tgsi_build_src_register_ext_mod(
- unsigned complement,
- unsigned bias,
- unsigned scale_2x,
- unsigned absolute,
- unsigned negate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_dimension
-tgsi_default_dimension( void );
-
-struct tgsi_dimension
-tgsi_build_dimension(
- unsigned indirect,
- unsigned index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_dst_register
-tgsi_default_dst_register( void );
-
-struct tgsi_dst_register
-tgsi_build_dst_register(
- unsigned file,
- unsigned mask,
- int index,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_full_dst_register
-tgsi_default_full_dst_register( void );
-
-struct tgsi_dst_register_ext_concode
-tgsi_default_dst_register_ext_concode( void );
-
-unsigned
-tgsi_compare_dst_register_ext_concode(
- struct tgsi_dst_register_ext_concode a,
- struct tgsi_dst_register_ext_concode b );
-
-struct tgsi_dst_register_ext_concode
-tgsi_build_dst_register_ext_concode(
- unsigned cc,
- unsigned swizzle_x,
- unsigned swizzle_y,
- unsigned swizzle_z,
- unsigned swizzle_w,
- int index,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_default_dst_register_ext_modulate( void );
-
-unsigned
-tgsi_compare_dst_register_ext_modulate(
- struct tgsi_dst_register_ext_modulate a,
- struct tgsi_dst_register_ext_modulate b );
-
-struct tgsi_dst_register_ext_modulate
-tgsi_build_dst_register_ext_modulate(
- unsigned modulate,
- struct tgsi_token *prev_token,
- struct tgsi_instruction *instruction,
- struct tgsi_header *header );
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_BUILD_H
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_dump.c b/src/mesa/pipe/tgsi/util/tgsi_dump.c
deleted file mode 100644
index b5c54847e0..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_dump.c
+++ /dev/null
@@ -1,1581 +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.
- *
- **************************************************************************/
-
-#include <stdio.h>
-
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "tgsi_dump.h"
-#include "tgsi_parse.h"
-#include "tgsi_build.h"
-
-struct gen_dump
-{
- unsigned tabs;
- void (* write)(
- struct gen_dump *dump,
- const void *data,
- unsigned size );
-};
-
-struct text_dump
-{
- struct gen_dump base;
- char *text;
- unsigned length;
- unsigned capacity;
-};
-
-static void
-_text_dump_write(
- struct gen_dump *dump,
- const void *data,
- unsigned size )
-{
- struct text_dump *td = (struct text_dump *) dump;
- unsigned new_length = td->length + size;
-
- if( new_length >= td->capacity ) {
- unsigned new_capacity = td->capacity;
-
- do {
- if( new_capacity == 0 ) {
- new_capacity = 256;
- }
- else {
- new_capacity *= 2;
- }
- } while( new_length >= new_capacity );
- td->text = (char *) REALLOC(
- td->text,
- td->capacity,
- new_capacity );
- td->capacity = new_capacity;
- }
- memcpy(
- &td->text[td->length],
- data,
- size );
- td->length = new_length;
- td->text[td->length] = '\0';
-}
-
-struct file_dump
-{
- struct gen_dump base;
- FILE *file;
-};
-
-static void
-_file_dump_write(
- struct gen_dump *dump,
- const void *data,
- unsigned size )
-{
- struct file_dump *fd = (struct file_dump *) dump;
-
-#if 0
- fwrite( data, 1, size, fd->file );
-#else
- {
- unsigned i;
-
- for (i = 0; i < size; i++ ) {
- fprintf( fd->file, "%c", ((const char *) data)[i] );
- }
- }
-#endif
-}
-
-static void
-gen_dump_str(
- struct gen_dump *dump,
- const char *str )
-{
- unsigned i;
- size_t len = strlen( str );
-
- for (i = 0; i < len; i++) {
- dump->write( dump, &str[i], 1 );
- if (str[i] == '\n') {
- unsigned i;
-
- for (i = 0; i < dump->tabs; i++) {
- dump->write( dump, " ", 4 );
- }
- }
- }
-}
-
-static void
-gen_dump_chr(
- struct gen_dump *dump,
- const char chr )
-{
- dump->write( dump, &chr, 1 );
-}
-
-static void
-gen_dump_uix(
- struct gen_dump *dump,
- const unsigned ui )
-{
- char str[36];
-
- sprintf( str, "0x%x", ui );
- gen_dump_str( dump, str );
-}
-
-static void
-gen_dump_uid(
- struct gen_dump *dump,
- const unsigned ui )
-{
- char str[16];
-
- sprintf( str, "%u", ui );
- gen_dump_str( dump, str );
-}
-
-static void
-gen_dump_sid(
- struct gen_dump *dump,
- const int si )
-{
- char str[16];
-
- sprintf( str, "%d", si );
- gen_dump_str( dump, str );
-}
-
-static void
-gen_dump_flt(
- struct gen_dump *dump,
- const float flt )
-{
- char str[48];
-
- sprintf( str, "%10.4f", flt );
- gen_dump_str( dump, str );
-}
-
-static void
-gen_dump_enum(
- struct gen_dump *dump,
- const unsigned e,
- const char **enums,
- const unsigned enums_count )
-{
- if (e >= enums_count) {
- gen_dump_uid( dump, e );
- }
- else {
- gen_dump_str( dump, enums[e] );
- }
-}
-
-static void
-gen_dump_tab(
- struct gen_dump *dump )
-{
- ++dump->tabs;
-}
-
-static void
-gen_dump_untab(
- struct gen_dump *dump )
-{
- assert( dump->tabs > 0 );
-
- --dump->tabs;
-}
-
-#define TXT(S) gen_dump_str( dump, S )
-#define CHR(C) gen_dump_chr( dump, C )
-#define UIX(I) gen_dump_uix( dump, I )
-#define UID(I) gen_dump_uid( dump, I )
-#define SID(I) gen_dump_sid( dump, I )
-#define FLT(F) gen_dump_flt( dump, F )
-#define TAB() gen_dump_tab( dump )
-#define UNT() gen_dump_untab( dump )
-#define ENM(E,ENUMS) gen_dump_enum( dump, E, ENUMS, sizeof( ENUMS ) / sizeof( *ENUMS ) )
-
-static const char *TGSI_PROCESSOR_TYPES[] =
-{
- "PROCESSOR_FRAGMENT",
- "PROCESSOR_VERTEX",
- "PROCESSOR_GEOMETRY"
-};
-
-static const char *TGSI_PROCESSOR_TYPES_SHORT[] =
-{
- "FRAG",
- "VERT",
- "GEOM"
-};
-
-static const char *TGSI_TOKEN_TYPES[] =
-{
- "TOKEN_TYPE_DECLARATION",
- "TOKEN_TYPE_IMMEDIATE",
- "TOKEN_TYPE_INSTRUCTION"
-};
-
-static const char *TGSI_FILES[] =
-{
- "FILE_NULL",
- "FILE_CONSTANT",
- "FILE_INPUT",
- "FILE_OUTPUT",
- "FILE_TEMPORARY",
- "FILE_SAMPLER",
- "FILE_ADDRESS",
- "FILE_IMMEDIATE"
-};
-
-static const char *TGSI_FILES_SHORT[] =
-{
- "NULL",
- "CONST",
- "IN",
- "OUT",
- "TEMP",
- "SAMP",
- "ADDR",
- "IMM"
-};
-
-static const char *TGSI_DECLARES[] =
-{
- "DECLARE_RANGE",
- "DECLARE_MASK"
-};
-
-static const char *TGSI_INTERPOLATES[] =
-{
- "INTERPOLATE_CONSTANT",
- "INTERPOLATE_LINEAR",
- "INTERPOLATE_PERSPECTIVE",
- "INTERPOLATE_ATTRIB"
-};
-
-static const char *TGSI_INTERPOLATES_SHORT[] =
-{
- "CONSTANT",
- "LINEAR",
- "PERSPECTIVE",
- "ATTRIB"
-};
-
-static const char *TGSI_SEMANTICS[] =
-{
- "SEMANTIC_POSITION",
- "SEMANTIC_COLOR",
- "SEMANTIC_BCOLOR",
- "SEMANTIC_FOG",
- "SEMANTIC_PSIZE",
- "SEMANTIC_GENERIC,"
-};
-
-static const char *TGSI_SEMANTICS_SHORT[] =
-{
- "POSITION",
- "COLOR",
- "BCOLOR",
- "FOG",
- "PSIZE",
- "GENERIC",
-};
-
-static const char *TGSI_IMMS[] =
-{
- "IMM_FLOAT32"
-};
-
-static const char *TGSI_IMMS_SHORT[] =
-{
- "FLT32"
-};
-
-static const char *TGSI_OPCODES[] =
-{
- "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_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_TEXBEM",
- "OPCODE_TEXBEML",
- "OPCODE_TEXREG2AR",
- "OPCODE_TEXM3X2PAD",
- "OPCODE_TEXM3X2TEX",
- "OPCODE_TEXM3X3PAD",
- "OPCODE_TEXM3X3TEX",
- "OPCODE_TEXM3X3SPEC",
- "OPCODE_TEXM3X3VSPEC",
- "OPCODE_TEXREG2GB",
- "OPCODE_TEXREG2RGB",
- "OPCODE_TEXDP3TEX",
- "OPCODE_TEXDP3",
- "OPCODE_TEXM3X3",
- "OPCODE_TEXM3X2DEPTH",
- "OPCODE_TEXDEPTH",
- "OPCODE_BEM",
- "OPCODE_M4X3",
- "OPCODE_M3X4",
- "OPCODE_M3X3",
- "OPCODE_M3X2",
- "OPCODE_NRM4",
- "OPCODE_CALLNZ",
- "OPCODE_IFC",
- "OPCODE_BREAKC",
- "OPCODE_KIL",
- "OPCODE_END"
-};
-
-static const char *TGSI_OPCODES_SHORT[] =
-{
- "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",
- "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",
- "TEXBEM",
- "TEXBEML",
- "TEXREG2AR",
- "TEXM3X2PAD",
- "TEXM3X2TEX",
- "TEXM3X3PAD",
- "TEXM3X3TEX",
- "TEXM3X3SPEC",
- "TEXM3X3VSPEC",
- "TEXREG2GB",
- "TEXREG2RGB",
- "TEXDP3TEX",
- "TEXDP3",
- "TEXM3X3",
- "TEXM3X2DEPTH",
- "TEXDEPTH",
- "BEM",
- "M4X3",
- "M3X4",
- "M3X3",
- "M3X2",
- "NRM4",
- "CALLNZ",
- "IFC",
- "BREAKC",
- "KIL",
- "END"
-};
-
-static const char *TGSI_SATS[] =
-{
- "SAT_NONE",
- "SAT_ZERO_ONE",
- "SAT_MINUS_PLUS_ONE"
-};
-
-static const char *TGSI_INSTRUCTION_EXTS[] =
-{
- "INSTRUCTION_EXT_TYPE_NV",
- "INSTRUCTION_EXT_TYPE_LABEL",
- "INSTRUCTION_EXT_TYPE_TEXTURE"
-};
-
-static const char *TGSI_PRECISIONS[] =
-{
- "PRECISION_DEFAULT",
- "TGSI_PRECISION_FLOAT32",
- "TGSI_PRECISION_FLOAT16",
- "TGSI_PRECISION_FIXED12"
-};
-
-static const char *TGSI_CCS[] =
-{
- "CC_GT",
- "CC_EQ",
- "CC_LT",
- "CC_UN",
- "CC_GE",
- "CC_LE",
- "CC_NE",
- "CC_TR",
- "CC_FL"
-};
-
-static const char *TGSI_SWIZZLES[] =
-{
- "SWIZZLE_X",
- "SWIZZLE_Y",
- "SWIZZLE_Z",
- "SWIZZLE_W"
-};
-
-static const char *TGSI_SWIZZLES_SHORT[] =
-{
- "x",
- "y",
- "z",
- "w"
-};
-
-static const char *TGSI_TEXTURES[] =
-{
- "TEXTURE_UNKNOWN",
- "TEXTURE_1D",
- "TEXTURE_2D",
- "TEXTURE_3D",
- "TEXTURE_CUBE",
- "TEXTURE_RECT",
- "TEXTURE_SHADOW1D",
- "TEXTURE_SHADOW2D",
- "TEXTURE_SHADOWRECT"
-};
-
-static const char *TGSI_SRC_REGISTER_EXTS[] =
-{
- "SRC_REGISTER_EXT_TYPE_SWZ",
- "SRC_REGISTER_EXT_TYPE_MOD"
-};
-
-static const char *TGSI_EXTSWIZZLES[] =
-{
- "EXTSWIZZLE_X",
- "EXTSWIZZLE_Y",
- "EXTSWIZZLE_Z",
- "EXTSWIZZLE_W",
- "EXTSWIZZLE_ZERO",
- "EXTSWIZZLE_ONE"
-};
-
-static const char *TGSI_EXTSWIZZLES_SHORT[] =
-{
- "x",
- "y",
- "z",
- "w",
- "0",
- "1"
-};
-
-static const char *TGSI_WRITEMASKS[] =
-{
- "0",
- "WRITEMASK_X",
- "WRITEMASK_Y",
- "WRITEMASK_XY",
- "WRITEMASK_Z",
- "WRITEMASK_XZ",
- "WRITEMASK_YZ",
- "WRITEMASK_XYZ",
- "WRITEMASK_W",
- "WRITEMASK_XW",
- "WRITEMASK_YW",
- "WRITEMASK_XYW",
- "WRITEMASK_ZW",
- "WRITEMASK_XZW",
- "WRITEMASK_YZW",
- "WRITEMASK_XYZW"
-};
-
-static const char *TGSI_DST_REGISTER_EXTS[] =
-{
- "DST_REGISTER_EXT_TYPE_CONDCODE",
- "DST_REGISTER_EXT_TYPE_MODULATE"
-};
-
-static const char *TGSI_MODULATES[] =
-{
- "MODULATE_1X",
- "MODULATE_2X",
- "MODULATE_4X",
- "MODULATE_8X",
- "MODULATE_HALF",
- "MODULATE_QUARTER",
- "MODULATE_EIGHTH"
-};
-
-static void
-dump_declaration_short(
- struct gen_dump *dump,
- struct tgsi_full_declaration *decl )
-{
- TXT( "\nDCL " );
- ENM( decl->Declaration.File, TGSI_FILES_SHORT );
-
- switch( decl->Declaration.Declare ) {
- case TGSI_DECLARE_RANGE:
- CHR( '[' );
- UID( decl->u.DeclarationRange.First );
- if( decl->u.DeclarationRange.First != decl->u.DeclarationRange.Last ) {
- TXT( ".." );
- UID( decl->u.DeclarationRange.Last );
- }
- CHR( ']' );
- break;
- default:
- assert( 0 );
- }
-
- if( decl->Declaration.UsageMask != TGSI_WRITEMASK_XYZW ) {
- CHR( '.' );
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_X ) {
- CHR( 'x' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_Y ) {
- CHR( 'y' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_Z ) {
- CHR( 'z' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_W ) {
- CHR( 'w' );
- }
- }
-
- if( decl->Declaration.Interpolate ) {
- TXT( ", " );
- ENM( decl->Interpolation.Interpolate, TGSI_INTERPOLATES_SHORT );
- }
-
- if( decl->Declaration.Semantic ) {
- TXT( ", " );
- ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS_SHORT );
- CHR( '[' );
- UID( decl->Semantic.SemanticIndex );
- CHR( ']' );
- }
-}
-
-static void
-dump_declaration_verbose(
- struct gen_dump *dump,
- struct tgsi_full_declaration *decl,
- unsigned ignored,
- unsigned deflt,
- struct tgsi_full_declaration *fd )
-{
- TXT( "\nFile : " );
- ENM( decl->Declaration.File, TGSI_FILES );
- TXT( "\nDeclare : " );
- ENM( decl->Declaration.Declare, TGSI_DECLARES );
- if( deflt || fd->Declaration.UsageMask != decl->Declaration.UsageMask ) {
- TXT( "\nUsageMask : " );
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_X ) {
- CHR( 'X' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_Y ) {
- CHR( 'Y' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_Z ) {
- CHR( 'Z' );
- }
- if( decl->Declaration.UsageMask & TGSI_WRITEMASK_W ) {
- CHR( 'W' );
- }
- }
- if( deflt || fd->Declaration.Interpolate != decl->Declaration.Interpolate ) {
- TXT( "\nInterpolate: " );
- UID( decl->Declaration.Interpolate );
- }
- if( deflt || fd->Declaration.Semantic != decl->Declaration.Semantic ) {
- TXT( "\nSemantic : " );
- UID( decl->Declaration.Semantic );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( decl->Declaration.Padding );
- }
-
- CHR( '\n' );
- switch( decl->Declaration.Declare ) {
- case TGSI_DECLARE_RANGE:
- TXT( "\nFirst: " );
- UID( decl->u.DeclarationRange.First );
- TXT( "\nLast : " );
- UID( decl->u.DeclarationRange.Last );
- break;
-
- case TGSI_DECLARE_MASK:
- TXT( "\nMask: " );
- UIX( decl->u.DeclarationMask.Mask );
- break;
-
- default:
- assert( 0 );
- }
-
- if( decl->Declaration.Interpolate ) {
- CHR( '\n' );
- TXT( "\nInterpolate: " );
- ENM( decl->Interpolation.Interpolate, TGSI_INTERPOLATES );
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( decl->Interpolation.Padding );
- }
- }
-
- if( decl->Declaration.Semantic ) {
- CHR( '\n' );
- TXT( "\nSemanticName : " );
- ENM( decl->Semantic.SemanticName, TGSI_SEMANTICS );
- TXT( "\nSemanticIndex: " );
- UID( decl->Semantic.SemanticIndex );
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( decl->Semantic.Padding );
- }
- }
-}
-
-static void
-dump_immediate_short(
- struct gen_dump *dump,
- struct tgsi_full_immediate *imm )
-{
- unsigned i;
-
- TXT( "\nIMM " );
- ENM( imm->Immediate.DataType, TGSI_IMMS_SHORT );
-
- TXT( " { " );
- for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
- switch( imm->Immediate.DataType ) {
- case TGSI_IMM_FLOAT32:
- FLT( imm->u.ImmediateFloat32[i].Float );
- break;
-
- default:
- assert( 0 );
- }
-
- if( i < imm->Immediate.Size - 2 ) {
- TXT( ", " );
- }
- }
- TXT( " }" );
-}
-
-static void
-dump_immediate_verbose(
- struct gen_dump *dump,
- struct tgsi_full_immediate *imm,
- unsigned ignored )
-{
- unsigned i;
-
- TXT( "\nDataType : " );
- ENM( imm->Immediate.DataType, TGSI_IMMS );
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( imm->Immediate.Padding );
- }
-
- for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
- CHR( '\n' );
- switch( imm->Immediate.DataType ) {
- case TGSI_IMM_FLOAT32:
- TXT( "\nFloat: " );
- FLT( imm->u.ImmediateFloat32[i].Float );
- break;
-
- default:
- assert( 0 );
- }
- }
-}
-
-static void
-dump_instruction_short(
- struct gen_dump *dump,
- struct tgsi_full_instruction *inst,
- unsigned instno )
-{
- unsigned i;
- boolean first_reg = TRUE;
-
- CHR( '\n' );
- UID( instno );
- CHR( ':' );
- ENM( inst->Instruction.Opcode, TGSI_OPCODES_SHORT );
-
- switch( inst->Instruction.Saturate ) {
- case TGSI_SAT_NONE:
- break;
- case TGSI_SAT_ZERO_ONE:
- TXT( "_SAT" );
- break;
- case TGSI_SAT_MINUS_PLUS_ONE:
- TXT( "_SAT[-1,1]" );
- break;
- default:
- assert( 0 );
- }
-
- for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
-
- if( !first_reg ) {
- CHR( ',' );
- }
- CHR( ' ' );
-
- ENM( dst->DstRegister.File, TGSI_FILES_SHORT );
-
- CHR( '[' );
- SID( dst->DstRegister.Index );
- CHR( ']' );
-
- if( dst->DstRegister.WriteMask != TGSI_WRITEMASK_XYZW ) {
- CHR( '.' );
- if( dst->DstRegister.WriteMask & TGSI_WRITEMASK_X ) {
- CHR( 'x' );
- }
- if( dst->DstRegister.WriteMask & TGSI_WRITEMASK_Y ) {
- CHR( 'y' );
- }
- if( dst->DstRegister.WriteMask & TGSI_WRITEMASK_Z ) {
- CHR( 'z' );
- }
- if( dst->DstRegister.WriteMask & TGSI_WRITEMASK_W ) {
- CHR( 'w' );
- }
- }
-
- first_reg = FALSE;
- }
-
- for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
-
- if( !first_reg ) {
- CHR( ',' );
- }
- CHR( ' ' );
-
- if( src->SrcRegisterExtMod.Complement ) {
- TXT( "(1 - " );
- }
- if( src->SrcRegisterExtMod.Negate ) {
- CHR( '-' );
- }
- if( src->SrcRegisterExtMod.Absolute ) {
- CHR( '|' );
- }
- if( src->SrcRegister.Negate ) {
- CHR( '-' );
- }
-
- ENM( src->SrcRegister.File, TGSI_FILES_SHORT );
-
- CHR( '[' );
- SID( src->SrcRegister.Index );
- CHR( ']' );
-
- if (src->SrcRegister.Extended) {
- if (src->SrcRegisterExtSwz.ExtSwizzleX != TGSI_EXTSWIZZLE_X ||
- src->SrcRegisterExtSwz.ExtSwizzleY != TGSI_EXTSWIZZLE_Y ||
- src->SrcRegisterExtSwz.ExtSwizzleZ != TGSI_EXTSWIZZLE_Z ||
- src->SrcRegisterExtSwz.ExtSwizzleW != TGSI_EXTSWIZZLE_W) {
- CHR( '.' );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES_SHORT );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES_SHORT );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES_SHORT );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES_SHORT );
- }
- }
- else if( src->SrcRegister.SwizzleX != TGSI_SWIZZLE_X ||
- src->SrcRegister.SwizzleY != TGSI_SWIZZLE_Y ||
- src->SrcRegister.SwizzleZ != TGSI_SWIZZLE_Z ||
- src->SrcRegister.SwizzleW != TGSI_SWIZZLE_W ) {
- CHR( '.' );
- ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES_SHORT );
- ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES_SHORT );
- ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES_SHORT );
- ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES_SHORT );
- }
-
- if( src->SrcRegisterExtMod.Absolute ) {
- CHR( '|' );
- }
- if( src->SrcRegisterExtMod.Complement ) {
- CHR( ')' );
- }
-
- first_reg = FALSE;
- }
-
- switch( inst->Instruction.Opcode ) {
- case TGSI_OPCODE_IF:
- case TGSI_OPCODE_ELSE:
- case TGSI_OPCODE_BGNLOOP2:
- case TGSI_OPCODE_ENDLOOP2:
- case TGSI_OPCODE_CAL:
- TXT( " :" );
- UID( inst->InstructionExtLabel.Label );
- break;
- }
-}
-
-static void
-dump_instruction_verbose(
- struct gen_dump *dump,
- struct tgsi_full_instruction *inst,
- unsigned ignored,
- unsigned deflt,
- struct tgsi_full_instruction *fi )
-{
- unsigned i;
-
- TXT( "\nOpcode : " );
- ENM( inst->Instruction.Opcode, TGSI_OPCODES );
- if( deflt || fi->Instruction.Saturate != inst->Instruction.Saturate ) {
- TXT( "\nSaturate : " );
- ENM( inst->Instruction.Saturate, TGSI_SATS );
- }
- if( deflt || fi->Instruction.NumDstRegs != inst->Instruction.NumDstRegs ) {
- TXT( "\nNumDstRegs : " );
- UID( inst->Instruction.NumDstRegs );
- }
- if( deflt || fi->Instruction.NumSrcRegs != inst->Instruction.NumSrcRegs ) {
- TXT( "\nNumSrcRegs : " );
- UID( inst->Instruction.NumSrcRegs );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( inst->Instruction.Padding );
- }
-
- if( deflt || tgsi_compare_instruction_ext_nv( inst->InstructionExtNv, fi->InstructionExtNv ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( inst->InstructionExtNv.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtNv.Precision != inst->InstructionExtNv.Precision ) {
- TXT( "\nPrecision : " );
- ENM( inst->InstructionExtNv.Precision, TGSI_PRECISIONS );
- }
- if( deflt || fi->InstructionExtNv.CondDstIndex != inst->InstructionExtNv.CondDstIndex ) {
- TXT( "\nCondDstIndex : " );
- UID( inst->InstructionExtNv.CondDstIndex );
- }
- if( deflt || fi->InstructionExtNv.CondFlowIndex != inst->InstructionExtNv.CondFlowIndex ) {
- TXT( "\nCondFlowIndex : " );
- UID( inst->InstructionExtNv.CondFlowIndex );
- }
- if( deflt || fi->InstructionExtNv.CondMask != inst->InstructionExtNv.CondMask ) {
- TXT( "\nCondMask : " );
- ENM( inst->InstructionExtNv.CondMask, TGSI_CCS );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleX != inst->InstructionExtNv.CondSwizzleX ) {
- TXT( "\nCondSwizzleX : " );
- ENM( inst->InstructionExtNv.CondSwizzleX, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleY != inst->InstructionExtNv.CondSwizzleY ) {
- TXT( "\nCondSwizzleY : " );
- ENM( inst->InstructionExtNv.CondSwizzleY, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleZ != inst->InstructionExtNv.CondSwizzleZ ) {
- TXT( "\nCondSwizzleZ : " );
- ENM( inst->InstructionExtNv.CondSwizzleZ, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondSwizzleW != inst->InstructionExtNv.CondSwizzleW ) {
- TXT( "\nCondSwizzleW : " );
- ENM( inst->InstructionExtNv.CondSwizzleW, TGSI_SWIZZLES );
- }
- if( deflt || fi->InstructionExtNv.CondDstUpdate != inst->InstructionExtNv.CondDstUpdate ) {
- TXT( "\nCondDstUpdate : " );
- UID( inst->InstructionExtNv.CondDstUpdate );
- }
- if( deflt || fi->InstructionExtNv.CondFlowEnable != inst->InstructionExtNv.CondFlowEnable ) {
- TXT( "\nCondFlowEnable: " );
- UID( inst->InstructionExtNv.CondFlowEnable );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( inst->InstructionExtNv.Padding );
- if( deflt || fi->InstructionExtNv.Extended != inst->InstructionExtNv.Extended ) {
- TXT( "\nExtended : " );
- UID( inst->InstructionExtNv.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_instruction_ext_label( inst->InstructionExtLabel, fi->InstructionExtLabel ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( inst->InstructionExtLabel.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtLabel.Label != inst->InstructionExtLabel.Label ) {
- TXT( "\nLabel : " );
- UID( inst->InstructionExtLabel.Label );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( inst->InstructionExtLabel.Padding );
- if( deflt || fi->InstructionExtLabel.Extended != inst->InstructionExtLabel.Extended ) {
- TXT( "\nExtended: " );
- UID( inst->InstructionExtLabel.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_instruction_ext_texture( inst->InstructionExtTexture, fi->InstructionExtTexture ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( inst->InstructionExtTexture.Type, TGSI_INSTRUCTION_EXTS );
- if( deflt || fi->InstructionExtTexture.Texture != inst->InstructionExtTexture.Texture ) {
- TXT( "\nTexture : " );
- ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( inst->InstructionExtTexture.Padding );
- if( deflt || fi->InstructionExtTexture.Extended != inst->InstructionExtTexture.Extended ) {
- TXT( "\nExtended: " );
- UID( inst->InstructionExtTexture.Extended );
- }
- }
- }
-
- for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- struct tgsi_full_dst_register *dst = &inst->FullDstRegisters[i];
- struct tgsi_full_dst_register *fd = &fi->FullDstRegisters[i];
-
- CHR( '\n' );
- TXT( "\nFile : " );
- ENM( dst->DstRegister.File, TGSI_FILES );
- if( deflt || fd->DstRegister.WriteMask != dst->DstRegister.WriteMask ) {
- TXT( "\nWriteMask: " );
- ENM( dst->DstRegister.WriteMask, TGSI_WRITEMASKS );
- }
- if( ignored ) {
- if( deflt || fd->DstRegister.Indirect != dst->DstRegister.Indirect ) {
- TXT( "\nIndirect : " );
- UID( dst->DstRegister.Indirect );
- }
- if( deflt || fd->DstRegister.Dimension != dst->DstRegister.Dimension ) {
- TXT( "\nDimension: " );
- UID( dst->DstRegister.Dimension );
- }
- }
- if( deflt || fd->DstRegister.Index != dst->DstRegister.Index ) {
- TXT( "\nIndex : " );
- SID( dst->DstRegister.Index );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( dst->DstRegister.Padding );
- if( deflt || fd->DstRegister.Extended != dst->DstRegister.Extended ) {
- TXT( "\nExtended : " );
- UID( dst->DstRegister.Extended );
- }
- }
-
- if( deflt || tgsi_compare_dst_register_ext_concode( dst->DstRegisterExtConcode, fd->DstRegisterExtConcode ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( dst->DstRegisterExtConcode.Type, TGSI_DST_REGISTER_EXTS );
- if( deflt || fd->DstRegisterExtConcode.CondMask != dst->DstRegisterExtConcode.CondMask ) {
- TXT( "\nCondMask : " );
- ENM( dst->DstRegisterExtConcode.CondMask, TGSI_CCS );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleX != dst->DstRegisterExtConcode.CondSwizzleX ) {
- TXT( "\nCondSwizzleX: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleX, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleY != dst->DstRegisterExtConcode.CondSwizzleY ) {
- TXT( "\nCondSwizzleY: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleY, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleZ != dst->DstRegisterExtConcode.CondSwizzleZ ) {
- TXT( "\nCondSwizzleZ: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleZ, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSwizzleW != dst->DstRegisterExtConcode.CondSwizzleW ) {
- TXT( "\nCondSwizzleW: " );
- ENM( dst->DstRegisterExtConcode.CondSwizzleW, TGSI_SWIZZLES );
- }
- if( deflt || fd->DstRegisterExtConcode.CondSrcIndex != dst->DstRegisterExtConcode.CondSrcIndex ) {
- TXT( "\nCondSrcIndex: " );
- UID( dst->DstRegisterExtConcode.CondSrcIndex );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( dst->DstRegisterExtConcode.Padding );
- if( deflt || fd->DstRegisterExtConcode.Extended != dst->DstRegisterExtConcode.Extended ) {
- TXT( "\nExtended : " );
- UID( dst->DstRegisterExtConcode.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_dst_register_ext_modulate( dst->DstRegisterExtModulate, fd->DstRegisterExtModulate ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( dst->DstRegisterExtModulate.Type, TGSI_DST_REGISTER_EXTS );
- if( deflt || fd->DstRegisterExtModulate.Modulate != dst->DstRegisterExtModulate.Modulate ) {
- TXT( "\nModulate: " );
- ENM( dst->DstRegisterExtModulate.Modulate, TGSI_MODULATES );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( dst->DstRegisterExtModulate.Padding );
- if( deflt || fd->DstRegisterExtModulate.Extended != dst->DstRegisterExtModulate.Extended ) {
- TXT( "\nExtended: " );
- UID( dst->DstRegisterExtModulate.Extended );
- }
- }
- }
- }
-
- for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
- struct tgsi_full_src_register *fs = &fi->FullSrcRegisters[i];
-
- CHR( '\n' );
- TXT( "\nFile : ");
- ENM( src->SrcRegister.File, TGSI_FILES );
- if( deflt || fs->SrcRegister.SwizzleX != src->SrcRegister.SwizzleX ) {
- TXT( "\nSwizzleX : " );
- ENM( src->SrcRegister.SwizzleX, TGSI_SWIZZLES );
- }
- if( deflt || fs->SrcRegister.SwizzleY != src->SrcRegister.SwizzleY ) {
- TXT( "\nSwizzleY : " );
- ENM( src->SrcRegister.SwizzleY, TGSI_SWIZZLES );
- }
- if( deflt || fs->SrcRegister.SwizzleZ != src->SrcRegister.SwizzleZ ) {
- TXT( "\nSwizzleZ : " );
- ENM( src->SrcRegister.SwizzleZ, TGSI_SWIZZLES );
- }
- if( deflt || fs->SrcRegister.SwizzleW != src->SrcRegister.SwizzleW ) {
- TXT( "\nSwizzleW : " );
- ENM( src->SrcRegister.SwizzleW, TGSI_SWIZZLES );
- }
- if( deflt || fs->SrcRegister.Negate != src->SrcRegister.Negate ) {
- TXT( "\nNegate : " );
- UID( src->SrcRegister.Negate );
- }
- if( ignored ) {
- if( deflt || fs->SrcRegister.Indirect != src->SrcRegister.Indirect ) {
- TXT( "\nIndirect : " );
- UID( src->SrcRegister.Indirect );
- }
- if( deflt || fs->SrcRegister.Dimension != src->SrcRegister.Dimension ) {
- TXT( "\nDimension: " );
- UID( src->SrcRegister.Dimension );
- }
- }
- if( deflt || fs->SrcRegister.Index != src->SrcRegister.Index ) {
- TXT( "\nIndex : " );
- SID( src->SrcRegister.Index );
- }
- if( ignored ) {
- if( deflt || fs->SrcRegister.Extended != src->SrcRegister.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegister.Extended );
- }
- }
-
- if( deflt || tgsi_compare_src_register_ext_swz( src->SrcRegisterExtSwz, fs->SrcRegisterExtSwz ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( src->SrcRegisterExtSwz.Type, TGSI_SRC_REGISTER_EXTS );
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleX != src->SrcRegisterExtSwz.ExtSwizzleX ) {
- TXT( "\nExtSwizzleX: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleX, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleY != src->SrcRegisterExtSwz.ExtSwizzleY ) {
- TXT( "\nExtSwizzleY: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleY, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleZ != src->SrcRegisterExtSwz.ExtSwizzleZ ) {
- TXT( "\nExtSwizzleZ: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleZ, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtSwizzleW != src->SrcRegisterExtSwz.ExtSwizzleW ) {
- TXT( "\nExtSwizzleW: " );
- ENM( src->SrcRegisterExtSwz.ExtSwizzleW, TGSI_EXTSWIZZLES );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateX != src->SrcRegisterExtSwz.NegateX ) {
- TXT( "\nNegateX : " );
- UID( src->SrcRegisterExtSwz.NegateX );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateY != src->SrcRegisterExtSwz.NegateY ) {
- TXT( "\nNegateY : " );
- UID( src->SrcRegisterExtSwz.NegateY );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateZ != src->SrcRegisterExtSwz.NegateZ ) {
- TXT( "\nNegateZ : " );
- UID( src->SrcRegisterExtSwz.NegateZ );
- }
- if( deflt || fs->SrcRegisterExtSwz.NegateW != src->SrcRegisterExtSwz.NegateW ) {
- TXT( "\nNegateW : " );
- UID( src->SrcRegisterExtSwz.NegateW );
- }
- if( deflt || fs->SrcRegisterExtSwz.ExtDivide != src->SrcRegisterExtSwz.ExtDivide ) {
- TXT( "\nExtDivide : " );
- ENM( src->SrcRegisterExtSwz.ExtDivide, TGSI_EXTSWIZZLES );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( src->SrcRegisterExtSwz.Padding );
- if( deflt || fs->SrcRegisterExtSwz.Extended != src->SrcRegisterExtSwz.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegisterExtSwz.Extended );
- }
- }
- }
-
- if( deflt || tgsi_compare_src_register_ext_mod( src->SrcRegisterExtMod, fs->SrcRegisterExtMod ) ) {
- CHR( '\n' );
- TXT( "\nType : " );
- ENM( src->SrcRegisterExtMod.Type, TGSI_SRC_REGISTER_EXTS );
- if( deflt || fs->SrcRegisterExtMod.Complement != src->SrcRegisterExtMod.Complement ) {
- TXT( "\nComplement: " );
- UID( src->SrcRegisterExtMod.Complement );
- }
- if( deflt || fs->SrcRegisterExtMod.Bias != src->SrcRegisterExtMod.Bias ) {
- TXT( "\nBias : " );
- UID( src->SrcRegisterExtMod.Bias );
- }
- if( deflt || fs->SrcRegisterExtMod.Scale2X != src->SrcRegisterExtMod.Scale2X ) {
- TXT( "\nScale2X : " );
- UID( src->SrcRegisterExtMod.Scale2X );
- }
- if( deflt || fs->SrcRegisterExtMod.Absolute != src->SrcRegisterExtMod.Absolute ) {
- TXT( "\nAbsolute : " );
- UID( src->SrcRegisterExtMod.Absolute );
- }
- if( deflt || fs->SrcRegisterExtMod.Negate != src->SrcRegisterExtMod.Negate ) {
- TXT( "\nNegate : " );
- UID( src->SrcRegisterExtMod.Negate );
- }
- if( ignored ) {
- TXT( "\nPadding : " );
- UIX( src->SrcRegisterExtMod.Padding );
- if( deflt || fs->SrcRegisterExtMod.Extended != src->SrcRegisterExtMod.Extended ) {
- TXT( "\nExtended : " );
- UID( src->SrcRegisterExtMod.Extended );
- }
- }
- }
- }
-}
-
-static void
-dump_gen(
- struct gen_dump *dump,
- const struct tgsi_token *tokens,
- unsigned flags )
-{
- struct tgsi_parse_context parse;
- struct tgsi_full_instruction fi;
- struct tgsi_full_declaration fd;
- unsigned verbose = flags & TGSI_DUMP_VERBOSE;
- unsigned ignored = !(flags & TGSI_DUMP_NO_IGNORED);
- unsigned deflt = !(flags & TGSI_DUMP_NO_DEFAULT);
- unsigned instno = 0;
-
- dump->tabs = 0;
-
- /* sanity check */
- assert(strcmp(TGSI_OPCODES[TGSI_OPCODE_CONT], "OPCODE_CONT") == 0);
-
- tgsi_parse_init( &parse, tokens );
-
- TXT( "tgsi-dump begin -----------------" );
-
- CHR( '\n' );
- ENM( parse.FullHeader.Processor.Processor, TGSI_PROCESSOR_TYPES_SHORT );
- CHR( ' ' );
- UID( parse.FullVersion.Version.MajorVersion );
- CHR( '.' );
- UID( parse.FullVersion.Version.MinorVersion );
-
- if( verbose ) {
- TXT( "\nMajorVersion: " );
- UID( parse.FullVersion.Version.MajorVersion );
- TXT( "\nMinorVersion: " );
- UID( parse.FullVersion.Version.MinorVersion );
- CHR( '\n' );
-
- TXT( "\nHeaderSize: " );
- UID( parse.FullHeader.Header.HeaderSize );
- TXT( "\nBodySize : " );
- UID( parse.FullHeader.Header.BodySize );
- TXT( "\nProcessor : " );
- ENM( parse.FullHeader.Processor.Processor, TGSI_PROCESSOR_TYPES );
- CHR( '\n' );
- }
-
- fi = tgsi_default_full_instruction();
- fd = tgsi_default_full_declaration();
-
- while( !tgsi_parse_end_of_tokens( &parse ) ) {
- tgsi_parse_token( &parse );
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- dump_declaration_short(
- dump,
- &parse.FullToken.FullDeclaration );
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- dump_immediate_short(
- dump,
- &parse.FullToken.FullImmediate );
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- dump_instruction_short(
- dump,
- &parse.FullToken.FullInstruction,
- instno );
- instno++;
- break;
-
- default:
- assert( 0 );
- }
-
- if( verbose ) {
- TXT( "\nType : " );
- ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES );
- if( ignored ) {
- TXT( "\nSize : " );
- UID( parse.FullToken.Token.Size );
- if( deflt || parse.FullToken.Token.Extended ) {
- TXT( "\nExtended : " );
- UID( parse.FullToken.Token.Extended );
- }
- }
-
- switch( parse.FullToken.Token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- dump_declaration_verbose(
- dump,
- &parse.FullToken.FullDeclaration,
- ignored,
- deflt,
- &fd );
- break;
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- dump_immediate_verbose(
- dump,
- &parse.FullToken.FullImmediate,
- ignored );
- break;
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- dump_instruction_verbose(
- dump,
- &parse.FullToken.FullInstruction,
- ignored,
- deflt,
- &fi );
- break;
-
- default:
- assert( 0 );
- }
-
- CHR( '\n' );
- }
- }
-
- TXT( "\ntgsi-dump end -------------------\n" );
-
- tgsi_parse_free( &parse );
-}
-
-
-static void
-sanity_checks(void)
-{
- assert(strcmp(TGSI_OPCODES[TGSI_OPCODE_END], "OPCODE_END") == 0);
- assert(strcmp(TGSI_OPCODES_SHORT[TGSI_OPCODE_END], "END") == 0);
-}
-
-
-void
-tgsi_dump(
- const struct tgsi_token *tokens,
- unsigned flags )
-{
- struct file_dump dump;
-
- sanity_checks();
-
- dump.base.write = _file_dump_write;
-#if 0
- {
- static unsigned counter = 0;
- char buffer[64];
- sprintf( buffer, "tgsi-dump-%.4u.txt", counter++ );
- dump.file = fopen( buffer, "wt" );
- }
-#else
- dump.file = stderr;
-#endif
-
- dump_gen(
- &dump.base,
- tokens,
- flags );
-
-#if 0
- fclose( dump.file );
-#endif
-}
-
-void
-tgsi_dump_str(
- char **str,
- const struct tgsi_token *tokens,
- unsigned flags )
-{
- struct text_dump dump;
-
- dump.base.write = _text_dump_write;
- dump.text = NULL;
- dump.length = 0;
- dump.capacity = 0;
-
- dump_gen(
- &dump.base,
- tokens,
- flags );
-
- *str = dump.text;
-}
diff --git a/src/mesa/pipe/tgsi/util/tgsi_dump.h b/src/mesa/pipe/tgsi/util/tgsi_dump.h
deleted file mode 100644
index 1adc9db251..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_dump.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#if !defined TGSI_DUMP_H
-#define TGSI_DUMP_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-#define TGSI_DUMP_VERBOSE 1
-#define TGSI_DUMP_NO_IGNORED 2
-#define TGSI_DUMP_NO_DEFAULT 4
-
-void
-tgsi_dump(
- const struct tgsi_token *tokens,
- unsigned flags );
-
-void
-tgsi_dump_str(
- char **str,
- const struct tgsi_token *tokens,
- unsigned flags );
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_DUMP_H
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_parse.c b/src/mesa/pipe/tgsi/util/tgsi_parse.c
deleted file mode 100644
index bf6b89ce56..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_parse.c
+++ /dev/null
@@ -1,319 +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.
- *
- **************************************************************************/
-
-#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
-#include "pipe/p_shader_tokens.h"
-#include "tgsi_parse.h"
-#include "tgsi_build.h"
-
-void
-tgsi_full_token_init(
- union tgsi_full_token *full_token )
-{
- full_token->Token.Type = TGSI_TOKEN_TYPE_DECLARATION;
-}
-
-void
-tgsi_full_token_free(
- union tgsi_full_token *full_token )
-{
- if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE ) {
- FREE( full_token->FullImmediate.u.Pointer );
- }
-}
-
-unsigned
-tgsi_parse_init(
- struct tgsi_parse_context *ctx,
- const struct tgsi_token *tokens )
-{
- ctx->FullVersion.Version = *(struct tgsi_version *) &tokens[0];
- if( ctx->FullVersion.Version.MajorVersion > 1 ) {
- return TGSI_PARSE_ERROR;
- }
-
- ctx->FullHeader.Header = *(struct tgsi_header *) &tokens[1];
- if( ctx->FullHeader.Header.HeaderSize >= 2 ) {
- ctx->FullHeader.Processor = *(struct tgsi_processor *) &tokens[2];
- }
- else {
- ctx->FullHeader.Processor = tgsi_default_processor();
- }
-
- ctx->Tokens = tokens;
- ctx->Position = 1 + ctx->FullHeader.Header.HeaderSize;
-
- tgsi_full_token_init( &ctx->FullToken );
-
- return TGSI_PARSE_OK;
-}
-
-void
-tgsi_parse_free(
- struct tgsi_parse_context *ctx )
-{
- tgsi_full_token_free( &ctx->FullToken );
-}
-
-boolean
-tgsi_parse_end_of_tokens(
- struct tgsi_parse_context *ctx )
-{
- return ctx->Position >=
- 1 + ctx->FullHeader.Header.HeaderSize + ctx->FullHeader.Header.BodySize;
-}
-
-static void
-next_token(
- struct tgsi_parse_context *ctx,
- void *token )
-{
- assert( !tgsi_parse_end_of_tokens( ctx ) );
-
- *(struct tgsi_token *) token = ctx->Tokens[ctx->Position++];
-}
-
-void
-tgsi_parse_token(
- struct tgsi_parse_context *ctx )
-{
- struct tgsi_token token;
- unsigned i;
-
- tgsi_full_token_free( &ctx->FullToken );
- tgsi_full_token_init( &ctx->FullToken );
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- {
- struct tgsi_full_declaration *decl = &ctx->FullToken.FullDeclaration;
-
- *decl = tgsi_default_full_declaration();
- decl->Declaration = *(struct tgsi_declaration *) &token;
-
- switch( decl->Declaration.Type ) {
- case TGSI_DECLARE_RANGE:
- next_token( ctx, &decl->u.DeclarationRange );
- break;
-
- case TGSI_DECLARE_MASK:
- next_token( ctx, &decl->u.DeclarationMask );
- break;
-
- default:
- assert (0);
- }
-
- if( decl->Declaration.Interpolate ) {
- next_token( ctx, &decl->Interpolation );
- }
-
- if( decl->Declaration.Semantic ) {
- next_token( ctx, &decl->Semantic );
- }
-
- break;
- }
-
- case TGSI_TOKEN_TYPE_IMMEDIATE:
- {
- struct tgsi_full_immediate *imm = &ctx->FullToken.FullImmediate;
-
- *imm = tgsi_default_full_immediate();
- imm->Immediate = *(struct tgsi_immediate *) &token;
-
- assert( !imm->Immediate.Extended );
-
- switch (imm->Immediate.DataType) {
- case TGSI_IMM_FLOAT32:
- imm->u.Pointer = MALLOC(
- sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
- for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
- next_token( ctx, &imm->u.ImmediateFloat32[i] );
- }
- break;
-
- default:
- assert( 0 );
- }
-
- break;
- }
-
- case TGSI_TOKEN_TYPE_INSTRUCTION:
- {
- struct tgsi_full_instruction *inst = &ctx->FullToken.FullInstruction;
- unsigned extended;
-
- *inst = tgsi_default_full_instruction();
- inst->Instruction = *(struct tgsi_instruction *) &token;
-
- extended = inst->Instruction.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_INSTRUCTION_EXT_TYPE_NV:
- inst->InstructionExtNv =
- *(struct tgsi_instruction_ext_nv *) &token;
- break;
-
- case TGSI_INSTRUCTION_EXT_TYPE_LABEL:
- inst->InstructionExtLabel =
- *(struct tgsi_instruction_ext_label *) &token;
- break;
-
- case TGSI_INSTRUCTION_EXT_TYPE_TEXTURE:
- inst->InstructionExtTexture =
- *(struct tgsi_instruction_ext_texture *) &token;
- break;
-
- default:
- assert( 0 );
- }
-
- extended = token.Extended;
- }
-
- assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
-
- for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
- unsigned extended;
-
- next_token( ctx, &inst->FullDstRegisters[i].DstRegister );
-
- /*
- * No support for indirect or multi-dimensional addressing.
- */
- assert( !inst->FullDstRegisters[i].DstRegister.Indirect );
- assert( !inst->FullDstRegisters[i].DstRegister.Dimension );
-
- extended = inst->FullDstRegisters[i].DstRegister.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_DST_REGISTER_EXT_TYPE_CONDCODE:
- inst->FullDstRegisters[i].DstRegisterExtConcode =
- *(struct tgsi_dst_register_ext_concode *) &token;
- break;
-
- case TGSI_DST_REGISTER_EXT_TYPE_MODULATE:
- inst->FullDstRegisters[i].DstRegisterExtModulate =
- *(struct tgsi_dst_register_ext_modulate *) &token;
- break;
-
- default:
- assert( 0 );
- }
-
- extended = token.Extended;
- }
- }
-
- assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
-
- for( i = 0; i < inst->Instruction.NumSrcRegs; i++ ) {
- unsigned extended;
-
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegister );
-
- extended = inst->FullSrcRegisters[i].SrcRegister.Extended;
-
- while( extended ) {
- struct tgsi_src_register_ext token;
-
- next_token( ctx, &token );
-
- switch( token.Type ) {
- case TGSI_SRC_REGISTER_EXT_TYPE_SWZ:
- inst->FullSrcRegisters[i].SrcRegisterExtSwz =
- *(struct tgsi_src_register_ext_swz *) &token;
- break;
-
- case TGSI_SRC_REGISTER_EXT_TYPE_MOD:
- inst->FullSrcRegisters[i].SrcRegisterExtMod =
- *(struct tgsi_src_register_ext_mod *) &token;
- break;
-
- default:
- assert( 0 );
- }
-
- extended = token.Extended;
- }
-
- if( inst->FullSrcRegisters[i].SrcRegister.Indirect ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterInd );
-
- /*
- * No support for indirect or multi-dimensional addressing.
- */
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
- }
-
- if( inst->FullSrcRegisters[i].SrcRegister.Dimension ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDim );
-
- /*
- * No support for multi-dimensional addressing.
- */
- assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterDim.Extended );
-
- if( inst->FullSrcRegisters[i].SrcRegisterDim.Indirect ) {
- next_token( ctx, &inst->FullSrcRegisters[i].SrcRegisterDimInd );
-
- /*
- * No support for indirect or multi-dimensional addressing.
- */
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Indirect );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Dimension );
- assert( !inst->FullSrcRegisters[i].SrcRegisterInd.Extended );
- }
- }
- }
-
- break;
- }
-
- default:
- assert( 0 );
- }
-}
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_parse.h b/src/mesa/pipe/tgsi/util/tgsi_parse.h
deleted file mode 100644
index 9372da8d5d..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_parse.h
+++ /dev/null
@@ -1,121 +0,0 @@
-#if !defined TGSI_PARSE_H
-#define TGSI_PARSE_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-struct tgsi_full_version
-{
- struct tgsi_version Version;
-};
-
-struct tgsi_full_header
-{
- struct tgsi_header Header;
- struct tgsi_processor Processor;
-};
-
-struct tgsi_full_dst_register
-{
- struct tgsi_dst_register DstRegister;
- struct tgsi_dst_register_ext_concode DstRegisterExtConcode;
- struct tgsi_dst_register_ext_modulate DstRegisterExtModulate;
-};
-
-struct tgsi_full_src_register
-{
- struct tgsi_src_register SrcRegister;
- struct tgsi_src_register_ext_swz SrcRegisterExtSwz;
- struct tgsi_src_register_ext_mod SrcRegisterExtMod;
- struct tgsi_src_register SrcRegisterInd;
- struct tgsi_dimension SrcRegisterDim;
- struct tgsi_src_register SrcRegisterDimInd;
-};
-
-struct tgsi_full_declaration
-{
- struct tgsi_declaration Declaration;
- union
- {
- struct tgsi_declaration_range DeclarationRange;
- struct tgsi_declaration_mask DeclarationMask;
- } u;
- struct tgsi_declaration_interpolation Interpolation;
- struct tgsi_declaration_semantic Semantic;
-};
-
-struct tgsi_full_immediate
-{
- struct tgsi_immediate Immediate;
- union
- {
- void *Pointer;
- struct tgsi_immediate_float32 *ImmediateFloat32;
- } u;
-};
-
-#define TGSI_FULL_MAX_DST_REGISTERS 2
-#define TGSI_FULL_MAX_SRC_REGISTERS 3
-
-struct tgsi_full_instruction
-{
- struct tgsi_instruction Instruction;
- struct tgsi_instruction_ext_nv InstructionExtNv;
- struct tgsi_instruction_ext_label InstructionExtLabel;
- struct tgsi_instruction_ext_texture InstructionExtTexture;
- struct tgsi_full_dst_register FullDstRegisters[TGSI_FULL_MAX_DST_REGISTERS];
- struct tgsi_full_src_register FullSrcRegisters[TGSI_FULL_MAX_SRC_REGISTERS];
-};
-
-union tgsi_full_token
-{
- struct tgsi_token Token;
- struct tgsi_full_declaration FullDeclaration;
- struct tgsi_full_immediate FullImmediate;
- struct tgsi_full_instruction FullInstruction;
-};
-
-void
-tgsi_full_token_init(
- union tgsi_full_token *full_token );
-
-void
-tgsi_full_token_free(
- union tgsi_full_token *full_token );
-
-struct tgsi_parse_context
-{
- const struct tgsi_token *Tokens;
- unsigned Position;
- struct tgsi_full_version FullVersion;
- struct tgsi_full_header FullHeader;
- union tgsi_full_token FullToken;
-};
-
-#define TGSI_PARSE_OK 0
-#define TGSI_PARSE_ERROR 1
-
-unsigned
-tgsi_parse_init(
- struct tgsi_parse_context *ctx,
- const struct tgsi_token *tokens );
-
-void
-tgsi_parse_free(
- struct tgsi_parse_context *ctx );
-
-boolean
-tgsi_parse_end_of_tokens(
- struct tgsi_parse_context *ctx );
-
-void
-tgsi_parse_token(
- struct tgsi_parse_context *ctx );
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_PARSE_H
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_util.c b/src/mesa/pipe/tgsi/util/tgsi_util.c
deleted file mode 100644
index 4cdd89182a..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_util.c
+++ /dev/null
@@ -1,274 +0,0 @@
-#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 "tgsi_util.h"
-
-union pointer_hack
-{
- void *pointer;
- unsigned long long uint64;
-};
-
-void *
-tgsi_align_128bit(
- void *unaligned )
-{
- union pointer_hack ph;
-
- ph.uint64 = 0;
- ph.pointer = unaligned;
- ph.uint64 = (ph.uint64 + 15) & ~15;
- return ph.pointer;
-}
-
-unsigned
-tgsi_util_get_src_register_swizzle(
- const struct tgsi_src_register *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->SwizzleX;
- case 1:
- return reg->SwizzleY;
- case 2:
- return reg->SwizzleZ;
- case 3:
- return reg->SwizzleW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-unsigned
-tgsi_util_get_src_register_extswizzle(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->ExtSwizzleX;
- case 1:
- return reg->ExtSwizzleY;
- case 2:
- return reg->ExtSwizzleZ;
- case 3:
- return reg->ExtSwizzleW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-unsigned
-tgsi_util_get_full_src_register_extswizzle(
- const struct tgsi_full_src_register *reg,
- unsigned component )
-{
- unsigned swizzle;
-
- /*
- * First, calculate the extended swizzle for a given channel. This will give
- * us either a channel index into the simple swizzle or a constant 1 or 0.
- */
- swizzle = tgsi_util_get_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);
-
- /*
- * Second, calculate the simple swizzle for the unswizzled channel index.
- * Leave the constants intact, they are not affected by the simple swizzle.
- */
- if( swizzle <= TGSI_SWIZZLE_W ) {
- swizzle = tgsi_util_get_src_register_swizzle(
- &reg->SrcRegister,
- component );
- }
-
- return swizzle;
-}
-
-void
-tgsi_util_set_src_register_swizzle(
- struct tgsi_src_register *reg,
- unsigned swizzle,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->SwizzleX = swizzle;
- break;
- case 1:
- reg->SwizzleY = swizzle;
- break;
- case 2:
- reg->SwizzleZ = swizzle;
- break;
- case 3:
- reg->SwizzleW = swizzle;
- break;
- default:
- assert( 0 );
- }
-}
-
-void
-tgsi_util_set_src_register_extswizzle(
- struct tgsi_src_register_ext_swz *reg,
- unsigned swizzle,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->ExtSwizzleX = swizzle;
- break;
- case 1:
- reg->ExtSwizzleY = swizzle;
- break;
- case 2:
- reg->ExtSwizzleZ = swizzle;
- break;
- case 3:
- reg->ExtSwizzleW = swizzle;
- break;
- default:
- assert( 0 );
- }
-}
-
-unsigned
-tgsi_util_get_src_register_extnegate(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component )
-{
- switch( component ) {
- case 0:
- return reg->NegateX;
- case 1:
- return reg->NegateY;
- case 2:
- return reg->NegateZ;
- case 3:
- return reg->NegateW;
- default:
- assert( 0 );
- }
- return 0;
-}
-
-void
-tgsi_util_set_src_register_extnegate(
- struct tgsi_src_register_ext_swz *reg,
- unsigned negate,
- unsigned component )
-{
- switch( component ) {
- case 0:
- reg->NegateX = negate;
- break;
- case 1:
- reg->NegateY = negate;
- break;
- case 2:
- reg->NegateZ = negate;
- break;
- case 3:
- reg->NegateW = negate;
- break;
- default:
- assert( 0 );
- }
-}
-
-unsigned
-tgsi_util_get_full_src_register_sign_mode(
- const struct tgsi_full_src_register *reg,
- unsigned component )
-{
- unsigned sign_mode;
-
- if( reg->SrcRegisterExtMod.Absolute ) {
- /* Consider only the post-abs negation. */
-
- if( reg->SrcRegisterExtMod.Negate ) {
- sign_mode = TGSI_UTIL_SIGN_SET;
- }
- else {
- sign_mode = TGSI_UTIL_SIGN_CLEAR;
- }
- }
- else {
- /* Accumulate the three negations. */
-
- unsigned negate;
-
- negate = reg->SrcRegister.Negate;
- if( tgsi_util_get_src_register_extnegate( &reg->SrcRegisterExtSwz, component ) ) {
- negate = !negate;
- }
- if( reg->SrcRegisterExtMod.Negate ) {
- negate = !negate;
- }
-
- if( negate ) {
- sign_mode = TGSI_UTIL_SIGN_TOGGLE;
- }
- else {
- sign_mode = TGSI_UTIL_SIGN_KEEP;
- }
- }
-
- return sign_mode;
-}
-
-void
-tgsi_util_set_full_src_register_sign_mode(
- struct tgsi_full_src_register *reg,
- unsigned sign_mode )
-{
- reg->SrcRegisterExtSwz.NegateX = 0;
- reg->SrcRegisterExtSwz.NegateY = 0;
- reg->SrcRegisterExtSwz.NegateZ = 0;
- reg->SrcRegisterExtSwz.NegateW = 0;
-
- switch (sign_mode)
- {
- case TGSI_UTIL_SIGN_CLEAR:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 1;
- reg->SrcRegisterExtMod.Negate = 0;
- break;
-
- case TGSI_UTIL_SIGN_SET:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 1;
- reg->SrcRegisterExtMod.Negate = 1;
- break;
-
- case TGSI_UTIL_SIGN_TOGGLE:
- reg->SrcRegister.Negate = 1;
- reg->SrcRegisterExtMod.Absolute = 0;
- reg->SrcRegisterExtMod.Negate = 0;
- break;
-
- case TGSI_UTIL_SIGN_KEEP:
- reg->SrcRegister.Negate = 0;
- reg->SrcRegisterExtMod.Absolute = 0;
- reg->SrcRegisterExtMod.Negate = 0;
- break;
-
- default:
- assert( 0 );
- }
-}
-
diff --git a/src/mesa/pipe/tgsi/util/tgsi_util.h b/src/mesa/pipe/tgsi/util/tgsi_util.h
deleted file mode 100644
index ef14446f0e..0000000000
--- a/src/mesa/pipe/tgsi/util/tgsi_util.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#if !defined TGSI_UTIL_H
-#define TGSI_UTIL_H
-
-#if defined __cplusplus
-extern "C" {
-#endif // defined __cplusplus
-
-void *
-tgsi_align_128bit(
- void *unaligned );
-
-unsigned
-tgsi_util_get_src_register_swizzle(
- const struct tgsi_src_register *reg,
- unsigned component );
-
-unsigned
-tgsi_util_get_src_register_extswizzle(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component);
-
-unsigned
-tgsi_util_get_full_src_register_extswizzle(
- const struct tgsi_full_src_register *reg,
- unsigned component );
-
-void
-tgsi_util_set_src_register_swizzle(
- struct tgsi_src_register *reg,
- unsigned swizzle,
- unsigned component );
-
-void
-tgsi_util_set_src_register_extswizzle(
- struct tgsi_src_register_ext_swz *reg,
- unsigned swizzle,
- unsigned component );
-
-unsigned
-tgsi_util_get_src_register_extnegate(
- const struct tgsi_src_register_ext_swz *reg,
- unsigned component );
-
-void
-tgsi_util_set_src_register_extnegate(
- struct tgsi_src_register_ext_swz *reg,
- unsigned negate,
- unsigned component );
-
-#define TGSI_UTIL_SIGN_CLEAR 0 /* Force positive */
-#define TGSI_UTIL_SIGN_SET 1 /* Force negative */
-#define TGSI_UTIL_SIGN_TOGGLE 2 /* Negate */
-#define TGSI_UTIL_SIGN_KEEP 3 /* No change */
-
-unsigned
-tgsi_util_get_full_src_register_sign_mode(
- const struct tgsi_full_src_register *reg,
- unsigned component );
-
-void
-tgsi_util_set_full_src_register_sign_mode(
- struct tgsi_full_src_register *reg,
- unsigned sign_mode );
-
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
-
-#endif // !defined TGSI_UTIL_H
-
diff --git a/src/mesa/pipe/util/p_debug.c b/src/mesa/pipe/util/p_debug.c
deleted file mode 100644
index b9607a6ba7..0000000000
--- a/src/mesa/pipe/util/p_debug.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include <stdarg.h>
-
-#ifdef WIN32
-#include <windows.h>
-#include <winddi.h>
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#endif
-
-#include "pipe/p_debug.h"
-#include "pipe/p_compiler.h"
-
-
-void debug_vprintf(const char *format, va_list ap)
-{
-#ifdef WIN32
- EngDebugPrint("Gallium3D: ", (PCHAR)format, ap);
-#else
- vfprintf(stderr, format, ap);
-#endif
-}
-
-
-void debug_printf(const char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- debug_vprintf(format, ap);
- va_end(ap);
-}
-
-
-static INLINE void debug_abort(void)
-{
-#ifdef WIN32
- EngDebugBreak();
-#else
- abort();
-#endif
-}
-
-
-void debug_assert_fail(const char *expr, const char *file, unsigned line)
-{
- debug_printf("%s:%i: Assertion `%s' failed.\n", file, line, expr);
- debug_abort();
-}
diff --git a/src/mesa/pipe/util/p_tile.c b/src/mesa/pipe/util/p_tile.c
deleted file mode 100644
index 3f795a3898..0000000000
--- a/src/mesa/pipe/util/p_tile.c
+++ /dev/null
@@ -1,699 +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.
- *
- **************************************************************************/
-
-/**
- * RGBA/float tile get/put functions.
- * Usable both by drivers and state trackers.
- * Surfaces should already be in a mapped state.
- */
-
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-
-#include "p_tile.h"
-
-
-
-/**
- * Move raw block of pixels from surface to user memory.
- * This should be usable by any hw driver that has mappable surfaces.
- */
-void
-pipe_get_tile_raw(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- void *p, int dst_stride)
-{
- const uint cpp = ps->cpp;
- const ubyte *pSrc;
- const uint src_stride = ps->pitch * cpp;
- ubyte *pDest;
- uint i;
-
- if (dst_stride == 0) {
- dst_stride = w * cpp;
- }
-
- if (pipe_clip_tile(x, y, &w, &h, ps))
- return;
-
- pSrc = (const ubyte *) pipe_surface_map(ps) + (y * ps->pitch + x) * cpp;
- pDest = (ubyte *) p;
-
- for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, w * cpp);
- pDest += dst_stride;
- pSrc += src_stride;
- }
-
- pipe_surface_unmap(ps);
-}
-
-
-/**
- * Move raw block of pixels from user memory to surface.
- * This should be usable by any hw driver that has mappable surfaces.
- */
-void
-pipe_put_tile_raw(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const void *p, int src_stride)
-{
- const uint cpp = ps->cpp;
- const ubyte *pSrc;
- const uint dst_stride = ps->pitch * cpp;
- ubyte *pDest;
- uint i;
-
- if (src_stride == 0) {
- src_stride = w * cpp;
- }
-
- if (pipe_clip_tile(x, y, &w, &h, ps))
- return;
-
- pSrc = (const ubyte *) p;
- pDest = (ubyte *) pipe_surface_map(ps) + (y * ps->pitch + x) * cpp;
-
- for (i = 0; i < h; i++) {
- memcpy(pDest, pSrc, w * cpp);
- pDest += dst_stride;
- pSrc += src_stride;
- }
-
- pipe_surface_unmap(ps);
-}
-
-
-
-
-/** Convert short in [-32768,32767] to GLfloat in [-1.0,1.0] */
-#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
-
-#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
- us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) )
-
-
-
-/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/
-
-static void
-a8r8g8b8_get_tile_rgba(unsigned *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- const 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);
- }
- p += dst_stride;
- }
-}
-
-
-static void
-a8r8g8b8_put_tile_rgba(unsigned *dst,
- unsigned w, unsigned h,
- const float *p,
- unsigned src_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- const float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- unsigned r, g, b, 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]);
- *dst++ = (a << 24) | (r << 16) | (g << 8) | b;
- }
- p += src_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/
-
-static void
-b8g8r8a8_get_tile_rgba(unsigned *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- const 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);
- }
- p += dst_stride;
- }
-}
-
-
-static void
-b8g8r8a8_put_tile_rgba(unsigned *dst,
- unsigned w, unsigned h,
- const float *p,
- unsigned src_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- const float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- unsigned r, g, b, 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]);
- *dst++ = (b << 24) | (g << 16) | (r << 8) | a;
- }
- p += src_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_A1R5G5B5_UNORM ***/
-
-static void
-a1r5g5b5_get_tile_rgba(ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- const ushort pixel = *src++;
- pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
- pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
- pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
- pRow[3] = ((pixel >> 15) ) * 1.0f;
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_A4R4G4B4_UNORM ***/
-
-static void
-a4r4g4b4_get_tile_rgba(ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- const ushort pixel = *src++;
- pRow[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f);
- pRow[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f);
- pRow[2] = ((pixel ) & 0xf) * (1.0f / 15.0f);
- pRow[3] = ((pixel >> 12) ) * (1.0f / 15.0f);
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_R5G6B5_UNORM ***/
-
-static void
-r5g6b5_get_tile_rgba(ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- const ushort pixel = *src++;
- pRow[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f);
- pRow[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f);
- pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
- pRow[3] = 1.0f;
- }
- p += dst_stride;
- }
-}
-
-
-static void
-r5g5b5_put_tile_rgba(ushort *dst,
- unsigned w, unsigned h,
- const float *p,
- unsigned src_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- const float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0);
- uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0);
- uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0);
- *dst++ = (r << 11) | (g << 5) | (b);
- }
- p += src_stride;
- }
-}
-
-
-
-/*** PIPE_FORMAT_Z16_UNORM ***/
-
-/**
- * Return each Z value as four floats in [0,1].
- */
-static void
-z16_get_tile_rgba(ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- const float scale = 1.0f / 65535.0f;
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = *src++ * scale;
- }
- p += dst_stride;
- }
-}
-
-
-
-
-/*** PIPE_FORMAT_U_L8 ***/
-
-static void
-l8_get_tile_rgba(ubyte *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, src++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] = UBYTE_TO_FLOAT(*src);
- pRow[3] = 1.0;
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_U_A8 ***/
-
-static void
-a8_get_tile_rgba(ubyte *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, src++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] = 0.0;
- pRow[3] = UBYTE_TO_FLOAT(*src);
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_R16G16B16A16_SNORM ***/
-
-static void
-r16g16b16a16_get_tile_rgba(short *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, src += 4, pRow += 4) {
- pRow[0] = SHORT_TO_FLOAT(src[0]);
- pRow[1] = SHORT_TO_FLOAT(src[1]);
- pRow[2] = SHORT_TO_FLOAT(src[2]);
- pRow[3] = SHORT_TO_FLOAT(src[3]);
- }
- p += dst_stride;
- }
-}
-
-
-static void
-r16g16b16a16_put_tile_rgba(short *dst,
- unsigned w, unsigned h,
- const float *p,
- unsigned src_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- const float *pRow = p;
- for (j = 0; j < w; j++, dst += 4, pRow += 4) {
- UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]);
- UNCLAMPED_FLOAT_TO_SHORT(dst[1], pRow[1]);
- UNCLAMPED_FLOAT_TO_SHORT(dst[2], pRow[2]);
- UNCLAMPED_FLOAT_TO_SHORT(dst[3], pRow[3]);
- }
- p += src_stride;
- }
-}
-
-
-
-/*** PIPE_FORMAT_U_I8 ***/
-
-static void
-i8_get_tile_rgba(ubyte *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, src++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = UBYTE_TO_FLOAT(*src);
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_U_A8_L8 ***/
-
-static void
-a8_l8_get_tile_rgba(ushort *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- ushort p = *src++;
- pRow[0] =
- pRow[1] =
- pRow[2] = UBYTE_TO_FLOAT(p & 0xff);
- pRow[3] = UBYTE_TO_FLOAT(p >> 8);
- }
- p += dst_stride;
- }
-}
-
-
-
-
-/*** PIPE_FORMAT_Z32_UNORM ***/
-
-/**
- * Return each Z value as four floats in [0,1].
- */
-static void
-z32_get_tile_rgba(unsigned *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- const double scale = 1.0 / (double) 0xffffffff;
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = (float) (*src++ * scale);
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_S8Z24_UNORM ***/
-
-/**
- * Return Z component as four float in [0,1]. Stencil part ignored.
- */
-static void
-s8z24_get_tile_rgba(unsigned *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- const double scale = 1.0 / ((1 << 24) - 1);
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = (float) (scale * (*src++ & 0xffffff));
- }
- p += dst_stride;
- }
-}
-
-
-/*** PIPE_FORMAT_Z24S8_UNORM ***/
-
-/**
- * Return Z component as four float in [0,1]. Stencil part ignored.
- */
-static void
-z24s8_get_tile_rgba(unsigned *src,
- unsigned w, unsigned h,
- float *p,
- unsigned dst_stride)
-{
- const double scale = 1.0 / ((1 << 24) - 1);
- unsigned i, j;
-
- for (i = 0; i < h; i++) {
- float *pRow = p;
- for (j = 0; j < w; j++, pRow += 4) {
- pRow[0] =
- pRow[1] =
- pRow[2] =
- pRow[3] = (float) (scale * (*src++ >> 8));
- }
- p += dst_stride;
- }
-}
-
-
-void
-pipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- float *p)
-{
- unsigned dst_stride = w * 4;
- void *packed;
-
- if (pipe_clip_tile(x, y, &w, &h, ps))
- return;
-
- packed = MALLOC(h * w * ps->cpp);
-
- if (!packed)
- return;
-
- pipe_get_tile_raw(pipe, ps, x, y, w, h, packed, w * ps->cpp);
-
- switch (ps->format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- a8r8g8b8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- b8g8r8a8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- a1r5g5b5_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- a4r4g4b4_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- r5g6b5_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_U_L8:
- l8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_U_A8:
- a8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_U_I8:
- i8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_U_A8_L8:
- a8_l8_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- r16g16b16a16_get_tile_rgba((short *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_Z16_UNORM:
- z16_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_Z32_UNORM:
- z32_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_S8Z24_UNORM:
- s8z24_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
- break;
- case PIPE_FORMAT_Z24S8_UNORM:
- z24s8_get_tile_rgba((unsigned *) packed, w, h, p, dst_stride);
- break;
- default:
- assert(0);
- }
-
- FREE(packed);
-}
-
-
-void
-pipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const float *p)
-{
- unsigned src_stride = w * 4;
- void *packed;
-
- if (pipe_clip_tile(x, y, &w, &h, ps))
- return;
-
- packed = MALLOC(h * w * ps->cpp);
-
- if (!packed)
- return;
-
- switch (ps->format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
- break;
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
- break;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- /*a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_R5G6B5_UNORM:
- r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
- break;
- case PIPE_FORMAT_R8G8B8A8_UNORM:
- break;
- case PIPE_FORMAT_U_L8:
- /*l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_U_A8:
- /*a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_U_I8:
- /*i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_U_A8_L8:
- /*a8_l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride);
- break;
- case PIPE_FORMAT_Z16_UNORM:
- /*z16_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_Z32_UNORM:
- /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_S8Z24_UNORM:
- /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
- break;
- case PIPE_FORMAT_Z24S8_UNORM:
- /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
- break;
- default:
- assert(0);
- }
-
- pipe_put_tile_raw(pipe, ps, x, y, w, h, packed, w * ps->cpp);
-
- FREE(packed);
-}
diff --git a/src/mesa/pipe/util/p_tile.h b/src/mesa/pipe/util/p_tile.h
deleted file mode 100644
index cd8124bf11..0000000000
--- a/src/mesa/pipe/util/p_tile.h
+++ /dev/null
@@ -1,81 +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_TILE_H
-#define P_TILE_H
-
-#include "pipe/p_compiler.h"
-
-struct pipe_context;
-struct pipe_surface;
-
-
-/**
- * Clip tile against surface dims.
- * \return TRUE if tile is totally clipped, FALSE otherwise
- */
-static INLINE boolean
-pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_surface *ps)
-{
- if (x >= ps->width)
- return TRUE;
- if (y >= ps->height)
- return TRUE;
- if (x + *w > ps->width)
- *w = ps->width - x;
- if (y + *h > ps->height)
- *h = ps->height - y;
- return FALSE;
-}
-
-
-extern void
-pipe_get_tile_raw(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- void *p, int dst_stride);
-
-extern void
-pipe_put_tile_raw(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const void *p, int src_stride);
-
-
-extern void
-pipe_get_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- float *p);
-
-extern void
-pipe_put_tile_rgba(struct pipe_context *pipe,
- struct pipe_surface *ps,
- uint x, uint y, uint w, uint h,
- const float *p);
-
-#endif
diff --git a/src/mesa/pipe/util/p_util.c b/src/mesa/pipe/util/p_util.c
deleted file mode 100644
index 2a92f8e408..0000000000
--- a/src/mesa/pipe/util/p_util.c
+++ /dev/null
@@ -1,73 +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"
-
-
-/**
- * Copy 2D rect from one place to another.
- * Position and sizes are in pixels.
- */
-void
-pipe_copy_rect(ubyte * dst,
- unsigned cpp,
- unsigned dst_pitch,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- int src_pitch,
- unsigned src_x,
- int src_y)
-{
- unsigned i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * src_pitch;
- width *= cpp;
-
- if (width == dst_pitch && width == src_pitch)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
diff --git a/src/mesa/pipe/xlib/brw_aub.c b/src/mesa/pipe/xlib/brw_aub.c
deleted file mode 100644
index 541d50c6e4..0000000000
--- a/src/mesa/pipe/xlib/brw_aub.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "brw_aub.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "imports.h"
-//#include "intel_winsys.h"
-
-
-struct brw_aubfile {
- FILE *file;
- unsigned next_free_page;
-};
-
-
-extern char *__progname;
-
-
-struct aub_file_header {
- unsigned int instruction_type;
- unsigned int pad0:16;
- unsigned int minor:8;
- unsigned int major:8;
- unsigned char application[8*4];
- unsigned int day:8;
- unsigned int month:8;
- unsigned int year:16;
- unsigned int timezone:8;
- unsigned int second:8;
- unsigned int minute:8;
- unsigned int hour:8;
- unsigned int comment_length:16;
- unsigned int pad1:16;
-};
-
-struct aub_block_header {
- unsigned int instruction_type;
- unsigned int operation:8;
- unsigned int type:8;
- unsigned int address_space:8;
- unsigned int pad0:8;
- unsigned int general_state_type:8;
- unsigned int surface_state_type:8;
- unsigned int pad1:16;
- unsigned int address;
- unsigned int length;
-};
-
-struct aub_dump_bmp {
- unsigned int instruction_type;
- unsigned int xmin:16;
- unsigned int ymin:16;
- unsigned int pitch:16;
- unsigned int bpp:8;
- unsigned int format:8;
- unsigned int xsize:16;
- unsigned int ysize:16;
- unsigned int addr;
- unsigned int unknown;
-};
-
-enum bh_operation {
- BH_COMMENT,
- BH_DATA_WRITE,
- BH_COMMAND_WRITE,
- BH_MMI0_WRITE32,
- BH_END_SCENE,
- BH_CONFIG_MEMORY_MAP,
- BH_MAX_OPERATION
-};
-
-enum command_write_type {
- CW_HWB_RING = 1,
- CW_PRIMARY_RING_A,
- CW_PRIMARY_RING_B, /* XXX - disagreement with listaub! */
- CW_PRIMARY_RING_C,
- CW_MAX_TYPE
-};
-
-enum memory_map_type {
- MM_DEFAULT,
- MM_DYNAMIC,
- MM_MAX_TYPE
-};
-
-enum address_space {
- ADDR_GTT,
- ADDR_LOCAL,
- ADDR_MAIN,
- ADDR_MAX
-};
-
-
-#define AUB_FILE_HEADER 0xe085000b
-#define AUB_BLOCK_HEADER 0xe0c10003
-#define AUB_DUMP_BMP 0xe09e0004
-
-/* Registers to control page table
- */
-#define PGETBL_CTL 0x2020
-#define PGETBL_ENABLED 0x1
-
-#define NR_GTT_ENTRIES 65536 /* 256 mb */
-
-#define FAIL \
-do { \
- fprintf(stderr, "failed to write aub data at %s/%d\n", __FUNCTION__, __LINE__); \
- exit(1); \
-} while (0)
-
-
-/* Emit the headers at the top of each aubfile. Initialize the GTT.
- */
-static void init_aubfile( FILE *aub_file )
-{
- struct aub_file_header fh;
- struct aub_block_header bh;
- unsigned int data;
-
- static int nr;
-
- nr++;
-
- /* Emit the aub header:
- */
- memset(&fh, 0, sizeof(fh));
-
- fh.instruction_type = AUB_FILE_HEADER;
- fh.minor = 0x0;
- fh.major = 0x7;
- memcpy(fh.application, __progname, sizeof(fh.application));
- fh.day = (nr>>24) & 0xff;
- fh.month = 0x0;
- fh.year = 0x0;
- fh.timezone = 0x0;
- fh.second = nr & 0xff;
- fh.minute = (nr>>8) & 0xff;
- fh.hour = (nr>>16) & 0xff;
- fh.comment_length = 0x0;
-
- if (fwrite(&fh, sizeof(fh), 1, aub_file) < 0)
- FAIL;
-
- /* Setup the GTT starting at main memory address zero (!):
- */
- memset(&bh, 0, sizeof(bh));
-
- bh.instruction_type = AUB_BLOCK_HEADER;
- bh.operation = BH_MMI0_WRITE32;
- bh.type = 0x0;
- bh.address_space = ADDR_GTT; /* ??? */
- bh.general_state_type = 0x0;
- bh.surface_state_type = 0x0;
- bh.address = PGETBL_CTL;
- bh.length = 0x4;
-
- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0)
- FAIL;
-
- data = 0x0 | PGETBL_ENABLED;
-
- if (fwrite(&data, sizeof(data), 1, aub_file) < 0)
- FAIL;
-}
-
-
-static void init_aub_gtt( struct brw_aubfile *aubfile,
- unsigned start_offset,
- unsigned size )
-{
- FILE *aub_file = aubfile->file;
- struct aub_block_header bh;
- unsigned int i;
-
- assert(start_offset + size < NR_GTT_ENTRIES * 4096);
-
-
- memset(&bh, 0, sizeof(bh));
-
- bh.instruction_type = AUB_BLOCK_HEADER;
- bh.operation = BH_DATA_WRITE;
- bh.type = 0x0;
- bh.address_space = ADDR_MAIN;
- bh.general_state_type = 0x0;
- bh.surface_state_type = 0x0;
- bh.address = start_offset / 4096 * 4;
- bh.length = size / 4096 * 4;
-
- if (fwrite(&bh, sizeof(bh), 1, aub_file) < 0)
- FAIL;
-
- for (i = 0; i < size / 4096; i++) {
- unsigned data = aubfile->next_free_page | 1;
-
- aubfile->next_free_page += 4096;
-
- if (fwrite(&data, sizeof(data), 1, aub_file) < 0)
- FAIL;
- }
-
-}
-
-static void write_block_header( FILE *aub_file,
- struct aub_block_header *bh,
- const unsigned *data,
- unsigned sz )
-{
- sz = (sz + 3) & ~3;
-
- if (fwrite(bh, sizeof(*bh), 1, aub_file) < 0)
- FAIL;
-
- if (fwrite(data, sz, 1, aub_file) < 0)
- FAIL;
-
- fflush(aub_file);
-}
-
-
-static void write_dump_bmp( FILE *aub_file,
- struct aub_dump_bmp *db )
-{
- if (fwrite(db, sizeof(*db), 1, aub_file) < 0)
- FAIL;
-
- fflush(aub_file);
-}
-
-
-
-void brw_aub_gtt_data( struct brw_aubfile *aubfile,
- unsigned offset,
- const void *data,
- unsigned sz,
- unsigned type,
- unsigned state_type )
-{
- struct aub_block_header bh;
-
- bh.instruction_type = AUB_BLOCK_HEADER;
- bh.operation = BH_DATA_WRITE;
- bh.type = type;
- bh.address_space = ADDR_GTT;
- bh.pad0 = 0;
-
- if (type == DW_GENERAL_STATE) {
- bh.general_state_type = state_type;
- bh.surface_state_type = 0;
- }
- else {
- bh.general_state_type = 0;
- bh.surface_state_type = state_type;
- }
-
- bh.pad1 = 0;
- bh.address = offset;
- bh.length = sz;
-
- write_block_header(aubfile->file, &bh, data, sz);
-}
-
-
-
-void brw_aub_gtt_cmds( struct brw_aubfile *aubfile,
- unsigned offset,
- const void *data,
- unsigned sz )
-{
- struct aub_block_header bh;
- unsigned type = CW_PRIMARY_RING_A;
-
-
- bh.instruction_type = AUB_BLOCK_HEADER;
- bh.operation = BH_COMMAND_WRITE;
- bh.type = type;
- bh.address_space = ADDR_GTT;
- bh.pad0 = 0;
- bh.general_state_type = 0;
- bh.surface_state_type = 0;
- bh.pad1 = 0;
- bh.address = offset;
- bh.length = sz;
-
- write_block_header(aubfile->file, &bh, data, sz);
-}
-
-void brw_aub_dump_bmp( struct brw_aubfile *aubfile,
- struct pipe_surface *surface,
- unsigned gtt_offset )
-{
- struct aub_dump_bmp db;
- unsigned format;
-
- if (surface->cpp == 4)
- format = 0x7;
- else
- format = 0x3;
-
- db.instruction_type = AUB_DUMP_BMP;
- db.xmin = 0;
- db.ymin = 0;
- db.format = format;
- db.bpp = surface->cpp * 8;
- db.pitch = surface->pitch;
- db.xsize = surface->width;
- db.ysize = surface->height;
- db.addr = gtt_offset;
- db.unknown = /* surface->tiled ? 0x4 : */ 0x0;
-
- write_dump_bmp(aubfile->file, &db);
-}
-
-
-
-struct brw_aubfile *brw_aubfile_create( void )
-{
- struct brw_aubfile *aubfile = CALLOC_STRUCT(brw_aubfile);
- char filename[80];
- int val;
- static int i = 0;
-
- i++;
-
- if (_mesa_getenv("INTEL_AUBFILE")) {
- val = snprintf(filename, sizeof(filename), "%s%d.aub", _mesa_getenv("INTEL_AUBFILE"), i%4);
- _mesa_printf("--> Aub file: %s\n", filename);
- aubfile->file = fopen(filename, "w");
- }
- else {
- val = snprintf(filename, sizeof(filename), "%s.aub", __progname);
- if (val < 0 || val > sizeof(filename))
- strcpy(filename, "default.aub");
-
- _mesa_printf("--> Aub file: %s\n", filename);
- aubfile->file = fopen(filename, "w");
- }
-
- if (!aubfile->file) {
- _mesa_printf("couldn't open aubfile\n");
- exit(1);
- }
-
- init_aubfile(aubfile->file);
-
- /* The GTT is located starting address zero in main memory. Pages
- * to populate the gtt start after this point.
- */
- aubfile->next_free_page = (NR_GTT_ENTRIES * 4 + 4095) & ~4095;
-
- /* More or less correspond with all the agp regions mapped by the
- * driver:
- */
- init_aub_gtt(aubfile, 0, 4096*4);
- init_aub_gtt(aubfile, AUB_BUF_START, AUB_BUF_SIZE);
-
- return aubfile;
-}
-
-void brw_aub_destroy( struct brw_aubfile *aubfile )
-{
- fclose(aubfile->file);
- FREE(aubfile);
-}
diff --git a/src/mesa/pipe/xlib/brw_aub.h b/src/mesa/pipe/xlib/brw_aub.h
deleted file mode 100644
index f5c60c7be2..0000000000
--- a/src/mesa/pipe/xlib/brw_aub.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef BRW_AUB_H
-#define BRW_AUB_H
-
-/* We set up this region, buffers may be allocated here:
- */
-#define AUB_BUF_START (4096*4)
-#define AUB_BUF_SIZE (8*1024*1024)
-
-struct intel_context;
-struct pipe_surface;
-
-struct brw_aubfile *brw_aubfile_create( void );
-
-void brw_aub_destroy( struct brw_aubfile *aubfile );
-
-void brw_aub_gtt_data( struct brw_aubfile *aubfile,
- unsigned offset,
- const void *data,
- unsigned sz,
- unsigned type,
- unsigned state_type );
-
-void brw_aub_gtt_cmds( struct brw_aubfile *aubfile,
- unsigned offset,
- const void *data,
- unsigned sz );
-
-void brw_aub_dump_bmp( struct brw_aubfile *aubfile,
- struct pipe_surface *surface,
- unsigned gtt_offset );
-
-
-enum data_write_type {
- DW_NOTYPE,
- DW_BATCH_BUFFER,
- DW_BIN_BUFFER,
- DW_BIN_POINTER_LIST,
- DW_SLOW_STATE_BUFFER,
- DW_VERTEX_BUFFER,
- DW_2D_MAP,
- DW_CUBE_MAP,
- DW_INDIRECT_STATE_BUFFER,
- DW_VOLUME_MAP,
- DW_1D_MAP,
- DW_CONSTANT_BUFFER,
- DW_CONSTANT_URB_ENTRY,
- DW_INDEX_BUFFER,
- DW_GENERAL_STATE,
- DW_SURFACE_STATE,
- DW_MEDIA_OBJECT_INDIRECT_DATA,
- DW_MAX_TYPE
-};
-
-enum data_write_general_state_type {
- DWGS_NOTYPE,
- DWGS_VERTEX_SHADER_STATE,
- DWGS_GEOMETRY_SHADER_STATE ,
- DWGS_CLIPPER_STATE,
- DWGS_STRIPS_FANS_STATE,
- DWGS_WINDOWER_IZ_STATE,
- DWGS_COLOR_CALC_STATE,
- DWGS_CLIPPER_VIEWPORT_STATE, /* was 0x7 */
- DWGS_STRIPS_FANS_VIEWPORT_STATE,
- DWGS_COLOR_CALC_VIEWPORT_STATE, /* was 0x9 */
- DWGS_SAMPLER_STATE,
- DWGS_KERNEL_INSTRUCTIONS,
- DWGS_SCRATCH_SPACE,
- DWGS_SAMPLER_DEFAULT_COLOR,
- DWGS_INTERFACE_DESCRIPTOR,
- DWGS_VLD_STATE,
- DWGS_VFE_STATE,
- DWGS_MAX_TYPE
-};
-
-enum data_write_surface_state_type {
- DWSS_NOTYPE,
- DWSS_BINDING_TABLE_STATE,
- DWSS_SURFACE_STATE,
- DWSS_MAX_TYPE
-};
-
-
-#endif
diff --git a/src/mesa/pipe/xlib/fakeglx.c b/src/mesa/pipe/xlib/fakeglx.c
deleted file mode 100644
index 902a755075..0000000000
--- a/src/mesa/pipe/xlib/fakeglx.c
+++ /dev/null
@@ -1,3188 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 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.
- */
-
-
-/*
- * This is an emulation of the GLX API which allows Mesa/GLX-based programs
- * to run on X servers which do not have the real GLX extension.
- *
- * Thanks to the contributors:
- *
- * Initial version: Philip Brown (phil@bolthole.com)
- * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
- * Further visual-handling refinements: Wolfram Gloger
- * (wmglo@Dent.MED.Uni-Muenchen.DE).
- *
- * Notes:
- * Don't be fooled, stereo isn't supported yet.
- */
-
-
-
-#include "glxheader.h"
-#include "glxapi.h"
-#include "GL/xmesa.h"
-#include "context.h"
-#include "config.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "version.h"
-#include "xfonts.h"
-#include "xmesaP.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-
-#ifdef __VMS
-#define _mesa_sprintf sprintf
-#endif
-
-/* This indicates the client-side GLX API and GLX encoder version. */
-#define CLIENT_MAJOR_VERSION 1
-#define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
-
-/* This indicates the server-side GLX decoder version.
- * GLX 1.4 indicates OpenGL 1.3 support
- */
-#define SERVER_MAJOR_VERSION 1
-#define SERVER_MINOR_VERSION 4
-
-/* This is appended onto the glXGetClient/ServerString version strings. */
-#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
-
-/* Who implemented this GLX? */
-#define VENDOR "Brian Paul"
-
-#define EXTENSIONS \
- "GLX_MESA_set_3dfx_mode " \
- "GLX_MESA_copy_sub_buffer " \
- "GLX_MESA_pixmap_colormap " \
- "GLX_MESA_release_buffers " \
- "GLX_ARB_get_proc_address " \
- "GLX_EXT_texture_from_pixmap " \
- "GLX_EXT_visual_info " \
- "GLX_EXT_visual_rating " \
- /*"GLX_SGI_video_sync "*/ \
- "GLX_SGIX_fbconfig " \
- "GLX_SGIX_pbuffer "
-
-/*
- * Our fake GLX context will contain a "real" GLX context and an XMesa context.
- *
- * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
- * and vice versa.
- *
- * We really just need this structure in order to make the libGL functions
- * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
- * work correctly.
- */
-struct fake_glx_context {
- __GLXcontext glxContext; /* this MUST be first! */
- XMesaContext xmesaContext;
-};
-
-
-
-/**********************************************************************/
-/*** GLX Visual Code ***/
-/**********************************************************************/
-
-#define DONT_CARE -1
-
-
-static XMesaVisual *VisualTable = NULL;
-static int NumVisuals = 0;
-
-
-/*
- * This struct and some code fragments borrowed
- * from Mark Kilgard's GLUT library.
- */
-typedef struct _OverlayInfo {
- /* Avoid 64-bit portability problems by being careful to use
- longs due to the way XGetWindowProperty is specified. Note
- that these parameters are passed as CARD32s over X
- protocol. */
- unsigned long overlay_visual;
- long transparent_type;
- long value;
- long layer;
-} OverlayInfo;
-
-
-
-/* Macro to handle c_class vs class field name in XVisualInfo struct */
-#if defined(__cplusplus) || defined(c_plusplus)
-#define CLASS c_class
-#else
-#define CLASS class
-#endif
-
-
-
-/*
- * Test if the given XVisualInfo is usable for Mesa rendering.
- */
-static GLboolean
-is_usable_visual( XVisualInfo *vinfo )
-{
- switch (vinfo->CLASS) {
- case StaticGray:
- case GrayScale:
- /* Any StaticGray/GrayScale visual works in RGB or CI mode */
- return GL_TRUE;
- case StaticColor:
- case PseudoColor:
- /* Any StaticColor/PseudoColor visual of at least 4 bits */
- if (vinfo->depth>=4) {
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
- case TrueColor:
- case DirectColor:
- /* Any depth of TrueColor or DirectColor works in RGB mode */
- return GL_TRUE;
- default:
- /* This should never happen */
- return GL_FALSE;
- }
-}
-
-
-
-/**
- * Get an array OverlayInfo records for specified screen.
- * \param dpy the display
- * \param screen screen number
- * \param numOverlays returns numver of OverlayInfo records
- * \return pointer to OverlayInfo array, free with XFree()
- */
-static OverlayInfo *
-GetOverlayInfo(Display *dpy, int screen, int *numOverlays)
-{
- Atom overlayVisualsAtom;
- Atom actualType;
- Status status;
- unsigned char *ovInfo;
- unsigned long sizeData, bytesLeft;
- int actualFormat;
-
- /*
- * The SERVER_OVERLAY_VISUALS property on the root window contains
- * a list of overlay visuals. Get that list now.
- */
- overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
- if (overlayVisualsAtom == None) {
- return 0;
- }
-
- status = XGetWindowProperty(dpy, RootWindow(dpy, screen),
- overlayVisualsAtom, 0L, (long) 10000, False,
- overlayVisualsAtom, &actualType, &actualFormat,
- &sizeData, &bytesLeft,
- &ovInfo);
-
- if (status != Success || actualType != overlayVisualsAtom ||
- actualFormat != 32 || sizeData < 4) {
- /* something went wrong */
- XFree((void *) ovInfo);
- *numOverlays = 0;
- return NULL;
- }
-
- *numOverlays = sizeData / 4;
- return (OverlayInfo *) ovInfo;
-}
-
-
-
-/**
- * Return the level (overlay, normal, underlay) of a given XVisualInfo.
- * Input: dpy - the X display
- * vinfo - the XVisualInfo to test
- * Return: level of the visual:
- * 0 = normal planes
- * >0 = overlay planes
- * <0 = underlay planes
- */
-static int
-level_of_visual( Display *dpy, XVisualInfo *vinfo )
-{
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen, i;
-
- overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
- if (!overlay_info) {
- return 0;
- }
-
- /* search the overlay visual list for the visual ID of interest */
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- if (ov->overlay_visual == vinfo->visualid) {
- /* found the visual */
- if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
- int level = ov->layer;
- XFree((void *) overlay_info);
- return level;
- }
- else {
- XFree((void *) overlay_info);
- return 0;
- }
- }
- }
-
- /* The visual ID was not found in the overlay list. */
- XFree((void *) overlay_info);
- return 0;
-}
-
-
-
-
-/*
- * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
- * configuration in our list of GLX visuals.
- */
-static XMesaVisual
-save_glx_visual( Display *dpy, XVisualInfo *vinfo,
- GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
- GLboolean stereoFlag,
- GLint depth_size, GLint stencil_size,
- GLint accumRedSize, GLint accumGreenSize,
- GLint accumBlueSize, GLint accumAlphaSize,
- GLint level, GLint numAuxBuffers )
-{
- GLboolean ximageFlag = GL_TRUE;
- XMesaVisual xmvis;
- GLint i;
- GLboolean comparePointers;
-
- if (dbFlag) {
- /* Check if the MESA_BACK_BUFFER env var is set */
- char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
- if (backbuffer) {
- if (backbuffer[0]=='p' || backbuffer[0]=='P') {
- ximageFlag = GL_FALSE;
- }
- else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
- ximageFlag = GL_TRUE;
- }
- else {
- _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
- }
- }
- }
-
- if (stereoFlag) {
- /* stereo not supported */
- return NULL;
- }
-
- /* Comparing IDs uses less memory but sometimes fails. */
- /* XXX revisit this after 3.0 is finished. */
- if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
- comparePointers = GL_TRUE;
- else
- comparePointers = GL_FALSE;
-
- /* Force the visual to have an alpha channel */
- if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
- alphaFlag = GL_TRUE;
-
- /* First check if a matching visual is already in the list */
- for (i=0; i<NumVisuals; i++) {
- XMesaVisual v = VisualTable[i];
- if (v->display == dpy
- && v->mesa_visual.level == level
- && v->mesa_visual.numAuxBuffers == numAuxBuffers
- && v->ximage_flag == ximageFlag
- && v->mesa_visual.rgbMode == rgbFlag
- && v->mesa_visual.doubleBufferMode == dbFlag
- && v->mesa_visual.stereoMode == stereoFlag
- && (v->mesa_visual.alphaBits > 0) == alphaFlag
- && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
- && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
- && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
- && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
- && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
- && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
- /* now either compare XVisualInfo pointers or visual IDs */
- if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
- || (comparePointers && v->vishandle == vinfo)) {
- return v;
- }
- }
- }
-
- /* Create a new visual and add it to the list. */
-
- xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
- stereoFlag, ximageFlag,
- depth_size, stencil_size,
- accumRedSize, accumBlueSize,
- accumBlueSize, accumAlphaSize, 0, level,
- GLX_NONE_EXT );
- if (xmvis) {
- /* Save a copy of the pointer now so we can find this visual again
- * if we need to search for it in find_glx_visual().
- */
- xmvis->vishandle = vinfo;
- /* Allocate more space for additional visual */
- VisualTable = (XMesaVisual *) _mesa_realloc( VisualTable,
- sizeof(XMesaVisual) * NumVisuals,
- sizeof(XMesaVisual) * (NumVisuals + 1));
- /* add xmvis to the list */
- VisualTable[NumVisuals] = xmvis;
- NumVisuals++;
- /* XXX minor hack, because XMesaCreateVisual doesn't support an
- * aux buffers parameter.
- */
- xmvis->mesa_visual.numAuxBuffers = numAuxBuffers;
- }
- return xmvis;
-}
-
-
-/**
- * Return the default number of bits for the Z buffer.
- * If defined, use the MESA_GLX_DEPTH_BITS env var value.
- * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
- * XXX probably do the same thing for stencil, accum, etc.
- */
-static GLint
-default_depth_bits(void)
-{
- int zBits;
- const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS");
- if (zEnv)
- zBits = _mesa_atoi(zEnv);
- else
- zBits = DEFAULT_SOFTWARE_DEPTH_BITS;
- return zBits;
-}
-
-static GLint
-default_alpha_bits(void)
-{
- int aBits;
- const char *aEnv = _mesa_getenv("MESA_GLX_ALPHA_BITS");
- if (aEnv)
- aBits = _mesa_atoi(aEnv);
- else
- aBits = 0;
- return aBits;
-}
-
-static GLint
-default_accum_bits(void)
-{
- return 16;
-}
-
-
-
-/*
- * Create a GLX visual from a regular XVisualInfo.
- * This is called when Fake GLX is given an XVisualInfo which wasn't
- * returned by glXChooseVisual. Since this is the first time we're
- * considering this visual we'll take a guess at reasonable values
- * for depth buffer size, stencil size, accum size, etc.
- * This is the best we can do with a client-side emulation of GLX.
- */
-static XMesaVisual
-create_glx_visual( Display *dpy, XVisualInfo *visinfo )
-{
- int vislevel;
- GLint zBits = 24; /*default_depth_bits();*/
- GLint accBits = default_accum_bits();
- GLboolean alphaFlag = default_alpha_bits() > 0;
-
- vislevel = level_of_visual( dpy, visinfo );
- if (vislevel) {
- /* Configure this visual as a CI, single-buffered overlay */
- return save_glx_visual( dpy, visinfo,
- GL_FALSE, /* rgb */
- GL_FALSE, /* alpha */
- GL_FALSE, /* double */
- GL_FALSE, /* stereo */
- 0, /* depth bits */
- 0, /* stencil bits */
- 0,0,0,0, /* accum bits */
- vislevel, /* level */
- 0 /* numAux */
- );
- }
- else if (is_usable_visual( visinfo )) {
- if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
- /* Configure this visual as a COLOR INDEX visual. */
- return save_glx_visual( dpy, visinfo,
- GL_FALSE, /* rgb */
- GL_FALSE, /* alpha */
- GL_TRUE, /* double */
- GL_FALSE, /* stereo */
- zBits,
- STENCIL_BITS,
- 0, 0, 0, 0, /* accum bits */
- 0, /* level */
- 0 /* numAux */
- );
- }
- else {
- /* Configure this visual as RGB, double-buffered, depth-buffered. */
- /* This is surely wrong for some people's needs but what else */
- /* can be done? They should use glXChooseVisual(). */
- return save_glx_visual( dpy, visinfo,
- GL_TRUE, /* rgb */
- alphaFlag, /* alpha */
- GL_TRUE, /* double */
- GL_FALSE, /* stereo */
- zBits,
- STENCIL_BITS,
- accBits, /* r */
- accBits, /* g */
- accBits, /* b */
- accBits, /* a */
- 0, /* level */
- 0 /* numAux */
- );
- }
- }
- else {
- _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
- return NULL;
- }
-}
-
-
-
-/*
- * Find the GLX visual associated with an XVisualInfo.
- */
-static XMesaVisual
-find_glx_visual( Display *dpy, XVisualInfo *vinfo )
-{
- int i;
-
- /* try to match visual id */
- for (i=0;i<NumVisuals;i++) {
- if (VisualTable[i]->display==dpy
- && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
- return VisualTable[i];
- }
- }
-
- /* if that fails, try to match pointers */
- for (i=0;i<NumVisuals;i++) {
- if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
- return VisualTable[i];
- }
- }
-
- return NULL;
-}
-
-
-
-/**
- * Return the transparent pixel value for a GLX visual.
- * Input: glxvis - the glx_visual
- * Return: a pixel value or -1 if no transparent pixel
- */
-static int
-transparent_pixel( XMesaVisual glxvis )
-{
- Display *dpy = glxvis->display;
- XVisualInfo *vinfo = glxvis->visinfo;
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen, i;
-
- overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
- if (!overlay_info) {
- return -1;
- }
-
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- if (ov->overlay_visual == vinfo->visualid) {
- /* found it! */
- if (ov->transparent_type == 0) {
- /* type 0 indicates no transparency */
- XFree((void *) overlay_info);
- return -1;
- }
- else {
- /* ov->value is the transparent pixel */
- XFree((void *) overlay_info);
- return ov->value;
- }
- }
- }
-
- /* The visual ID was not found in the overlay list. */
- XFree((void *) overlay_info);
- return -1;
-}
-
-
-
-/**
- * Try to get an X visual which matches the given arguments.
- */
-static XVisualInfo *
-get_visual( Display *dpy, int scr, unsigned int depth, int xclass )
-{
- XVisualInfo temp, *vis;
- long mask;
- int n;
- unsigned int default_depth;
- int default_class;
-
- mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
- temp.screen = scr;
- temp.depth = depth;
- temp.CLASS = xclass;
-
- default_depth = DefaultDepth(dpy,scr);
- default_class = DefaultVisual(dpy,scr)->CLASS;
-
- if (depth==default_depth && xclass==default_class) {
- /* try to get root window's visual */
- temp.visualid = DefaultVisual(dpy,scr)->visualid;
- mask |= VisualIDMask;
- }
-
- vis = XGetVisualInfo( dpy, mask, &temp, &n );
-
- /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
- * An SGI Infinite Reality system, for example, can have 30bpp pixels:
- * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
- */
- if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
- if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 &&
- _mesa_bitcount((GLuint) vis->green_mask) <= 8 &&
- _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) {
- return vis;
- }
- else {
- XFree((void *) vis);
- return NULL;
- }
- }
-
- return vis;
-}
-
-
-
-/*
- * Retrieve the value of the given environment variable and find
- * the X visual which matches it.
- * Input: dpy - the display
- * screen - the screen number
- * varname - the name of the environment variable
- * Return: an XVisualInfo pointer to NULL if error.
- */
-static XVisualInfo *
-get_env_visual(Display *dpy, int scr, const char *varname)
-{
- char value[100], type[100];
- int depth, xclass = -1;
- XVisualInfo *vis;
-
- if (!_mesa_getenv( varname )) {
- return NULL;
- }
-
- _mesa_strncpy( value, _mesa_getenv(varname), 100 );
- value[99] = 0;
-
- sscanf( value, "%s %d", type, &depth );
-
- if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor;
- else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor;
- else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor;
- else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor;
- else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale;
- else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray;
-
- if (xclass>-1 && depth>0) {
- vis = get_visual( dpy, scr, depth, xclass );
- if (vis) {
- return vis;
- }
- }
-
- _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.",
- type, depth);
-
- return NULL;
-}
-
-
-
-/*
- * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
- * Input: dpy, screen - X display and screen number
- * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
- * min_depth - minimum visual depth
- * preferred_class - preferred GLX visual class or DONT_CARE
- * Return: pointer to an XVisualInfo or NULL.
- */
-static XVisualInfo *
-choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
- int preferred_class )
-{
- XVisualInfo *vis;
- int xclass, visclass = 0;
- int depth;
-
- if (rgba) {
- Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
- /* First see if the MESA_RGB_VISUAL env var is defined */
- vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
- if (vis) {
- return vis;
- }
- /* Otherwise, search for a suitable visual */
- if (preferred_class==DONT_CARE) {
- for (xclass=0;xclass<6;xclass++) {
- switch (xclass) {
- case 0: visclass = TrueColor; break;
- case 1: visclass = DirectColor; break;
- case 2: visclass = PseudoColor; break;
- case 3: visclass = StaticColor; break;
- case 4: visclass = GrayScale; break;
- case 5: visclass = StaticGray; break;
- }
- if (min_depth==0) {
- /* start with shallowest */
- for (depth=0;depth<=32;depth++) {
- if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
- /* Special case: try to get 8-bit PseudoColor before */
- /* 8-bit TrueColor */
- vis = get_visual( dpy, screen, 8, PseudoColor );
- if (vis) {
- return vis;
- }
- }
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- else {
- /* start with deepest */
- for (depth=32;depth>=min_depth;depth--) {
- if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
- /* Special case: try to get 8-bit PseudoColor before */
- /* 8-bit TrueColor */
- vis = get_visual( dpy, screen, 8, PseudoColor );
- if (vis) {
- return vis;
- }
- }
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- }
- }
- else {
- /* search for a specific visual class */
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
- default: return NULL;
- }
- if (min_depth==0) {
- /* start with shallowest */
- for (depth=0;depth<=32;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- else {
- /* start with deepest */
- for (depth=32;depth>=min_depth;depth--) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- }
- }
- else {
- /* First see if the MESA_CI_VISUAL env var is defined */
- vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
- if (vis) {
- return vis;
- }
- /* Otherwise, search for a suitable visual, starting with shallowest */
- if (preferred_class==DONT_CARE) {
- for (xclass=0;xclass<4;xclass++) {
- switch (xclass) {
- case 0: visclass = PseudoColor; break;
- case 1: visclass = StaticColor; break;
- case 2: visclass = GrayScale; break;
- case 3: visclass = StaticGray; break;
- }
- /* try 8-bit up through 16-bit */
- for (depth=8;depth<=16;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- /* try min_depth up to 8-bit */
- for (depth=min_depth;depth<8;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- }
- else {
- /* search for a specific visual class */
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
- default: return NULL;
- }
- /* try 8-bit up through 16-bit */
- for (depth=8;depth<=16;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- /* try min_depth up to 8-bit */
- for (depth=min_depth;depth<8;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- }
-
- /* didn't find a visual */
- return NULL;
-}
-
-
-
-/*
- * Find the deepest X over/underlay visual of at least min_depth.
- * Input: dpy, screen - X display and screen number
- * level - the over/underlay level
- * trans_type - transparent pixel type: GLX_NONE_EXT,
- * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
- * or DONT_CARE
- * trans_value - transparent pixel value or DONT_CARE
- * min_depth - minimum visual depth
- * preferred_class - preferred GLX visual class or DONT_CARE
- * Return: pointer to an XVisualInfo or NULL.
- */
-static XVisualInfo *
-choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag,
- int level, int trans_type, int trans_value,
- int min_depth, int preferred_class )
-{
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen;
- int i;
- XVisualInfo *deepvis;
- int deepest;
-
- /*DEBUG int tt, tv; */
-
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break;
- default: preferred_class = DONT_CARE;
- }
-
- overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen);
- if (!overlay_info) {
- return NULL;
- }
-
- /* Search for the deepest overlay which satisifies all criteria. */
- deepest = min_depth;
- deepvis = NULL;
-
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- XVisualInfo *vislist, vistemplate;
- int count;
-
- if (ov->layer!=level) {
- /* failed overlay level criteria */
- continue;
- }
- if (!(trans_type==DONT_CARE
- || (trans_type==GLX_TRANSPARENT_INDEX_EXT
- && ov->transparent_type>0)
- || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
- /* failed transparent pixel type criteria */
- continue;
- }
- if (trans_value!=DONT_CARE && trans_value!=ov->value) {
- /* failed transparent pixel value criteria */
- continue;
- }
-
- /* get XVisualInfo and check the depth */
- vistemplate.visualid = ov->overlay_visual;
- vistemplate.screen = scr;
- vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
- &vistemplate, &count );
-
- if (count!=1) {
- /* something went wrong */
- continue;
- }
- if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
- /* wrong visual class */
- continue;
- }
-
- /* if RGB was requested, make sure we have True/DirectColor */
- if (rgbFlag && vislist->CLASS != TrueColor
- && vislist->CLASS != DirectColor)
- continue;
-
- /* if CI was requested, make sure we have a color indexed visual */
- if (!rgbFlag
- && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
- continue;
-
- if (deepvis==NULL || vislist->depth > deepest) {
- /* YES! found a satisfactory visual */
- if (deepvis) {
- XFree( deepvis );
- }
- deepest = vislist->depth;
- deepvis = vislist;
- /* DEBUG tt = ov->transparent_type;*/
- /* DEBUG tv = ov->value; */
- }
- }
-
-/*DEBUG
- if (deepvis) {
- printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
- deepvis->visualid, level, deepvis->depth, tt, tv );
- }
-*/
- return deepvis;
-}
-
-
-/**********************************************************************/
-/*** Display-related functions ***/
-/**********************************************************************/
-
-
-/**
- * Free all XMesaVisuals which are associated with the given display.
- */
-static void
-destroy_visuals_on_display(Display *dpy)
-{
- int i;
- for (i = 0; i < NumVisuals; i++) {
- if (VisualTable[i]->display == dpy) {
- /* remove this visual */
- int j;
- free(VisualTable[i]);
- for (j = i; j < NumVisuals - 1; j++)
- VisualTable[j] = VisualTable[j + 1];
- NumVisuals--;
- }
- }
-}
-
-
-/**
- * Called from XCloseDisplay() to let us free our display-related data.
- */
-static int
-close_display_callback(Display *dpy, XExtCodes *codes)
-{
- destroy_visuals_on_display(dpy);
- xmesa_destroy_buffers_on_display(dpy);
- return 0;
-}
-
-
-/**
- * Look for the named extension on given display and return a pointer
- * to the _XExtension data, or NULL if extension not found.
- */
-static _XExtension *
-lookup_extension(Display *dpy, const char *extName)
-{
- _XExtension *ext;
- for (ext = dpy->ext_procs; ext; ext = ext->next) {
- if (ext->name && strcmp(ext->name, extName) == 0) {
- return ext;
- }
- }
- return NULL;
-}
-
-
-/**
- * Whenever we're given a new Display pointer, call this function to
- * register our close_display_callback function.
- */
-static void
-register_with_display(Display *dpy)
-{
- const char *extName = "MesaGLX";
- _XExtension *ext;
-
- ext = lookup_extension(dpy, extName);
- if (!ext) {
- XExtCodes *c = XAddExtension(dpy);
- ext = dpy->ext_procs; /* new extension is at head of list */
- assert(c->extension == ext->codes.extension);
- ext->name = _mesa_strdup(extName);
- ext->close_display = close_display_callback;
- }
-}
-
-
-/**********************************************************************/
-/*** Begin Fake GLX API Functions ***/
-/**********************************************************************/
-
-
-/**
- * Helper used by glXChooseVisual and glXChooseFBConfig.
- * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
- * the later.
- * In either case, the attribute list is terminated with the value 'None'.
- */
-static XMesaVisual
-choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
-{
- const GLboolean rgbModeDefault = fbConfig;
- const int *parselist;
- XVisualInfo *vis;
- int min_ci = 0;
- int min_red=0, min_green=0, min_blue=0;
- GLboolean rgb_flag = rgbModeDefault;
- GLboolean alpha_flag = GL_FALSE;
- GLboolean double_flag = GL_FALSE;
- GLboolean stereo_flag = GL_FALSE;
- GLint depth_size = 0;
- GLint stencil_size = 0;
- GLint accumRedSize = 0;
- GLint accumGreenSize = 0;
- GLint accumBlueSize = 0;
- GLint accumAlphaSize = 0;
- int level = 0;
- int visual_type = DONT_CARE;
- int trans_type = DONT_CARE;
- int trans_value = DONT_CARE;
- GLint caveat = DONT_CARE;
- XMesaVisual xmvis = NULL;
- int desiredVisualID = -1;
- int numAux = 0;
-
- parselist = list;
-
- while (*parselist) {
-
- switch (*parselist) {
- case GLX_USE_GL:
- if (fbConfig) {
- /* invalid token */
- return NULL;
- }
- else {
- /* skip */
- parselist++;
- }
- break;
- case GLX_BUFFER_SIZE:
- parselist++;
- min_ci = *parselist++;
- break;
- case GLX_LEVEL:
- parselist++;
- level = *parselist++;
- break;
- case GLX_RGBA:
- if (fbConfig) {
- /* invalid token */
- return NULL;
- }
- else {
- rgb_flag = GL_TRUE;
- parselist++;
- }
- break;
- case GLX_DOUBLEBUFFER:
- parselist++;
- if (fbConfig) {
- double_flag = *parselist++;
- }
- else {
- double_flag = GL_TRUE;
- }
- break;
- case GLX_STEREO:
- parselist++;
- if (fbConfig) {
- stereo_flag = *parselist++;
- }
- else {
- stereo_flag = GL_TRUE;
- }
- break;
- case GLX_AUX_BUFFERS:
- parselist++;
- numAux = *parselist++;
- if (numAux > MAX_AUX_BUFFERS)
- return NULL;
- break;
- case GLX_RED_SIZE:
- parselist++;
- min_red = *parselist++;
- break;
- case GLX_GREEN_SIZE:
- parselist++;
- min_green = *parselist++;
- break;
- case GLX_BLUE_SIZE:
- parselist++;
- min_blue = *parselist++;
- break;
- case GLX_ALPHA_SIZE:
- parselist++;
- {
- GLint size = *parselist++;
- alpha_flag = size ? GL_TRUE : GL_FALSE;
- }
- break;
- case GLX_DEPTH_SIZE:
- parselist++;
- depth_size = *parselist++;
- break;
- case GLX_STENCIL_SIZE:
- parselist++;
- stencil_size = *parselist++;
- break;
- case GLX_ACCUM_RED_SIZE:
- parselist++;
- {
- GLint size = *parselist++;
- accumRedSize = MAX2( accumRedSize, size );
- }
- break;
- case GLX_ACCUM_GREEN_SIZE:
- parselist++;
- {
- GLint size = *parselist++;
- accumGreenSize = MAX2( accumGreenSize, size );
- }
- break;
- case GLX_ACCUM_BLUE_SIZE:
- parselist++;
- {
- GLint size = *parselist++;
- accumBlueSize = MAX2( accumBlueSize, size );
- }
- break;
- case GLX_ACCUM_ALPHA_SIZE:
- parselist++;
- {
- GLint size = *parselist++;
- accumAlphaSize = MAX2( accumAlphaSize, size );
- }
- break;
-
- /*
- * GLX_EXT_visual_info extension
- */
- case GLX_X_VISUAL_TYPE_EXT:
- parselist++;
- visual_type = *parselist++;
- break;
- case GLX_TRANSPARENT_TYPE_EXT:
- parselist++;
- trans_type = *parselist++;
- break;
- case GLX_TRANSPARENT_INDEX_VALUE_EXT:
- parselist++;
- trans_value = *parselist++;
- break;
- case GLX_TRANSPARENT_RED_VALUE_EXT:
- case GLX_TRANSPARENT_GREEN_VALUE_EXT:
- case GLX_TRANSPARENT_BLUE_VALUE_EXT:
- case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
- /* ignore */
- parselist++;
- parselist++;
- break;
-
- /*
- * GLX_EXT_visual_info extension
- */
- case GLX_VISUAL_CAVEAT_EXT:
- parselist++;
- caveat = *parselist++; /* ignored for now */
- break;
-
- /*
- * GLX_ARB_multisample
- */
- case GLX_SAMPLE_BUFFERS_ARB:
- /* ms not supported */
- return NULL;
- case GLX_SAMPLES_ARB:
- /* ms not supported */
- return NULL;
-
- /*
- * FBConfig attribs.
- */
- case GLX_RENDER_TYPE:
- if (!fbConfig)
- return NULL;
- parselist++;
- if (*parselist == GLX_RGBA_BIT) {
- rgb_flag = GL_TRUE;
- }
- else if (*parselist == GLX_COLOR_INDEX_BIT) {
- rgb_flag = GL_FALSE;
- }
- else if (*parselist == 0) {
- rgb_flag = GL_TRUE;
- }
- parselist++;
- break;
- case GLX_DRAWABLE_TYPE:
- if (!fbConfig)
- return NULL;
- parselist++;
- if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
- return NULL; /* bad bit */
- }
- parselist++;
- break;
- case GLX_FBCONFIG_ID:
- if (!fbConfig)
- return NULL;
- parselist++;
- desiredVisualID = *parselist++;
- break;
- case GLX_X_RENDERABLE:
- if (!fbConfig)
- return NULL;
- parselist += 2;
- /* ignore */
- break;
-
-#ifdef GLX_EXT_texture_from_pixmap
- case GLX_BIND_TO_TEXTURE_RGB_EXT:
- parselist++; /*skip*/
- break;
- case GLX_BIND_TO_TEXTURE_RGBA_EXT:
- parselist++; /*skip*/
- break;
- case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
- parselist++; /*skip*/
- break;
- case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
- parselist++;
- if (*parselist & ~(GLX_TEXTURE_1D_BIT_EXT |
- GLX_TEXTURE_2D_BIT_EXT |
- GLX_TEXTURE_RECTANGLE_BIT_EXT)) {
- /* invalid bit */
- return NULL;
- }
- break;
- case GLX_Y_INVERTED_EXT:
- parselist++; /*skip*/
- break;
-#endif
-
- case None:
- /* end of list */
- break;
-
- default:
- /* undefined attribute */
- _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()",
- *parselist);
- return NULL;
- }
- }
-
- (void) caveat;
-
- /*
- * Since we're only simulating the GLX extension this function will never
- * find any real GL visuals. Instead, all we can do is try to find an RGB
- * or CI visual of appropriate depth. Other requested attributes such as
- * double buffering, depth buffer, etc. will be associated with the X
- * visual and stored in the VisualTable[].
- */
- if (desiredVisualID != -1) {
- /* try to get a specific visual, by visualID */
- XVisualInfo temp;
- int n;
- temp.visualid = desiredVisualID;
- temp.screen = screen;
- vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n);
- if (vis) {
- /* give the visual some useful GLX attributes */
- double_flag = GL_TRUE;
- if (vis->depth > 8)
- rgb_flag = GL_TRUE;
- depth_size = 24; /*default_depth_bits();*/
- stencil_size = STENCIL_BITS;
- /* XXX accum??? */
- }
- }
- else if (level==0) {
- /* normal color planes */
- if (rgb_flag) {
- /* Get an RGB visual */
- int min_rgb = min_red + min_green + min_blue;
- if (min_rgb>1 && min_rgb<8) {
- /* a special case to be sure we can get a monochrome visual */
- min_rgb = 1;
- }
- vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
- }
- else {
- /* Get a color index visual */
- vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
- accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
- }
- }
- else {
- /* over/underlay planes */
- if (rgb_flag) {
- /* rgba overlay */
- int min_rgb = min_red + min_green + min_blue;
- if (min_rgb>1 && min_rgb<8) {
- /* a special case to be sure we can get a monochrome visual */
- min_rgb = 1;
- }
- vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
- trans_type, trans_value, min_rgb, visual_type );
- }
- else {
- /* color index overlay */
- vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
- trans_type, trans_value, min_ci, visual_type );
- }
- }
-
- if (vis) {
- /* Note: we're not exactly obeying the glXChooseVisual rules here.
- * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the
- * largest depth buffer size, which is 32bits/value. Instead, we
- * return 16 to maintain performance with earlier versions of Mesa.
- */
- if (stencil_size > 0)
- depth_size = 24; /* if Z and stencil, always use 24+8 format */
- else if (depth_size > 24)
- depth_size = 32;
- else if (depth_size > 16)
- depth_size = 24;
- else if (depth_size > 0) {
- depth_size = default_depth_bits();
- }
-
- if (!alpha_flag) {
- alpha_flag = default_alpha_bits() > 0;
- }
-
- /* we only support one size of stencil and accum buffers. */
- if (stencil_size > 0)
- stencil_size = STENCIL_BITS;
- if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
- accumAlphaSize > 0) {
- accumRedSize =
- accumGreenSize =
- accumBlueSize = default_accum_bits();
- accumAlphaSize = alpha_flag ? accumRedSize : 0;
- }
-
- xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
- stereo_flag, depth_size, stencil_size,
- accumRedSize, accumGreenSize,
- accumBlueSize, accumAlphaSize, level, numAux );
- }
-
- return xmvis;
-}
-
-
-static XVisualInfo *
-Fake_glXChooseVisual( Display *dpy, int screen, int *list )
-{
- XMesaVisual xmvis;
-
- /* register ourselves as an extension on this display */
- register_with_display(dpy);
-
- xmvis = choose_visual(dpy, screen, list, GL_FALSE);
- if (xmvis) {
-#if 0
- return xmvis->vishandle;
-#else
- /* create a new vishandle - the cached one may be stale */
- xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
- if (xmvis->vishandle) {
- _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
- }
- return xmvis->vishandle;
-#endif
- }
- else
- return NULL;
-}
-
-
-static GLXContext
-Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct )
-{
- XMesaVisual xmvis;
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
-
- if (!dpy || !visinfo)
- return 0;
-
- glxCtx = CALLOC_STRUCT(fake_glx_context);
- if (!glxCtx)
- return 0;
-
- /* deallocate unused windows/buffers */
-#if 0
- XMesaGarbageCollect();
-#endif
-
- xmvis = find_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* This visual wasn't found with glXChooseVisual() */
- xmvis = create_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* unusable visual */
- _mesa_free(glxCtx);
- return NULL;
- }
- }
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- _mesa_free(glxCtx);
- return NULL;
- }
-
- glxCtx->glxContext.isDirect = GL_FALSE;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
-
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
-
- return (GLXContext) glxCtx;
-}
-
-
-/* XXX these may have to be removed due to thread-safety issues. */
-static GLXContext MakeCurrent_PrevContext = 0;
-static GLXDrawable MakeCurrent_PrevDrawable = 0;
-static GLXDrawable MakeCurrent_PrevReadable = 0;
-static XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
-static XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
-
-
-/* GLX 1.3 and later */
-static Bool
-Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext ctx )
-{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
-
- if (ctx && draw && read) {
- XMesaBuffer drawBuffer, readBuffer;
- XMesaContext xmctx = glxCtx->xmesaContext;
-
- /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
- if (ctx == MakeCurrent_PrevContext
- && draw == MakeCurrent_PrevDrawable) {
- drawBuffer = MakeCurrent_PrevDrawBuffer;
- }
- else {
- drawBuffer = XMesaFindBuffer( dpy, draw );
- }
- if (!drawBuffer) {
- /* drawable must be a new window! */
- drawBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, draw );
- if (!drawBuffer) {
- /* Out of memory, or context/drawable depth mismatch */
- return False;
- }
-#ifdef FX
- FXcreateContext( xmctx->xm_visual, draw, xmctx, drawBuffer );
-#endif
- }
-
- /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
- if (ctx == MakeCurrent_PrevContext
- && read == MakeCurrent_PrevReadable) {
- readBuffer = MakeCurrent_PrevReadBuffer;
- }
- else {
- readBuffer = XMesaFindBuffer( dpy, read );
- }
- if (!readBuffer) {
- /* drawable must be a new window! */
- readBuffer = XMesaCreateWindowBuffer( xmctx->xm_visual, read );
- if (!readBuffer) {
- /* Out of memory, or context/drawable depth mismatch */
- return False;
- }
-#ifdef FX
- FXcreateContext( xmctx->xm_visual, read, xmctx, readBuffer );
-#endif
- }
-
- MakeCurrent_PrevContext = ctx;
- MakeCurrent_PrevDrawable = draw;
- MakeCurrent_PrevReadable = read;
- MakeCurrent_PrevDrawBuffer = drawBuffer;
- MakeCurrent_PrevReadBuffer = readBuffer;
-
- /* Now make current! */
- if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
- ((__GLXcontext *) ctx)->currentDpy = dpy;
- ((__GLXcontext *) ctx)->currentDrawable = draw;
- ((__GLXcontext *) ctx)->currentReadable = read;
- return True;
- }
- else {
- return False;
- }
- }
- else if (!ctx && !draw && !read) {
- /* release current context w/out assigning new one. */
- XMesaMakeCurrent( NULL, NULL );
- MakeCurrent_PrevContext = 0;
- MakeCurrent_PrevDrawable = 0;
- MakeCurrent_PrevReadable = 0;
- MakeCurrent_PrevDrawBuffer = 0;
- MakeCurrent_PrevReadBuffer = 0;
- return True;
- }
- else {
- /* The args must either all be non-zero or all zero.
- * This is an error.
- */
- return False;
- }
-}
-
-
-static Bool
-Fake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
-{
- return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
-}
-
-
-static GLXPixmap
-Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
-{
- XMesaVisual v;
- XMesaBuffer b;
-
- v = find_glx_visual( dpy, visinfo );
- if (!v) {
- v = create_glx_visual( dpy, visinfo );
- if (!v) {
- /* unusable visual */
- return 0;
- }
- }
-
- b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
- if (!b) {
- return 0;
- }
- return b->drawable;
-}
-
-
-/*** GLX_MESA_pixmap_colormap ***/
-
-static GLXPixmap
-Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
- Pixmap pixmap, Colormap cmap )
-{
- XMesaVisual v;
- XMesaBuffer b;
-
- v = find_glx_visual( dpy, visinfo );
- if (!v) {
- v = create_glx_visual( dpy, visinfo );
- if (!v) {
- /* unusable visual */
- return 0;
- }
- }
-
- b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
- if (!b) {
- return 0;
- }
- return b->drawable;
-}
-
-
-static void
-Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
- if (b) {
- XMesaDestroyBuffer(b);
- }
- else if (_mesa_getenv("MESA_DEBUG")) {
- _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
- }
-}
-
-
-static void
-Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
- unsigned long mask )
-{
- struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
- struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
- XMesaContext xm_src = fakeSrc->xmesaContext;
- XMesaContext xm_dst = fakeDst->xmesaContext;
- (void) dpy;
- if (MakeCurrent_PrevContext == src) {
- _mesa_Flush();
- }
- st_copy_context_state( xm_src->st, xm_dst->st, (GLuint) mask );
-}
-
-
-static Bool
-Fake_glXQueryExtension( Display *dpy, int *errorb, int *event )
-{
- /* Mesa's GLX isn't really an X extension but we try to act like one. */
- (void) dpy;
- (void) errorb;
- (void) event;
- return True;
-}
-
-
-extern void _kw_ungrab_all( Display *dpy );
-void _kw_ungrab_all( Display *dpy )
-{
- XUngrabPointer( dpy, CurrentTime );
- XUngrabKeyboard( dpy, CurrentTime );
-}
-
-
-static void
-Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
-{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
- (void) dpy;
- MakeCurrent_PrevContext = 0;
- MakeCurrent_PrevDrawable = 0;
- MakeCurrent_PrevReadable = 0;
- MakeCurrent_PrevDrawBuffer = 0;
- MakeCurrent_PrevReadBuffer = 0;
- XMesaDestroyContext( glxCtx->xmesaContext );
- XMesaGarbageCollect();
- _mesa_free(glxCtx);
-}
-
-
-static Bool
-Fake_glXIsDirect( Display *dpy, GLXContext ctx )
-{
- (void) dpy;
- (void) ctx;
- return False;
-}
-
-
-
-static void
-Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
-{
- XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
-
- if (buffer) {
- XMesaSwapBuffers(buffer);
- }
- else if (_mesa_getenv("MESA_DEBUG")) {
- _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
- (int) drawable);
- }
-}
-
-
-
-/*** GLX_MESA_copy_sub_buffer ***/
-
-static void
-Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
- int x, int y, int width, int height )
-{
- XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
- if (buffer) {
- XMesaCopySubBuffer(buffer, x, y, width, height);
- }
- else if (_mesa_getenv("MESA_DEBUG")) {
- _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
- }
-}
-
-
-static Bool
-Fake_glXQueryVersion( Display *dpy, int *maj, int *min )
-{
- (void) dpy;
- /* Return GLX version, not Mesa version */
- assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
- *maj = CLIENT_MAJOR_VERSION;
- *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
- return True;
-}
-
-
-/*
- * Query the GLX attributes of the given XVisualInfo.
- */
-static int
-get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
-{
- ASSERT(xmvis);
- switch(attrib) {
- case GLX_USE_GL:
- if (fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = (int) True;
- return 0;
- case GLX_BUFFER_SIZE:
- *value = xmvis->visinfo->depth;
- return 0;
- case GLX_LEVEL:
- *value = xmvis->mesa_visual.level;
- return 0;
- case GLX_RGBA:
- if (fbconfig)
- return GLX_BAD_ATTRIBUTE;
- if (xmvis->mesa_visual.rgbMode) {
- *value = True;
- }
- else {
- *value = False;
- }
- return 0;
- case GLX_DOUBLEBUFFER:
- *value = (int) xmvis->mesa_visual.doubleBufferMode;
- return 0;
- case GLX_STEREO:
- *value = (int) xmvis->mesa_visual.stereoMode;
- return 0;
- case GLX_AUX_BUFFERS:
- *value = xmvis->mesa_visual.numAuxBuffers;
- return 0;
- case GLX_RED_SIZE:
- *value = xmvis->mesa_visual.redBits;
- return 0;
- case GLX_GREEN_SIZE:
- *value = xmvis->mesa_visual.greenBits;
- return 0;
- case GLX_BLUE_SIZE:
- *value = xmvis->mesa_visual.blueBits;
- return 0;
- case GLX_ALPHA_SIZE:
- *value = xmvis->mesa_visual.alphaBits;
- return 0;
- case GLX_DEPTH_SIZE:
- *value = xmvis->mesa_visual.depthBits;
- return 0;
- case GLX_STENCIL_SIZE:
- *value = xmvis->mesa_visual.stencilBits;
- return 0;
- case GLX_ACCUM_RED_SIZE:
- *value = xmvis->mesa_visual.accumRedBits;
- return 0;
- case GLX_ACCUM_GREEN_SIZE:
- *value = xmvis->mesa_visual.accumGreenBits;
- return 0;
- case GLX_ACCUM_BLUE_SIZE:
- *value = xmvis->mesa_visual.accumBlueBits;
- return 0;
- case GLX_ACCUM_ALPHA_SIZE:
- *value = xmvis->mesa_visual.accumAlphaBits;
- return 0;
-
- /*
- * GLX_EXT_visual_info extension
- */
- case GLX_X_VISUAL_TYPE_EXT:
- switch (xmvis->visinfo->CLASS) {
- case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0;
- case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0;
- case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0;
- case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0;
- case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0;
- case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0;
- }
- return 0;
- case GLX_TRANSPARENT_TYPE_EXT:
- if (xmvis->mesa_visual.level==0) {
- /* normal planes */
- *value = GLX_NONE_EXT;
- }
- else if (xmvis->mesa_visual.level>0) {
- /* overlay */
- if (xmvis->mesa_visual.rgbMode) {
- *value = GLX_TRANSPARENT_RGB_EXT;
- }
- else {
- *value = GLX_TRANSPARENT_INDEX_EXT;
- }
- }
- else if (xmvis->mesa_visual.level<0) {
- /* underlay */
- *value = GLX_NONE_EXT;
- }
- return 0;
- case GLX_TRANSPARENT_INDEX_VALUE_EXT:
- {
- int pixel = transparent_pixel( xmvis );
- if (pixel>=0) {
- *value = pixel;
- }
- /* else undefined */
- }
- return 0;
- case GLX_TRANSPARENT_RED_VALUE_EXT:
- /* undefined */
- return 0;
- case GLX_TRANSPARENT_GREEN_VALUE_EXT:
- /* undefined */
- return 0;
- case GLX_TRANSPARENT_BLUE_VALUE_EXT:
- /* undefined */
- return 0;
- case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
- /* undefined */
- return 0;
-
- /*
- * GLX_EXT_visual_info extension
- */
- case GLX_VISUAL_CAVEAT_EXT:
- /* test for zero, just in case */
- if (xmvis->mesa_visual.visualRating > 0)
- *value = xmvis->mesa_visual.visualRating;
- else
- *value = GLX_NONE_EXT;
- return 0;
-
- /*
- * GLX_ARB_multisample
- */
- case GLX_SAMPLE_BUFFERS_ARB:
- *value = 0;
- return 0;
- case GLX_SAMPLES_ARB:
- *value = 0;
- return 0;
-
- /*
- * For FBConfigs:
- */
- case GLX_SCREEN_EXT:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = xmvis->visinfo->screen;
- break;
- case GLX_DRAWABLE_TYPE: /*SGIX too */
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
- break;
- case GLX_RENDER_TYPE_SGIX:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- if (xmvis->mesa_visual.rgbMode)
- *value = GLX_RGBA_BIT;
- else
- *value = GLX_COLOR_INDEX_BIT;
- break;
- case GLX_X_RENDERABLE_SGIX:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = True; /* XXX really? */
- break;
- case GLX_FBCONFIG_ID_SGIX:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = xmvis->visinfo->visualid;
- break;
- case GLX_MAX_PBUFFER_WIDTH:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- /* XXX or MAX_WIDTH? */
- *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen);
- break;
- case GLX_MAX_PBUFFER_HEIGHT:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen);
- break;
- case GLX_MAX_PBUFFER_PIXELS:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) *
- DisplayHeight(xmvis->display, xmvis->visinfo->screen);
- break;
- case GLX_VISUAL_ID:
- if (!fbconfig)
- return GLX_BAD_ATTRIBUTE;
- *value = xmvis->visinfo->visualid;
- break;
-
-#ifdef GLX_EXT_texture_from_pixmap
- case GLX_BIND_TO_TEXTURE_RGB_EXT:
- *value = True; /*XXX*/
- break;
- case GLX_BIND_TO_TEXTURE_RGBA_EXT:
- /* XXX review */
- *value = xmvis->mesa_visual.alphaBits > 0 ? True : False;
- break;
- case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
- *value = True; /*XXX*/
- break;
- case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
- *value = (GLX_TEXTURE_1D_BIT_EXT |
- GLX_TEXTURE_2D_BIT_EXT |
- GLX_TEXTURE_RECTANGLE_BIT_EXT); /*XXX*/
- break;
- case GLX_Y_INVERTED_EXT:
- *value = True; /*XXX*/
- break;
-#endif
-
- default:
- return GLX_BAD_ATTRIBUTE;
- }
- return Success;
-}
-
-
-static int
-Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
- int attrib, int *value )
-{
- XMesaVisual xmvis;
- int k;
- if (!dpy || !visinfo)
- return GLX_BAD_ATTRIBUTE;
-
- xmvis = find_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* this visual wasn't obtained with glXChooseVisual */
- xmvis = create_glx_visual( dpy, visinfo );
- if (!xmvis) {
- /* this visual can't be used for GL rendering */
- if (attrib==GLX_USE_GL) {
- *value = (int) False;
- return 0;
- }
- else {
- return GLX_BAD_VISUAL;
- }
- }
- }
-
- k = get_config(xmvis, attrib, value, GL_FALSE);
- return k;
-}
-
-
-static void
-Fake_glXWaitGL( void )
-{
- XMesaContext xmesa = XMesaGetCurrentContext();
- XMesaFlush( xmesa );
-}
-
-
-
-static void
-Fake_glXWaitX( void )
-{
- XMesaContext xmesa = XMesaGetCurrentContext();
- XMesaFlush( xmesa );
-}
-
-
-static const char *
-get_extensions( void )
-{
-#ifdef FX
- const char *fx = _mesa_getenv("MESA_GLX_FX");
- if (fx && fx[0] != 'd') {
- return EXTENSIONS;
- }
-#endif
- return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
-}
-
-
-
-/* GLX 1.1 and later */
-static const char *
-Fake_glXQueryExtensionsString( Display *dpy, int screen )
-{
- (void) dpy;
- (void) screen;
- return get_extensions();
-}
-
-
-
-/* GLX 1.1 and later */
-static const char *
-Fake_glXQueryServerString( Display *dpy, int screen, int name )
-{
- static char version[1000];
- _mesa_sprintf(version, "%d.%d %s",
- SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION);
-
- (void) dpy;
- (void) screen;
-
- switch (name) {
- case GLX_EXTENSIONS:
- return get_extensions();
- case GLX_VENDOR:
- return VENDOR;
- case GLX_VERSION:
- return version;
- default:
- return NULL;
- }
-}
-
-
-
-/* GLX 1.1 and later */
-static const char *
-Fake_glXGetClientString( Display *dpy, int name )
-{
- static char version[1000];
- _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,
- CLIENT_MINOR_VERSION, MESA_GLX_VERSION);
-
- (void) dpy;
-
- switch (name) {
- case GLX_EXTENSIONS:
- return get_extensions();
- case GLX_VENDOR:
- return VENDOR;
- case GLX_VERSION:
- return version;
- default:
- return NULL;
- }
-}
-
-
-
-/*
- * GLX 1.3 and later
- */
-
-
-static int
-Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
- int attribute, int *value )
-{
- XMesaVisual v = (XMesaVisual) config;
- (void) dpy;
- (void) config;
-
- if (!dpy || !config || !value)
- return -1;
-
- return get_config(v, attribute, value, GL_TRUE);
-}
-
-
-static GLXFBConfig *
-Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
-{
- XVisualInfo *visuals, visTemplate;
- const long visMask = VisualScreenMask;
- int i;
-
- /* Get list of all X visuals */
- visTemplate.screen = screen;
- visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
- if (*nelements > 0) {
- XMesaVisual *results;
- results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));
- if (!results) {
- *nelements = 0;
- return NULL;
- }
- for (i = 0; i < *nelements; i++) {
- results[i] = create_glx_visual(dpy, visuals + i);
- }
- return (GLXFBConfig *) results;
- }
- return NULL;
-}
-
-
-static GLXFBConfig *
-Fake_glXChooseFBConfig( Display *dpy, int screen,
- const int *attribList, int *nitems )
-{
- XMesaVisual xmvis;
-
- if (!attribList || !attribList[0]) {
- /* return list of all configs (per GLX_SGIX_fbconfig spec) */
- return Fake_glXGetFBConfigs(dpy, screen, nitems);
- }
-
- xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);
- if (xmvis) {
- GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));
- if (!config) {
- *nitems = 0;
- return NULL;
- }
- *nitems = 1;
- config[0] = (GLXFBConfig) xmvis;
- return (GLXFBConfig *) config;
- }
- else {
- *nitems = 0;
- return NULL;
- }
-}
-
-
-static XVisualInfo *
-Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
-{
- if (dpy && config) {
- XMesaVisual xmvis = (XMesaVisual) config;
-#if 0
- return xmvis->vishandle;
-#else
- /* create a new vishandle - the cached one may be stale */
- xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
- if (xmvis->vishandle) {
- _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
- }
- return xmvis->vishandle;
-#endif
- }
- else {
- return NULL;
- }
-}
-
-
-static GLXWindow
-Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
- const int *attribList )
-{
- XMesaVisual xmvis = (XMesaVisual) config;
- XMesaBuffer xmbuf;
- if (!xmvis)
- return 0;
-
- xmbuf = XMesaCreateWindowBuffer(xmvis, win);
- if (!xmbuf)
- return 0;
-
-#ifdef FX
- /* XXX this will segfault if actually called */
- FXcreateContext(xmvis, win, NULL, xmbuf);
-#endif
-
- (void) dpy;
- (void) attribList; /* Ignored in GLX 1.3 */
-
- return win; /* A hack for now */
-}
-
-
-static void
-Fake_glXDestroyWindow( Display *dpy, GLXWindow window )
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
- if (b)
- XMesaDestroyBuffer(b);
- /* don't destroy X window */
-}
-
-
-/* XXX untested */
-static GLXPixmap
-Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
- const int *attribList )
-{
- XMesaVisual v = (XMesaVisual) config;
- XMesaBuffer b;
- const int *attr;
- int target = 0, format = 0, mipmap = 0;
- int value;
-
- if (!dpy || !config || !pixmap)
- return 0;
-
- for (attr = attribList; *attr; attr++) {
- switch (*attr) {
- case GLX_TEXTURE_FORMAT_EXT:
- attr++;
- switch (*attr) {
- case GLX_TEXTURE_FORMAT_NONE_EXT:
- case GLX_TEXTURE_FORMAT_RGB_EXT:
- case GLX_TEXTURE_FORMAT_RGBA_EXT:
- format = *attr;
- break;
- default:
- /* error */
- return 0;
- }
- break;
- case GLX_TEXTURE_TARGET_EXT:
- attr++;
- switch (*attr) {
- case GLX_TEXTURE_1D_EXT:
- case GLX_TEXTURE_2D_EXT:
- case GLX_TEXTURE_RECTANGLE_EXT:
- target = *attr;
- break;
- default:
- /* error */
- return 0;
- }
- break;
- case GLX_MIPMAP_TEXTURE_EXT:
- attr++;
- if (*attr)
- mipmap = 1;
- break;
- default:
- /* error */
- return 0;
- }
- }
-
- if (format == GLX_TEXTURE_FORMAT_RGB_EXT) {
- if (get_config(v, GLX_BIND_TO_TEXTURE_RGB_EXT,
- &value, GL_TRUE) != Success
- || !value) {
- return 0; /* error! */
- }
- }
- else if (format == GLX_TEXTURE_FORMAT_RGBA_EXT) {
- if (get_config(v, GLX_BIND_TO_TEXTURE_RGBA_EXT,
- &value, GL_TRUE) != Success
- || !value) {
- return 0; /* error! */
- }
- }
- if (mipmap) {
- if (get_config(v, GLX_BIND_TO_MIPMAP_TEXTURE_EXT,
- &value, GL_TRUE) != Success
- || !value) {
- return 0; /* error! */
- }
- }
- if (target == GLX_TEXTURE_1D_EXT) {
- if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT,
- &value, GL_TRUE) != Success
- || (value & GLX_TEXTURE_1D_BIT_EXT) == 0) {
- return 0; /* error! */
- }
- }
- else if (target == GLX_TEXTURE_2D_EXT) {
- if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT,
- &value, GL_TRUE) != Success
- || (value & GLX_TEXTURE_2D_BIT_EXT) == 0) {
- return 0; /* error! */
- }
- }
- if (target == GLX_TEXTURE_RECTANGLE_EXT) {
- if (get_config(v, GLX_BIND_TO_TEXTURE_TARGETS_EXT,
- &value, GL_TRUE) != Success
- || (value & GLX_TEXTURE_RECTANGLE_BIT_EXT) == 0) {
- return 0; /* error! */
- }
- }
-
- if (format || target || mipmap) {
- /* texture from pixmap */
- b = XMesaCreatePixmapTextureBuffer(v, pixmap, 0, format, target, mipmap);
- }
- else {
- b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
- }
- if (!b) {
- return 0;
- }
-
- return pixmap;
-}
-
-
-static void
-Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
- if (b)
- XMesaDestroyBuffer(b);
- /* don't destroy X pixmap */
-}
-
-
-static GLXPbuffer
-Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
- const int *attribList )
-{
- XMesaVisual xmvis = (XMesaVisual) config;
- XMesaBuffer xmbuf;
- const int *attrib;
- int width = 0, height = 0;
- GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
-
- (void) dpy;
-
- for (attrib = attribList; *attrib; attrib++) {
- switch (*attrib) {
- case GLX_PBUFFER_WIDTH:
- attrib++;
- width = *attrib;
- break;
- case GLX_PBUFFER_HEIGHT:
- attrib++;
- height = *attrib;
- break;
- case GLX_PRESERVED_CONTENTS:
- attrib++;
- preserveContents = *attrib; /* ignored */
- break;
- case GLX_LARGEST_PBUFFER:
- attrib++;
- useLargest = *attrib; /* ignored */
- break;
- default:
- return 0;
- }
- }
-
- /* not used at this time */
- (void) useLargest;
- (void) preserveContents;
-
- if (width == 0 || height == 0)
- return 0;
-
- xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
- /* A GLXPbuffer handle must be an X Drawable because that's what
- * glXMakeCurrent takes.
- */
- if (xmbuf)
- return (GLXPbuffer) xmbuf->drawable;
- else
- return 0;
-}
-
-
-static void
-Fake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);
- if (b) {
- XMesaDestroyBuffer(b);
- }
-}
-
-
-static void
-Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
- unsigned int *value )
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
- if (!xmbuf)
- return;
-
- switch (attribute) {
- case GLX_WIDTH:
- *value = xmesa_buffer_width(xmbuf);
- break;
- case GLX_HEIGHT:
- *value = xmesa_buffer_width(xmbuf);
- break;
- case GLX_PRESERVED_CONTENTS:
- *value = True;
- break;
- case GLX_LARGEST_PBUFFER:
- *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
- break;
- case GLX_FBCONFIG_ID:
- *value = xmbuf->xm_visual->visinfo->visualid;
- return;
-#ifdef GLX_EXT_texture_from_pixmap
- case GLX_TEXTURE_FORMAT_EXT:
- *value = xmbuf->TextureFormat;
- break;
- case GLX_TEXTURE_TARGET_EXT:
- *value = xmbuf->TextureTarget;
- break;
- case GLX_MIPMAP_TEXTURE_EXT:
- *value = xmbuf->TextureMipmap;
- break;
-#endif
-
- default:
- return; /* raise BadValue error */
- }
-}
-
-
-static GLXContext
-Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
- int renderType, GLXContext shareList, Bool direct )
-{
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
- XMesaVisual xmvis = (XMesaVisual) config;
-
- if (!dpy || !config ||
- (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
- return 0;
-
- glxCtx = CALLOC_STRUCT(fake_glx_context);
- if (!glxCtx)
- return 0;
-
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- _mesa_free(glxCtx);
- return NULL;
- }
-
- glxCtx->glxContext.isDirect = GL_FALSE;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
-
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
-
- return (GLXContext) glxCtx;
-}
-
-
-static int
-Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
-{
- struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
- XMesaContext xmctx = glxCtx->xmesaContext;
-
- (void) dpy;
- (void) ctx;
-
- switch (attribute) {
- case GLX_FBCONFIG_ID:
- *value = xmctx->xm_visual->visinfo->visualid;
- break;
- case GLX_RENDER_TYPE:
- if (xmctx->xm_visual->mesa_visual.rgbMode)
- *value = GLX_RGBA_BIT;
- else
- *value = GLX_COLOR_INDEX_BIT;
- break;
- case GLX_SCREEN:
- *value = 0;
- return Success;
- default:
- return GLX_BAD_ATTRIBUTE;
- }
- return 0;
-}
-
-
-static void
-Fake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
- if (xmbuf)
- xmbuf->selectedEvents = mask;
-}
-
-
-static void
-Fake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
- unsigned long *mask )
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
- if (xmbuf)
- *mask = xmbuf->selectedEvents;
- else
- *mask = 0;
-}
-
-
-
-/*** GLX_SGI_swap_control ***/
-
-static int
-Fake_glXSwapIntervalSGI(int interval)
-{
- (void) interval;
- return 0;
-}
-
-
-
-/*** GLX_SGI_video_sync ***/
-
-static unsigned int FrameCounter = 0;
-
-static int
-Fake_glXGetVideoSyncSGI(unsigned int *count)
-{
- /* this is a bogus implementation */
- *count = FrameCounter++;
- return 0;
-}
-
-static int
-Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
-{
- if (divisor <= 0 || remainder < 0)
- return GLX_BAD_VALUE;
- /* this is a bogus implementation */
- FrameCounter++;
- while (FrameCounter % divisor != remainder)
- FrameCounter++;
- *count = FrameCounter;
- return 0;
-}
-
-
-
-/*** GLX_SGI_make_current_read ***/
-
-static Bool
-Fake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
-{
- return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
-}
-
-/* not used
-static GLXDrawable
-Fake_glXGetCurrentReadDrawableSGI(void)
-{
- return 0;
-}
-*/
-
-
-/*** GLX_SGIX_video_source ***/
-#if defined(_VL_H)
-
-static GLXVideoSourceSGIX
-Fake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
-{
- (void) dpy;
- (void) screen;
- (void) server;
- (void) path;
- (void) nodeClass;
- (void) drainNode;
- return 0;
-}
-
-static void
-Fake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
-{
- (void) dpy;
- (void) src;
-}
-
-#endif
-
-
-/*** GLX_EXT_import_context ***/
-
-static void
-Fake_glXFreeContextEXT(Display *dpy, GLXContext context)
-{
- (void) dpy;
- (void) context;
-}
-
-static GLXContextID
-Fake_glXGetContextIDEXT(const GLXContext context)
-{
- (void) context;
- return 0;
-}
-
-static GLXContext
-Fake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
-{
- (void) dpy;
- (void) contextID;
- return 0;
-}
-
-static int
-Fake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
-{
- (void) dpy;
- (void) context;
- (void) attribute;
- (void) value;
- return 0;
-}
-
-
-
-/*** GLX_SGIX_fbconfig ***/
-
-static int
-Fake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
-{
- return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
-}
-
-static GLXFBConfigSGIX *
-Fake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
-{
- return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
-}
-
-
-static GLXPixmap
-Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
-{
- XMesaVisual xmvis = (XMesaVisual) config;
- XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
- return xmbuf->drawable; /* need to return an X ID */
-}
-
-
-static GLXContext
-Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
-{
- XMesaVisual xmvis = (XMesaVisual) config;
- struct fake_glx_context *glxCtx;
- struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
-
- glxCtx = CALLOC_STRUCT(fake_glx_context);
- if (!glxCtx)
- return 0;
-
- /* deallocate unused windows/buffers */
- XMesaGarbageCollect();
-
- glxCtx->xmesaContext = XMesaCreateContext(xmvis,
- shareCtx ? shareCtx->xmesaContext : NULL);
- if (!glxCtx->xmesaContext) {
- _mesa_free(glxCtx);
- return NULL;
- }
-
- glxCtx->glxContext.isDirect = GL_FALSE;
- glxCtx->glxContext.currentDpy = dpy;
- glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
-
- assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
-
- return (GLXContext) glxCtx;
-}
-
-
-static XVisualInfo *
-Fake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
-{
- return Fake_glXGetVisualFromFBConfig(dpy, config);
-}
-
-
-static GLXFBConfigSGIX
-Fake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
-{
- XMesaVisual xmvis = find_glx_visual(dpy, vis);
- if (!xmvis) {
- /* This visual wasn't found with glXChooseVisual() */
- xmvis = create_glx_visual(dpy, vis);
- }
-
- return (GLXFBConfigSGIX) xmvis;
-}
-
-
-
-/*** GLX_SGIX_pbuffer ***/
-
-static GLXPbufferSGIX
-Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
- unsigned int width, unsigned int height,
- int *attribList)
-{
- XMesaVisual xmvis = (XMesaVisual) config;
- XMesaBuffer xmbuf;
- const int *attrib;
- GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
-
- (void) dpy;
-
- for (attrib = attribList; attrib && *attrib; attrib++) {
- switch (*attrib) {
- case GLX_PRESERVED_CONTENTS_SGIX:
- attrib++;
- preserveContents = *attrib; /* ignored */
- break;
- case GLX_LARGEST_PBUFFER_SGIX:
- attrib++;
- useLargest = *attrib; /* ignored */
- break;
- default:
- return 0;
- }
- }
-
- /* not used at this time */
- (void) useLargest;
- (void) preserveContents;
-
- xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
- /* A GLXPbuffer handle must be an X Drawable because that's what
- * glXMakeCurrent takes.
- */
- return (GLXPbuffer) xmbuf->drawable;
-}
-
-
-static void
-Fake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
- if (xmbuf) {
- XMesaDestroyBuffer(xmbuf);
- }
-}
-
-
-static int
-Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
-{
- const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
-
- if (!xmbuf) {
- /* Generate GLXBadPbufferSGIX for bad pbuffer */
- return 0;
- }
-
- switch (attribute) {
- case GLX_PRESERVED_CONTENTS_SGIX:
- *value = True;
- break;
- case GLX_LARGEST_PBUFFER_SGIX:
- *value = xmesa_buffer_width(xmbuf) * xmesa_buffer_height(xmbuf);
- break;
- case GLX_WIDTH_SGIX:
- *value = xmesa_buffer_width(xmbuf);
- break;
- case GLX_HEIGHT_SGIX:
- *value = xmesa_buffer_height(xmbuf);
- break;
- case GLX_EVENT_MASK_SGIX:
- *value = 0; /* XXX might be wrong */
- break;
- default:
- *value = 0;
- }
- return 0;
-}
-
-
-static void
-Fake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
- if (xmbuf) {
- /* Note: we'll never generate clobber events */
- xmbuf->selectedEvents = mask;
- }
-}
-
-
-static void
-Fake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
-{
- XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
- if (xmbuf) {
- *mask = xmbuf->selectedEvents;
- }
- else {
- *mask = 0;
- }
-}
-
-
-
-/*** GLX_SGI_cushion ***/
-
-static void
-Fake_glXCushionSGI(Display *dpy, Window win, float cushion)
-{
- (void) dpy;
- (void) win;
- (void) cushion;
-}
-
-
-
-/*** GLX_SGIX_video_resize ***/
-
-static int
-Fake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
-{
- (void) dpy;
- (void) screen;
- (void) channel;
- (void) window;
- return 0;
-}
-
-static int
-Fake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
-{
- (void) dpy;
- (void) screen;
- (void) channel;
- (void) x;
- (void) y;
- (void) w;
- (void) h;
- return 0;
-}
-
-static int
-Fake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
-{
- (void) dpy;
- (void) screen;
- (void) channel;
- (void) x;
- (void) y;
- (void) w;
- (void) h;
- return 0;
-}
-
-static int
-Fake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
-{
- (void) dpy;
- (void) screen;
- (void) channel;
- (void) dx;
- (void) dy;
- (void) dw;
- (void) dh;
- return 0;
-}
-
-static int
-Fake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
-{
- (void) dpy;
- (void) screen;
- (void) channel;
- (void) synctype;
- return 0;
-}
-
-
-
-/*** GLX_SGIX_dmbuffer **/
-
-#if defined(_DM_BUFFER_H_)
-static Bool
-Fake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
-{
- (void) dpy;
- (void) pbuffer;
- (void) params;
- (void) dmbuffer;
- return False;
-}
-#endif
-
-
-/*** GLX_SGIX_swap_group ***/
-
-static void
-Fake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
-{
- (void) dpy;
- (void) drawable;
- (void) member;
-}
-
-
-
-/*** GLX_SGIX_swap_barrier ***/
-
-static void
-Fake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
-{
- (void) dpy;
- (void) drawable;
- (void) barrier;
-}
-
-static Bool
-Fake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
-{
- (void) dpy;
- (void) screen;
- (void) max;
- return False;
-}
-
-
-
-/*** GLX_SUN_get_transparent_index ***/
-
-static Status
-Fake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
-{
- (void) dpy;
- (void) overlay;
- (void) underlay;
- (void) pTransparent;
- return 0;
-}
-
-
-
-/*** GLX_MESA_release_buffers ***/
-
-/*
- * Release the depth, stencil, accum buffers attached to a GLXDrawable
- * (a window or pixmap) prior to destroying the GLXDrawable.
- */
-static Bool
-Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, d);
- if (b) {
- XMesaDestroyBuffer(b);
- return True;
- }
- return False;
-}
-
-
-
-/*** GLX_MESA_set_3dfx_mode ***/
-
-static Bool
-Fake_glXSet3DfxModeMESA( int mode )
-{
- return XMesaSetFXmode( mode );
-}
-
-
-
-/*** GLX_NV_vertex_array range ***/
-static void *
-Fake_glXAllocateMemoryNV( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority )
-{
- (void) size;
- (void) readFrequency;
- (void) writeFrequency;
- (void) priority;
- return NULL;
-}
-
-
-static void
-Fake_glXFreeMemoryNV( GLvoid *pointer )
-{
- (void) pointer;
-}
-
-
-/*** GLX_MESA_agp_offset ***/
-
-static GLuint
-Fake_glXGetAGPOffsetMESA( const GLvoid *pointer )
-{
- (void) pointer;
- return ~0;
-}
-
-
-/*** GLX_EXT_texture_from_pixmap ***/
-
-static void
-Fake_glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
- const int *attrib_list)
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, drawable);
- if (b)
- XMesaBindTexImage(dpy, b, buffer, attrib_list);
-}
-
-static void
-Fake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
-{
- XMesaBuffer b = XMesaFindBuffer(dpy, drawable);
- if (b)
- XMesaReleaseTexImage(dpy, b, buffer);
-}
-
-
-/* silence warning */
-extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-
-
-/**
- * Create a new GLX API dispatch table with its function pointers
- * initialized to point to Mesa's "fake" GLX API functions.
- * Note: there's a similar function (_real_GetGLXDispatchTable) that
- * returns a new dispatch table with all pointers initalized to point
- * to "real" GLX functions (which understand GLX wire protocol, etc).
- */
-struct _glxapi_table *
-_mesa_GetGLXDispatchTable(void)
-{
- static struct _glxapi_table glx;
-
- /* be sure our dispatch table size <= libGL's table */
- {
- GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
- (void) size;
- assert(_glxapi_get_dispatch_table_size() >= size);
- }
-
- /* initialize the whole table to no-ops */
- _glxapi_set_no_op_table(&glx);
-
- /* now initialize the table with the functions I implement */
- glx.ChooseVisual = Fake_glXChooseVisual;
- glx.CopyContext = Fake_glXCopyContext;
- glx.CreateContext = Fake_glXCreateContext;
- glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
- glx.DestroyContext = Fake_glXDestroyContext;
- glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
- glx.GetConfig = Fake_glXGetConfig;
- /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
- /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
- glx.IsDirect = Fake_glXIsDirect;
- glx.MakeCurrent = Fake_glXMakeCurrent;
- glx.QueryExtension = Fake_glXQueryExtension;
- glx.QueryVersion = Fake_glXQueryVersion;
- glx.SwapBuffers = Fake_glXSwapBuffers;
- glx.UseXFont = Fake_glXUseXFont;
- glx.WaitGL = Fake_glXWaitGL;
- glx.WaitX = Fake_glXWaitX;
-
- /*** GLX_VERSION_1_1 ***/
- glx.GetClientString = Fake_glXGetClientString;
- glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
- glx.QueryServerString = Fake_glXQueryServerString;
-
- /*** GLX_VERSION_1_2 ***/
- /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
-
- /*** GLX_VERSION_1_3 ***/
- glx.ChooseFBConfig = Fake_glXChooseFBConfig;
- glx.CreateNewContext = Fake_glXCreateNewContext;
- glx.CreatePbuffer = Fake_glXCreatePbuffer;
- glx.CreatePixmap = Fake_glXCreatePixmap;
- glx.CreateWindow = Fake_glXCreateWindow;
- glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
- glx.DestroyPixmap = Fake_glXDestroyPixmap;
- glx.DestroyWindow = Fake_glXDestroyWindow;
- /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/
- glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib;
- glx.GetFBConfigs = Fake_glXGetFBConfigs;
- glx.GetSelectedEvent = Fake_glXGetSelectedEvent;
- glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig;
- glx.MakeContextCurrent = Fake_glXMakeContextCurrent;
- glx.QueryContext = Fake_glXQueryContext;
- glx.QueryDrawable = Fake_glXQueryDrawable;
- glx.SelectEvent = Fake_glXSelectEvent;
-
- /*** GLX_SGI_swap_control ***/
- glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
-
- /*** GLX_SGI_video_sync ***/
- glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
- glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
-
- /*** GLX_SGI_make_current_read ***/
- glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
- /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
-
-/*** GLX_SGIX_video_source ***/
-#if defined(_VL_H)
- glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
- glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
-#endif
-
- /*** GLX_EXT_import_context ***/
- glx.FreeContextEXT = Fake_glXFreeContextEXT;
- glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
- /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
- glx.ImportContextEXT = Fake_glXImportContextEXT;
- glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
-
- /*** GLX_SGIX_fbconfig ***/
- glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
- glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
- glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
- glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
- glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
- glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
-
- /*** GLX_SGIX_pbuffer ***/
- glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
- glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
- glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
- glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
- glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
-
- /*** GLX_SGI_cushion ***/
- glx.CushionSGI = Fake_glXCushionSGI;
-
- /*** GLX_SGIX_video_resize ***/
- glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
- glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
- glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
- glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
- glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
-
- /*** GLX_SGIX_dmbuffer **/
-#if defined(_DM_BUFFER_H_)
- glx.AssociateDMPbufferSGIX = NULL;
-#endif
-
- /*** GLX_SGIX_swap_group ***/
- glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
-
- /*** GLX_SGIX_swap_barrier ***/
- glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
- glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
-
- /*** GLX_SUN_get_transparent_index ***/
- glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
-
- /*** GLX_MESA_copy_sub_buffer ***/
- glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
-
- /*** GLX_MESA_release_buffers ***/
- glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
-
- /*** GLX_MESA_pixmap_colormap ***/
- glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
-
- /*** GLX_MESA_set_3dfx_mode ***/
- glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
-
- /*** GLX_NV_vertex_array_range ***/
- glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
- glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
-
- /*** GLX_MESA_agp_offset ***/
- glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
-
- /*** GLX_EXT_texture_from_pixmap ***/
- glx.BindTexImageEXT = Fake_glXBindTexImageEXT;
- glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT;
-
- return &glx;
-}
diff --git a/src/mesa/pipe/xlib/glxapi.c b/src/mesa/pipe/xlib/glxapi.c
deleted file mode 100644
index c2ccce6f52..0000000000
--- a/src/mesa/pipe/xlib/glxapi.c
+++ /dev/null
@@ -1,1408 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 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.
- */
-
-
-/*
- * This is the GLX API dispatcher. Calls to the glX* functions are
- * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
- * See the glxapi.h file for more details.
- */
-
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include "main/glheader.h"
-#include "glapi/glapi.h"
-#include "glxapi.h"
-
-
-extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
-extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-
-
-struct display_dispatch {
- Display *Dpy;
- struct _glxapi_table *Table;
- struct display_dispatch *Next;
-};
-
-static struct display_dispatch *DispatchList = NULL;
-
-
-/* Display -> Dispatch caching */
-static Display *prevDisplay = NULL;
-static struct _glxapi_table *prevTable = NULL;
-
-
-static struct _glxapi_table *
-get_dispatch(Display *dpy)
-{
- if (!dpy)
- return NULL;
-
- /* search list of display/dispatch pairs for this display */
- {
- const struct display_dispatch *d = DispatchList;
- while (d) {
- if (d->Dpy == dpy) {
- prevDisplay = dpy;
- prevTable = d->Table;
- return d->Table; /* done! */
- }
- d = d->Next;
- }
- }
-
- /* A new display, determine if we should use real GLX
- * or Mesa's pseudo-GLX.
- */
- {
- struct _glxapi_table *t = _mesa_GetGLXDispatchTable();
-
- if (t) {
- struct display_dispatch *d;
- d = (struct display_dispatch *) malloc(sizeof(struct display_dispatch));
- if (d) {
- d->Dpy = dpy;
- d->Table = t;
- /* insert at head of list */
- d->Next = DispatchList;
- DispatchList = d;
- /* update cache */
- prevDisplay = dpy;
- prevTable = t;
- return t;
- }
- }
- }
-
- /* If we get here that means we can't use real GLX on this display
- * and the Mesa pseudo-GLX software renderer wasn't compiled in.
- * Or, we ran out of memory!
- */
- return NULL;
-}
-
-
-/* Don't use the GET_DISPATCH defined in glthread.h */
-#undef GET_DISPATCH
-
-#define GET_DISPATCH(DPY, TABLE) \
- if (DPY == prevDisplay) { \
- TABLE = prevTable; \
- } \
- else if (!DPY) { \
- TABLE = NULL; \
- } \
- else { \
- TABLE = get_dispatch(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
-
-
-static void
-SetCurrentContext(GLXContext c)
-{
-#if defined(GLX_USE_TLS)
- CurrentContext = c;
-#elif defined(THREADS)
- _glthread_SetTSD(&ContextTSD, c);
-#else
- CurrentContext = c;
-#endif
-}
-
-
-/*
- * GLX API entrypoints
- */
-
-/*** GLX_VERSION_1_0 ***/
-
-XVisualInfo PUBLIC *
-glXChooseVisual(Display *dpy, int screen, int *list)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->ChooseVisual)(dpy, screen, list);
-}
-
-
-void PUBLIC
-glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->CopyContext)(dpy, src, dst, mask);
-}
-
-
-GLXContext PUBLIC
-glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateContext)(dpy, visinfo, shareList, direct);
-}
-
-
-GLXPixmap PUBLIC
-glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateGLXPixmap)(dpy, visinfo, pixmap);
-}
-
-
-void PUBLIC
-glXDestroyContext(Display *dpy, GLXContext ctx)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- if (glXGetCurrentContext() == ctx)
- SetCurrentContext(NULL);
- (t->DestroyContext)(dpy, ctx);
-}
-
-
-void PUBLIC
-glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->DestroyGLXPixmap)(dpy, pixmap);
-}
-
-
-int PUBLIC
-glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return GLX_NO_EXTENSION;
- return (t->GetConfig)(dpy, visinfo, attrib, value);
-}
-
-
-GLXContext PUBLIC
-glXGetCurrentContext(void)
-{
-#if defined(GLX_USE_TLS)
- return CurrentContext;
-#elif defined(THREADS)
- return (GLXContext) _glthread_GetTSD(&ContextTSD);
-#else
- return CurrentContext;
-#endif
-}
-
-
-GLXDrawable PUBLIC
-glXGetCurrentDrawable(void)
-{
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
- return gc ? gc->currentDrawable : 0;
-}
-
-
-Bool PUBLIC
-glXIsDirect(Display *dpy, GLXContext ctx)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->IsDirect)(dpy, ctx);
-}
-
-
-Bool PUBLIC
-glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
-{
- Bool b;
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t) {
- return False;
- }
- b = (*t->MakeCurrent)(dpy, drawable, ctx);
- if (b) {
- SetCurrentContext(ctx);
- }
- return b;
-}
-
-
-Bool PUBLIC
-glXQueryExtension(Display *dpy, int *errorb, int *event)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->QueryExtension)(dpy, errorb, event);
-}
-
-
-Bool PUBLIC
-glXQueryVersion(Display *dpy, int *maj, int *min)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->QueryVersion)(dpy, maj, min);
-}
-
-
-void PUBLIC
-glXSwapBuffers(Display *dpy, GLXDrawable drawable)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->SwapBuffers)(dpy, drawable);
-}
-
-
-void PUBLIC
-glXUseXFont(Font font, int first, int count, int listBase)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->UseXFont)(font, first, count, listBase);
-}
-
-
-void PUBLIC
-glXWaitGL(void)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->WaitGL)();
-}
-
-
-void PUBLIC
-glXWaitX(void)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->WaitX)();
-}
-
-
-
-/*** GLX_VERSION_1_1 ***/
-
-const char PUBLIC *
-glXGetClientString(Display *dpy, int name)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->GetClientString)(dpy, name);
-}
-
-
-const char PUBLIC *
-glXQueryExtensionsString(Display *dpy, int screen)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->QueryExtensionsString)(dpy, screen);
-}
-
-
-const char PUBLIC *
-glXQueryServerString(Display *dpy, int screen, int name)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->QueryServerString)(dpy, screen, name);
-}
-
-
-/*** GLX_VERSION_1_2 ***/
-
-Display PUBLIC *
-glXGetCurrentDisplay(void)
-{
- /* Same code as in libGL's glxext.c */
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
- if (NULL == gc) return NULL;
- return gc->currentDpy;
-}
-
-
-
-/*** GLX_VERSION_1_3 ***/
-
-GLXFBConfig PUBLIC *
-glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->ChooseFBConfig)(dpy, screen, attribList, nitems);
-}
-
-
-GLXContext PUBLIC
-glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateNewContext)(dpy, config, renderType, shareList, direct);
-}
-
-
-GLXPbuffer PUBLIC
-glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreatePbuffer)(dpy, config, attribList);
-}
-
-
-GLXPixmap PUBLIC
-glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreatePixmap)(dpy, config, pixmap, attribList);
-}
-
-
-GLXWindow PUBLIC
-glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateWindow)(dpy, config, win, attribList);
-}
-
-
-void PUBLIC
-glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->DestroyPbuffer)(dpy, pbuf);
-}
-
-
-void PUBLIC
-glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->DestroyPixmap)(dpy, pixmap);
-}
-
-
-void PUBLIC
-glXDestroyWindow(Display *dpy, GLXWindow window)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->DestroyWindow)(dpy, window);
-}
-
-
-GLXDrawable PUBLIC
-glXGetCurrentReadDrawable(void)
-{
- __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
- return gc ? gc->currentReadable : 0;
-}
-
-
-int PUBLIC
-glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return GLX_NO_EXTENSION;
- return (t->GetFBConfigAttrib)(dpy, config, attribute, value);
-}
-
-
-GLXFBConfig PUBLIC *
-glXGetFBConfigs(Display *dpy, int screen, int *nelements)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->GetFBConfigs)(dpy, screen, nelements);
-}
-
-void PUBLIC
-glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->GetSelectedEvent)(dpy, drawable, mask);
-}
-
-
-XVisualInfo PUBLIC *
-glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->GetVisualFromFBConfig)(dpy, config);
-}
-
-
-Bool PUBLIC
-glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
-{
- Bool b;
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- b = (t->MakeContextCurrent)(dpy, draw, read, ctx);
- if (b) {
- SetCurrentContext(ctx);
- }
- return b;
-}
-
-
-int PUBLIC
-glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- assert(t);
- if (!t)
- return 0; /* XXX correct? */
- return (t->QueryContext)(dpy, ctx, attribute, value);
-}
-
-
-void PUBLIC
-glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->QueryDrawable)(dpy, draw, attribute, value);
-}
-
-
-void PUBLIC
-glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->SelectEvent)(dpy, drawable, mask);
-}
-
-
-
-/*** GLX_SGI_swap_control ***/
-
-int PUBLIC
-glXSwapIntervalSGI(int interval)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->SwapIntervalSGI)(interval);
-}
-
-
-
-/*** GLX_SGI_video_sync ***/
-
-int PUBLIC
-glXGetVideoSyncSGI(unsigned int *count)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t || !glXGetCurrentContext())
- return GLX_BAD_CONTEXT;
- return (t->GetVideoSyncSGI)(count);
-}
-
-int PUBLIC
-glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t || !glXGetCurrentContext())
- return GLX_BAD_CONTEXT;
- return (t->WaitVideoSyncSGI)(divisor, remainder, count);
-}
-
-
-
-/*** GLX_SGI_make_current_read ***/
-
-Bool PUBLIC
-glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->MakeCurrentReadSGI)(dpy, draw, read, ctx);
-}
-
-GLXDrawable PUBLIC
-glXGetCurrentReadDrawableSGI(void)
-{
- return glXGetCurrentReadDrawable();
-}
-
-
-#if defined(_VL_H)
-
-GLXVideoSourceSGIX PUBLIC
-glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateGLXVideoSourceSGIX)(dpy, screen, server, path, nodeClass, drainNode);
-}
-
-void PUBLIC
-glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->DestroyGLXVideoSourceSGIX)(dpy, src);
-}
-
-#endif
-
-
-/*** GLX_EXT_import_context ***/
-
-void PUBLIC
-glXFreeContextEXT(Display *dpy, GLXContext context)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->FreeContextEXT)(dpy, context);
-}
-
-GLXContextID PUBLIC
-glXGetContextIDEXT(const GLXContext context)
-{
- return ((__GLXcontext *) context)->xid;
-}
-
-Display PUBLIC *
-glXGetCurrentDisplayEXT(void)
-{
- return glXGetCurrentDisplay();
-}
-
-GLXContext PUBLIC
-glXImportContextEXT(Display *dpy, GLXContextID contextID)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->ImportContextEXT)(dpy, contextID);
-}
-
-int PUBLIC
-glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0; /* XXX ok? */
- return (t->QueryContextInfoEXT)(dpy, context, attribute, value);
-}
-
-
-
-/*** GLX_SGIX_fbconfig ***/
-
-int PUBLIC
-glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->GetFBConfigAttribSGIX)(dpy, config, attribute, value);
-}
-
-GLXFBConfigSGIX PUBLIC *
-glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->ChooseFBConfigSGIX)(dpy, screen, attrib_list, nelements);
-}
-
-GLXPixmap PUBLIC
-glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateGLXPixmapWithConfigSGIX)(dpy, config, pixmap);
-}
-
-GLXContext PUBLIC
-glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateContextWithConfigSGIX)(dpy, config, render_type, share_list, direct);
-}
-
-XVisualInfo PUBLIC *
-glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->GetVisualFromFBConfigSGIX)(dpy, config);
-}
-
-GLXFBConfigSGIX PUBLIC
-glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->GetFBConfigFromVisualSGIX)(dpy, vis);
-}
-
-
-
-/*** GLX_SGIX_pbuffer ***/
-
-GLXPbufferSGIX PUBLIC
-glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateGLXPbufferSGIX)(dpy, config, width, height, attrib_list);
-}
-
-void PUBLIC
-glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->DestroyGLXPbufferSGIX)(dpy, pbuf);
-}
-
-int PUBLIC
-glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->QueryGLXPbufferSGIX)(dpy, pbuf, attribute, value);
-}
-
-void PUBLIC
-glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->SelectEventSGIX)(dpy, drawable, mask);
-}
-
-void PUBLIC
-glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->GetSelectedEventSGIX)(dpy, drawable, mask);
-}
-
-
-
-/*** GLX_SGI_cushion ***/
-
-void PUBLIC
-glXCushionSGI(Display *dpy, Window win, float cushion)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->CushionSGI)(dpy, win, cushion);
-}
-
-
-
-/*** GLX_SGIX_video_resize ***/
-
-int PUBLIC
-glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->BindChannelToWindowSGIX)(dpy, screen, channel, window);
-}
-
-int PUBLIC
-glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->ChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
-}
-
-int PUBLIC
-glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->QueryChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
-}
-
-int PUBLIC
-glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->QueryChannelDeltasSGIX)(dpy, screen, channel, dx, dy, dw, dh);
-}
-
-int PUBLIC
-glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->ChannelRectSyncSGIX)(dpy, screen, channel, synctype);
-}
-
-
-
-#if defined(_DM_BUFFER_H_)
-
-Bool PUBLIC
-glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->AssociateDMPbufferSGIX)(dpy, pbuffer, params, dmbuffer);
-}
-
-#endif
-
-
-/*** GLX_SGIX_swap_group ***/
-
-void PUBLIC
-glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (*t->JoinSwapGroupSGIX)(dpy, drawable, member);
-}
-
-
-/*** GLX_SGIX_swap_barrier ***/
-
-void PUBLIC
-glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (*t->BindSwapBarrierSGIX)(dpy, drawable, barrier);
-}
-
-Bool PUBLIC
-glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (*t->QueryMaxSwapBarriersSGIX)(dpy, screen, max);
-}
-
-
-
-/*** GLX_SUN_get_transparent_index ***/
-
-Status PUBLIC
-glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (*t->GetTransparentIndexSUN)(dpy, overlay, underlay, pTransparent);
-}
-
-
-
-/*** GLX_MESA_copy_sub_buffer ***/
-
-void PUBLIC
-glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->CopySubBufferMESA)(dpy, drawable, x, y, width, height);
-}
-
-
-
-/*** GLX_MESA_release_buffers ***/
-
-Bool PUBLIC
-glXReleaseBuffersMESA(Display *dpy, Window w)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->ReleaseBuffersMESA)(dpy, w);
-}
-
-
-
-/*** GLX_MESA_pixmap_colormap ***/
-
-GLXPixmap PUBLIC
-glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (!t)
- return 0;
- return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
-}
-
-
-
-/*** GLX_MESA_set_3dfx_mode ***/
-
-Bool PUBLIC
-glXSet3DfxModeMESA(int mode)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->Set3DfxModeMESA)(mode);
-}
-
-
-
-/*** GLX_NV_vertex_array_range ***/
-
-void PUBLIC *
-glXAllocateMemoryNV( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->AllocateMemoryNV)(size, readFrequency, writeFrequency, priority);
-}
-
-
-void PUBLIC
-glXFreeMemoryNV( GLvoid *pointer )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->FreeMemoryNV)(pointer);
-}
-
-
-
-
-/*** GLX_MESA_agp_offset */
-
-GLuint PUBLIC
-glXGetAGPOffsetMESA( const GLvoid *pointer )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return ~0;
- return (t->GetAGPOffsetMESA)(pointer);
-}
-
-
-/*** GLX_MESA_allocate_memory */
-
-void *
-glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
- float readfreq, float writefreq, float priority)
-{
- /* dummy */
- return NULL;
-}
-
-void
-glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
-{
- /* dummy */
-}
-
-
-GLuint
-glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
-{
- /* dummy */
- return 0;
-}
-
-
-/*** GLX_EXT_texture_from_pixmap */
-
-void
-glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer,
- const int *attrib_list)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (t)
- t->BindTexImageEXT(dpy, drawable, buffer, attrib_list);
-}
-
-void
-glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
-{
- struct _glxapi_table *t;
- GET_DISPATCH(dpy, t);
- if (t)
- t->ReleaseTexImageEXT(dpy, drawable, buffer);
-}
-
-
-/**********************************************************************/
-/* GLX API management functions */
-/**********************************************************************/
-
-
-const char *
-_glxapi_get_version(void)
-{
- return "1.3";
-}
-
-
-/*
- * Return array of extension strings.
- */
-const char **
-_glxapi_get_extensions(void)
-{
- static const char *extensions[] = {
-#ifdef GLX_EXT_import_context
- "GLX_EXT_import_context",
-#endif
-#ifdef GLX_SGI_video_sync
- "GLX_SGI_video_sync",
-#endif
-#ifdef GLX_MESA_copy_sub_buffer
- "GLX_MESA_copy_sub_buffer",
-#endif
-#ifdef GLX_MESA_release_buffers
- "GLX_MESA_release_buffers",
-#endif
-#ifdef GLX_MESA_pixmap_colormap
- "GLX_MESA_pixmap_colormap",
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
- "GLX_MESA_set_3dfx_mode",
-#endif
-#ifdef GLX_SGIX_fbconfig
- "GLX_SGIX_fbconfig",
-#endif
-#ifdef GLX_SGIX_pbuffer
- "GLX_SGIX_pbuffer",
-#endif
-#ifdef GLX_EXT_texture_from_pixmap
- "GLX_EXT_texture_from_pixmap",
-#endif
- NULL
- };
- return extensions;
-}
-
-
-/*
- * Return size of the GLX dispatch table, in entries, not bytes.
- */
-GLuint
-_glxapi_get_dispatch_table_size(void)
-{
- return sizeof(struct _glxapi_table) / sizeof(void *);
-}
-
-
-static int
-generic_no_op_func(void)
-{
- return 0;
-}
-
-
-/*
- * Initialize all functions in given dispatch table to be no-ops
- */
-void
-_glxapi_set_no_op_table(struct _glxapi_table *t)
-{
- typedef int (*nop_func)(void);
- nop_func *dispatch = (nop_func *) t;
- GLuint n = _glxapi_get_dispatch_table_size();
- GLuint i;
- for (i = 0; i < n; i++) {
- dispatch[i] = generic_no_op_func;
- }
-}
-
-
-struct name_address_pair {
- const char *Name;
- __GLXextFuncPtr Address;
-};
-
-static struct name_address_pair GLX_functions[] = {
- /*** GLX_VERSION_1_0 ***/
- { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
- { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
- { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
- { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
- { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
- { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
- { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
- { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
- { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
- { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
- { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
- { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
- { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
- { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
- { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
- { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
- { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
-
- /*** GLX_VERSION_1_1 ***/
- { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
- { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
- { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
-
- /*** GLX_VERSION_1_2 ***/
- { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
-
- /*** GLX_VERSION_1_3 ***/
- { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
- { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
- { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
- { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
- { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
- { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
- { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
- { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
- { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
- { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
- { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
- { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
- { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
- { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
- { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
- { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
- { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
-
- /*** GLX_VERSION_1_4 ***/
- { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
-
- /*** GLX_SGI_swap_control ***/
- { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
-
- /*** GLX_SGI_video_sync ***/
- { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
- { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
-
- /*** GLX_SGI_make_current_read ***/
- { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
- { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
-
- /*** GLX_SGIX_video_source ***/
-#if defined(_VL_H)
- { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
- { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
-#endif
-
- /*** GLX_EXT_import_context ***/
- { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
- { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
- { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
- { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
- { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
-
- /*** GLX_SGIX_fbconfig ***/
- { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
- { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
- { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
- { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
- { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
- { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
-
- /*** GLX_SGIX_pbuffer ***/
- { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
- { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
- { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
- { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
- { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
-
- /*** GLX_SGI_cushion ***/
- { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
-
- /*** GLX_SGIX_video_resize ***/
- { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
- { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
- { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
- { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
- { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
-
- /*** GLX_SGIX_dmbuffer **/
-#if defined(_DM_BUFFER_H_)
- { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
-#endif
-
- /*** GLX_SGIX_swap_group ***/
- { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr) glXJoinSwapGroupSGIX },
-
- /*** GLX_SGIX_swap_barrier ***/
- { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr) glXBindSwapBarrierSGIX },
- { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr) glXQueryMaxSwapBarriersSGIX },
-
- /*** GLX_SUN_get_transparent_index ***/
- { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
-
- /*** GLX_MESA_copy_sub_buffer ***/
- { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
-
- /*** GLX_MESA_pixmap_colormap ***/
- { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
-
- /*** GLX_MESA_release_buffers ***/
- { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
-
- /*** GLX_MESA_set_3dfx_mode ***/
- { "glXSet3DfxModeMESA", (__GLXextFuncPtr) glXSet3DfxModeMESA },
-
- /*** GLX_ARB_get_proc_address ***/
- { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
-
- /*** GLX_NV_vertex_array_range ***/
- { "glXAllocateMemoryNV", (__GLXextFuncPtr) glXAllocateMemoryNV },
- { "glXFreeMemoryNV", (__GLXextFuncPtr) glXFreeMemoryNV },
-
- /*** GLX_MESA_agp_offset ***/
- { "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
-
- /*** GLX_MESA_allocate_memory ***/
- { "glXAllocateMemoryMESA", (__GLXextFuncPtr) glXAllocateMemoryMESA },
- { "glXFreeMemoryMESA", (__GLXextFuncPtr) glXFreeMemoryMESA },
- { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr) glXGetMemoryOffsetMESA },
-
- /*** GLX_EXT_texture_from_pixmap ***/
- { "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
- { "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
-
- { NULL, NULL } /* end of list */
-};
-
-
-
-/*
- * Return address of named glX function, or NULL if not found.
- */
-__GLXextFuncPtr
-_glxapi_get_proc_address(const char *funcName)
-{
- GLuint i;
- for (i = 0; GLX_functions[i].Name; i++) {
- if (strcmp(GLX_functions[i].Name, funcName) == 0)
- return GLX_functions[i].Address;
- }
- return NULL;
-}
-
-
-
-/*
- * This function does not get dispatched through the dispatch table
- * since it's really a "meta" function.
- */
-__GLXextFuncPtr
-glXGetProcAddressARB(const GLubyte *procName)
-{
- __GLXextFuncPtr f;
-
- f = _glxapi_get_proc_address((const char *) procName);
- if (f) {
- return f;
- }
-
- f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
- return f;
-}
-
-
-/* GLX 1.4 */
-void (*glXGetProcAddress(const GLubyte *procName))()
-{
- return glXGetProcAddressARB(procName);
-}
diff --git a/src/mesa/pipe/xlib/glxapi.h b/src/mesa/pipe/xlib/glxapi.h
deleted file mode 100644
index 37de81e55a..0000000000
--- a/src/mesa/pipe/xlib/glxapi.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2004 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.
- */
-
-
-#ifndef _glxapi_h_
-#define _glxapi_h_
-
-
-#define GLX_GLXEXT_PROTOTYPES
-#include "GL/glx.h"
-
-
-/* The GLX API dispatcher (i.e. this code) is being built into stand-alone
- * Mesa. We don't know anything about XFree86 or real GLX so we define a
- * minimal __GLXContextRec here so some of the functions in this file can
- * work properly.
- */
-typedef struct __GLXcontextRec {
- Display *currentDpy;
- GLboolean isDirect;
- GLXDrawable currentDrawable;
- GLXDrawable currentReadable;
- XID xid;
-} __GLXcontext;
-
-
-/*
- * Almost all the GLX API functions get routed through this dispatch table.
- * The exceptions are the glXGetCurrentXXX() functions.
- *
- * This dispatch table allows multiple GLX client-side modules to coexist.
- * Specifically, a real GLX library (like SGI's or the Utah GLX) and Mesa's
- * pseudo-GLX can be present at the same time. The former being used on
- * GLX-enabled X servers and the later on non-GLX X servers.
- *
- * Red Hat has been using this since Red Hat Linux 7.0 (I think).
- * This'll be a standard feature in XFree86 4.3. It basically allows one
- * libGL to do both DRI-rendering and "fake GLX" rendering to X displays
- * that lack the GLX extension.
- */
-struct _glxapi_table {
- /*** GLX_VERSION_1_0 ***/
- XVisualInfo *(*ChooseVisual)(Display *dpy, int screen, int *list);
- void (*CopyContext)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
- GLXContext (*CreateContext)(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct);
- GLXPixmap (*CreateGLXPixmap)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap);
- void (*DestroyContext)(Display *dpy, GLXContext ctx);
- void (*DestroyGLXPixmap)(Display *dpy, GLXPixmap pixmap);
- int (*GetConfig)(Display *dpy, XVisualInfo *visinfo, int attrib, int *value);
- /*GLXContext (*GetCurrentContext)(void);*/
- /*GLXDrawable (*GetCurrentDrawable)(void);*/
- Bool (*IsDirect)(Display *dpy, GLXContext ctx);
- Bool (*MakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
- Bool (*QueryExtension)(Display *dpy, int *errorb, int *event);
- Bool (*QueryVersion)(Display *dpy, int *maj, int *min);
- void (*SwapBuffers)(Display *dpy, GLXDrawable drawable);
- void (*UseXFont)(Font font, int first, int count, int listBase);
- void (*WaitGL)(void);
- void (*WaitX)(void);
-
- /*** GLX_VERSION_1_1 ***/
- const char *(*GetClientString)(Display *dpy, int name);
- const char *(*QueryExtensionsString)(Display *dpy, int screen);
- const char *(*QueryServerString)(Display *dpy, int screen, int name);
-
- /*** GLX_VERSION_1_2 ***/
- /*Display *(*GetCurrentDisplay)(void);*/
-
- /*** GLX_VERSION_1_3 ***/
- GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
- GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
- GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList);
- GLXPixmap (*CreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList);
- GLXWindow (*CreateWindow)(Display *dpy, GLXFBConfig config, Window win, const int *attribList);
- void (*DestroyPbuffer)(Display *dpy, GLXPbuffer pbuf);
- void (*DestroyPixmap)(Display *dpy, GLXPixmap pixmap);
- void (*DestroyWindow)(Display *dpy, GLXWindow window);
- /*GLXDrawable (*GetCurrentReadDrawable)(void);*/
- int (*GetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value);
- GLXFBConfig *(*GetFBConfigs)(Display *dpy, int screen, int *nelements);
- void (*GetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask);
- XVisualInfo *(*GetVisualFromFBConfig)(Display *dpy, GLXFBConfig config);
- Bool (*MakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
- int (*QueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value);
- void (*QueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
- void (*SelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask);
-
- /*** GLX_SGI_swap_control ***/
- int (*SwapIntervalSGI)(int);
-
- /*** GLX_SGI_video_sync ***/
- int (*GetVideoSyncSGI)(unsigned int *count);
- int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
-
- /*** GLX_SGI_make_current_read ***/
- Bool (*MakeCurrentReadSGI)(Display *, GLXDrawable, GLXDrawable, GLXContext);
- /*GLXDrawable (*GetCurrentReadDrawableSGI)(void);*/
-
- /*** GLX_SGIX_video_source (needs video library) ***/
-#if defined(_VL_H_)
- GLXVideoSourceSGIX (*CreateGLXVideoSourceSGIX)(Display *, int, VLServer, VLPath, int, VLNode);
- void (*DestroyGLXVideoSourceSGIX)(Display *, GLXVideoSourceSGIX);
-#else
- void *CreateGLXVideoSourceSGIX;
- void *DestroyGLXVideoSourceSGIX;
-#endif
-
- /*** GLX_EXT_import_context ***/
- void (*FreeContextEXT)(Display *dpy, GLXContext context);
- GLXContextID (*GetContextIDEXT)(const GLXContext context);
- /*Display *(*GetCurrentDisplayEXT)(void);*/
- GLXContext (*ImportContextEXT)(Display *dpy, GLXContextID contextID);
- int (*QueryContextInfoEXT)(Display *dpy, GLXContext context, int attribute,int *value);
-
- /*** GLX_SGIX_fbconfig ***/
- int (*GetFBConfigAttribSGIX)(Display *, GLXFBConfigSGIX, int, int *);
- GLXFBConfigSGIX * (*ChooseFBConfigSGIX)(Display *, int, int *, int *);
- GLXPixmap (*CreateGLXPixmapWithConfigSGIX)(Display *, GLXFBConfigSGIX, Pixmap);
- GLXContext (*CreateContextWithConfigSGIX)(Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
- XVisualInfo * (*GetVisualFromFBConfigSGIX)(Display *, GLXFBConfigSGIX);
- GLXFBConfigSGIX (*GetFBConfigFromVisualSGIX)(Display *, XVisualInfo *);
-
- /*** GLX_SGIX_pbuffer ***/
- GLXPbufferSGIX (*CreateGLXPbufferSGIX)(Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
- void (*DestroyGLXPbufferSGIX)(Display *, GLXPbufferSGIX);
- int (*QueryGLXPbufferSGIX)(Display *, GLXPbufferSGIX, int, unsigned int *);
- void (*SelectEventSGIX)(Display *, GLXDrawable, unsigned long);
- void (*GetSelectedEventSGIX)(Display *, GLXDrawable, unsigned long *);
-
- /*** GLX_SGI_cushion ***/
- void (*CushionSGI)(Display *, Window, float);
-
- /*** GLX_SGIX_video_resize ***/
- int (*BindChannelToWindowSGIX)(Display *, int, int, Window);
- int (*ChannelRectSGIX)(Display *, int, int, int, int, int, int);
- int (*QueryChannelRectSGIX)(Display *, int, int, int *, int *, int *, int *);
- int (*QueryChannelDeltasSGIX)(Display *, int, int, int *, int *, int *, int *);
- int (*ChannelRectSyncSGIX)(Display *, int, int, GLenum);
-
- /*** GLX_SGIX_dmbuffer (needs dmedia library) ***/
-#if defined (_DM_BUFFER_H_)
- Bool (*AssociateDMPbufferSGIX)(Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
-#else
- void *AssociciateDMPbufferSGIX;
-#endif
-
- /*** GLX_SGIX_swap_group ***/
- void (*JoinSwapGroupSGIX)(Display *, GLXDrawable, GLXDrawable);
-
- /*** GLX_SGIX_swap_barrier ***/
- void (*BindSwapBarrierSGIX)(Display *, GLXDrawable, int);
- Bool (*QueryMaxSwapBarriersSGIX)(Display *, int, int *);
-
- /*** GLX_SUN_get_transparent_index ***/
- Status (*GetTransparentIndexSUN)(Display *, Window, Window, long *);
-
- /*** GLX_MESA_copy_sub_buffer ***/
- void (*CopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
-
- /*** GLX_MESA_release_buffers ***/
- Bool (*ReleaseBuffersMESA)(Display *dpy, Window w);
-
- /*** GLX_MESA_pixmap_colormap ***/
- GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
-
- /*** GLX_MESA_set_3dfx_mode ***/
- Bool (*Set3DfxModeMESA)(int mode);
-
- /*** GLX_NV_vertex_array_range ***/
- void * (*AllocateMemoryNV)( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority );
- void (*FreeMemoryNV)( GLvoid *pointer );
-
- /*** GLX_MESA_agp_offset ***/
- GLuint (*GetAGPOffsetMESA)( const GLvoid *pointer );
-
- /*** GLX_EXT_texture_from_pixmap ***/
- void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
- const int *attrib_list);
- void (*ReleaseTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer);
-};
-
-
-
-extern const char *
-_glxapi_get_version(void);
-
-
-extern const char **
-_glxapi_get_extensions(void);
-
-
-extern GLuint
-_glxapi_get_dispatch_table_size(void);
-
-
-extern void
-_glxapi_set_no_op_table(struct _glxapi_table *t);
-
-
-extern __GLXextFuncPtr
-_glxapi_get_proc_address(const char *funcName);
-
-
-#endif
diff --git a/src/mesa/pipe/xlib/glxheader.h b/src/mesa/pipe/xlib/glxheader.h
deleted file mode 100644
index a402191f13..0000000000
--- a/src/mesa/pipe/xlib/glxheader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * 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.
- */
-
-
-#ifndef GLX_HEADER_H
-#define GLX_HEADER_H
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include "glheader.h"
-
-#ifdef XFree86Server
-
-# include "resource.h"
-# include "windowstr.h"
-
-#else
-
-# include <X11/Xlib.h>
-# include <X11/Xlibint.h>
-# include <X11/Xutil.h>
-# ifdef USE_XSHM /* was SHM */
-# include <sys/ipc.h>
-# include <sys/shm.h>
-# include <X11/extensions/XShm.h>
-# endif
-# include <GL/glx.h>
-# include <sys/time.h>
-
-#endif
-
-
-
-/* this silences a compiler warning on several systems */
-struct timespec;
-struct itimerspec;
-
-
-#endif /*GLX_HEADER*/
diff --git a/src/mesa/pipe/xlib/realglx.c b/src/mesa/pipe/xlib/realglx.c
deleted file mode 100644
index 30adb7465b..0000000000
--- a/src/mesa/pipe/xlib/realglx.c
+++ /dev/null
@@ -1,180 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2002 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.
- */
-
-
-#include <assert.h>
-#include <GL/glx.h>
-#include "realglx.h"
-#include "glxapi.h"
-
-
-struct _glxapi_table *
-_real_GetGLXDispatchTable(void)
-{
- static struct _glxapi_table glx;
-
- /* be sure our dispatch table size <= libGL's table */
- {
- GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
- (void) size;
- assert(_glxapi_get_dispatch_table_size() >= size);
- }
-
- /* initialize the whole table to no-ops */
- _glxapi_set_no_op_table(&glx);
-
- /* now initialize the table with the functions I implement */
-
- /*** GLX_VERSION_1_0 ***/
- glx.ChooseVisual = _real_glXChooseVisual;
- glx.CopyContext = _real_glXCopyContext;
- glx.CreateContext = _real_glXCreateContext;
- glx.CreateGLXPixmap = _real_glXCreateGLXPixmap;
- glx.DestroyContext = _real_glXDestroyContext;
- glx.DestroyGLXPixmap = _real_glXDestroyGLXPixmap;
- glx.GetConfig = _real_glXGetConfig;
- /*glx.GetCurrentContext = _real_glXGetCurrentContext;*/
- /*glx.GetCurrentDrawable = _real_glXGetCurrentDrawable;*/
- glx.IsDirect = _real_glXIsDirect;
- glx.MakeCurrent = _real_glXMakeCurrent;
- glx.QueryExtension = _real_glXQueryExtension;
- glx.QueryVersion = _real_glXQueryVersion;
- glx.SwapBuffers = _real_glXSwapBuffers;
- glx.UseXFont = _real_glXUseXFont;
- glx.WaitGL = _real_glXWaitGL;
- glx.WaitX = _real_glXWaitX;
-
- /*** GLX_VERSION_1_1 ***/
- glx.GetClientString = _real_glXGetClientString;
- glx.QueryExtensionsString = _real_glXQueryExtensionsString;
- glx.QueryServerString = _real_glXQueryServerString;
-
- /*** GLX_VERSION_1_2 ***/
- /*glx.GetCurrentDisplay = _real_glXGetCurrentDisplay;*/
-
- /*** GLX_VERSION_1_3 ***/
- glx.ChooseFBConfig = _real_glXChooseFBConfig;
- glx.CreateNewContext = _real_glXCreateNewContext;
- glx.CreatePbuffer = _real_glXCreatePbuffer;
- glx.CreatePixmap = _real_glXCreatePixmap;
- glx.CreateWindow = _real_glXCreateWindow;
- glx.DestroyPbuffer = _real_glXDestroyPbuffer;
- glx.DestroyPixmap = _real_glXDestroyPixmap;
- glx.DestroyWindow = _real_glXDestroyWindow;
- /*glx.GetCurrentReadDrawable = _real_glXGetCurrentReadDrawable;*/
- glx.GetFBConfigAttrib = _real_glXGetFBConfigAttrib;
- glx.GetFBConfigs = _real_glXGetFBConfigs;
- glx.GetSelectedEvent = _real_glXGetSelectedEvent;
- glx.GetVisualFromFBConfig = _real_glXGetVisualFromFBConfig;
- glx.MakeContextCurrent = _real_glXMakeContextCurrent;
- glx.QueryContext = _real_glXQueryContext;
- glx.QueryDrawable = _real_glXQueryDrawable;
- glx.SelectEvent = _real_glXSelectEvent;
-
- /*** GLX_SGI_swap_control ***/
- glx.SwapIntervalSGI = _real_glXSwapIntervalSGI;
-
- /*** GLX_SGI_video_sync ***/
- glx.GetVideoSyncSGI = _real_glXGetVideoSyncSGI;
- glx.WaitVideoSyncSGI = _real_glXWaitVideoSyncSGI;
-
- /*** GLX_SGI_make_current_read ***/
- glx.MakeCurrentReadSGI = _real_glXMakeCurrentReadSGI;
- /*glx.GetCurrentReadDrawableSGI = _real_glXGetCurrentReadDrawableSGI;*/
-
-#if defined(_VL_H)
- /*** GLX_SGIX_video_source ***/
- glx.CreateGLXVideoSourceSGIX = _real_glXCreateGLXVideoSourceSGIX;
- glx.DestroyGLXVideoSourceSGIX = _real_glXDestroyGLXVideoSourceSGIX;
-#endif
-
- /*** GLX_EXT_import_context ***/
- glx.FreeContextEXT = _real_glXFreeContextEXT;
- /*glx.GetContextIDEXT = _real_glXGetContextIDEXT;*/
- /*glx.GetCurrentDisplayEXT = _real_glXGetCurrentDisplayEXT;*/
- glx.ImportContextEXT = _real_glXImportContextEXT;
- glx.QueryContextInfoEXT = _real_glXQueryContextInfoEXT;
-
- /*** GLX_SGIX_fbconfig ***/
- glx.GetFBConfigAttribSGIX = _real_glXGetFBConfigAttribSGIX;
- glx.ChooseFBConfigSGIX = _real_glXChooseFBConfigSGIX;
- glx.CreateGLXPixmapWithConfigSGIX = _real_glXCreateGLXPixmapWithConfigSGIX;
- glx.CreateContextWithConfigSGIX = _real_glXCreateContextWithConfigSGIX;
- glx.GetVisualFromFBConfigSGIX = _real_glXGetVisualFromFBConfigSGIX;
- glx.GetFBConfigFromVisualSGIX = _real_glXGetFBConfigFromVisualSGIX;
-
- /*** GLX_SGIX_pbuffer ***/
- glx.CreateGLXPbufferSGIX = _real_glXCreateGLXPbufferSGIX;
- glx.DestroyGLXPbufferSGIX = _real_glXDestroyGLXPbufferSGIX;
- glx.QueryGLXPbufferSGIX = _real_glXQueryGLXPbufferSGIX;
- glx.SelectEventSGIX = _real_glXSelectEventSGIX;
- glx.GetSelectedEventSGIX = _real_glXGetSelectedEventSGIX;
-
- /*** GLX_SGI_cushion ***/
- glx.CushionSGI = _real_glXCushionSGI;
-
- /*** GLX_SGIX_video_resize ***/
- glx.BindChannelToWindowSGIX = _real_glXBindChannelToWindowSGIX;
- glx.ChannelRectSGIX = _real_glXChannelRectSGIX;
- glx.QueryChannelRectSGIX = _real_glXQueryChannelRectSGIX;
- glx.QueryChannelDeltasSGIX = _real_glXQueryChannelDeltasSGIX;
- glx.ChannelRectSyncSGIX = _real_glXChannelRectSyncSGIX;
-
-#if defined(_DM_BUFFER_H_)
- /*** (GLX_SGIX_dmbuffer ***/
- glx.AssociateDMPbufferSGIX = NULL;
-#endif
-
- /*** GLX_SGIX_swap_group ***/
- glx.JoinSwapGroupSGIX = _real_glXJoinSwapGroupSGIX;
-
- /*** GLX_SGIX_swap_barrier ***/
- glx.BindSwapBarrierSGIX = _real_glXBindSwapBarrierSGIX;
- glx.QueryMaxSwapBarriersSGIX = _real_glXQueryMaxSwapBarriersSGIX;
-
- /*** GLX_SUN_get_transparent_index ***/
- glx.GetTransparentIndexSUN = _real_glXGetTransparentIndexSUN;
-
- /*** GLX_MESA_copy_sub_buffer ***/
- glx.CopySubBufferMESA = _real_glXCopySubBufferMESA;
-
- /*** GLX_MESA_release_buffers ***/
- glx.ReleaseBuffersMESA = _real_glXReleaseBuffersMESA;
-
- /*** GLX_MESA_pixmap_colormap ***/
- glx.CreateGLXPixmapMESA = _real_glXCreateGLXPixmapMESA;
-
- /*** GLX_MESA_set_3dfx_mode ***/
- glx.Set3DfxModeMESA = _real_glXSet3DfxModeMESA;
-
- /*** GLX_NV_vertex_array_range ***/
- glx.AllocateMemoryNV = _real_glXAllocateMemoryNV;
- glx.FreeMemoryNV = _real_glXFreeMemoryNV;
-
- /*** GLX_MESA_agp_offset ***/
- glx.GetAGPOffsetMESA = _real_glXGetAGPOffsetMESA;
-
- return &glx;
-}
diff --git a/src/mesa/pipe/xlib/realglx.h b/src/mesa/pipe/xlib/realglx.h
deleted file mode 100644
index 150129db68..0000000000
--- a/src/mesa/pipe/xlib/realglx.h
+++ /dev/null
@@ -1,326 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 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.
- */
-
-
-#ifndef REALGLX_H
-#define REALGLX_H
-
-
-extern struct _glxapi_table *
-_real_GetGLXDispatchTable(void);
-
-
-/*
- * Basically just need these to prevent compiler warnings.
- */
-
-
-extern XVisualInfo *
-_real_glXChooseVisual( Display *dpy, int screen, int *list );
-
-extern GLXContext
-_real_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct );
-
-extern GLXPixmap
-_real_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap );
-
-extern GLXPixmap
-_real_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
- Pixmap pixmap, Colormap cmap );
-
-extern void
-_real_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
-
-extern void
-_real_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
- unsigned long mask );
-
-extern Bool
-_real_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx );
-
-extern Bool
-_real_glXQueryExtension( Display *dpy, int *errorb, int *event );
-
-extern void
-_real_glXDestroyContext( Display *dpy, GLXContext ctx );
-
-extern Bool
-_real_glXIsDirect( Display *dpy, GLXContext ctx );
-
-extern void
-_real_glXSwapBuffers( Display *dpy, GLXDrawable drawable );
-
-extern void
-_real_glXUseXFont( Font font, int first, int count, int listbase );
-
-extern Bool
-_real_glXQueryVersion( Display *dpy, int *maj, int *min );
-
-extern int
-_real_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
- int attrib, int *value );
-
-extern void
-_real_glXWaitGL( void );
-
-
-extern void
-_real_glXWaitX( void );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXQueryExtensionsString( Display *dpy, int screen );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXQueryServerString( Display *dpy, int screen, int name );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXGetClientString( Display *dpy, int name );
-
-
-/*
- * GLX 1.3 and later
- */
-
-extern GLXFBConfig *
-_real_glXChooseFBConfig( Display *dpy, int screen,
- const int *attribList, int *nitems );
-
-extern int
-_real_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
- int attribute, int *value );
-
-extern GLXFBConfig *
-_real_glXGetFBConfigs( Display *dpy, int screen, int *nelements );
-
-extern XVisualInfo *
-_real_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
-
-extern GLXWindow
-_real_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
- const int *attribList );
-
-extern void
-_real_glXDestroyWindow( Display *dpy, GLXWindow window );
-
-extern GLXPixmap
-_real_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
- const int *attribList );
-
-extern void
-_real_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
-
-extern GLXPbuffer
-_real_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
- const int *attribList );
-
-extern void
-_real_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
-
-extern void
-_real_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
- unsigned int *value );
-
-extern GLXContext
-_real_glXCreateNewContext( Display *dpy, GLXFBConfig config,
- int renderType, GLXContext shareList, Bool direct );
-
-
-extern Bool
-_real_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext ctx );
-
-extern int
-_real_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value );
-
-extern void
-_real_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask );
-
-extern void
-_real_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
- unsigned long *mask );
-
-#ifdef GLX_SGI_swap_control
-extern int
-_real_glXSwapIntervalSGI(int interval);
-#endif
-
-
-#ifdef GLX_SGI_video_sync
-extern int
-_real_glXGetVideoSyncSGI(unsigned int *count);
-
-extern int
-_real_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
-#endif
-
-
-#ifdef GLX_SGI_make_current_read
-extern Bool
-_real_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-
-extern GLXDrawable
-_real_glXGetCurrentReadDrawableSGI(void);
-#endif
-
-#if defined(_VL_H) && defined(GLX_SGIX_video_source)
-extern GLXVideoSourceSGIX
-_real_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
-
-extern void
-_real_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src);
-#endif
-
-#ifdef GLX_EXT_import_context
-extern void
-_real_glXFreeContextEXT(Display *dpy, GLXContext context);
-
-extern GLXContextID
-_real_glXGetContextIDEXT(const GLXContext context);
-
-extern Display *
-_real_glXGetCurrentDisplayEXT(void);
-
-extern GLXContext
-_real_glXImportContextEXT(Display *dpy, GLXContextID contextID);
-
-extern int
-_real_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value);
-#endif
-
-#ifdef GLX_SGIX_fbconfig
-extern int
-_real_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
-
-extern GLXFBConfigSGIX *
-_real_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements);
-
-extern GLXPixmap
-_real_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
-
-extern GLXContext
-_real_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
-
-extern XVisualInfo *
-_real_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config);
-
-extern GLXFBConfigSGIX
-_real_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis);
-#endif
-
-#ifdef GLX_SGIX_pbuffer
-extern GLXPbufferSGIX
-_real_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
-
-extern void
-_real_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf);
-
-extern int
-_real_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
-
-extern void
-_real_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask);
-
-extern void
-_real_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask);
-#endif
-
-#ifdef GLX_SGI_cushion
-extern void
-_real_glXCushionSGI(Display *dpy, Window win, float cushion);
-#endif
-
-#ifdef GLX_SGIX_video_resize
-extern int
-_real_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window);
-
-extern int
-_real_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h);
-
-extern int
-_real_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h);
-
-extern int
-_real_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
-
-extern int
-_real_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype);
-#endif
-
-#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
-extern Bool
-_real_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
-#endif
-
-#ifdef GLX_SGIX_swap_group
-extern void
-_real_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member);
-#endif
-
-#ifdef GLX_SGIX_swap_barrier
-extern void
-_real_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier);
-
-extern Bool
-_real_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max);
-#endif
-
-#ifdef GLX_SUN_get_transparent_index
-extern Status
-_real_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent);
-#endif
-
-#ifdef GLX_MESA_release_buffers
-extern Bool
-_real_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
-#endif
-
-#ifdef GLX_MESA_set_3dfx_mode
-extern Bool
-_real_glXSet3DfxModeMESA( int mode );
-#endif
-
-#ifdef GLX_NV_vertex_array_range
-extern void *
-_real_glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
-extern void
-_real_glXFreeMemoryNV(GLvoid *pointer);
-#endif
-
-#ifdef GLX_MESA_agp_offset
-extern GLuint
-_real_glXGetAGPOffsetMESA(const GLvoid *pointer);
-#endif
-
-#ifdef GLX_MESA_copy_sub_buffer
-extern void
-_real_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
- int x, int y, int width, int height );
-#endif
-
-#endif /* REALGLX_H */
diff --git a/src/mesa/pipe/xlib/xfonts.c b/src/mesa/pipe/xlib/xfonts.c
deleted file mode 100644
index d72c600bd1..0000000000
--- a/src/mesa/pipe/xlib/xfonts.c
+++ /dev/null
@@ -1,377 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2000 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.
- */
-
-
-/* xfonts.c -- glXUseXFont() for Mesa written by
- * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
- */
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include "glxheader.h"
-#include "context.h"
-#include "imports.h"
-#include "xfonts.h"
-
-
-/* Some debugging info. */
-
-#ifdef DEBUG
-#undef _R
-#undef _G
-#undef _B
-#include <ctype.h>
-
-int debug_xfonts = 0;
-
-static void
-dump_char_struct(XCharStruct * ch, char *prefix)
-{
- printf("%slbearing = %d, rbearing = %d, width = %d\n",
- prefix, ch->lbearing, ch->rbearing, ch->width);
- printf("%sascent = %d, descent = %d, attributes = %u\n",
- prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
-}
-
-static void
-dump_font_struct(XFontStruct * font)
-{
- printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
- printf("char_or_byte2 = (%u,%u)\n",
- font->min_char_or_byte2, font->max_char_or_byte2);
- printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
- printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
- printf("default_char = %c (\\%03o)\n",
- (char) (isprint(font->default_char) ? font->default_char : ' '),
- font->default_char);
- dump_char_struct(&font->min_bounds, "min> ");
- dump_char_struct(&font->max_bounds, "max> ");
-#if 0
- for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
- char prefix[8];
- sprintf(prefix, "%d> ", c);
- dump_char_struct(&font->per_char[c], prefix);
- }
-#endif
-}
-
-static void
-dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
-{
- unsigned int x, y;
-
- printf(" ");
- for (x = 0; x < 8 * width; x++)
- printf("%o", 7 - (x % 8));
- putchar('\n');
- for (y = 0; y < height; y++) {
- printf("%3o:", y);
- for (x = 0; x < 8 * width; x++)
- putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
- 8))))
- ? '*' : '.');
- printf(" ");
- for (x = 0; x < width; x++)
- printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
- putchar('\n');
- }
-}
-#endif /* DEBUG */
-
-
-/* Implementation. */
-
-/* Fill a BITMAP with a character C from thew current font
- in the graphics context GC. WIDTH is the width in bytes
- and HEIGHT is the height in bits.
-
- Note that the generated bitmaps must be used with
-
- glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
- glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
-
- Possible optimizations:
-
- * use only one reusable pixmap with the maximum dimensions.
- * draw the entire font into a single pixmap (careful with
- proportional fonts!).
-*/
-
-
-/*
- * Generate OpenGL-compatible bitmap.
- */
-static void
-fill_bitmap(Display * dpy, Window win, GC gc,
- unsigned int width, unsigned int height,
- int x0, int y0, unsigned int c, GLubyte * bitmap)
-{
- XImage *image;
- unsigned int x, y;
- Pixmap pixmap;
- XChar2b char2b;
-
- pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
- XSetForeground(dpy, gc, 0);
- XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
- XSetForeground(dpy, gc, 1);
-
- char2b.byte1 = (c >> 8) & 0xff;
- char2b.byte2 = (c & 0xff);
-
- XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
-
- image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
- if (image) {
- /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
- for (y = 0; y < height; y++)
- for (x = 0; x < 8 * width; x++)
- if (XGetPixel(image, x, y))
- bitmap[width * (height - y - 1) + x / 8] |=
- (1 << (7 - (x % 8)));
- XDestroyImage(image);
- }
-
- XFreePixmap(dpy, pixmap);
-}
-
-/*
- * determine if a given glyph is valid and return the
- * corresponding XCharStruct.
- */
-static XCharStruct *
-isvalid(XFontStruct * fs, unsigned int which)
-{
- unsigned int rows, pages;
- unsigned int byte1 = 0, byte2 = 0;
- int i, valid = 1;
-
- rows = fs->max_byte1 - fs->min_byte1 + 1;
- pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
-
- if (rows == 1) {
- /* "linear" fonts */
- if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
- valid = 0;
- }
- else {
- /* "matrix" fonts */
- byte2 = which & 0xff;
- byte1 = which >> 8;
- if ((fs->min_char_or_byte2 > byte2) ||
- (fs->max_char_or_byte2 < byte2) ||
- (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
- valid = 0;
- }
-
- if (valid) {
- if (fs->per_char) {
- if (rows == 1) {
- /* "linear" fonts */
- return (fs->per_char + (which - fs->min_char_or_byte2));
- }
- else {
- /* "matrix" fonts */
- i = ((byte1 - fs->min_byte1) * pages) +
- (byte2 - fs->min_char_or_byte2);
- return (fs->per_char + i);
- }
- }
- else {
- return (&fs->min_bounds);
- }
- }
- return (NULL);
-}
-
-
-void
-Fake_glXUseXFont(Font font, int first, int count, int listbase)
-{
- Display *dpy;
- Window win;
- Pixmap pixmap;
- GC gc;
- XGCValues values;
- unsigned long valuemask;
- XFontStruct *fs;
- GLint swapbytes, lsbfirst, rowlength;
- GLint skiprows, skippixels, alignment;
- unsigned int max_width, max_height, max_bm_width, max_bm_height;
- GLubyte *bm;
- int i;
-
- dpy = glXGetCurrentDisplay();
- if (!dpy)
- return; /* I guess glXMakeCurrent wasn't called */
- win = RootWindow(dpy, DefaultScreen(dpy));
-
- fs = XQueryFont(dpy, font);
- if (!fs) {
- _mesa_error(NULL, GL_INVALID_VALUE,
- "Couldn't get font structure information");
- return;
- }
-
- /* Allocate a bitmap that can fit all characters. */
- max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
- max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
- max_bm_width = (max_width + 7) / 8;
- max_bm_height = max_height;
-
- bm = (GLubyte *) MALLOC((max_bm_width * max_bm_height) * sizeof(GLubyte));
- if (!bm) {
- XFreeFontInfo(NULL, fs, 1);
- _mesa_error(NULL, GL_OUT_OF_MEMORY,
- "Couldn't allocate bitmap in glXUseXFont()");
- return;
- }
-
-#if 0
- /* get the page info */
- pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
- firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
- lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
- rows = fs->max_byte1 - fs->min_byte1 + 1;
- unsigned int first_char, last_char, pages, rows;
-#endif
-
- /* Save the current packing mode for bitmaps. */
- glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
- glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
- glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
- glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
- glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
- glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
-
- /* Enforce a standard packing mode which is compatible with
- fill_bitmap() from above. This is actually the default mode,
- except for the (non)alignment. */
- glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
- glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-
- pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
- values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
- values.background = WhitePixel(dpy, DefaultScreen(dpy));
- values.font = fs->fid;
- valuemask = GCForeground | GCBackground | GCFont;
- gc = XCreateGC(dpy, pixmap, valuemask, &values);
- XFreePixmap(dpy, pixmap);
-
-#ifdef DEBUG
- if (debug_xfonts)
- dump_font_struct(fs);
-#endif
-
- for (i = 0; i < count; i++) {
- unsigned int width, height, bm_width, bm_height;
- GLfloat x0, y0, dx, dy;
- XCharStruct *ch;
- int x, y;
- unsigned int c = first + i;
- int list = listbase + i;
- int valid;
-
- /* check on index validity and get the bounds */
- ch = isvalid(fs, c);
- if (!ch) {
- ch = &fs->max_bounds;
- valid = 0;
- }
- else {
- valid = 1;
- }
-
-#ifdef DEBUG
- if (debug_xfonts) {
- char s[7];
- sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
- dump_char_struct(ch, s);
- }
-#endif
-
- /* glBitmap()' parameters:
- straight from the glXUseXFont(3) manpage. */
- width = ch->rbearing - ch->lbearing;
- height = ch->ascent + ch->descent;
- x0 = -ch->lbearing;
- y0 = ch->descent - 0; /* XXX used to subtract 1 here */
- /* but that caused a conformace failure */
- dx = ch->width;
- dy = 0;
-
- /* X11's starting point. */
- x = -ch->lbearing;
- y = ch->ascent;
-
- /* Round the width to a multiple of eight. We will use this also
- for the pixmap for capturing the X11 font. This is slightly
- inefficient, but it makes the OpenGL part real easy. */
- bm_width = (width + 7) / 8;
- bm_height = height;
-
- glNewList(list, GL_COMPILE);
- if (valid && (bm_width > 0) && (bm_height > 0)) {
-
- MEMSET(bm, '\0', bm_width * bm_height);
- fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
-
- glBitmap(width, height, x0, y0, dx, dy, bm);
-#ifdef DEBUG
- if (debug_xfonts) {
- printf("width/height = %u/%u\n", width, height);
- printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
- dump_bitmap(bm_width, bm_height, bm);
- }
-#endif
- }
- else {
- glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
- }
- glEndList();
- }
-
- FREE(bm);
- XFreeFontInfo(NULL, fs, 1);
- XFreeGC(dpy, gc);
-
- /* Restore saved packing modes. */
- glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
- glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
- glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
-}
diff --git a/src/mesa/pipe/xlib/xfonts.h b/src/mesa/pipe/xlib/xfonts.h
deleted file mode 100644
index e36f42f817..0000000000
--- a/src/mesa/pipe/xlib/xfonts.h
+++ /dev/null
@@ -1,41 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2000 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.
- */
-
-
-#ifndef XFONTS_H
-#define XFONTS_H
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include <X11/Xlib.h>
-
-
-extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
-
-
-#endif
-
diff --git a/src/mesa/pipe/xlib/xm_api.c b/src/mesa/pipe/xlib/xm_api.c
deleted file mode 100644
index e5fef1d7a8..0000000000
--- a/src/mesa/pipe/xlib/xm_api.c
+++ /dev/null
@@ -1,1380 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 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.
- */
-
-/**
- * \file xm_api.c
- *
- * All the XMesa* API functions.
- *
- *
- * NOTES:
- *
- * The window coordinate system origin (0,0) is in the lower-left corner
- * of the window. X11's window coordinate origin is in the upper-left
- * corner of the window. Therefore, most drawing functions in this
- * file have to flip Y coordinates.
- *
- * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile
- * in support for the MIT Shared Memory extension. If enabled, when you
- * use an Ximage for the back buffer in double buffered mode, the "swap"
- * operation will be faster. You must also link with -lXext.
- *
- * Byte swapping: If the Mesa host and the X display use a different
- * byte order then there's some trickiness to be aware of when using
- * XImages. The byte ordering used for the XImage is that of the X
- * display, not the Mesa host.
- * The color-to-pixel encoding for True/DirectColor must be done
- * according to the display's visual red_mask, green_mask, and blue_mask.
- * If XPutPixel is used to put a pixel into an XImage then XPutPixel will
- * do byte swapping if needed. If one wants to directly "poke" the pixel
- * into the XImage's buffer then the pixel must be byte swapped first.
- *
- */
-
-#ifdef __CYGWIN__
-#undef WIN32
-#undef __WIN32__
-#endif
-
-#include "glxheader.h"
-#include "GL/xmesa.h"
-#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_context.h"
-
-#include "xm_winsys_aub.h"
-
-/**
- * Global X driver lock
- */
-_glthread_Mutex _xmesa_lock;
-
-
-int xmesa_mode;
-
-
-/**********************************************************************/
-/***** X Utility Functions *****/
-/**********************************************************************/
-
-
-/**
- * Return the host's byte order as LSBFirst or MSBFirst ala X.
- */
-#ifndef XFree86Server
-static int host_byte_order( void )
-{
- int i = 1;
- char *cptr = (char *) &i;
- return (*cptr==1) ? LSBFirst : MSBFirst;
-}
-#endif
-
-
-/**
- * Check if the X Shared Memory extension is available.
- * Return: 0 = not available
- * 1 = shared XImage support available
- * 2 = shared Pixmap support available also
- */
-static int check_for_xshm( XMesaDisplay *display )
-{
-#if defined(USE_XSHM) && !defined(XFree86Server)
- int major, minor, ignore;
- Bool pixmaps;
-
- if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) {
- if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) {
- return (pixmaps==True) ? 2 : 1;
- }
- else {
- return 0;
- }
- }
- else {
- return 0;
- }
-#else
- /* No XSHM support */
- return 0;
-#endif
-}
-
-
-/**
- * Return the true number of bits per pixel for XImages.
- * For example, if we request a 24-bit deep visual we may actually need/get
- * 32bpp XImages. This function returns the appropriate bpp.
- * Input: dpy - the X display
- * visinfo - desribes the visual to be used for XImages
- * Return: true number of bits per pixel for XImages
- */
-static int
-bits_per_pixel( XMesaVisual xmv )
-{
-#ifdef XFree86Server
- const int depth = xmv->nplanes;
- int i;
- assert(depth > 0);
- for (i = 0; i < screenInfo.numPixmapFormats; i++) {
- if (screenInfo.formats[i].depth == depth)
- return screenInfo.formats[i].bitsPerPixel;
- }
- return depth; /* should never get here, but this should be safe */
-#else
- XMesaDisplay *dpy = xmv->display;
- XMesaVisualInfo visinfo = xmv->visinfo;
- XMesaImage *img;
- int bitsPerPixel;
- /* Create a temporary XImage */
- img = XCreateImage( dpy, visinfo->visual, visinfo->depth,
- ZPixmap, 0, /*format, offset*/
- (char*) MALLOC(8), /*data*/
- 1, 1, /*width, height*/
- 32, /*bitmap_pad*/
- 0 /*bytes_per_line*/
- );
- assert(img);
- /* grab the bits/pixel value */
- bitsPerPixel = img->bits_per_pixel;
- /* free the XImage */
- _mesa_free( img->data );
- img->data = NULL;
- XMesaDestroyImage( img );
- return bitsPerPixel;
-#endif
-}
-
-
-
-/*
- * Determine if a given X window ID is valid (window exists).
- * Do this by calling XGetWindowAttributes() for the window and
- * checking if we catch an X error.
- * Input: dpy - the display
- * win - the window to check for existance
- * Return: GL_TRUE - window exists
- * GL_FALSE - window doesn't exist
- */
-#ifndef XFree86Server
-static GLboolean WindowExistsFlag;
-
-static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
-{
- (void) dpy;
- if (xerr->error_code == BadWindow) {
- WindowExistsFlag = GL_FALSE;
- }
- return 0;
-}
-
-static GLboolean window_exists( XMesaDisplay *dpy, Window win )
-{
- XWindowAttributes wa;
- int (*old_handler)( XMesaDisplay*, XErrorEvent* );
- WindowExistsFlag = GL_TRUE;
- old_handler = XSetErrorHandler(window_exists_err_handler);
- XGetWindowAttributes( dpy, win, &wa ); /* dummy request */
- XSetErrorHandler(old_handler);
- return WindowExistsFlag;
-}
-
-static Status
-get_drawable_size( XMesaDisplay *dpy, Drawable d, uint *width, uint *height )
-{
- Window root;
- Status stat;
- int xpos, ypos;
- unsigned int w, h, bw, depth;
- stat = XGetGeometry(dpy, d, &root, &xpos, &ypos, &w, &h, &bw, &depth);
- *width = w;
- *height = h;
- return stat;
-}
-#endif
-
-
-/**
- * Return the size of the window (or pixmap) that corresponds to the
- * given XMesaBuffer.
- * \param width returns width in pixels
- * \param height returns height in pixels
- */
-static void
-xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
- GLuint *width, GLuint *height)
-{
-#ifdef XFree86Server
- *width = MIN2(b->drawable->width, MAX_WIDTH);
- *height = MIN2(b->drawable->height, MAX_HEIGHT);
-#else
- Status stat;
-
- _glthread_LOCK_MUTEX(_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);
-
- if (!stat) {
- /* probably querying a window that's recently been destroyed */
- _mesa_warning(NULL, "XGetGeometry failed!\n");
- *width = *height = 1;
- }
-#endif
-}
-
-
-/**
- * Choose the pixel format for the given visual.
- * This will tell the gallium driver how to pack pixel data into
- * drawing surfaces.
- */
-static GLuint
-choose_pixel_format(XMesaVisual v)
-{
- if ( GET_REDMASK(v) == 0x0000ff
- && GET_GREENMASK(v) == 0x00ff00
- && GET_BLUEMASK(v) == 0xff0000
- && v->BitsPerPixel == 32) {
- if (CHECK_BYTE_ORDER(v)) {
- /* no byteswapping needed */
- return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */;
- }
- else {
- return PIPE_FORMAT_R8G8B8A8_UNORM;
- }
- }
- else if ( GET_REDMASK(v) == 0xff0000
- && GET_GREENMASK(v) == 0x00ff00
- && GET_BLUEMASK(v) == 0x0000ff
- && v->BitsPerPixel == 32) {
- if (CHECK_BYTE_ORDER(v)) {
- /* no byteswapping needed */
- return PIPE_FORMAT_A8R8G8B8_UNORM;
- }
- else {
- return PIPE_FORMAT_B8G8R8A8_UNORM;
- }
- }
- else if ( GET_REDMASK(v) == 0xf800
- && GET_GREENMASK(v) == 0x07e0
- && GET_BLUEMASK(v) == 0x001f
- && CHECK_BYTE_ORDER(v)
- && v->BitsPerPixel == 16) {
- /* 5-6-5 RGB */
- return PIPE_FORMAT_R5G6B5_UNORM;
- }
-
- assert(0);
- return 0;
-}
-
-
-
-/**********************************************************************/
-/***** Linked list of XMesaBuffers *****/
-/**********************************************************************/
-
-XMesaBuffer XMesaBufferList = NULL;
-
-
-/**
- * Allocate a new XMesaBuffer object which corresponds to the given drawable.
- * Note that XMesaBuffer is derived from GLframebuffer.
- * The new XMesaBuffer will not have any size (Width=Height=0).
- *
- * \param d the corresponding X drawable (window or pixmap)
- * \param type either WINDOW, PIXMAP or PBUFFER, describing d
- * \param vis the buffer's visual
- * \param cmap the window's colormap, if known.
- * \return new XMesaBuffer or NULL if any problem
- */
-static XMesaBuffer
-create_xmesa_buffer(XMesaDrawable d, BufferType type,
- XMesaVisual vis, XMesaColormap cmap)
-{
- XMesaBuffer b;
- GLframebuffer *fb;
- enum pipe_format colorFormat, depthFormat, stencilFormat;
- uint width, height;
-
- ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
-
- b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer);
- if (!b)
- return NULL;
-
- b->drawable = d;
-
- b->xm_visual = vis;
- b->type = type;
- b->cmap = cmap;
-
- /* determine PIPE_FORMATs for buffers */
- colorFormat = choose_pixel_format(vis);
-
- if (vis->mesa_visual.depthBits == 0)
- depthFormat = PIPE_FORMAT_NONE;
- else if (vis->mesa_visual.depthBits <= 16)
- depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (vis->mesa_visual.depthBits <= 24)
- depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- depthFormat = PIPE_FORMAT_Z32_UNORM;
-
- if (vis->mesa_visual.stencilBits == 8) {
- if (depthFormat == PIPE_FORMAT_S8Z24_UNORM)
- stencilFormat = depthFormat;
- else
- stencilFormat = PIPE_FORMAT_S8_UNORM;
- }
- else {
- stencilFormat = PIPE_FORMAT_NONE;
- }
-
-
- get_drawable_size(vis->display, d, &width, &height);
-
- /*
- * Create framebuffer, but we'll plug in our own renderbuffers below.
- */
- b->stfb = st_create_framebuffer(&vis->mesa_visual,
- colorFormat, depthFormat, stencilFormat,
- width, height,
- (void *) b);
- fb = &b->stfb->Base;
-
- /*
- * Create scratch XImage for xmesa_display_surface()
- */
- b->tempImage = XCreateImage(vis->display,
- vis->visinfo->visual,
- vis->visinfo->depth,
- ZPixmap, 0, /* format, offset */
- NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
- 0); /* bytes_per_line */
-
- /* GLX_EXT_texture_from_pixmap */
- b->TextureTarget = 0;
- b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT;
- b->TextureMipmap = 0;
-
- /* insert buffer into linked list */
- b->Next = XMesaBufferList;
- XMesaBufferList = b;
-
- return b;
-}
-
-
-/**
- * Find an XMesaBuffer by matching X display and colormap but NOT matching
- * the notThis buffer.
- */
-XMesaBuffer
-xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis)
-{
- XMesaBuffer b;
- for (b = XMesaBufferList; b; b = b->Next) {
- if (b->xm_visual->display == dpy &&
- b->cmap == cmap &&
- b != notThis) {
- return b;
- }
- }
- return NULL;
-}
-
-
-/**
- * Remove buffer from linked list, delete if no longer referenced.
- */
-static void
-xmesa_free_buffer(XMesaBuffer buffer)
-{
- XMesaBuffer prev = NULL, b;
-
- for (b = XMesaBufferList; b; b = b->Next) {
- if (b == buffer) {
- struct gl_framebuffer *fb = &buffer->stfb->Base;
-
- /* unlink buffer from list */
- if (prev)
- prev->Next = buffer->Next;
- else
- XMesaBufferList = buffer->Next;
-
- /* mark as delete pending */
- fb->DeletePending = GL_TRUE;
-
- /* Since the X window for the XMesaBuffer is going away, we don't
- * want to dereference this pointer in the future.
- */
- b->drawable = 0;
-
- buffer->tempImage->data = NULL;
- XDestroyImage(buffer->tempImage);
-
- /* Unreference. If count = zero we'll really delete the buffer */
- _mesa_unreference_framebuffer(&fb);
-
- XFreeGC(b->xm_visual->display, b->gc);
-
- free(buffer);
-
- return;
- }
- /* continue search */
- prev = b;
- }
- /* buffer not found in XMesaBufferList */
- _mesa_problem(NULL,"xmesa_free_buffer() - buffer not found\n");
-}
-
-
-
-/**********************************************************************/
-/***** Misc Private Functions *****/
-/**********************************************************************/
-
-
-/**
- * When a context is bound for the first time, we can finally finish
- * initializing the context's visual and buffer information.
- * \param v the XMesaVisual to initialize
- * \param b the XMesaBuffer to initialize (may be NULL)
- * \param rgb_flag TRUE = RGBA mode, FALSE = color index mode
- * \param window the window/pixmap we're rendering into
- * \param cmap the colormap associated with the window/pixmap
- * \return GL_TRUE=success, GL_FALSE=failure
- */
-static GLboolean
-initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
- GLboolean rgb_flag, XMesaDrawable window,
- XMesaColormap cmap)
-{
-#ifdef XFree86Server
- int client = (window) ? CLIENT_ID(window->id) : 0;
-#endif
-
- ASSERT(!b || b->xm_visual == v);
-
- /* Save true bits/pixel */
- v->BitsPerPixel = bits_per_pixel(v);
- assert(v->BitsPerPixel > 0);
-
- if (rgb_flag == GL_FALSE) {
- /* COLOR-INDEXED WINDOW: not supported*/
- return GL_FALSE;
- }
- else {
- /* RGB WINDOW:
- * We support RGB rendering into almost any kind of visual.
- */
- const int xclass = v->mesa_visual.visualType;
- if (xclass != GLX_TRUE_COLOR && xclass == !GLX_DIRECT_COLOR) {
- _mesa_warning(NULL,
- "XMesa: RGB mode rendering not supported in given visual.\n");
- return GL_FALSE;
- }
- v->mesa_visual.indexBits = 0;
- }
-
- /*
- * If MESA_INFO env var is set print out some debugging info
- * which can help Brian figure out what's going on when a user
- * reports bugs.
- */
- if (_mesa_getenv("MESA_INFO")) {
- _mesa_printf("X/Mesa visual = %p\n", (void *) v);
- _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level);
- _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v));
- _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel);
- }
-
- if (b && window) {
- /* these should have been set in create_xmesa_buffer */
- ASSERT(b->drawable == window);
-
- /* Setup for single/double buffering */
- if (v->mesa_visual.doubleBufferMode) {
- /* Double buffered */
- b->shm = check_for_xshm( v->display );
- }
-
- /* X11 graphics context */
-#ifdef XFree86Server
- b->gc = CreateScratchGC(v->display, window->depth);
-#else
- b->gc = XCreateGC( v->display, window, 0, NULL );
-#endif
- XMesaSetFunction( v->display, b->gc, GXcopy );
- }
-
- return GL_TRUE;
-}
-
-
-
-#define NUM_VISUAL_TYPES 6
-
-/**
- * Convert an X visual type to a GLX visual type.
- *
- * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
- * to be converted.
- * \return If \c visualType is a valid X visual type, a GLX visual type will
- * be returned. Otherwise \c GLX_NONE will be returned.
- *
- * \note
- * This code was lifted directly from lib/GL/glx/glcontextmodes.c in the
- * DRI CVS tree.
- */
-static GLint
-xmesa_convert_from_x_visual_type( int visualType )
-{
- static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
- GLX_STATIC_GRAY, GLX_GRAY_SCALE,
- GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
- GLX_TRUE_COLOR, GLX_DIRECT_COLOR
- };
-
- return ( (unsigned) visualType < NUM_VISUAL_TYPES )
- ? glx_visual_types[ visualType ] : GLX_NONE;
-}
-
-
-/**********************************************************************/
-/***** Public Functions *****/
-/**********************************************************************/
-
-
-/*
- * Create a new X/Mesa visual.
- * Input: display - X11 display
- * visinfo - an XVisualInfo pointer
- * rgb_flag - GL_TRUE = RGB mode,
- * GL_FALSE = color index mode
- * alpha_flag - alpha buffer requested?
- * db_flag - GL_TRUE = double-buffered,
- * GL_FALSE = single buffered
- * stereo_flag - stereo visual?
- * ximage_flag - GL_TRUE = use an XImage for back buffer,
- * GL_FALSE = use an off-screen pixmap for back buffer
- * depth_size - requested bits/depth values, or zero
- * stencil_size - requested bits/stencil values, or zero
- * accum_red_size - requested bits/red accum values, or zero
- * accum_green_size - requested bits/green accum values, or zero
- * accum_blue_size - requested bits/blue accum values, or zero
- * accum_alpha_size - requested bits/alpha accum values, or zero
- * num_samples - number of samples/pixel if multisampling, or zero
- * level - visual level, usually 0
- * visualCaveat - ala the GLX extension, usually GLX_NONE
- * Return; a new XMesaVisual or 0 if error.
- */
-PUBLIC
-XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
- XMesaVisualInfo visinfo,
- GLboolean rgb_flag,
- GLboolean alpha_flag,
- GLboolean db_flag,
- GLboolean stereo_flag,
- GLboolean ximage_flag,
- GLint depth_size,
- GLint stencil_size,
- GLint accum_red_size,
- GLint accum_green_size,
- GLint accum_blue_size,
- GLint accum_alpha_size,
- GLint num_samples,
- GLint level,
- GLint visualCaveat )
-{
- XMesaVisual v;
- GLint red_bits, green_bits, blue_bits, alpha_bits;
-
-#ifndef XFree86Server
- /* For debugging only */
- if (_mesa_getenv("MESA_XSYNC")) {
- /* This makes debugging X easier.
- * In your debugger, set a breakpoint on _XError to stop when an
- * X protocol error is generated.
- */
- XSynchronize( display, 1 );
- }
-#endif
-
- v = (XMesaVisual) CALLOC_STRUCT(xmesa_visual);
- if (!v) {
- return NULL;
- }
-
- v->display = display;
-
- /* Save a copy of the XVisualInfo struct because the user may X_mesa_free()
- * the struct but we may need some of the information contained in it
- * at a later time.
- */
-#ifndef XFree86Server
- v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
- if(!v->visinfo) {
- _mesa_free(v);
- return NULL;
- }
- MEMCPY(v->visinfo, visinfo, sizeof(*visinfo));
-#endif
-
- v->ximage_flag = ximage_flag;
-
-#ifdef XFree86Server
- /* We could calculate these values by ourselves. nplanes is either the sum
- * of the red, green, and blue bits or the number index bits.
- * ColormapEntries is either (1U << index_bits) or
- * (1U << max(redBits, greenBits, blueBits)).
- */
- assert(visinfo->nplanes > 0);
- v->nplanes = visinfo->nplanes;
- v->ColormapEntries = visinfo->ColormapEntries;
-
- v->mesa_visual.redMask = visinfo->redMask;
- v->mesa_visual.greenMask = visinfo->greenMask;
- v->mesa_visual.blueMask = visinfo->blueMask;
- v->mesa_visual.visualID = visinfo->vid;
- v->mesa_visual.screen = 0; /* FIXME: What should be done here? */
-#else
- v->mesa_visual.redMask = visinfo->red_mask;
- v->mesa_visual.greenMask = visinfo->green_mask;
- v->mesa_visual.blueMask = visinfo->blue_mask;
- v->mesa_visual.visualID = visinfo->visualid;
- v->mesa_visual.screen = visinfo->screen;
-#endif
-
-#if defined(XFree86Server) || !(defined(__cplusplus) || defined(c_plusplus))
- v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->class);
-#else
- v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->c_class);
-#endif
-
- v->mesa_visual.visualRating = visualCaveat;
-
- if (alpha_flag)
- v->mesa_visual.alphaBits = 8;
-
- (void) initialize_visual_and_buffer( v, NULL, rgb_flag, 0, 0 );
-
- {
- const int xclass = v->mesa_visual.visualType;
- if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
- red_bits = _mesa_bitcount(GET_REDMASK(v));
- green_bits = _mesa_bitcount(GET_GREENMASK(v));
- blue_bits = _mesa_bitcount(GET_BLUEMASK(v));
- }
- else {
- /* this is an approximation */
- int depth;
- depth = GET_VISUAL_DEPTH(v);
- red_bits = depth / 3;
- depth -= red_bits;
- green_bits = depth / 2;
- depth -= green_bits;
- blue_bits = depth;
- alpha_bits = 0;
- assert( red_bits + green_bits + blue_bits == GET_VISUAL_DEPTH(v) );
- }
- alpha_bits = v->mesa_visual.alphaBits;
- }
-
- _mesa_initialize_visual( &v->mesa_visual,
- rgb_flag, db_flag, stereo_flag,
- red_bits, green_bits,
- blue_bits, alpha_bits,
- v->mesa_visual.indexBits,
- depth_size,
- stencil_size,
- accum_red_size, accum_green_size,
- accum_blue_size, accum_alpha_size,
- 0 );
-
- /* XXX minor hack */
- v->mesa_visual.level = level;
- return v;
-}
-
-
-PUBLIC
-void XMesaDestroyVisual( XMesaVisual v )
-{
-#ifndef XFree86Server
- _mesa_free(v->visinfo);
-#endif
- _mesa_free(v);
-}
-
-
-
-/**
- * Create a new XMesaContext.
- * \param v the XMesaVisual
- * \param share_list another XMesaContext with which to share display
- * lists or NULL if no sharing is wanted.
- * \return an XMesaContext or NULL if error.
- */
-PUBLIC
-XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
-{
- static GLboolean firstTime = GL_TRUE;
- struct pipe_context *pipe;
- XMesaContext c;
- GLcontext *mesaCtx;
- uint pf;
-
- if (firstTime) {
- _glthread_INIT_MUTEX(_xmesa_lock);
- firstTime = GL_FALSE;
- }
-
- /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
- c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
- if (!c)
- return NULL;
-
- pf = choose_pixel_format(v);
- assert(pf);
-
- if (!getenv("XM_AUB")) {
- xmesa_mode = XMESA_SOFTPIPE;
- pipe = xmesa_create_pipe_context( c, pf );
- }
- else {
- xmesa_mode = XMESA_AUB;
- pipe = xmesa_create_i965simple( xmesa_get_pipe_winsys_aub() );
- }
-
- c->st = st_create_context(pipe, &v->mesa_visual,
- share_list ? share_list->st : NULL);
- mesaCtx = c->st->ctx;
- c->st->ctx->DriverCtx = c;
-
-#if 00
- _mesa_enable_sw_extensions(mesaCtx);
- _mesa_enable_1_3_extensions(mesaCtx);
- _mesa_enable_1_4_extensions(mesaCtx);
- _mesa_enable_1_5_extensions(mesaCtx);
- _mesa_enable_2_0_extensions(mesaCtx);
-#endif
-
-#ifdef XFree86Server
- /* If we're running in the X server, do bounds checking to prevent
- * segfaults and server crashes!
- */
- mesaCtx->Const.CheckArrayBounds = GL_TRUE;
-#endif
-
- /* finish up xmesa context initializations */
- c->xm_visual = v;
- c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
-
- c->st->haveFramebufferSurfaces = GL_TRUE;
-
- return c;
-}
-
-
-
-PUBLIC
-void XMesaDestroyContext( XMesaContext c )
-{
- st_destroy_context(c->st);
- _mesa_free(c);
-}
-
-
-
-/**
- * Private function for creating an XMesaBuffer which corresponds to an
- * X window or pixmap.
- * \param v the window's XMesaVisual
- * \param w the window we're wrapping
- * \return new XMesaBuffer or NULL if error
- */
-PUBLIC XMesaBuffer
-XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w)
-{
-#ifndef XFree86Server
- XWindowAttributes attr;
-#endif
- XMesaBuffer b;
- XMesaColormap cmap;
- int depth;
-
- assert(v);
- assert(w);
-
- /* Check that window depth matches visual depth */
-#ifdef XFree86Server
- depth = ((XMesaDrawable)w)->depth;
-#else
- XGetWindowAttributes( v->display, w, &attr );
- depth = attr.depth;
-#endif
- if (GET_VISUAL_DEPTH(v) != depth) {
- _mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
- GET_VISUAL_DEPTH(v), depth);
- return NULL;
- }
-
- /* Find colormap */
-#ifdef XFree86Server
- cmap = (ColormapPtr)LookupIDByType(wColormap(w), RT_COLORMAP);
-#else
- if (attr.colormap) {
- cmap = attr.colormap;
- }
- else {
- _mesa_warning(NULL, "Window %u has no colormap!\n", (unsigned int) w);
- /* this is weird, a window w/out a colormap!? */
- /* OK, let's just allocate a new one and hope for the best */
- cmap = XCreateColormap(v->display, w, attr.visual, AllocNone);
- }
-#endif
-
- b = create_xmesa_buffer((XMesaDrawable) w, WINDOW, v, cmap);
- if (!b)
- return NULL;
-
- if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) w, cmap )) {
- xmesa_free_buffer(b);
- return NULL;
- }
-
- return b;
-}
-
-
-
-/**
- * Create a new XMesaBuffer from an X pixmap.
- *
- * \param v the XMesaVisual
- * \param p the pixmap
- * \param cmap the colormap, may be 0 if using a \c GLX_TRUE_COLOR or
- * \c GLX_DIRECT_COLOR visual for the pixmap
- * \returns new XMesaBuffer or NULL if error
- */
-PUBLIC XMesaBuffer
-XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
-{
- XMesaBuffer b;
-
- assert(v);
-
- b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap);
- if (!b)
- return NULL;
-
- if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) p, cmap)) {
- xmesa_free_buffer(b);
- return NULL;
- }
-
- return b;
-}
-
-
-/**
- * For GLX_EXT_texture_from_pixmap
- */
-XMesaBuffer
-XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
- XMesaColormap cmap,
- int format, int target, int mipmap)
-{
- GET_CURRENT_CONTEXT(ctx);
- XMesaBuffer b;
- GLuint width, height;
-
- assert(v);
-
- b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap);
- if (!b)
- return NULL;
-
- /* get pixmap size, update framebuffer/renderbuffer dims */
- xmesa_get_window_size(v->display, b, &width, &height);
- _mesa_resize_framebuffer(NULL, &(b->stfb->Base), width, height);
-
- if (target == 0) {
- /* examine dims */
- if (ctx->Extensions.ARB_texture_non_power_of_two) {
- target = GLX_TEXTURE_2D_EXT;
- }
- else if ( _mesa_bitcount(width) == 1
- && _mesa_bitcount(height) == 1) {
- /* power of two size */
- if (height == 1) {
- target = GLX_TEXTURE_1D_EXT;
- }
- else {
- target = GLX_TEXTURE_2D_EXT;
- }
- }
- else if (ctx->Extensions.NV_texture_rectangle) {
- target = GLX_TEXTURE_RECTANGLE_EXT;
- }
- else {
- /* non power of two textures not supported */
- XMesaDestroyBuffer(b);
- return 0;
- }
- }
-
- b->TextureTarget = target;
- b->TextureFormat = format;
- b->TextureMipmap = mipmap;
-
- if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) p, cmap)) {
- xmesa_free_buffer(b);
- return NULL;
- }
-
- return b;
-}
-
-
-
-XMesaBuffer
-XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
- unsigned int width, unsigned int height)
-{
-#ifndef XFree86Server
- XMesaWindow root;
- XMesaDrawable drawable; /* X Pixmap Drawable */
- XMesaBuffer b;
-
- /* allocate pixmap for front buffer */
- root = RootWindow( v->display, v->visinfo->screen );
- drawable = XCreatePixmap(v->display, root, width, height,
- v->visinfo->depth);
- if (!drawable)
- return NULL;
-
- b = create_xmesa_buffer(drawable, PBUFFER, v, cmap);
- if (!b)
- return NULL;
-
- if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
- drawable, cmap)) {
- xmesa_free_buffer(b);
- return NULL;
- }
-
- return b;
-#else
- return 0;
-#endif
-}
-
-
-
-/*
- * Deallocate an XMesaBuffer structure and all related info.
- */
-PUBLIC void
-XMesaDestroyBuffer(XMesaBuffer b)
-{
- xmesa_free_buffer(b);
-}
-
-
-/**
- * Query the current window size and update the corresponding GLframebuffer
- * and all attached renderbuffers.
- * Called when:
- * 1. the first time a buffer is bound to a context.
- * 2. from the XMesaResizeBuffers() API function.
- * 3. SwapBuffers. XXX probabaly from xm_flush_frontbuffer() too...
- * Note: it's possible (and legal) for xmctx to be NULL. That can happen
- * when resizing a buffer when no rendering context is bound.
- */
-void
-xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer)
-{
- GLuint width, height;
- xmesa_get_window_size(drawBuffer->xm_visual->display, drawBuffer, &width, &height);
- st_resize_framebuffer(drawBuffer->stfb, width, height);
-}
-
-
-/*
- * Bind buffer b to context c and make c the current rendering context.
- */
-GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b )
-{
- return XMesaMakeCurrent2( c, b, b );
-}
-
-
-/*
- * Bind buffer b to context c and make c the current rendering context.
- */
-PUBLIC
-GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
- XMesaBuffer readBuffer )
-{
- if (c) {
- if (!drawBuffer || !readBuffer)
- return GL_FALSE; /* must specify buffers! */
-
-#if 0
- /* XXX restore this optimization */
- if (&(c->mesa) == _mesa_get_current_context()
- && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
- && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
- && xmesa_buffer(c->mesa.DrawBuffer)->wasCurrent) {
- /* same context and buffer, do nothing */
- return GL_TRUE;
- }
-#endif
-
- c->xm_buffer = drawBuffer;
-
- /* Call this periodically to detect when the user has begun using
- * GL rendering from multiple threads.
- */
- _glapi_check_multithread();
-
- st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb);
-
- xmesa_check_and_update_buffer_size(c, drawBuffer);
- if (readBuffer != drawBuffer)
- xmesa_check_and_update_buffer_size(c, readBuffer);
-
- /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
- drawBuffer->wasCurrent = GL_TRUE;
- }
- else {
- /* Detach */
- st_make_current( NULL, NULL, NULL );
- }
- return GL_TRUE;
-}
-
-
-/*
- * Unbind the context c from its buffer.
- */
-GLboolean XMesaUnbindContext( XMesaContext c )
-{
- /* A no-op for XFree86 integration purposes */
- return GL_TRUE;
-}
-
-
-XMesaContext XMesaGetCurrentContext( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- XMesaContext xmesa = xmesa_context(ctx);
- return xmesa;
- }
- else {
- return 0;
- }
-}
-
-
-XMesaBuffer XMesaGetCurrentBuffer( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- XMesaBuffer xmbuf = xmesa_buffer(ctx->DrawBuffer);
- return xmbuf;
- }
- else {
- return 0;
- }
-}
-
-
-/* New in Mesa 3.1 */
-XMesaBuffer XMesaGetCurrentReadBuffer( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- return xmesa_buffer(ctx->ReadBuffer);
- }
- else {
- return 0;
- }
-}
-
-
-#ifdef XFree86Server
-PUBLIC
-GLboolean XMesaForceCurrent(XMesaContext c)
-{
- if (c) {
- _glapi_set_dispatch(c->mesa.CurrentDispatch);
-
- if (&(c->mesa) != _mesa_get_current_context()) {
- _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer);
- }
- }
- else {
- _mesa_make_current(NULL, NULL, NULL);
- }
- return GL_TRUE;
-}
-
-
-PUBLIC
-GLboolean XMesaLoseCurrent(XMesaContext c)
-{
- (void) c;
- _mesa_make_current(NULL, NULL, NULL);
- return GL_TRUE;
-}
-
-
-PUBLIC
-GLboolean XMesaCopyContext( XMesaContext xm_src, XMesaContext xm_dst, GLuint mask )
-{
- _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask);
- return GL_TRUE;
-}
-#endif /* XFree86Server */
-
-
-#ifndef FX
-GLboolean XMesaSetFXmode( GLint mode )
-{
- (void) mode;
- return GL_FALSE;
-}
-#endif
-
-
-
-/*
- * Copy the back buffer to the front buffer. If there's no back buffer
- * this is a no-op.
- */
-PUBLIC
-void XMesaSwapBuffers( XMesaBuffer b )
-{
- struct pipe_surface *surf;
-
- /* If we're swapping the buffer associated with the current context
- * we have to flush any pending rendering commands first.
- */
- st_notify_swapbuffers(b->stfb);
-
- surf = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT);
- if (surf) {
- if (xmesa_mode == XMESA_AUB)
- xmesa_display_aub( surf );
- else
- xmesa_display_surface(b, surf);
- }
-
- xmesa_check_and_update_buffer_size(NULL, b);
-}
-
-
-
-/*
- * Copy sub-region of back buffer to front buffer
- */
-void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
-{
- struct pipe_surface *surf_front
- = st_get_framebuffer_surface(b->stfb, ST_SURFACE_FRONT_LEFT);
- struct pipe_surface *surf_back
- = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT);
- struct pipe_context *pipe = NULL; /* XXX fix */
-
- if (!surf_front || !surf_back)
- return;
-
- pipe->surface_copy(pipe,
- FALSE,
- surf_front, x, y, /* dest */
- surf_back, x, y, /* src */
- width, height);
-}
-
-
-
-/*
- * Return the depth buffer associated with an XMesaBuffer.
- * Input: b - the XMesa buffer handle
- * Output: width, height - size of buffer in pixels
- * bytesPerValue - bytes per depth value (2 or 4)
- * buffer - pointer to depth buffer values
- * Return: GL_TRUE or GL_FALSE to indicate success or failure.
- */
-GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
- GLint *bytesPerValue, void **buffer )
-{
- *width = 0;
- *height = 0;
- *bytesPerValue = 0;
- *buffer = 0;
- return GL_FALSE;
-}
-
-
-void XMesaFlush( XMesaContext c )
-{
- if (c && c->xm_visual->display) {
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
- XSync( c->xm_visual->display, False );
-#endif
- }
-}
-
-
-
-const char *XMesaGetString( XMesaContext c, int name )
-{
- (void) c;
- if (name==XMESA_VERSION) {
- return "5.0";
- }
- else if (name==XMESA_EXTENSIONS) {
- return "";
- }
- else {
- return NULL;
- }
-}
-
-
-
-XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
-{
- XMesaBuffer b;
- for (b=XMesaBufferList; b; b=b->Next) {
- if (b->drawable == d && b->xm_visual->display == dpy) {
- return b;
- }
- }
- return NULL;
-}
-
-
-/**
- * Free/destroy all XMesaBuffers associated with given display.
- */
-void xmesa_destroy_buffers_on_display(XMesaDisplay *dpy)
-{
- XMesaBuffer b, next;
- for (b = XMesaBufferList; b; b = next) {
- next = b->Next;
- if (b->xm_visual->display == dpy) {
- xmesa_free_buffer(b);
- }
- }
-}
-
-
-/*
- * Look for XMesaBuffers whose X window has been destroyed.
- * Deallocate any such XMesaBuffers.
- */
-void XMesaGarbageCollect( void )
-{
- XMesaBuffer b, next;
- for (b=XMesaBufferList; b; b=next) {
- next = b->Next;
- if (b->xm_visual &&
- b->xm_visual->display &&
- b->drawable &&
- b->type == WINDOW) {
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
- XSync(b->xm_visual->display, False);
- if (!window_exists( b->xm_visual->display, b->drawable )) {
- /* found a dead window, free the ancillary info */
- XMesaDestroyBuffer( b );
- }
-#endif
- }
- }
-}
-
-
-unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
- GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha )
-{
- /* no longer supported */
- return 0;
-}
-
-
-/*
- * This is typically called when the window size changes and we need
- * to reallocate the buffer's back/depth/stencil/accum buffers.
- */
-PUBLIC void
-XMesaResizeBuffers( XMesaBuffer b )
-{
- GET_CURRENT_CONTEXT(ctx);
- XMesaContext xmctx = xmesa_context(ctx);
- if (!xmctx)
- return;
- xmesa_check_and_update_buffer_size(xmctx, b);
-}
-
-
-
-
-PUBLIC void
-XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
- const int *attrib_list)
-{
-}
-
-
-
-PUBLIC void
-XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer)
-{
-}
-
diff --git a/src/mesa/pipe/xlib/xm_image.c b/src/mesa/pipe/xlib/xm_image.c
deleted file mode 100644
index 087b4e4c3a..0000000000
--- a/src/mesa/pipe/xlib/xm_image.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT 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:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- */
-
-#include <stdlib.h>
-#include <X11/Xmd.h>
-
-#include "glxheader.h"
-#include "xmesaP.h"
-
-#ifdef XFree86Server
-
-#ifdef ROUNDUP
-#undef ROUNDUP
-#endif
-
-#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
-
-XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
-{
- XMesaImage *image;
-
- image = (XMesaImage *)xalloc(sizeof(XMesaImage));
-
- if (image) {
- image->width = width;
- image->height = height;
- image->data = data;
- /* Always pad to 32 bits */
- image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
- image->bits_per_pixel = bitsPerPixel;
- }
-
- return image;
-}
-
-void XMesaDestroyImage(XMesaImage *image)
-{
- if (image->data)
- free(image->data);
- xfree(image);
-}
-
-unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
-{
- CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
- CARD8 *i8;
- CARD16 *i16;
- CARD32 *i32;
- switch (image->bits_per_pixel) {
- case 8:
- i8 = (CARD8 *)row;
- return i8[x];
- break;
- case 15:
- case 16:
- i16 = (CARD16 *)row;
- return i16[x];
- break;
- case 24: /* WARNING: architecture specific code */
- i8 = (CARD8 *)row;
- return (((CARD32)i8[x*3]) |
- (((CARD32)i8[x*3+1])<<8) |
- (((CARD32)i8[x*3+2])<<16));
- break;
- case 32:
- i32 = (CARD32 *)row;
- return i32[x];
- break;
- }
- return 0;
-}
-
-#ifndef XMESA_USE_PUTPIXEL_MACRO
-void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
-{
- CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
- CARD8 *i8;
- CARD16 *i16;
- CARD32 *i32;
- switch (image->bits_per_pixel) {
- case 8:
- i8 = (CARD8 *)row;
- i8[x] = (CARD8)pixel;
- break;
- case 15:
- case 16:
- i16 = (CARD16 *)row;
- i16[x] = (CARD16)pixel;
- break;
- case 24: /* WARNING: architecture specific code */
- i8 = (CARD8 *)__row;
- i8[x*3] = (CARD8)(p);
- i8[x*3+1] = (CARD8)(p>>8);
- i8[x*3+2] = (CARD8)(p>>16);
- case 32:
- i32 = (CARD32 *)row;
- i32[x] = (CARD32)pixel;
- break;
- }
-}
-#endif
-
-#endif /* XFree86Server */
diff --git a/src/mesa/pipe/xlib/xm_image.h b/src/mesa/pipe/xlib/xm_image.h
deleted file mode 100644
index 2a5e0f3777..0000000000
--- a/src/mesa/pipe/xlib/xm_image.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT 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:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- */
-
-#ifndef _XM_IMAGE_H_
-#define _XM_IMAGE_H_
-
-#define XMESA_USE_PUTPIXEL_MACRO
-
-extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
- char *data);
-extern void XMesaDestroyImage(XMesaImage *image);
-extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
-#ifdef XMESA_USE_PUTPIXEL_MACRO
-#define XMesaPutPixel(__i,__x,__y,__p) \
-{ \
- CARD8 *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
- CARD8 *__i8; \
- CARD16 *__i16; \
- CARD32 *__i32; \
- switch (__i->bits_per_pixel) { \
- case 8: \
- __i8 = (CARD8 *)__row; \
- __i8[__x] = (CARD8)__p; \
- break; \
- case 15: \
- case 16: \
- __i16 = (CARD16 *)__row; \
- __i16[__x] = (CARD16)__p; \
- break; \
- case 24: /* WARNING: architecture specific code */ \
- __i8 = (CARD8 *)__row; \
- __i8[__x*3] = (CARD8)(__p); \
- __i8[__x*3+1] = (CARD8)(__p>>8); \
- __i8[__x*3+2] = (CARD8)(__p>>16); \
- break; \
- case 32: \
- __i32 = (CARD32 *)__row; \
- __i32[__x] = (CARD32)__p; \
- break; \
- } \
-}
-#else
-extern void XMesaPutPixel(XMesaImage *image, int x, int y,
- unsigned long pixel);
-#endif
-
-#endif /* _XM_IMAGE_H_ */
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
deleted file mode 100644
index c3cd22eea3..0000000000
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ /dev/null
@@ -1,466 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell
- * Brian Paul
- */
-
-
-#include "glxheader.h"
-#include "xmesaP.h"
-
-#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 "pipe/softpipe/sp_winsys.h"
-
-#ifdef GALLIUM_CELL
-#include "pipe/cell/ppu/cell_context.h"
-#include "pipe/cell/ppu/cell_winsys.h"
-#else
-#define TILE_SIZE 32 /* avoid compilation errors */
-#endif
-
-#include "xm_winsys_aub.h"
-
-
-/**
- * Low-level OS/window system memory buffer
- */
-struct xm_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
- void *mapped;
-};
-
-
-struct xmesa_surface
-{
- struct pipe_surface surface;
-
- int tileSize;
-};
-
-
-/**
- * Derived from softpipe_winsys.
- * We just need one extra field which indicates the pixel format to use for
- * drawing surfaces so that we're compatible with the XVisual/window format.
- */
-struct xmesa_softpipe_winsys
-{
- struct softpipe_winsys spws;
- enum pipe_format pixelformat;
-};
-
-
-
-/** Cast wrapper */
-static INLINE struct xmesa_surface *
-xmesa_surface(struct pipe_surface *ps)
-{
-// assert(0);
- return (struct xmesa_surface *) ps;
-}
-
-/** cast wrapper */
-static INLINE struct xmesa_softpipe_winsys *
-xmesa_softpipe_winsys(struct softpipe_winsys *spws)
-{
- return (struct xmesa_softpipe_winsys *) spws;
-}
-
-/**
- * Turn the softpipe opaque buffer pointer into a dri_bufmgr opaque
- * buffer pointer...
- */
-static INLINE struct xm_buffer *
-xm_buffer( struct pipe_buffer *buf )
-{
- return (struct xm_buffer *)buf;
-}
-
-
-
-/* Most callbacks map direcly onto dri_bufmgr operations:
- */
-static void *
-xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
- unsigned flags)
-{
- struct xm_buffer *xm_buf = xm_buffer(buf);
- xm_buf->mapped = xm_buf->data;
- return xm_buf->mapped;
-}
-
-static void
-xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
- struct xm_buffer *xm_buf = xm_buffer(buf);
- xm_buf->mapped = NULL;
-}
-
-static void
-xm_buffer_destroy(struct pipe_winsys *pws,
- struct pipe_buffer *buf)
-{
- struct xm_buffer *oldBuf = xm_buffer(buf);
-
- if (oldBuf->data) {
- if (!oldBuf->userBuffer)
- align_free(oldBuf->data);
- oldBuf->data = NULL;
- }
-
- free(oldBuf);
-}
-
-
-/**
- * Display a surface that's in a tiled configuration. That is, all the
- * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory.
- */
-static void
-xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
-{
- XImage *ximage = b->tempImage;
- struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
- 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);
-
- /* update XImage's fields */
- ximage->width = TILE_SIZE;
- ximage->height = TILE_SIZE;
- ximage->bytes_per_line = TILE_SIZE * 4;
-
- 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;
-
- offset *= 4 * TILE_SIZE * TILE_SIZE;
-
- ximage->data = (char *) xm_buf->data + offset;
-
- XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, dx, dy, TILE_SIZE, TILE_SIZE);
- }
- }
-}
-
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-void
-xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
-{
- XImage *ximage = b->tempImage;
- struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
- const struct xmesa_surface *xm_surf
- = xmesa_surface((struct pipe_surface *) surf);
-
- if (xm_surf->tileSize) {
- xmesa_display_surface_tiled(b, surf);
- return;
- }
-
- /* check that the XImage has been previously initialized */
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
- /* update XImage's fields */
- ximage->width = surf->width;
- ximage->height = surf->height;
- ximage->bytes_per_line = surf->pitch * (ximage->bits_per_pixel / 8);
- ximage->data = xm_buf->data;
-
- /* display image in Window */
- XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, 0, 0, surf->width, surf->height);
-}
-
-
-static void
-xm_flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *surf,
- void *context_private)
-{
- /* The Xlib driver's front color surfaces are actually X Windows so
- * this flush is a no-op.
- * If we instead did front buffer rendering to a temporary XImage,
- * this would be the place to copy the Ximage to the on-screen Window.
- */
- XMesaContext xmctx = (XMesaContext) context_private;
- xmesa_display_surface(xmctx->xm_buffer, surf);
-}
-
-
-
-static void
-xm_printf(struct pipe_winsys *pws, const char *fmtString, ...)
-{
- va_list args;
- va_start( args, fmtString );
- vfprintf(stderr, fmtString, args);
- va_end( args );
-}
-
-
-static const char *
-xm_get_name(struct pipe_winsys *pws)
-{
- return "Xlib";
-}
-
-
-static struct pipe_buffer *
-xm_buffer_create(struct pipe_winsys *pws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- /* align to 16-byte multiple for Cell */
- buffer->data = align_malloc(size, max(alignment, 16));
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-{
- struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
- buffer->base.refcount = 1;
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-static int
-xm_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags)
-{
- const unsigned alignment = 64;
-
- surf->width = width;
- surf->height = height;
- surf->format = format;
- surf->cpp = pf_get_size(format);
- surf->pitch = round_up(width, alignment / surf->cpp);
-
-#ifdef GALLIUM_CELL /* XXX a bit of a hack */
- height = round_up(height, TILE_SIZE);
-#endif
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->pitch * surf->cpp * height);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-
-/**
- * Called via pipe->surface_alloc() to create new surfaces (textures,
- * renderbuffers, etc.
- */
-static struct pipe_surface *
-xm_surface_alloc(struct pipe_winsys *ws)
-{
- struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
-
- assert(ws);
-
- xms->surface.refcount = 1;
- xms->surface.winsys = ws;
-
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- xms->tileSize = 32; /** probably temporary */
- }
-#endif
-
- return &xms->surface;
-}
-
-
-
-static void
-xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
-}
-
-
-
-/**
- * Return pointer to a pipe_winsys object.
- * For Xlib, this is a singleton object.
- * Nothing special for the Xlib driver so no subclassing or anything.
- */
-struct pipe_winsys *
-xmesa_get_pipe_winsys_aub(void)
-{
- static struct pipe_winsys *ws = NULL;
-
- if (!ws && getenv("XM_AUB")) {
- ws = xmesa_create_pipe_winsys_aub();
- }
- else if (!ws) {
- ws = CALLOC_STRUCT(pipe_winsys);
-
- /* Fill in this struct with callbacks that pipe will need to
- * communicate with the window system, buffer manager, etc.
- */
- ws->buffer_create = xm_buffer_create;
- ws->user_buffer_create = xm_user_buffer_create;
- ws->buffer_map = xm_buffer_map;
- ws->buffer_unmap = xm_buffer_unmap;
- ws->buffer_destroy = xm_buffer_destroy;
-
- ws->surface_alloc = xm_surface_alloc;
- ws->surface_alloc_storage = xm_surface_alloc_storage;
- ws->surface_release = xm_surface_release;
-
- ws->flush_frontbuffer = xm_flush_frontbuffer;
- ws->printf = xm_printf;
- ws->get_name = xm_get_name;
- }
-
- return ws;
-}
-
-
-/**
- * Called via softpipe_winsys->is_format_supported().
- * This function is only called to test formats for front/back color surfaces.
- * The winsys being queried will have been created at glXCreateContext
- * time, with a pixel format corresponding to the context's visual.
- */
-static boolean
-xmesa_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- struct xmesa_softpipe_winsys *xmws = xmesa_softpipe_winsys(sws);
- return (format == xmws->pixelformat);
-}
-
-
-/**
- * Return pointer to a softpipe_winsys object.
- */
-static struct softpipe_winsys *
-xmesa_get_softpipe_winsys(uint pixelformat)
-{
- struct xmesa_softpipe_winsys *xmws
- = CALLOC_STRUCT(xmesa_softpipe_winsys);
- if (!xmws)
- return NULL;
-
- xmws->spws.is_format_supported = xmesa_is_format_supported;
- xmws->pixelformat = pixelformat;
-
- return &xmws->spws;
-}
-
-
-struct pipe_context *
-xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
-{
- struct pipe_winsys *pws = xmesa_get_pipe_winsys_aub();
- struct pipe_context *pipe;
-
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- struct cell_winsys *cws = cell_get_winsys(pixelformat);
- pipe = cell_create_context(pws, cws);
- if (pipe)
- pipe->priv = xmesa;
- return pipe;
- }
- else
-#endif
- {
- struct softpipe_winsys *spws = xmesa_get_softpipe_winsys(pixelformat);
- pipe = softpipe_create( pws, spws );
- if (pipe)
- pipe->priv = xmesa;
-
- return pipe;
- }
-}
diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c
deleted file mode 100644
index bf41570257..0000000000
--- a/src/mesa/pipe/xlib/xm_winsys_aub.c
+++ /dev/null
@@ -1,589 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell
- * Brian Paul
- */
-
-
-#include "glxheader.h"
-#include "xmesaP.h"
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/i965simple/brw_winsys.h"
-#include "brw_aub.h"
-#include "xm_winsys_aub.h"
-
-
-
-struct aub_buffer {
- char *data;
- unsigned offset;
- unsigned size;
- unsigned refcount;
- unsigned map_count;
- boolean dump_on_unmap;
-};
-
-
-
-struct aub_pipe_winsys {
- struct pipe_winsys winsys;
-
- struct brw_aubfile *aubfile;
-
- /* This is simple, isn't it:
- */
- char *pool;
- unsigned size;
- unsigned used;
-};
-
-
-/* Turn a pipe winsys into an aub/pipe winsys:
- */
-static inline struct aub_pipe_winsys *
-aub_pipe_winsys( struct pipe_winsys *winsys )
-{
- return (struct aub_pipe_winsys *)winsys;
-}
-
-
-
-static INLINE struct aub_buffer *
-aub_bo( struct pipe_buffer *bo )
-{
- return (struct aub_buffer *)bo;
-}
-
-static INLINE struct pipe_buffer *
-pipe_bo( struct aub_buffer *bo )
-{
- return (struct pipe_buffer *)bo;
-}
-
-
-
-
-static void *aub_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags )
-{
- struct aub_buffer *sbo = aub_bo(buf);
-
- assert(sbo->data);
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- sbo->dump_on_unmap = 1;
-
- sbo->map_count++;
- return sbo->data;
-}
-
-static void aub_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = aub_bo(buf);
-
- sbo->map_count--;
-
- if (sbo->map_count == 0 &&
- sbo->dump_on_unmap) {
-
- sbo->dump_on_unmap = 0;
-
- brw_aub_gtt_data( iws->aubfile,
- sbo->offset,
- sbo->data,
- sbo->size,
- 0,
- 0);
- }
-}
-
-
-static void
-aub_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- free(buf);
-}
-
-
-void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned aub_type,
- unsigned aub_sub_type)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = aub_bo(buf);
-
- assert(sbo->size > offset + size);
- memcpy(sbo->data + offset, data, size);
-
- brw_aub_gtt_data( iws->aubfile,
- sbo->offset + offset,
- sbo->data + offset,
- size,
- aub_type,
- aub_sub_type );
-}
-
-void xmesa_commands_aub(struct pipe_winsys *winsys,
- unsigned *cmds,
- unsigned nr_dwords)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- unsigned size = nr_dwords * 4;
-
- assert(iws->used + size < iws->size);
-
- brw_aub_gtt_cmds( iws->aubfile,
- AUB_BUF_START + iws->used,
- cmds,
- nr_dwords * sizeof(int) );
-
- iws->used += align(size, 4096);
-}
-
-
-static struct aub_pipe_winsys *global_winsys = NULL;
-
-void xmesa_display_aub( /* struct pipe_winsys *winsys, */
- struct pipe_surface *surface )
-{
-// struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- brw_aub_dump_bmp( global_winsys->aubfile,
- surface,
- aub_bo(surface->buffer)->offset );
-}
-
-
-
-/* Pipe has no concept of pools. We choose the tex/region pool
- * for all buffers.
- */
-static struct pipe_buffer *
-aub_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer);
-
- sbo->refcount = 1;
-
- /* Could reuse buffers that are not referenced in current
- * batchbuffer. Can't do that atm, so always reallocate:
- */
- assert(iws->used + size < iws->size);
- sbo->data = iws->pool + iws->used;
- sbo->offset = AUB_BUF_START + iws->used;
- iws->used += align(size, 4096);
-
- sbo->size = size;
-
- return pipe_bo(sbo);
-}
-
-
-static struct pipe_buffer *
-aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
-{
- struct aub_buffer *sbo;
-
- /* Lets hope this is meant for upload, not as a result!
- */
- sbo = aub_bo(aub_buffer_create( winsys, 0, 0, 0 ));
-
- sbo->data = ptr;
- sbo->size = bytes;
-
- return pipe_bo(sbo);
-}
-
-
-/* The state tracker (should!) keep track of whether the fake
- * frontbuffer has been touched by any rendering since the last time
- * we copied its contents to the real frontbuffer. Our task is easy:
- */
-static void
-aub_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- xmesa_display_aub( surf );
-}
-
-static struct pipe_surface *
-aub_i915_surface_alloc(struct pipe_winsys *winsys)
-{
- struct pipe_surface *surf = CALLOC_STRUCT(pipe_surface);
- if (surf) {
- surf->refcount = 1;
- surf->winsys = winsys;
- }
- return surf;
-}
-
-
-/**
- * Round n up to next multiple.
- */
-static INLINE unsigned
-round_up(unsigned n, unsigned multiple)
-{
- return (n + multiple - 1) & ~(multiple - 1);
-}
-
-static int
-aub_i915_surface_alloc_storage(struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned flags)
-{
- const unsigned alignment = 64;
-
- surf->width = width;
- surf->height = height;
- surf->format = format;
- surf->cpp = pf_get_size(format);
- surf->pitch = round_up(width, alignment / surf->cpp);
-
- assert(!surf->buffer);
- surf->buffer = winsys->buffer_create(winsys, alignment,
- PIPE_BUFFER_USAGE_PIXEL,
- surf->pitch * surf->cpp * height);
- if(!surf->buffer)
- return -1;
-
- return 0;
-}
-
-static void
-aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
-{
- struct pipe_surface *surf = *s;
- surf->refcount--;
- if (surf->refcount == 0) {
- if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
- free(surf);
- }
- *s = NULL;
-}
-
-
-
-static void
-aub_printf( struct pipe_winsys *winsys, const char *fmtString, ... )
-{
- va_list args;
- va_start( args, fmtString );
- vfprintf(stderr, fmtString, args);
- va_end( args );
-}
-
-static const char *
-aub_get_name( struct pipe_winsys *winsys )
-{
- return "Aub/xlib";
-}
-
-struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void )
-{
- struct aub_pipe_winsys *iws = CALLOC_STRUCT( aub_pipe_winsys );
-
- /* Fill in this struct with callbacks that pipe will need to
- * communicate with the window system, buffer manager, etc.
- *
- * Pipe would be happy with a malloc based memory manager, but
- * the SwapBuffers implementation in this winsys driver requires
- * that rendering be done to an appropriate _DriBufferObject.
- */
- iws->winsys.buffer_create = aub_buffer_create;
- iws->winsys.user_buffer_create = aub_user_buffer_create;
- iws->winsys.buffer_map = aub_buffer_map;
- iws->winsys.buffer_unmap = aub_buffer_unmap;
- iws->winsys.buffer_destroy = aub_buffer_destroy;
- iws->winsys.flush_frontbuffer = aub_flush_frontbuffer;
- iws->winsys.printf = aub_printf;
- iws->winsys.get_name = aub_get_name;
-
- iws->winsys.surface_alloc = aub_i915_surface_alloc;
- iws->winsys.surface_alloc_storage = aub_i915_surface_alloc_storage;
- iws->winsys.surface_release = aub_i915_surface_release;
-
- iws->aubfile = brw_aubfile_create();
- iws->size = AUB_BUF_SIZE;
- iws->pool = malloc(AUB_BUF_SIZE);
-
- /* HACK: static copy of this pointer:
- */
- assert(global_winsys == NULL);
- global_winsys = iws;
-
- return &iws->winsys;
-}
-
-
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys )
-
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- brw_aub_destroy(iws->aubfile);
- free(iws->pool);
- free(iws);
-}
-
-
-
-
-
-
-
-#define IWS_BATCHBUFFER_SIZE 1024
-
-struct aub_brw_winsys {
- struct brw_winsys winsys; /**< batch buffer funcs */
- struct aub_context *aub;
-
- struct pipe_winsys *pipe_winsys;
-
- unsigned batch_data[IWS_BATCHBUFFER_SIZE];
- unsigned batch_nr;
- unsigned batch_size;
- unsigned batch_alloc;
-};
-
-
-/* Turn a i965simple winsys into an aub/i965simple winsys:
- */
-static inline struct aub_brw_winsys *
-aub_brw_winsys( struct brw_winsys *sws )
-{
- return (struct aub_brw_winsys *)sws;
-}
-
-
-/* Simple batchbuffer interface:
- */
-
-static unsigned *aub_i965_batch_start( struct brw_winsys *sws,
- unsigned dwords,
- unsigned relocs )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- if (iws->batch_size < iws->batch_nr + dwords)
- return NULL;
-
- iws->batch_alloc = iws->batch_nr + dwords;
- return (void *)1; /* not a valid pointer! */
-}
-
-static void aub_i965_batch_dword( struct brw_winsys *sws,
- unsigned dword )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr < iws->batch_alloc);
- iws->batch_data[iws->batch_nr++] = dword;
-}
-
-static void aub_i965_batch_reloc( struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr < iws->batch_alloc);
- iws->batch_data[iws->batch_nr++] = aub_bo(buf)->offset + delta;
-}
-
-static unsigned aub_i965_get_buffer_offset( struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags )
-{
- return aub_bo(buf)->offset;
-}
-
-static void aub_i965_batch_end( struct brw_winsys *sws )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr <= iws->batch_alloc);
- iws->batch_alloc = 0;
-}
-
-static void aub_i965_batch_flush( struct brw_winsys *sws,
- struct pipe_fence_handle **fence )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
- assert(iws->batch_nr <= iws->batch_size);
-
- if (iws->batch_nr) {
- xmesa_commands_aub( iws->pipe_winsys,
- iws->batch_data,
- iws->batch_nr );
- }
-
- iws->batch_nr = 0;
-}
-
-
-
-static void aub_i965_buffer_subdata_typed(struct brw_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned data_type)
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(winsys);
- unsigned aub_type = DW_GENERAL_STATE;
- unsigned aub_sub_type;
-
- switch (data_type) {
- case BRW_CC_VP:
- aub_sub_type = DWGS_COLOR_CALC_VIEWPORT_STATE;
- break;
- case BRW_CC_UNIT:
- aub_sub_type = DWGS_COLOR_CALC_STATE;
- break;
- case BRW_WM_PROG:
- aub_sub_type = DWGS_KERNEL_INSTRUCTIONS;
- break;
- case BRW_SAMPLER_DEFAULT_COLOR:
- aub_sub_type = DWGS_SAMPLER_DEFAULT_COLOR;
- break;
- case BRW_SAMPLER:
- aub_sub_type = DWGS_SAMPLER_STATE;
- break;
- case BRW_WM_UNIT:
- aub_sub_type = DWGS_WINDOWER_IZ_STATE;
- break;
- case BRW_SF_PROG:
- aub_sub_type = DWGS_KERNEL_INSTRUCTIONS;
- break;
- case BRW_SF_VP:
- aub_sub_type = DWGS_STRIPS_FANS_VIEWPORT_STATE;
- break;
- case BRW_SF_UNIT:
- aub_sub_type = DWGS_STRIPS_FANS_STATE;
- break;
- case BRW_VS_UNIT:
- aub_sub_type = DWGS_VERTEX_SHADER_STATE;
- break;
- case BRW_VS_PROG:
- aub_sub_type = DWGS_KERNEL_INSTRUCTIONS;
- break;
- case BRW_GS_UNIT:
- aub_sub_type = DWGS_GEOMETRY_SHADER_STATE;
- break;
- case BRW_GS_PROG:
- aub_sub_type = DWGS_KERNEL_INSTRUCTIONS;
- break;
- case BRW_CLIP_VP:
- aub_sub_type = DWGS_CLIPPER_VIEWPORT_STATE;
- break;
- case BRW_CLIP_UNIT:
- aub_sub_type = DWGS_CLIPPER_STATE;
- break;
- case BRW_CLIP_PROG:
- aub_sub_type = DWGS_KERNEL_INSTRUCTIONS;
- break;
- case BRW_SS_SURFACE:
- aub_type = DW_SURFACE_STATE;
- aub_sub_type = DWSS_SURFACE_STATE;
- break;
- case BRW_SS_SURF_BIND:
- aub_type = DW_SURFACE_STATE;
- aub_sub_type = DWSS_BINDING_TABLE_STATE;
- break;
- case BRW_CONSTANT_BUFFER:
- aub_type = DW_CONSTANT_URB_ENTRY;
- aub_sub_type = 0;
- break;
-
- default:
- assert(0);
- break;
- }
-
- xmesa_buffer_subdata_aub( iws->pipe_winsys,
- buf,
- offset,
- size,
- data,
- aub_type,
- aub_sub_type );
-}
-
-/**
- * Create i965 hardware rendering context.
- */
-struct pipe_context *
-xmesa_create_i965simple( struct pipe_winsys *winsys )
-{
- struct aub_brw_winsys *iws = CALLOC_STRUCT( aub_brw_winsys );
-
- /* Fill in this struct with callbacks that i965simple will need to
- * communicate with the window system, buffer manager, etc.
- */
- iws->winsys.batch_start = aub_i965_batch_start;
- iws->winsys.batch_dword = aub_i965_batch_dword;
- iws->winsys.batch_reloc = aub_i965_batch_reloc;
- iws->winsys.batch_end = aub_i965_batch_end;
- iws->winsys.batch_flush = aub_i965_batch_flush;
- iws->winsys.buffer_subdata_typed = aub_i965_buffer_subdata_typed;
- iws->winsys.get_buffer_offset = aub_i965_get_buffer_offset;
-
- iws->pipe_winsys = winsys;
-
- iws->batch_size = IWS_BATCHBUFFER_SIZE;
-
- /* Create the i965simple context:
- */
- return brw_create( winsys,
- &iws->winsys,
- 0 );
-}
diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.h b/src/mesa/pipe/xlib/xm_winsys_aub.h
deleted file mode 100644
index 7bee199116..0000000000
--- a/src/mesa/pipe/xlib/xm_winsys_aub.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef AUB_WINSYS_H
-#define AUB_WINSYS_H
-
-struct pipe_context;
-struct pipe_winsys;
-struct pipe_buffer;
-struct pipe_surface;
-
-struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void );
-
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys );
-
-
-
-struct pipe_context *
-xmesa_create_i965simple( struct pipe_winsys *winsys );
-
-
-
-void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned aub_type,
- unsigned aub_sub_type);
-
-void xmesa_commands_aub(struct pipe_winsys *winsys,
- unsigned *cmds,
- unsigned nr_dwords);
-
-
-void xmesa_display_aub( /* struct pipe_winsys *winsys, */
- struct pipe_surface *surface );
-
-struct pipe_winsys *xmesa_get_pipe_winsys_aub(void);
-
-#endif
diff --git a/src/mesa/pipe/xlib/xmesaP.h b/src/mesa/pipe/xlib/xmesaP.h
deleted file mode 100644
index fa8d1f14b9..0000000000
--- a/src/mesa/pipe/xlib/xmesaP.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 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.
- */
-
-
-#ifndef XMESAP_H
-#define XMESAP_H
-
-
-#include "GL/xmesa.h"
-#include "mtypes.h"
-#ifdef XFree86Server
-#include "xm_image.h"
-#endif
-
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-
-
-extern _glthread_Mutex _xmesa_lock;
-
-extern XMesaBuffer XMesaBufferList;
-
-/*
- */
-#define XMESA_SOFTPIPE 1
-#define XMESA_AUB 2
-extern int xmesa_mode;
-
-
-/**
- * Visual inforation, derived from GLvisual.
- * Basically corresponds to an XVisualInfo.
- */
-struct xmesa_visual {
- GLvisual mesa_visual; /* Device independent visual parameters */
- XMesaDisplay *display; /* The X11 display */
-#ifdef XFree86Server
- GLint ColormapEntries;
- GLint nplanes;
-#else
- XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
- XVisualInfo *vishandle; /* Only used in fakeglx.c */
-#endif
- GLint BitsPerPixel; /* True bits per pixel for XImages */
-
- GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
-};
-
-
-/**
- * Context info, derived from st_context.
- * Basically corresponds to a GLXContext.
- */
-struct xmesa_context {
- struct st_context *st;
- XMesaVisual xm_visual; /** pixel format info */
- XMesaBuffer xm_buffer; /** current drawbuffer */
-};
-
-
-/**
- * Types of X/GLX drawables we might render into.
- */
-typedef enum {
- WINDOW, /* An X window */
- GLXWINDOW, /* GLX window */
- PIXMAP, /* GLX pixmap */
- PBUFFER /* GLX Pbuffer */
-} BufferType;
-
-
-/**
- * Framebuffer information, derived from.
- * Basically corresponds to a GLXDrawable.
- */
-struct xmesa_buffer {
- struct st_framebuffer *stfb;
-
- GLboolean wasCurrent; /* was ever the current buffer? */
- XMesaVisual xm_visual; /* the X/Mesa visual */
- XMesaDrawable drawable; /* Usually the X window ID */
- XMesaColormap cmap; /* the X colormap */
- BufferType type; /* window, pixmap, pbuffer or glxwindow */
-
- XMesaImage *tempImage;
- unsigned long selectedEvents;/* for pbuffers only */
-
- GLuint shm; /* X Shared Memory extension status: */
- /* 0 = not available */
- /* 1 = XImage support available */
- /* 2 = Pixmap support available too */
-#if defined(USE_XSHM) && !defined(XFree86Server)
- XShmSegmentInfo shminfo;
-#endif
-
- XMesaGC gc; /* scratch GC for span, line, tri drawing */
-
- /* GLX_EXT_texture_from_pixmap */
- GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
- GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
- GLint TextureMipmap; /** 0 or 1 */
-
- struct xmesa_buffer *Next; /* Linked list pointer: */
-};
-
-
-
-/** cast wrapper */
-static INLINE XMesaContext
-xmesa_context(GLcontext *ctx)
-{
- return (XMesaContext) ctx->DriverCtx;
-}
-
-
-/** cast wrapper */
-static INLINE XMesaBuffer
-xmesa_buffer(GLframebuffer *fb)
-{
- struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
- return (XMesaBuffer) st_framebuffer_private(stfb);
-}
-
-
-extern void
-xmesa_delete_framebuffer(struct gl_framebuffer *fb);
-
-extern XMesaBuffer
-xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
-
-extern void
-xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
-
-extern void
-xmesa_destroy_buffers_on_display(XMesaDisplay *dpy);
-
-extern struct pipe_context *
-xmesa_create_pipe_context(XMesaContext xm, uint pixelformat);
-
-static INLINE GLuint
-xmesa_buffer_width(XMesaBuffer b)
-{
- return b->stfb->Base.Width;
-}
-
-static INLINE GLuint
-xmesa_buffer_height(XMesaBuffer b)
-{
- return b->stfb->Base.Height;
-}
-
-extern void
-xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf);
-
-#endif
diff --git a/src/mesa/ppc/rtasm/spe_asm.c b/src/mesa/ppc/rtasm/spe_asm.c
new file mode 100644
index 0000000000..f8aff9050b
--- /dev/null
+++ b/src/mesa/ppc/rtasm/spe_asm.c
@@ -0,0 +1,351 @@
+/*
+ * (C) Copyright IBM Corporation 2008
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file spe_asm.c
+ * Real-time assembly generation interface for Cell B.E. SPEs.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+#ifdef GALLIUM_CELL
+#include <inttypes.h>
+#include <imports.h>
+#include "spe_asm.h"
+
+/**
+ * SPE instruction types
+ *
+ * There are 6 primary instruction encodings used on the Cell's SPEs. Each of
+ * the following unions encodes one type.
+ *
+ * \bug
+ * If, at some point, we start generating SPE code from a little-endian host
+ * these unions will not work.
+ */
+/*@{*/
+/**
+ * Encode one output register with two input registers
+ */
+union spe_inst_RR {
+ uint32_t bits;
+ struct {
+ unsigned op:11;
+ unsigned rB:7;
+ unsigned rA:7;
+ unsigned rT:7;
+ } inst;
+};
+
+
+/**
+ * Encode one output register with three input registers
+ */
+union spe_inst_RRR {
+ uint32_t bits;
+ struct {
+ unsigned op:4;
+ unsigned rT:7;
+ unsigned rB:7;
+ unsigned rA:7;
+ unsigned rC:7;
+ } inst;
+};
+
+
+/**
+ * Encode one output register with one input reg. and a 7-bit signed immed
+ */
+union spe_inst_RI7 {
+ uint32_t bits;
+ struct {
+ unsigned op:11;
+ unsigned i7:7;
+ unsigned rA:7;
+ unsigned rT:7;
+ } inst;
+};
+
+
+/**
+ * Encode one output register with one input reg. and a 10-bit signed immed
+ */
+union spe_inst_RI10 {
+ uint32_t bits;
+ struct {
+ unsigned op:8;
+ unsigned i10:10;
+ unsigned rA:7;
+ unsigned rT:7;
+ } inst;
+};
+
+
+/**
+ * Encode one output register with a 16-bit signed immediate
+ */
+union spe_inst_RI16 {
+ uint32_t bits;
+ struct {
+ unsigned op:9;
+ unsigned i16:16;
+ unsigned rT:7;
+ } inst;
+};
+
+
+/**
+ * Encode one output register with a 18-bit signed immediate
+ */
+union spe_inst_RI18 {
+ uint32_t bits;
+ struct {
+ unsigned op:7;
+ unsigned i18:18;
+ unsigned rT:7;
+ } inst;
+};
+/*@}*/
+
+
+static void emit_RR(struct spe_function *p, unsigned op, unsigned rT,
+ unsigned rA, unsigned rB)
+{
+ union spe_inst_RR inst;
+ inst.inst.op = op;
+ inst.inst.rB = rB;
+ inst.inst.rA = rA;
+ inst.inst.rT = rT;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+static void emit_RRR(struct spe_function *p, unsigned op, unsigned rT,
+ unsigned rA, unsigned rB, unsigned rC)
+{
+ union spe_inst_RRR inst;
+ inst.inst.op = op;
+ inst.inst.rT = rT;
+ inst.inst.rB = rB;
+ inst.inst.rA = rA;
+ inst.inst.rC = rC;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+static void emit_RI7(struct spe_function *p, unsigned op, unsigned rT,
+ unsigned rA, int imm)
+{
+ union spe_inst_RI7 inst;
+ inst.inst.op = op;
+ inst.inst.i7 = imm;
+ inst.inst.rA = rA;
+ inst.inst.rT = rT;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+
+static void emit_RI10(struct spe_function *p, unsigned op, unsigned rT,
+ unsigned rA, int imm)
+{
+ union spe_inst_RI10 inst;
+ inst.inst.op = op;
+ inst.inst.i10 = imm;
+ inst.inst.rA = rA;
+ inst.inst.rT = rT;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+static void emit_RI16(struct spe_function *p, unsigned op, unsigned rT,
+ int imm)
+{
+ union spe_inst_RI16 inst;
+ inst.inst.op = op;
+ inst.inst.i16 = imm;
+ inst.inst.rT = rT;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+static void emit_RI18(struct spe_function *p, unsigned op, unsigned rT,
+ int imm)
+{
+ union spe_inst_RI18 inst;
+ inst.inst.op = op;
+ inst.inst.i18 = imm;
+ inst.inst.rT = rT;
+ *p->csr = inst.bits;
+ p->csr++;
+}
+
+
+
+
+#define EMIT_(_name, _op) \
+void _name (struct spe_function *p, unsigned rT) \
+{ \
+ emit_RR(p, _op, rT, 0, 0); \
+}
+
+#define EMIT_R(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, unsigned rA) \
+{ \
+ emit_RR(p, _op, rT, rA, 0); \
+}
+
+#define EMIT_RR(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, unsigned rA, unsigned rB) \
+{ \
+ emit_RR(p, _op, rT, rA, rB); \
+}
+
+#define EMIT_RRR(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, unsigned rA, unsigned rB, unsigned rC) \
+{ \
+ emit_RRR(p, _op, rT, rA, rB, rC); \
+}
+
+#define EMIT_RI7(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, unsigned rA, int imm) \
+{ \
+ emit_RI7(p, _op, rT, rA, imm); \
+}
+
+#define EMIT_RI10(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, unsigned rA, int imm) \
+{ \
+ emit_RI10(p, _op, rT, rA, imm); \
+}
+
+#define EMIT_RI16(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, int imm) \
+{ \
+ emit_RI16(p, _op, rT, imm); \
+}
+
+#define EMIT_RI18(_name, _op) \
+void _name (struct spe_function *p, unsigned rT, int imm) \
+{ \
+ emit_RI18(p, _op, rT, imm); \
+}
+
+#define EMIT_I16(_name, _op) \
+void _name (struct spe_function *p, int imm) \
+{ \
+ emit_RI16(p, _op, 0, imm); \
+}
+
+#include "spe_asm.h"
+
+
+/*
+ */
+void spe_init_func(struct spe_function *p, unsigned code_size)
+{
+ p->store = _mesa_align_malloc(code_size, 16);
+ p->csr = p->store;
+}
+
+
+void spe_release_func(struct spe_function *p)
+{
+ _mesa_align_free(p->store);
+ p->store = NULL;
+ p->csr = NULL;
+}
+
+
+void spe_bi(struct spe_function *p, unsigned rA, int d, int e)
+{
+ emit_RI7(p, 0x1a8, 0, rA, (d << 5) | (e << 4));
+}
+
+void spe_iret(struct spe_function *p, unsigned rA, int d, int e)
+{
+ emit_RI7(p, 0x1aa, 0, rA, (d << 5) | (e << 4));
+}
+
+void spe_bisled(struct spe_function *p, unsigned rT, unsigned rA, int d,
+ int e)
+{
+ emit_RI7(p, 0x1ab, rT, rA, (d << 5) | (e << 4));
+}
+
+void spe_bisl(struct spe_function *p, unsigned rT, unsigned rA, int d,
+ int e)
+{
+ emit_RI7(p, 0x1a9, rT, rA, (d << 5) | (e << 4));
+}
+
+void spe_biz(struct spe_function *p, unsigned rT, unsigned rA, int d,
+ int e)
+{
+ emit_RI7(p, 0x128, rT, rA, (d << 5) | (e << 4));
+}
+
+void spe_binz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
+{
+ emit_RI7(p, 0x129, rT, rA, (d << 5) | (e << 4));
+}
+
+void spe_bihz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
+{
+ emit_RI7(p, 0x12a, rT, rA, (d << 5) | (e << 4));
+}
+
+void spe_bihnz(struct spe_function *p, unsigned rT, unsigned rA, int d, int e)
+{
+ emit_RI7(p, 0x12b, rT, rA, (d << 5) | (e << 4));
+}
+
+
+/* Hint-for-branch instructions
+ */
+#if 0
+hbr;
+hbra;
+hbrr;
+#endif
+
+
+/* Control instructions
+ */
+#if 0
+stop;
+EMIT_RR (spe_stopd, 0x140);
+EMIT_ (spe_lnop, 0x001);
+EMIT_ (spe_nop, 0x201);
+sync;
+EMIT_ (spe_dsync, 0x003);
+EMIT_R (spe_mfspr, 0x00c);
+EMIT_R (spe_mtspr, 0x10c);
+#endif
+
+#endif /* GALLIUM_CELL */
diff --git a/src/mesa/ppc/rtasm/spe_asm.h b/src/mesa/ppc/rtasm/spe_asm.h
new file mode 100644
index 0000000000..9532669b8c
--- /dev/null
+++ b/src/mesa/ppc/rtasm/spe_asm.h
@@ -0,0 +1,310 @@
+/*
+ * (C) Copyright IBM Corporation 2008
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file spe_asm.h
+ * Real-time assembly generation interface for Cell B.E. SPEs.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef SPE_ASM_H
+#define SPE_ASM_H
+
+struct spe_function {
+ /**
+ *
+ */
+ uint32_t *store;
+ uint32_t *csr;
+ const char *fn;
+};
+
+extern void spe_init_func(struct spe_function *p, unsigned code_size);
+extern void spe_release_func(struct spe_function *p);
+
+#endif /* SPE_ASM_H */
+
+#ifndef EMIT_
+#define EMIT_(name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT)
+#define EMIT_R(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, unsigned rA)
+#define EMIT_RR(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
+ unsigned rB)
+#define EMIT_RRR(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
+ unsigned rB, unsigned rC)
+#define EMIT_RI7(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
+ int imm)
+#define EMIT_RI10(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, unsigned rA, \
+ int imm)
+#define EMIT_RI16(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, int imm)
+#define EMIT_RI18(_name, _op) \
+ extern void _name (struct spe_function *p, unsigned rT, int imm)
+#define EMIT_I16(_name, _op) \
+ extern void _name (struct spe_function *p, int imm)
+#define UNDEF_EMIT_MACROS
+#endif /* EMIT_ */
+
+
+/* Memory load / store instructions
+ */
+EMIT_RI10(spe_lqd, 0x034);
+EMIT_RR (spe_lqx, 0x1c4);
+EMIT_RI16(spe_lqa, 0x061);
+EMIT_RI16(spe_lqr, 0x067);
+EMIT_RI10(spe_stqd, 0x024);
+EMIT_RR (spe_stqx, 0x144);
+EMIT_RI16(spe_stqa, 0x041);
+EMIT_RI16(spe_stqr, 0x047);
+EMIT_RI7 (spe_cbd, 0x1f4);
+EMIT_RR (spe_cbx, 0x1d4);
+EMIT_RI7 (spe_chd, 0x1f5);
+EMIT_RI7 (spe_chx, 0x1d5);
+EMIT_RI7 (spe_cwd, 0x1f6);
+EMIT_RI7 (spe_cwx, 0x1d6);
+EMIT_RI7 (spe_cdd, 0x1f7);
+EMIT_RI7 (spe_cdx, 0x1d7);
+
+
+/* Constant formation instructions
+ */
+EMIT_RI16(spe_ilh, 0x083);
+EMIT_RI16(spe_ilhu, 0x082);
+EMIT_RI16(spe_il, 0x081);
+EMIT_RI18(spe_ila, 0x021);
+EMIT_RI16(spe_iohl, 0x0c1);
+EMIT_RI16(spe_fsmbi, 0x0c5);
+
+
+/* Integer and logical instructions
+ */
+EMIT_RR (spe_ah, 0x0c8);
+EMIT_RI10(spe_ahi, 0x01d);
+EMIT_RR (spe_a, 0x0c0);
+EMIT_RI10(spe_ai, 0x01c);
+EMIT_RR (spe_sfh, 0x048);
+EMIT_RI10(spe_sfhi, 0x00d);
+EMIT_RR (spe_sf, 0x040);
+EMIT_RI10(spe_sfi, 0x00c);
+EMIT_RR (spe_addx, 0x340);
+EMIT_RR (spe_cg, 0x0c2);
+EMIT_RR (spe_cgx, 0x342);
+EMIT_RR (spe_sfx, 0x341);
+EMIT_RR (spe_bg, 0x042);
+EMIT_RR (spe_bgx, 0x343);
+EMIT_RR (spe_mpy, 0x3c4);
+EMIT_RR (spe_mpyu, 0x3cc);
+EMIT_RI10(spe_mpyi, 0x074);
+EMIT_RI10(spe_mpyui, 0x075);
+EMIT_RRR (spe_mpya, 0x00c);
+EMIT_RR (spe_mpyh, 0x3c5);
+EMIT_RR (spe_mpys, 0x3c7);
+EMIT_RR (spe_mpyhh, 0x3c6);
+EMIT_RR (spe_mpyhha, 0x346);
+EMIT_RR (spe_mpyhhu, 0x3ce);
+EMIT_RR (spe_mpyhhau, 0x34e);
+EMIT_R (spe_clz, 0x2a5);
+EMIT_R (spe_cntb, 0x2b4);
+EMIT_R (spe_fsmb, 0x1b6);
+EMIT_R (spe_fsmh, 0x1b5);
+EMIT_R (spe_fsm, 0x1b4);
+EMIT_R (spe_gbb, 0x1b2);
+EMIT_R (spe_gbh, 0x1b1);
+EMIT_R (spe_gb, 0x1b0);
+EMIT_RR (spe_avgb, 0x0d3);
+EMIT_RR (spe_absdb, 0x053);
+EMIT_RR (spe_sumb, 0x253);
+EMIT_R (spe_xsbh, 0x2b6);
+EMIT_R (spe_xshw, 0x2ae);
+EMIT_R (spe_xswd, 0x2a6);
+EMIT_RR (spe_and, 0x0c1);
+EMIT_RR (spe_andc, 0x2c1);
+EMIT_RI10(spe_andbi, 0x016);
+EMIT_RI10(spe_andhi, 0x015);
+EMIT_RI10(spe_andi, 0x014);
+EMIT_RR (spe_or, 0x041);
+EMIT_RR (spe_orc, 0x2c9);
+EMIT_RI10(spe_orbi, 0x006);
+EMIT_RI10(spe_orhi, 0x005);
+EMIT_RI10(spe_ori, 0x004);
+EMIT_R (spe_orx, 0x1f0);
+EMIT_RR (spe_xor, 0x241);
+EMIT_RI10(spe_xorbi, 0x026);
+EMIT_RI10(spe_xorhi, 0x025);
+EMIT_RI10(spe_xori, 0x024);
+EMIT_RR (spe_nand, 0x0c9);
+EMIT_RR (spe_nor, 0x049);
+EMIT_RR (spe_eqv, 0x249);
+EMIT_RRR (spe_selb, 0x008);
+EMIT_RRR (spe_shufb, 0x00b);
+
+
+/* Shift and rotate instructions
+ */
+EMIT_RR (spe_shlh, 0x05f);
+EMIT_RI7 (spe_shlhi, 0x07f);
+EMIT_RR (spe_shl, 0x05b);
+EMIT_RI7 (spe_shli, 0x07b);
+EMIT_RR (spe_shlqbi, 0x1db);
+EMIT_RI7 (spe_shlqbii, 0x1fb);
+EMIT_RR (spe_shlqby, 0x1df);
+EMIT_RI7 (spe_shlqbyi, 0x1ff);
+EMIT_RR (spe_shlqbybi, 0x1cf);
+EMIT_RR (spe_roth, 0x05c);
+EMIT_RI7 (spe_rothi, 0x07c);
+EMIT_RR (spe_rot, 0x058);
+EMIT_RI7 (spe_roti, 0x078);
+EMIT_RR (spe_rotqby, 0x1dc);
+EMIT_RI7 (spe_rotqbyi, 0x1fc);
+EMIT_RR (spe_rotqbybi, 0x1cc);
+EMIT_RR (spe_rotqbi, 0x1d8);
+EMIT_RI7 (spe_rotqbii, 0x1f8);
+EMIT_RR (spe_rothm, 0x05d);
+EMIT_RI7 (spe_rothmi, 0x07d);
+EMIT_RR (spe_rotm, 0x059);
+EMIT_RI7 (spe_rotmi, 0x079);
+EMIT_RR (spe_rotqmby, 0x1dd);
+EMIT_RI7 (spe_rotqmbyi, 0x1fd);
+EMIT_RR (spe_rotqmbybi, 0x1cd);
+EMIT_RR (spe_rotqmbi, 0x1c9);
+EMIT_RI7 (spe_rotqmbii, 0x1f9);
+EMIT_RR (spe_rotmah, 0x05e);
+EMIT_RI7 (spe_rotmahi, 0x07e);
+EMIT_RR (spe_rotma, 0x05a);
+EMIT_RI7 (spe_rotmai, 0x07a);
+
+
+/* Compare, branch, and halt instructions
+ */
+EMIT_RR (spe_heq, 0x3d8);
+EMIT_RI10(spe_heqi, 0x07f);
+EMIT_RR (spe_hgt, 0x258);
+EMIT_RI10(spe_hgti, 0x04f);
+EMIT_RR (spe_hlgt, 0x2d8);
+EMIT_RI10(spe_hlgti, 0x05f);
+EMIT_RR (spe_ceqb, 0x3d0);
+EMIT_RI10(spe_ceqbi, 0x07e);
+EMIT_RR (spe_ceqh, 0x3c8);
+EMIT_RI10(spe_ceqhi, 0x07d);
+EMIT_RR (spe_ceq, 0x3c0);
+EMIT_RI10(spe_ceqi, 0x07c);
+EMIT_RR (spe_cgtb, 0x250);
+EMIT_RI10(spe_cgtbi, 0x04e);
+EMIT_RR (spe_cgth, 0x248);
+EMIT_RI10(spe_cgthi, 0x04d);
+EMIT_RR (spe_cgt, 0x240);
+EMIT_RI10(spe_cgti, 0x04c);
+EMIT_RR (spe_clgtb, 0x2d0);
+EMIT_RI10(spe_clgtbi, 0x05e);
+EMIT_RR (spe_clgth, 0x2c8);
+EMIT_RI10(spe_clgthi, 0x05d);
+EMIT_RR (spe_clgt, 0x2c0);
+EMIT_RI10(spe_clgti, 0x05c);
+EMIT_I16 (spe_br, 0x064);
+EMIT_I16 (spe_bra, 0x060);
+EMIT_RI16(spe_brsl, 0x066);
+EMIT_RI16(spe_brasl, 0x062);
+EMIT_RI16(spe_brnz, 0x042);
+EMIT_RI16(spe_brz, 0x040);
+EMIT_RI16(spe_brhnz, 0x046);
+EMIT_RI16(spe_brhz, 0x044);
+
+extern void spe_bi(struct spe_function *p, unsigned rA, int d, int e);
+extern void spe_iret(struct spe_function *p, unsigned rA, int d, int e);
+extern void spe_bisled(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+extern void spe_bisl(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+extern void spe_biz(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+extern void spe_binz(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+extern void spe_bihz(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+extern void spe_bihnz(struct spe_function *p, unsigned rT, unsigned rA,
+ int d, int e);
+
+
+/* Floating-point instructions
+ */
+EMIT_RR (spe_fa, 0x2c4);
+EMIT_RR (spe_dfa, 0x2cc);
+EMIT_RR (spe_fs, 0x2c5);
+EMIT_RR (spe_dfs, 0x2cd);
+EMIT_RR (spe_fm, 0x2c6);
+EMIT_RR (spe_dfm, 0x2ce);
+EMIT_RRR (spe_fma, 0x00e);
+EMIT_RR (spe_dfma, 0x35c);
+EMIT_RRR (spe_fnms, 0x00d);
+EMIT_RR (spe_dfnms, 0x35e);
+EMIT_RRR (spe_fms, 0x00f);
+EMIT_RR (spe_dfms, 0x35d);
+EMIT_RR (spe_dfnma, 0x35f);
+EMIT_R (spe_frest, 0x1b8);
+EMIT_R (spe_frsqest, 0x1b9);
+EMIT_RR (spe_fi, 0x3d4);
+EMIT_RI7 (spe_csflt, 0x3da);
+EMIT_RI7 (spe_cflts, 0x3d8);
+EMIT_RI7 (spe_cuflt, 0x3db);
+EMIT_RI7 (spe_cfltu, 0x3d9);
+EMIT_R (spe_frds, 0x3b9);
+EMIT_R (spe_fesd, 0x3b8);
+EMIT_RR (spe_dfceq, 0x3c3);
+EMIT_RR (spe_dfcmeq, 0x3cb);
+EMIT_RR (spe_dfcgt, 0x2c3);
+EMIT_RR (spe_dfcmgt, 0x2cb);
+EMIT_RI7 (spe_dftsv, 0x3bf);
+EMIT_RR (spe_fceq, 0x3c2);
+EMIT_RR (spe_fcmeq, 0x3ca);
+EMIT_RR (spe_fcgt, 0x2c2);
+EMIT_RR (spe_fcmgt, 0x2ca);
+EMIT_R (spe_fscrwr, 0x3ba);
+EMIT_ (spe_fscrrd, 0x398);
+
+
+/* Channel instructions
+ */
+EMIT_R (spe_rdch, 0x00d);
+EMIT_R (spe_rdchcnt, 0x00f);
+EMIT_R (spe_wrch, 0x10d);
+
+
+#ifdef UNDEF_EMIT_MACROS
+#undef EMIT_
+#undef EMIT_R
+#undef EMIT_RR
+#undef EMIT_RRR
+#undef EMIT_RI7
+#undef EMIT_RI10
+#undef EMIT_RI16
+#undef EMIT_RI18
+#undef EMIT_I16
+#undef UNDEF_EMIT_MACROS
+#endif /* EMIT_ */
diff --git a/src/mesa/sources b/src/mesa/sources
index 96ae3dbca0..2d07738210 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -158,45 +158,45 @@ VF_SOURCES = \
DRAW_SOURCES = \
- pipe/draw/draw_clip.c \
- pipe/draw/draw_context.c\
- pipe/draw/draw_cull.c \
- pipe/draw/draw_debug.c \
- pipe/draw/draw_flatshade.c \
- pipe/draw/draw_offset.c \
- pipe/draw/draw_prim.c \
- pipe/draw/draw_stipple.c \
- pipe/draw/draw_twoside.c \
- pipe/draw/draw_unfilled.c \
- pipe/draw/draw_validate.c \
- pipe/draw/draw_vbuf.c \
- pipe/draw/draw_vertex.c \
- pipe/draw/draw_vertex_cache.c \
- pipe/draw/draw_vertex_fetch.c \
- pipe/draw/draw_vertex_shader.c \
- pipe/draw/draw_vf.c \
- pipe/draw/draw_vf_generic.c \
- pipe/draw/draw_vf_sse.c \
- pipe/draw/draw_wide_prims.c
+ $(TOP)/src/gallium/aux/draw/draw_clip.c \
+ $(TOP)/src/gallium/aux/draw/draw_context.c\
+ $(TOP)/src/gallium/aux/draw/draw_cull.c \
+ $(TOP)/src/gallium/aux/draw/draw_debug.c \
+ $(TOP)/src/gallium/aux/draw/draw_flatshade.c \
+ $(TOP)/src/gallium/aux/draw/draw_offset.c \
+ $(TOP)/src/gallium/aux/draw/draw_prim.c \
+ $(TOP)/src/gallium/aux/draw/draw_stipple.c \
+ $(TOP)/src/gallium/aux/draw/draw_twoside.c \
+ $(TOP)/src/gallium/aux/draw/draw_unfilled.c \
+ $(TOP)/src/gallium/aux/draw/draw_validate.c \
+ $(TOP)/src/gallium/aux/draw/draw_vbuf.c \
+ $(TOP)/src/gallium/aux/draw/draw_vertex.c \
+ $(TOP)/src/gallium/aux/draw/draw_vertex_cache.c \
+ $(TOP)/src/gallium/aux/draw/draw_vertex_fetch.c \
+ $(TOP)/src/gallium/aux/draw/draw_vertex_shader.c \
+ $(TOP)/src/gallium/aux/draw/draw_vf.c \
+ $(TOP)/src/gallium/aux/draw/draw_vf_generic.c \
+ $(TOP)/src/gallium/aux/draw/draw_vf_sse.c \
+ $(TOP)/src/gallium/aux/draw/draw_wide_prims.c
TGSIEXEC_SOURCES = \
- pipe/tgsi/exec/tgsi_exec.c \
- pipe/tgsi/exec/tgsi_sse2.c
+ $(TOP)/src/gallium/aux/tgsi/exec/tgsi_exec.c \
+ $(TOP)/src/gallium/aux/tgsi/exec/tgsi_sse2.c
TGSIUTIL_SOURCES = \
- pipe/tgsi/util/tgsi_build.c \
- pipe/tgsi/util/tgsi_dump.c \
- pipe/tgsi/util/tgsi_parse.c \
- pipe/tgsi/util/tgsi_util.c
+ $(TOP)/src/gallium/aux/tgsi/util/tgsi_build.c \
+ $(TOP)/src/gallium/aux/tgsi/util/tgsi_dump.c \
+ $(TOP)/src/gallium/aux/tgsi/util/tgsi_parse.c \
+ $(TOP)/src/gallium/aux/tgsi/util/tgsi_util.c
STATECACHE_SOURCES = \
- pipe/cso_cache/cso_hash.c \
- pipe/cso_cache/cso_cache.c
+ $(TOP)/src/gallium/aux/cso_cache/cso_hash.c \
+ $(TOP)/src/gallium/aux/cso_cache/cso_cache.c
PIPEUTIL_SOURCES = \
- pipe/util/p_debug.c \
- pipe/util/p_tile.c \
- pipe/util/p_util.c
+ $(TOP)/src/gallium/aux/util/p_debug.c \
+ $(TOP)/src/gallium/aux/util/p_tile.c \
+ $(TOP)/src/gallium/aux/util/p_util.c
STATETRACKER_SOURCES = \
state_tracker/st_atom.c \
@@ -288,6 +288,7 @@ ASM_C_SOURCES = \
x86/rtasm/x86sse.c \
sparc/sparc.c \
ppc/common_ppc.c \
+ ppc/rtasm/spe_asm.c \
x86-64/x86-64.c
X86_SOURCES = \
@@ -330,13 +331,13 @@ __COMMON_DRIVER_SOURCES = \
drivers/common/driverfuncs.c
X11_DRIVER_SOURCES = \
- pipe/xlib/glxapi.c \
- pipe/xlib/fakeglx.c \
- pipe/xlib/xfonts.c \
- pipe/xlib/xm_api.c \
- pipe/xlib/xm_winsys.c \
- pipe/xlib/xm_winsys_aub.c \
- pipe/xlib/brw_aub.c
+ $(TOP)/src/gallium/winsys/xlib/glxapi.c \
+ $(TOP)/src/gallium/winsys/xlib/fakeglx.c \
+ $(TOP)/src/gallium/winsys/xlib/xfonts.c \
+ $(TOP)/src/gallium/winsys/xlib/xm_api.c \
+ $(TOP)/src/gallium/winsys/xlib/xm_winsys.c \
+ $(TOP)/src/gallium/winsys/xlib/xm_winsys_aub.c \
+ $(TOP)/src/gallium/winsys/xlib/brw_aub.c
OSMESA_DRIVER_SOURCES = \
drivers/osmesa/osmesa.c
@@ -424,7 +425,10 @@ FBDEV_DRIVER_OBJECTS = $(FBDEV_DRIVER_SOURCES:.c=.o)
INCLUDE_DIRS = \
-I$(TOP)/include \
-I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/gallium/include \
+ -I$(TOP)/src/gallium/drivers \
+ -I$(TOP)/src/gallium/aux
OLD_INCLUDE_DIRS = \
-I$(TOP)/src/mesa/tnl \
@@ -434,4 +438,4 @@ OLD_INCLUDE_DIRS = \
-I$(TOP)/src/mesa/shader \
-I$(TOP)/src/mesa/shader/grammar \
-I$(TOP)/src/mesa/shader/slang \
- -I$(TOP)/src/mesa/pipe/tgsi
+ -I$(TOP)/s$(TOP)/src/gallium/aux/tgsi
diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c
index 2c6ec8421b..b67b620eaa 100644
--- a/src/mesa/state_tracker/st_atom_shader.c
+++ b/src/mesa/state_tracker/st_atom_shader.c
@@ -43,7 +43,7 @@
#include "pipe/p_context.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/cso_cache/cso_cache.h"
+#include "cso_cache/cso_cache.h"
#include "st_context.h"
#include "st_cache.h"
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index e0965b217a..2979e7fae5 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -36,8 +36,8 @@
#include "pipe/p_state.h"
-#include "pipe/cso_cache/cso_cache.h"
-#include "pipe/cso_cache/cso_hash.h"
+#include "cso_cache/cso_cache.h"
+#include "cso_cache/cso_hash.h"
/* Those function will either find the state of the given template
diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h
index e0c176b0ff..b81de316ec 100644
--- a/src/mesa/state_tracker/st_cache.h
+++ b/src/mesa/state_tracker/st_cache.h
@@ -33,7 +33,7 @@
#ifndef ST_CACHE_H
#define ST_CACHE_H
-#include "pipe/cso_cache/cso_cache.h"
+#include "cso_cache/cso_cache.h"
struct pipe_blend_state;
struct pipe_sampler_state;
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 3a3bf9016d..663c4f205d 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -43,7 +43,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/util/p_tile.h"
+#include "util/p_tile.h"
#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 410062e1e8..78baf772f4 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -272,6 +272,14 @@ clear_with_quad(GLcontext *ctx,
const GLfloat x1 = ctx->DrawBuffer->_Xmax;
const GLfloat y1 = ctx->DrawBuffer->_Ymax;
+ /*
+ printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__,
+ color ? "color, " : "",
+ depth ? "depth, " : "",
+ stencil ? "stencil" : "",
+ x0, y0,
+ x1, y1);
+ */
/* blend state: RGBA masking */
{
@@ -389,13 +397,44 @@ clear_with_quad(GLcontext *ctx,
* Determine if we need to clear the depth buffer by drawing a quad.
*/
static INLINE GLboolean
-check_clear_color_with_quad(GLcontext *ctx)
+check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const struct st_renderbuffer *strb = st_renderbuffer(rb);
+
+ if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED)
+ return FALSE;
+
+ if (ctx->Scissor.Enabled)
+ return TRUE;
+
+ if (!ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3])
+ return TRUE;
+
+ return FALSE;
+}
+
+
+static INLINE GLboolean
+check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
- return !(ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3] &&
- !ctx->Scissor.Enabled);
+ const struct st_renderbuffer *strb = st_renderbuffer(rb);
+ const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+ GLboolean maskStencil
+ = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+
+ if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED)
+ return FALSE;
+
+ if (ctx->Scissor.Enabled)
+ return TRUE;
+
+ if (maskStencil)
+ return TRUE;
+
+ return FALSE;
}
@@ -407,10 +446,19 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
- return ctx->Scissor.Enabled
- || (isDS &&
- strb->surface->status == PIPE_SURFACE_STATUS_DEFINED &&
- ctx->DrawBuffer->Visual.stencilBits > 0);
+
+ if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED)
+ return FALSE;
+
+ if (ctx->Scissor.Enabled)
+ return TRUE;
+
+ if (isDS &&
+ strb->surface->status == PIPE_SURFACE_STATUS_DEFINED &&
+ ctx->DrawBuffer->Visual.stencilBits > 0)
+ return TRUE;
+
+ return FALSE;
}
@@ -425,9 +473,27 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
const GLuint stencilMax = (1 << rb->StencilBits) - 1;
const GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
- return maskStencil
- || ctx->Scissor.Enabled
- || (isDS && ctx->DrawBuffer->Visual.depthBits > 0);
+
+ if (strb->surface->status == PIPE_SURFACE_STATUS_UNDEFINED)
+ return FALSE;
+
+ if (maskStencil)
+ return TRUE;
+
+ if (ctx->Scissor.Enabled)
+ return TRUE;
+
+ /* This is correct, but it is necessary to look at the depth clear
+ * value held in the surface when it comes time to issue the clear,
+ * rather than taking depth and stencil clear values from the
+ * current state.
+ */
+ if (isDS &&
+ strb->surface->status == PIPE_SURFACE_STATUS_DEFINED &&
+ ctx->DrawBuffer->Visual.depthBits > 0)
+ return TRUE;
+
+ return FALSE;
}
@@ -436,14 +502,10 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
static void
clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
- struct st_renderbuffer *strb = st_renderbuffer(rb);
-
- if (ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3] &&
- !ctx->Scissor.Enabled)
+ if (!check_clear_color_with_quad( ctx, rb ))
{
+ struct st_renderbuffer *strb = st_renderbuffer(rb);
+
/* clear whole buffer w/out masking */
GLuint clearValue
= color_value(strb->surface->format, ctx->Color.ClearColor);
@@ -482,14 +544,8 @@ static void
clear_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *strb = st_renderbuffer(rb);
- const GLboolean isDS = is_depth_stencil_format(strb->surface->format);
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
- GLboolean maskStencil
- = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
- if (maskStencil ||
- ctx->Scissor.Enabled ||
- (isDS && ctx->DrawBuffer->Visual.depthBits > 0)) {
+ if (check_clear_stencil_with_quad(ctx, rb)) {
/* masking or scissoring or combined depth/stencil buffer */
clear_with_quad(ctx, GL_FALSE, GL_FALSE, GL_TRUE);
}
@@ -505,13 +561,10 @@ static void
clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
{
struct st_renderbuffer *strb = st_renderbuffer(rb);
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
- GLboolean maskStencil
- = (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
assert(is_depth_stencil_format(strb->surface->format));
- if (!maskStencil && !ctx->Scissor.Enabled) {
+ if (check_clear_depth_stencil_with_quad(ctx, rb)) {
/* clear whole buffer w/out masking */
GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear);
@@ -520,7 +573,7 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
clearValue |= ctx->Stencil.Clear << 24;
break;
case PIPE_FORMAT_Z24S8_UNORM:
- clearValue |= clearValue | ctx->Stencil.Clear;
+ clearValue |= ctx->Stencil.Clear;
break;
default:
assert(0);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index f13199a3c0..e2d4e06da1 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -56,7 +56,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "pipe/util/p_tile.h"
+#include "util/p_tile.h"
#include "shader/prog_instruction.h"
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index 31744151f1..5315294c07 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -53,10 +53,10 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/cso_cache/cso_cache.h"
+#include "cso_cache/cso_cache.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.h"
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
/**
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index af3ee65504..61d4f4c41c 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -39,8 +39,8 @@
#include "shader/programopt.h"
#include "shader/shader_api.h"
-#include "pipe/cso_cache/cso_cache.h"
-#include "pipe/draw/draw_context.h"
+#include "cso_cache/cso_cache.h"
+#include "draw/draw_context.h"
#include "st_context.h"
#include "st_program.h"
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 7e347c4893..5b0eb6022b 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -44,8 +44,8 @@
#include "st_draw.h"
#include "st_cb_rasterpos.h"
#include "st_draw.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/draw/draw_private.h"
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
#include "shader/prog_instruction.h"
#include "vbo/vbo.h"
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 868c5f3c5f..c89c74229e 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -40,7 +40,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/util/p_tile.h"
+#include "util/p_tile.h"
#include "st_context.h"
#include "st_cb_readpixels.h"
#include "st_cb_fbo.h"
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 91a40288cc..03dbb30b0f 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -47,7 +47,7 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/util/p_tile.h"
+#include "util/p_tile.h"
#define DBG if (0) printf
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index bf4618bed8..09e389f9dc 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -54,8 +54,8 @@
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/cso_cache/cso_cache.h"
+#include "draw/draw_context.h"
+#include "cso_cache/cso_cache.h"
/**
diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c
index 57450e52bf..5888bcb98a 100644
--- a/src/mesa/state_tracker/st_debug.c
+++ b/src/mesa/state_tracker/st_debug.c
@@ -31,9 +31,9 @@
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
+#include "tgsi/util/tgsi_dump.h"
-#include "pipe/cso_cache/cso_cache.h"
+#include "cso_cache/cso_cache.h"
#include "st_context.h"
#include "st_debug.h"
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index ae9f5c8b11..1c0fa8c6aa 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -47,8 +47,8 @@
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
-#include "pipe/draw/draw_private.h"
-#include "pipe/draw/draw_context.h"
+#include "draw/draw_private.h"
+#include "draw/draw_context.h"
static GLuint double_types[4] = {
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 459941cca8..6c09b86033 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -37,7 +37,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "pipe/cso_cache/cso_cache.h"
+#include "cso_cache/cso_cache.h"
#include "st_context.h"
#include "st_draw.h"
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 325aa20173..97206752af 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -32,9 +32,9 @@
#include "pipe/p_compiler.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/tgsi/util/tgsi_parse.h"
-#include "pipe/tgsi/util/tgsi_build.h"
-#include "pipe/tgsi/util/tgsi_util.h"
+#include "tgsi/util/tgsi_parse.h"
+#include "tgsi/util/tgsi_build.h"
+#include "tgsi/util/tgsi_util.h"
#include "st_mesa_to_tgsi.h"
#include "shader/prog_instruction.h"
#include "shader/prog_parameter.h"
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index c8297baded..dc992ee9c2 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -38,8 +38,8 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
-#include "pipe/draw/draw_context.h"
-#include "pipe/tgsi/util/tgsi_dump.h"
+#include "draw/draw_context.h"
+#include "tgsi/util/tgsi_dump.h"
#include "st_context.h"
#include "st_cache.h"