summaryrefslogtreecommitdiff
path: root/xc/lib/GL/mesa/src
diff options
context:
space:
mode:
authordawes <dawes>2002-02-14 01:59:27 +0000
committerdawes <dawes>2002-02-14 01:59:27 +0000
commit316e8f1af01604b1638a7613f2becd051cf3fcb5 (patch)
tree42de1a90195578a20c62fe804d9bc7db2c1613cf /xc/lib/GL/mesa/src
parentd7079b0d92edbc78a16a913bfa9851332bfcc435 (diff)
First pass of mesa-4-0 branch merge into trunk.
Diffstat (limited to 'xc/lib/GL/mesa/src')
-rw-r--r--xc/lib/GL/mesa/src/Imakefile25
-rw-r--r--xc/lib/GL/mesa/src/Imakefile.inc636
-rw-r--r--xc/lib/GL/mesa/src/OSmesa/Imakefile10
-rw-r--r--xc/lib/GL/mesa/src/SPARC/Imakefile52
-rw-r--r--xc/lib/GL/mesa/src/SPARC/Imakefile.inc58
-rw-r--r--xc/lib/GL/mesa/src/X/Imakefile75
-rw-r--r--xc/lib/GL/mesa/src/X/Imakefile.inc57
-rw-r--r--xc/lib/GL/mesa/src/X/xdri.c111
-rw-r--r--xc/lib/GL/mesa/src/X/xdriP.h37
-rw-r--r--xc/lib/GL/mesa/src/X86/Imakefile59
-rw-r--r--xc/lib/GL/mesa/src/X86/Imakefile.inc266
-rw-r--r--xc/lib/GL/mesa/src/array_cache/Imakefile86
-rw-r--r--xc/lib/GL/mesa/src/drv/common/spantmp.h12
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/Imakefile31
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc166
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.c156
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c22
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_context.h182
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c58
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c32
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c212
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h11
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h238
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h5
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c84
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h11
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_points.c126
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_points.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h123
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_rendertmp.h648
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_span.c45
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_state.c543
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_state.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c39
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tex.c51
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tex.h (renamed from xc/lib/GL/mesa/src/drv/i810/i810dd.h)21
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c1027
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h24
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h315
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c396
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h77
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h177
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.c429
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c425
-rw-r--r--xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h5
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/Imakefile10
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc113
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_client.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_context.c212
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_context.h406
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_dd.c125
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.c3314
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.h381
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c5312
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_gl.h384
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_init.c112
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_init.h251
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c916
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c57
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_lock.h88
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h109
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c229
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_region.h45
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h48
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_render.c317
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c145
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_screen.h30
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_span.c339
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_state.c1731
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c417
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c528
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c214
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c245
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_texture.h67
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c654
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tris.h36
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_tritmp.h495
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c317
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_vb.h60
-rw-r--r--xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c727
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/Imakefile8
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/Imakefile.inc92
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h46
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c684
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.c448
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810context.h194
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810dd.c140
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810fastpath.c523
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810fasttmp.h143
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ioctl.c456
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810ioctl.h69
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810log.h47
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810pipeline.c114
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810pipeline.h14
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810render.c214
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810screen.c321
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810screen.h (renamed from xc/lib/GL/mesa/src/drv/i810/i810_init.h)62
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810span.c121
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810span.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810state.c817
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810state.h10
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tex.c1546
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tex.h24
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810texmem.c410
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810texstate.c754
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tris.c902
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tris.h149
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810tritmp.h196
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810vb.c765
-rw-r--r--xc/lib/GL/mesa/src/drv/i810/i810vb.h106
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/Imakefile7
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/Imakefile.inc37
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c409
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h6
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgabuffers.c36
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgabuffers.h3
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgacontext.h134
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgadd.c78
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c460
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h269
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgafastpath.c537
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h182
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.c292
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaioctl.h37
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgapipeline.c162
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgapixel.c149
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgapixel.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaregs.h2682
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgarender.c208
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgaspan.c135
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.c359
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgastate.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatex.c346
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatris.c952
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatris.h187
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgatritmp.h233
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.c787
-rw-r--r--xc/lib/GL/mesa/src/drv/mga/mgavb.h102
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/Imakefile8
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/Imakefile.inc60
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.c209
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h138
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.c71
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c499
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h263
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c534
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h190
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c299
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h38
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_lock.c6
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c167
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h53
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.c209
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.h5
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.c106
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.c404
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.c1595
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tex.h26
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_texmem.c592
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_texobj.h8
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_texstate.c597
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.c766
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tris.h314
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h333
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.c838
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_vb.h147
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c318
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/Imakefile6
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc63
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_context.c667
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_context.h341
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_dd.c226
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_dd.h46
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_eltpath.c504
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_elttmp.h246
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_fastpath.c542
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_fasttmp.h185
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c767
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h143
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c51
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h12
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.c168
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.h54
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_render.c258
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c57
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h30
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_span.c174
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_span.h4
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_state.c1924
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_state.h22
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c1018
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h47
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c172
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_texobj.h77
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c325
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c618
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h306
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_tritmp.h349
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c840
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h130
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c785
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.h (renamed from xc/lib/GL/mesa/src/drv/mga/mgapipeline.h)30
-rw-r--r--xc/lib/GL/mesa/src/drv/radeon/radeon_xmesa.c312
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/Imakefile8
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc65
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c508
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h279
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c157
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_fastpath.c594
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_fasttmp.h293
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c24
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.c177
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c170
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h10
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c184
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c286
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h5
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c180
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c468
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h9
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c2109
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h131
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c1561
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h68
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c502
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.h (renamed from xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.h)22
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c1447
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h147
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_tritmp.h415
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c682
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h141
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_vbtmp.h442
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.c392
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.h673
-rw-r--r--xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c429
-rw-r--r--xc/lib/GL/mesa/src/math/Imakefile111
-rw-r--r--xc/lib/GL/mesa/src/swrast/Imakefile173
-rw-r--r--xc/lib/GL/mesa/src/swrast_setup/Imakefile87
-rw-r--r--xc/lib/GL/mesa/src/tnl/Imakefile147
-rw-r--r--xc/lib/GL/mesa/src/tnl_dd/Imakefile86
245 files changed, 34741 insertions, 42544 deletions
diff --git a/xc/lib/GL/mesa/src/Imakefile b/xc/lib/GL/mesa/src/Imakefile
index 203651d9a..145babf29 100644
--- a/xc/lib/GL/mesa/src/Imakefile
+++ b/xc/lib/GL/mesa/src/Imakefile
@@ -26,13 +26,15 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/Imakefile,v 1.26 2001/05/02 15:06:02 dawes Ex
ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
-#if GlxBuiltInTdfx
- TDFX_DEFINES = -DFX
-#endif
-
#ifdef i386Architecture
#define MesaX86BuildDir /**/
#include "X86/Imakefile.inc"
+ASM_SUBDIRS = X86
+#endif
+#ifdef Sparcrchitecture
+#define MesaSparcBuildDir /**/
+#include "SPARC/Imakefile.inc"
+ASM_SUBDIRS = SPARC
#endif
#define MesaBuildDir /**/
#define NeedToLinkMesaSrc
@@ -42,12 +44,13 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
MATH_DEFINES = -DCCPML
#endif
- DEFINES = $(ALLOC_DEFINES) GlxDefines $(TDFX_DEFINES) \
+ DEFINES = $(ALLOC_DEFINES) GlxDefines \
$(MESA_ASM_DEFINES) $(MATH_DEFINES)
INCLUDES = -I$(INCLUDESRC) -I$(XINCLUDESRC) -I$(EXTINCSRC) \
- -I$(MESASRCDIR)/src -I$(GLXLIBSRC)/dri
- SRCS = $(COREMESASRCS)
- OBJS = $(COREMESAOBJS)
+ -I$(MESASRCDIR)/src -I$(GLXLIBSRC)/dri \
+ -I$(MESASRCDIR)/include -I$(GLXLIBSRC)/include
+ SRCS = $(COREMESABASESRCS)
+ OBJS = $(COREMESABASEOBJS)
#include <Library.tmpl>
@@ -56,16 +59,14 @@ LibraryObjectRule()
SubdirLibraryRule($(OBJS))
NormalLintTarget($(SRCS))
-#ifdef i386Architecture
-
#define IHaveSubdirs
#define PassCDebugFlags
-SUBDIRS = X86
+SUBDIRS = $(ASM_SUBDIRS) math array_cache swrast swrast_setup tnl tnl_dd X
+
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
-#endif
DependTarget()
diff --git a/xc/lib/GL/mesa/src/Imakefile.inc b/xc/lib/GL/mesa/src/Imakefile.inc
index 45d36b409..57473d867 100644
--- a/xc/lib/GL/mesa/src/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/Imakefile.inc
@@ -13,22 +13,28 @@ GLAPINOOPSRCS = $(MESABUILDDIR)glapinoop.c
GLTHREADSRCS = $(MESABUILDDIR)glthread.c
#endif
-COREMESASRCS = $(MESABUILDDIR)aatriangle.c \
+MESA_CORE_INCLUDES = -I$(MESASRCDIR)/src/array_cache \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/swrast -I$(MESASRCDIR)/src/swrast_setup \
+ -I$(MESASRCDIR)/src/tnl -I$(MESASRCDIR)/src/tnl_dd
+
+
+COREMESABASESRCS = \
$(MESABUILDDIR)accum.c \
- $(MESABUILDDIR)alpha.c \
- $(MESABUILDDIR)alphabuf.c \
+ $(MESABUILDDIR)api_arrayelt.c \
+ $(MESABUILDDIR)api_eval.c \
+ $(MESABUILDDIR)api_loopback.c \
+ $(MESABUILDDIR)api_noop.c \
+ $(MESABUILDDIR)api_validate.c \
$(MESABUILDDIR)attrib.c \
- $(MESABUILDDIR)bbox.c \
- $(MESABUILDDIR)bitmap.c \
$(MESABUILDDIR)blend.c \
$(MESABUILDDIR)buffers.c \
$(MESABUILDDIR)clip.c \
$(MESABUILDDIR)colortab.c \
$(MESABUILDDIR)config.c \
$(MESABUILDDIR)context.c \
- $(MESABUILDDIR)copypix.c \
- $(MESABUILDDIR)cva.c \
- $(MESABUILDDIR)debug_xform.c \
+ $(MESABUILDDIR)convolve.c \
+ $(MESABUILDDIR)debug.c \
$(MESABUILDDIR)depth.c \
$(DISPATCHSRCS) \
$(MESABUILDDIR)dlist.c \
@@ -41,73 +47,116 @@ COREMESASRCS = $(MESABUILDDIR)aatriangle.c \
$(MESABUILDDIR)fog.c \
$(MESABUILDDIR)get.c \
$(GLAPISRCS) \
- $(GLAPINOOPSRCS) \
$(GLTHREADSRCS) \
$(MESABUILDDIR)hash.c \
$(MESABUILDDIR)hint.c \
+ $(MESABUILDDIR)histogram.c \
$(MESABUILDDIR)image.c \
- $(MESABUILDDIR)imaging.c \
+ $(MESABUILDDIR)imports.c \
$(MESABUILDDIR)light.c \
$(MESABUILDDIR)lines.c \
- $(MESABUILDDIR)logic.c \
- $(MESABUILDDIR)masking.c \
$(MESABUILDDIR)matrix.c \
$(MESABUILDDIR)mem.c \
$(MESABUILDDIR)mmath.c \
- $(MESABUILDDIR)pb.c \
- $(MESABUILDDIR)pipeline.c \
$(MESABUILDDIR)pixel.c \
- $(MESABUILDDIR)pixeltex.c \
$(MESABUILDDIR)points.c \
$(MESABUILDDIR)polygon.c \
- $(MESABUILDDIR)quads.c \
$(MESABUILDDIR)rastpos.c \
- $(MESABUILDDIR)readpix.c \
- $(MESABUILDDIR)rect.c \
- $(MESABUILDDIR)scissor.c \
- $(MESABUILDDIR)shade.c \
- $(MESABUILDDIR)span.c \
- $(MESABUILDDIR)stages.c \
$(MESABUILDDIR)state.c \
$(MESABUILDDIR)stencil.c \
$(MESABUILDDIR)texformat.c \
$(MESABUILDDIR)teximage.c \
$(MESABUILDDIR)texobj.c \
$(MESABUILDDIR)texstate.c \
- $(MESABUILDDIR)texture.c \
+ $(MESABUILDDIR)texstore.c \
$(MESABUILDDIR)texutil.c \
- $(MESABUILDDIR)translate.c \
- $(MESABUILDDIR)triangle.c \
$(MESABUILDDIR)varray.c \
- $(MESABUILDDIR)vb.c \
- $(MESABUILDDIR)vbcull.c \
- $(MESABUILDDIR)vbfill.c \
- $(MESABUILDDIR)vbindirect.c \
- $(MESABUILDDIR)vbrender.c \
- $(MESABUILDDIR)vbxform.c \
- $(MESABUILDDIR)vector.c \
- $(MESABUILDDIR)vertices.c \
- $(MESABUILDDIR)winpos.c \
- $(MESABUILDDIR)xform.c \
- $(MESABUILDDIR)zoom.c
+ $(MESABUILDDIR)vtxfmt.c
+
+COREMESASRCS = $(COREMESABASESRCS) \
+ $(MESABUILDDIR)array_cache/ac_context.c \
+ $(MESABUILDDIR)array_cache/ac_import.c \
+ $(MESABUILDDIR)math/m_debug_clip.c \
+ $(MESABUILDDIR)math/m_debug_norm.c \
+ $(MESABUILDDIR)math/m_debug_vertex.c \
+ $(MESABUILDDIR)math/m_debug_xform.c \
+ $(MESABUILDDIR)math/m_eval.c \
+ $(MESABUILDDIR)math/m_matrix.c \
+ $(MESABUILDDIR)math/m_translate.c \
+ $(MESABUILDDIR)math/m_vector.c \
+ $(MESABUILDDIR)math/m_vertices.c \
+ $(MESABUILDDIR)math/m_xform.c \
+ $(MESABUILDDIR)swrast/s_aaline.c \
+ $(MESABUILDDIR)swrast/s_aatriangle.c \
+ $(MESABUILDDIR)swrast/s_accum.c \
+ $(MESABUILDDIR)swrast/s_alpha.c \
+ $(MESABUILDDIR)swrast/s_alphabuf.c \
+ $(MESABUILDDIR)swrast/s_bitmap.c \
+ $(MESABUILDDIR)swrast/s_blend.c \
+ $(MESABUILDDIR)swrast/s_buffers.c \
+ $(MESABUILDDIR)swrast/s_copypix.c \
+ $(MESABUILDDIR)swrast/s_context.c \
+ $(MESABUILDDIR)swrast/s_depth.c \
+ $(MESABUILDDIR)swrast/s_drawpix.c \
+ $(MESABUILDDIR)swrast/s_feedback.c \
+ $(MESABUILDDIR)swrast/s_fog.c \
+ $(MESABUILDDIR)swrast/s_histogram.c \
+ $(MESABUILDDIR)swrast/s_imaging.c \
+ $(MESABUILDDIR)swrast/s_lines.c \
+ $(MESABUILDDIR)swrast/s_logic.c \
+ $(MESABUILDDIR)swrast/s_masking.c \
+ $(MESABUILDDIR)swrast/s_pb.c \
+ $(MESABUILDDIR)swrast/s_pixeltex.c \
+ $(MESABUILDDIR)swrast/s_points.c \
+ $(MESABUILDDIR)swrast/s_readpix.c \
+ $(MESABUILDDIR)swrast/s_scissor.c \
+ $(MESABUILDDIR)swrast/s_span.c \
+ $(MESABUILDDIR)swrast/s_stencil.c \
+ $(MESABUILDDIR)swrast/s_texture.c \
+ $(MESABUILDDIR)swrast/s_texstore.c \
+ $(MESABUILDDIR)swrast/s_triangle.c \
+ $(MESABUILDDIR)swrast/s_zoom.c \
+ $(MESABUILDDIR)swrast_setup/ss_context.c \
+ $(MESABUILDDIR)swrast_setup/ss_triangle.c \
+ $(MESABUILDDIR)swrast_setup/ss_vb.c \
+ $(MESABUILDDIR)tnl/t_array_api.c \
+ $(MESABUILDDIR)tnl/t_array_import.c \
+ $(MESABUILDDIR)tnl/t_context.c \
+ $(MESABUILDDIR)tnl/t_eval_api.c \
+ $(MESABUILDDIR)tnl/t_imm_alloc.c \
+ $(MESABUILDDIR)tnl/t_imm_api.c \
+ $(MESABUILDDIR)tnl/t_imm_debug.c \
+ $(MESABUILDDIR)tnl/t_imm_dlist.c \
+ $(MESABUILDDIR)tnl/t_imm_elt.c \
+ $(MESABUILDDIR)tnl/t_imm_eval.c \
+ $(MESABUILDDIR)tnl/t_imm_exec.c \
+ $(MESABUILDDIR)tnl/t_imm_fixup.c \
+ $(MESABUILDDIR)tnl/t_pipeline.c \
+ $(MESABUILDDIR)tnl/t_vb_fog.c \
+ $(MESABUILDDIR)tnl/t_vb_light.c \
+ $(MESABUILDDIR)tnl/t_vb_normals.c \
+ $(MESABUILDDIR)tnl/t_vb_points.c \
+ $(MESABUILDDIR)tnl/t_vb_render.c \
+ $(MESABUILDDIR)tnl/t_vb_texgen.c \
+ $(MESABUILDDIR)tnl/t_vb_texmat.c \
+ $(MESABUILDDIR)tnl/t_vb_vertex.c
#ifdef NeedToLinkMesaSrc
-LinkSourceFile(aatriangle.c, $(MESASRCDIR)/src)
LinkSourceFile(accum.c, $(MESASRCDIR)/src)
-LinkSourceFile(alpha.c, $(MESASRCDIR)/src)
-LinkSourceFile(alphabuf.c, $(MESASRCDIR)/src)
+LinkSourceFile(api_arrayelt.c, $(MESASRCDIR)/src)
+LinkSourceFile(api_eval.c, $(MESASRCDIR)/src)
+LinkSourceFile(api_loopback.c, $(MESASRCDIR)/src)
+LinkSourceFile(api_noop.c, $(MESASRCDIR)/src)
+LinkSourceFile(api_validate.c, $(MESASRCDIR)/src)
LinkSourceFile(attrib.c, $(MESASRCDIR)/src)
-LinkSourceFile(bbox.c, $(MESASRCDIR)/src)
-LinkSourceFile(bitmap.c, $(MESASRCDIR)/src)
LinkSourceFile(blend.c, $(MESASRCDIR)/src)
LinkSourceFile(buffers.c, $(MESASRCDIR)/src)
LinkSourceFile(clip.c, $(MESASRCDIR)/src)
LinkSourceFile(colortab.c, $(MESASRCDIR)/src)
LinkSourceFile(config.c, $(MESASRCDIR)/src)
LinkSourceFile(context.c, $(MESASRCDIR)/src)
-LinkSourceFile(copypix.c, $(MESASRCDIR)/src)
-LinkSourceFile(cva.c, $(MESASRCDIR)/src)
-LinkSourceFile(debug_xform.c, $(MESASRCDIR)/src)
+LinkSourceFile(convolve.c, $(MESASRCDIR)/src)
+LinkSourceFile(debug.c, $(MESASRCDIR)/src)
LinkSourceFile(depth.c, $(MESASRCDIR)/src)
#ifdef NeedAllMesaSrc
LinkSourceFile(dispatch.c, $(MESASRCDIR)/src)
@@ -123,56 +172,32 @@ LinkSourceFile(fog.c, $(MESASRCDIR)/src)
LinkSourceFile(get.c, $(MESASRCDIR)/src)
#ifdef NeedAllMesaSrc
LinkSourceFile(glapi.c, $(MESASRCDIR)/src)
-LinkSourceFile(glapinoop.c, $(MESASRCDIR)/src)
LinkSourceFile(glthread.c, $(MESASRCDIR)/src)
#endif
LinkSourceFile(hash.c, $(MESASRCDIR)/src)
LinkSourceFile(hint.c, $(MESASRCDIR)/src)
+LinkSourceFile(histogram.c, $(MESASRCDIR)/src)
LinkSourceFile(image.c, $(MESASRCDIR)/src)
-LinkSourceFile(imaging.c, $(MESASRCDIR)/src)
+LinkSourceFile(imports.c, $(MESASRCDIR)/src)
LinkSourceFile(light.c, $(MESASRCDIR)/src)
LinkSourceFile(lines.c, $(MESASRCDIR)/src)
-LinkSourceFile(logic.c, $(MESASRCDIR)/src)
-LinkSourceFile(masking.c, $(MESASRCDIR)/src)
LinkSourceFile(matrix.c, $(MESASRCDIR)/src)
LinkSourceFile(mem.c, $(MESASRCDIR)/src)
LinkSourceFile(mmath.c, $(MESASRCDIR)/src)
-LinkSourceFile(pb.c, $(MESASRCDIR)/src)
-LinkSourceFile(pipeline.c, $(MESASRCDIR)/src)
LinkSourceFile(pixel.c, $(MESASRCDIR)/src)
-LinkSourceFile(pixeltex.c, $(MESASRCDIR)/src)
LinkSourceFile(points.c, $(MESASRCDIR)/src)
LinkSourceFile(polygon.c, $(MESASRCDIR)/src)
-LinkSourceFile(quads.c, $(MESASRCDIR)/src)
LinkSourceFile(rastpos.c, $(MESASRCDIR)/src)
-LinkSourceFile(readpix.c, $(MESASRCDIR)/src)
-LinkSourceFile(rect.c, $(MESASRCDIR)/src)
-LinkSourceFile(scissor.c, $(MESASRCDIR)/src)
-LinkSourceFile(shade.c, $(MESASRCDIR)/src)
-LinkSourceFile(span.c, $(MESASRCDIR)/src)
-LinkSourceFile(stages.c, $(MESASRCDIR)/src)
LinkSourceFile(state.c, $(MESASRCDIR)/src)
LinkSourceFile(stencil.c, $(MESASRCDIR)/src)
LinkSourceFile(texformat.c, $(MESASRCDIR)/src)
LinkSourceFile(teximage.c, $(MESASRCDIR)/src)
LinkSourceFile(texobj.c, $(MESASRCDIR)/src)
LinkSourceFile(texstate.c, $(MESASRCDIR)/src)
-LinkSourceFile(texture.c, $(MESASRCDIR)/src)
+LinkSourceFile(texstore.c, $(MESASRCDIR)/src)
LinkSourceFile(texutil.c, $(MESASRCDIR)/src)
-LinkSourceFile(translate.c, $(MESASRCDIR)/src)
-LinkSourceFile(triangle.c, $(MESASRCDIR)/src)
LinkSourceFile(varray.c, $(MESASRCDIR)/src)
-LinkSourceFile(vb.c, $(MESASRCDIR)/src)
-LinkSourceFile(vbcull.c, $(MESASRCDIR)/src)
-LinkSourceFile(vbfill.c, $(MESASRCDIR)/src)
-LinkSourceFile(vbindirect.c, $(MESASRCDIR)/src)
-LinkSourceFile(vbrender.c, $(MESASRCDIR)/src)
-LinkSourceFile(vbxform.c, $(MESASRCDIR)/src)
-LinkSourceFile(vector.c, $(MESASRCDIR)/src)
-LinkSourceFile(vertices.c, $(MESASRCDIR)/src)
-LinkSourceFile(winpos.c, $(MESASRCDIR)/src)
-LinkSourceFile(xform.c, $(MESASRCDIR)/src)
-LinkSourceFile(zoom.c, $(MESASRCDIR)/src)
+LinkSourceFile(vtxfmt.c, $(MESASRCDIR)/src)
#endif
#ifdef NeedAllMesaSrc
@@ -182,25 +207,25 @@ GLAPINOOPOBJS = $(MESABUILDDIR)glapinoop.o
GLTHREADOBJS = $(MESABUILDDIR)glthread.o
#endif
-COREMESAOBJS = $(MESABUILDDIR)aatriangle.o \
+COREMESABASEOBJS = \
$(MESABUILDDIR)accum.o \
- $(MESABUILDDIR)alpha.o \
- $(MESABUILDDIR)alphabuf.o \
+ $(MESABUILDDIR)api_arrayelt.o \
+ $(MESABUILDDIR)api_eval.o \
+ $(MESABUILDDIR)api_loopback.o \
+ $(MESABUILDDIR)api_noop.o \
+ $(MESABUILDDIR)api_validate.o \
$(MESABUILDDIR)attrib.o \
- $(MESABUILDDIR)bbox.o \
- $(MESABUILDDIR)bitmap.o \
$(MESABUILDDIR)blend.o \
$(MESABUILDDIR)buffers.o \
$(MESABUILDDIR)clip.o \
$(MESABUILDDIR)colortab.o \
$(MESABUILDDIR)config.o \
$(MESABUILDDIR)context.o \
- $(MESABUILDDIR)copypix.o \
- $(MESABUILDDIR)cva.o \
- $(MESABUILDDIR)debug_xform.o \
+ $(MESABUILDDIR)convolve.o \
+ $(MESABUILDDIR)debug.o \
$(MESABUILDDIR)depth.o \
- $(MESABUILDDIR)dlist.o \
$(DISPATCHOBJS) \
+ $(MESABUILDDIR)dlist.o \
$(MESABUILDDIR)drawpix.o \
$(MESABUILDDIR)enable.o \
$(MESABUILDDIR)enums.o \
@@ -210,55 +235,99 @@ COREMESAOBJS = $(MESABUILDDIR)aatriangle.o \
$(MESABUILDDIR)fog.o \
$(MESABUILDDIR)get.o \
$(GLAPIOBJS) \
- $(GLAPINOOPOBJS) \
$(GLTHREADOBJS) \
$(MESABUILDDIR)hash.o \
$(MESABUILDDIR)hint.o \
+ $(MESABUILDDIR)histogram.o \
$(MESABUILDDIR)image.o \
- $(MESABUILDDIR)imaging.o \
+ $(MESABUILDDIR)imports.o \
$(MESABUILDDIR)light.o \
$(MESABUILDDIR)lines.o \
- $(MESABUILDDIR)logic.o \
- $(MESABUILDDIR)masking.o \
$(MESABUILDDIR)matrix.o \
$(MESABUILDDIR)mem.o \
$(MESABUILDDIR)mmath.o \
- $(MESABUILDDIR)pb.o \
- $(MESABUILDDIR)pipeline.o \
$(MESABUILDDIR)pixel.o \
- $(MESABUILDDIR)pixeltex.o \
$(MESABUILDDIR)points.o \
$(MESABUILDDIR)polygon.o \
- $(MESABUILDDIR)quads.o \
$(MESABUILDDIR)rastpos.o \
- $(MESABUILDDIR)readpix.o \
- $(MESABUILDDIR)rect.o \
- $(MESABUILDDIR)scissor.o \
- $(MESABUILDDIR)shade.o \
- $(MESABUILDDIR)span.o \
- $(MESABUILDDIR)stages.o \
$(MESABUILDDIR)state.o \
$(MESABUILDDIR)stencil.o \
$(MESABUILDDIR)texformat.o \
$(MESABUILDDIR)teximage.o \
$(MESABUILDDIR)texobj.o \
$(MESABUILDDIR)texstate.o \
- $(MESABUILDDIR)texture.o \
+ $(MESABUILDDIR)texstore.o \
$(MESABUILDDIR)texutil.o \
- $(MESABUILDDIR)translate.o \
- $(MESABUILDDIR)triangle.o \
$(MESABUILDDIR)varray.o \
- $(MESABUILDDIR)vb.o \
- $(MESABUILDDIR)vbcull.o \
- $(MESABUILDDIR)vbfill.o \
- $(MESABUILDDIR)vbindirect.o \
- $(MESABUILDDIR)vbrender.o \
- $(MESABUILDDIR)vbxform.o \
- $(MESABUILDDIR)vector.o \
- $(MESABUILDDIR)vertices.o \
- $(MESABUILDDIR)winpos.o \
- $(MESABUILDDIR)xform.o \
- $(MESABUILDDIR)zoom.o
+ $(MESABUILDDIR)vtxfmt.o
+
+COREMESAOBJS = $(COREMESABASEOBJS) \
+ $(MESABUILDDIR)array_cache/ac_context.o \
+ $(MESABUILDDIR)array_cache/ac_import.o \
+ $(MESABUILDDIR)math/m_debug_clip.o \
+ $(MESABUILDDIR)math/m_debug_norm.o \
+ $(MESABUILDDIR)math/m_debug_vertex.o \
+ $(MESABUILDDIR)math/m_debug_xform.o \
+ $(MESABUILDDIR)math/m_eval.o \
+ $(MESABUILDDIR)math/m_matrix.o \
+ $(MESABUILDDIR)math/m_translate.o \
+ $(MESABUILDDIR)math/m_vector.o \
+ $(MESABUILDDIR)math/m_vertices.o \
+ $(MESABUILDDIR)math/m_xform.o \
+ $(MESABUILDDIR)swrast/s_aaline.o \
+ $(MESABUILDDIR)swrast/s_aatriangle.o \
+ $(MESABUILDDIR)swrast/s_accum.o \
+ $(MESABUILDDIR)swrast/s_alpha.o \
+ $(MESABUILDDIR)swrast/s_alphabuf.o \
+ $(MESABUILDDIR)swrast/s_bitmap.o \
+ $(MESABUILDDIR)swrast/s_blend.o \
+ $(MESABUILDDIR)swrast/s_buffers.o \
+ $(MESABUILDDIR)swrast/s_copypix.o \
+ $(MESABUILDDIR)swrast/s_context.o \
+ $(MESABUILDDIR)swrast/s_depth.o \
+ $(MESABUILDDIR)swrast/s_drawpix.o \
+ $(MESABUILDDIR)swrast/s_feedback.o \
+ $(MESABUILDDIR)swrast/s_fog.o \
+ $(MESABUILDDIR)swrast/s_histogram.o \
+ $(MESABUILDDIR)swrast/s_imaging.o \
+ $(MESABUILDDIR)swrast/s_lines.o \
+ $(MESABUILDDIR)swrast/s_logic.o \
+ $(MESABUILDDIR)swrast/s_masking.o \
+ $(MESABUILDDIR)swrast/s_pb.o \
+ $(MESABUILDDIR)swrast/s_pixeltex.o \
+ $(MESABUILDDIR)swrast/s_points.o \
+ $(MESABUILDDIR)swrast/s_readpix.o \
+ $(MESABUILDDIR)swrast/s_scissor.o \
+ $(MESABUILDDIR)swrast/s_span.o \
+ $(MESABUILDDIR)swrast/s_stencil.o \
+ $(MESABUILDDIR)swrast/s_texture.o \
+ $(MESABUILDDIR)swrast/s_texstore.o \
+ $(MESABUILDDIR)swrast/s_triangle.o \
+ $(MESABUILDDIR)swrast/s_zoom.o \
+ $(MESABUILDDIR)swrast_setup/ss_context.o \
+ $(MESABUILDDIR)swrast_setup/ss_triangle.o \
+ $(MESABUILDDIR)swrast_setup/ss_vb.o \
+ $(MESABUILDDIR)tnl/t_array_api.o \
+ $(MESABUILDDIR)tnl/t_array_import.o \
+ $(MESABUILDDIR)tnl/t_context.o \
+ $(MESABUILDDIR)tnl/t_eval_api.o \
+ $(MESABUILDDIR)tnl/t_imm_alloc.o \
+ $(MESABUILDDIR)tnl/t_imm_api.o \
+ $(MESABUILDDIR)tnl/t_imm_debug.o \
+ $(MESABUILDDIR)tnl/t_imm_dlist.o \
+ $(MESABUILDDIR)tnl/t_imm_elt.o \
+ $(MESABUILDDIR)tnl/t_imm_eval.o \
+ $(MESABUILDDIR)tnl/t_imm_exec.o \
+ $(MESABUILDDIR)tnl/t_imm_fixup.o \
+ $(MESABUILDDIR)tnl/t_pipeline.o \
+ $(MESABUILDDIR)tnl/t_vb_fog.o \
+ $(MESABUILDDIR)tnl/t_vb_light.o \
+ $(MESABUILDDIR)tnl/t_vb_normals.o \
+ $(MESABUILDDIR)tnl/t_vb_points.o \
+ $(MESABUILDDIR)tnl/t_vb_render.o \
+ $(MESABUILDDIR)tnl/t_vb_texgen.o \
+ $(MESABUILDDIR)tnl/t_vb_texmat.o \
+ $(MESABUILDDIR)tnl/t_vb_vertex.o
#ifdef NeedAllMesaSrc
DISPATCHUOBJS = $(MESABUILDDIR)unshared/dispatch.o
@@ -267,22 +336,21 @@ GLAPINOOPUOBJS = $(MESABUILDDIR)unshared/glapinoop.o
GLTHREADUOBJS = $(MESABUILDDIR)unshared/glthread.o
#endif
-COREMESAUOBJS = $(MESABUILDDIR)unshared/aatriangle.o \
- $(MESABUILDDIR)unshared/accum.o \
- $(MESABUILDDIR)unshared/alpha.o \
- $(MESABUILDDIR)unshared/alphabuf.o \
+COREMESAUOBJS = $(MESABUILDDIR)unshared/accum.o \
+ $(MESABUILDDIR)unshared/api_arrayelt.o \
+ $(MESABUILDDIR)unshared/api_eval.o \
+ $(MESABUILDDIR)unshared/api_loopback.o \
+ $(MESABUILDDIR)unshared/api_noop.o \
+ $(MESABUILDDIR)unshared/api_validate.o \
$(MESABUILDDIR)unshared/attrib.o \
- $(MESABUILDDIR)unshared/bbox.o \
- $(MESABUILDDIR)unshared/bitmap.o \
$(MESABUILDDIR)unshared/blend.o \
$(MESABUILDDIR)unshared/buffers.o \
$(MESABUILDDIR)unshared/clip.o \
$(MESABUILDDIR)unshared/colortab.o \
$(MESABUILDDIR)unshared/config.o \
$(MESABUILDDIR)unshared/context.o \
- $(MESABUILDDIR)unshared/copypix.o \
- $(MESABUILDDIR)unshared/cva.o \
- $(MESABUILDDIR)unshared/debug_xform.o \
+ $(MESABUILDDIR)unshared/convolve.o \
+ $(MESABUILDDIR)unshared/debug.o \
$(MESABUILDDIR)unshared/depth.o \
$(DISPATCHUOBJS) \
$(MESABUILDDIR)unshared/dlist.o \
@@ -295,55 +363,97 @@ COREMESAUOBJS = $(MESABUILDDIR)unshared/aatriangle.o \
$(MESABUILDDIR)unshared/fog.o \
$(MESABUILDDIR)unshared/get.o \
$(GLAPIUOBJS) \
- $(GLAPINOOPUOBJS) \
$(GLTHREADUOBJS) \
$(MESABUILDDIR)unshared/hash.o \
$(MESABUILDDIR)unshared/hint.o \
+ $(MESABUILDDIR)unshared/histogram.o \
$(MESABUILDDIR)unshared/image.o \
- $(MESABUILDDIR)unshared/imaging.o \
+ $(MESABUILDDIR)unshared/imports.o \
$(MESABUILDDIR)unshared/light.o \
$(MESABUILDDIR)unshared/lines.o \
- $(MESABUILDDIR)unshared/logic.o \
- $(MESABUILDDIR)unshared/masking.o \
$(MESABUILDDIR)unshared/matrix.o \
$(MESABUILDDIR)unshared/mem.o \
$(MESABUILDDIR)unshared/mmath.o \
- $(MESABUILDDIR)unshared/pb.o \
- $(MESABUILDDIR)unshared/pipeline.o \
$(MESABUILDDIR)unshared/pixel.o \
- $(MESABUILDDIR)unshared/pixeltex.o \
$(MESABUILDDIR)unshared/points.o \
$(MESABUILDDIR)unshared/polygon.o \
- $(MESABUILDDIR)unshared/quads.o \
$(MESABUILDDIR)unshared/rastpos.o \
- $(MESABUILDDIR)unshared/readpix.o \
- $(MESABUILDDIR)unshared/rect.o \
- $(MESABUILDDIR)unshared/scissor.o \
- $(MESABUILDDIR)unshared/shade.o \
- $(MESABUILDDIR)unshared/span.o \
- $(MESABUILDDIR)unshared/stages.o \
$(MESABUILDDIR)unshared/state.o \
$(MESABUILDDIR)unshared/stencil.o \
$(MESABUILDDIR)unshared/texformat.o \
$(MESABUILDDIR)unshared/teximage.o \
$(MESABUILDDIR)unshared/texobj.o \
$(MESABUILDDIR)unshared/texstate.o \
- $(MESABUILDDIR)unshared/texture.o \
+ $(MESABUILDDIR)unshared/texstore.o \
$(MESABUILDDIR)unshared/texutil.o \
- $(MESABUILDDIR)unshared/translate.o \
- $(MESABUILDDIR)unshared/triangle.o \
$(MESABUILDDIR)unshared/varray.o \
- $(MESABUILDDIR)unshared/vb.o \
- $(MESABUILDDIR)unshared/vbcull.o \
- $(MESABUILDDIR)unshared/vbfill.o \
- $(MESABUILDDIR)unshared/vbindirect.o \
- $(MESABUILDDIR)unshared/vbrender.o \
- $(MESABUILDDIR)unshared/vbxform.o \
- $(MESABUILDDIR)unshared/vector.o \
- $(MESABUILDDIR)unshared/vertices.o \
- $(MESABUILDDIR)unshared/winpos.o \
- $(MESABUILDDIR)unshared/xform.o \
- $(MESABUILDDIR)unshared/zoom.o
+ $(MESABUILDDIR)unshared/vtxfmt.o \
+ $(MESABUILDDIR)array_cache/unshared/ac_context.o \
+ $(MESABUILDDIR)array_cache/unshared/ac_import.o \
+ $(MESABUILDDIR)math/unshared/m_debug_clip.o \
+ $(MESABUILDDIR)math/unshared/m_debug_norm.o \
+ $(MESABUILDDIR)math/unshared/m_debug_vertex.o \
+ $(MESABUILDDIR)math/unshared/m_debug_xform.o \
+ $(MESABUILDDIR)math/unshared/m_eval.o \
+ $(MESABUILDDIR)math/unshared/m_matrix.o \
+ $(MESABUILDDIR)math/unshared/m_translate.o \
+ $(MESABUILDDIR)math/unshared/m_vector.o \
+ $(MESABUILDDIR)math/unshared/m_vertices.o \
+ $(MESABUILDDIR)math/unshared/m_xform.o \
+ $(MESABUILDDIR)swrast/unshared/s_aaline.o \
+ $(MESABUILDDIR)swrast/unshared/s_aatriangle.o \
+ $(MESABUILDDIR)swrast/unshared/s_accum.o \
+ $(MESABUILDDIR)swrast/unshared/s_alpha.o \
+ $(MESABUILDDIR)swrast/unshared/s_alphabuf.o \
+ $(MESABUILDDIR)swrast/unshared/s_bitmap.o \
+ $(MESABUILDDIR)swrast/unshared/s_blend.o \
+ $(MESABUILDDIR)swrast/unshared/s_buffers.o \
+ $(MESABUILDDIR)swrast/unshared/s_copypix.o \
+ $(MESABUILDDIR)swrast/unshared/s_context.o \
+ $(MESABUILDDIR)swrast/unshared/s_depth.o \
+ $(MESABUILDDIR)swrast/unshared/s_drawpix.o \
+ $(MESABUILDDIR)swrast/unshared/s_feedback.o \
+ $(MESABUILDDIR)swrast/unshared/s_fog.o \
+ $(MESABUILDDIR)swrast/unshared/s_histogram.o \
+ $(MESABUILDDIR)swrast/unshared/s_imaging.o \
+ $(MESABUILDDIR)swrast/unshared/s_lines.o \
+ $(MESABUILDDIR)swrast/unshared/s_logic.o \
+ $(MESABUILDDIR)swrast/unshared/s_masking.o \
+ $(MESABUILDDIR)swrast/unshared/s_pb.o \
+ $(MESABUILDDIR)swrast/unshared/s_pixeltex.o \
+ $(MESABUILDDIR)swrast/unshared/s_points.o \
+ $(MESABUILDDIR)swrast/unshared/s_readpix.o \
+ $(MESABUILDDIR)swrast/unshared/s_scissor.o \
+ $(MESABUILDDIR)swrast/unshared/s_span.o \
+ $(MESABUILDDIR)swrast/unshared/s_stencil.o \
+ $(MESABUILDDIR)swrast/unshared/s_texture.o \
+ $(MESABUILDDIR)swrast/unshared/s_texstore.o \
+ $(MESABUILDDIR)swrast/unshared/s_triangle.o \
+ $(MESABUILDDIR)swrast/unshared/s_zoom.o \
+ $(MESABUILDDIR)swrast_setup/unshared/ss_context.o \
+ $(MESABUILDDIR)swrast_setup/unshared/ss_triangle.o \
+ $(MESABUILDDIR)swrast_setup/unshared/ss_vb.o \
+ $(MESABUILDDIR)tnl/unshared/t_array_api.o \
+ $(MESABUILDDIR)tnl/unshared/t_array_import.o \
+ $(MESABUILDDIR)tnl/unshared/t_context.o \
+ $(MESABUILDDIR)tnl/unshared/t_eval_api.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_alloc.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_api.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_debug.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_dlist.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_elt.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_eval.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_exec.o \
+ $(MESABUILDDIR)tnl/unshared/t_imm_fixup.o \
+ $(MESABUILDDIR)tnl/unshared/t_pipeline.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_fog.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_light.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_normals.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_points.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_render.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_texgen.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_texmat.o \
+ $(MESABUILDDIR)tnl/unshared/t_vb_vertex.o
#ifdef NeedAllMesaSrc
DISPATCHDOBJS = $(MESABUILDDIR)debugger/dispatch.o
@@ -352,22 +462,21 @@ GLAPINOOPDOBJS = $(MESABUILDDIR)debugger/glapinoop.o
GLTHREADDOBJS = $(MESABUILDDIR)debugger/glthread.o
#endif
-COREMESADOBJS = $(MESABUILDDIR)debugger/aatriangle.o \
- $(MESABUILDDIR)debugger/unshared/accum.o \
- $(MESABUILDDIR)debugger/alpha.o \
- $(MESABUILDDIR)debugger/alphabuf.o \
+COREMESADOBJS = $(MESABUILDDIR)debugger/accum.o \
+ $(MESABUILDDIR)debugger/api_arrayelt.o \
+ $(MESABUILDDIR)debugger/api_eval.o \
+ $(MESABUILDDIR)debugger/api_loopback.o \
+ $(MESABUILDDIR)debugger/api_noop.o \
+ $(MESABUILDDIR)debugger/api_validate.o \
$(MESABUILDDIR)debugger/attrib.o \
- $(MESABUILDDIR)debugger/bbox.o \
- $(MESABUILDDIR)debugger/bitmap.o \
$(MESABUILDDIR)debugger/blend.o \
$(MESABUILDDIR)debugger/buffers.o \
$(MESABUILDDIR)debugger/clip.o \
$(MESABUILDDIR)debugger/colortab.o \
$(MESABUILDDIR)debugger/config.o \
$(MESABUILDDIR)debugger/context.o \
- $(MESABUILDDIR)debugger/copypix.o \
- $(MESABUILDDIR)debugger/cva.o \
- $(MESABUILDDIR)debugger/debug_xform.o \
+ $(MESABUILDDIR)debugger/convolve.o \
+ $(MESABUILDDIR)debugger/debug.o \
$(MESABUILDDIR)debugger/depth.o \
$(DISPATCHDOBJS) \
$(MESABUILDDIR)debugger/dlist.o \
@@ -379,56 +488,98 @@ COREMESADOBJS = $(MESABUILDDIR)debugger/aatriangle.o \
$(MESABUILDDIR)debugger/feedback.o \
$(MESABUILDDIR)debugger/fog.o \
$(MESABUILDDIR)debugger/get.o \
- $(GLAPIUOBJS) \
- $(GLAPINOOPUOBJS) \
- $(GLTHREADUOBJS) \
+ $(GLAPIDOBJS) \
+ $(GLTHREADDOBJS) \
$(MESABUILDDIR)debugger/hash.o \
$(MESABUILDDIR)debugger/hint.o \
+ $(MESABUILDDIR)debugger/histogram.o \
$(MESABUILDDIR)debugger/image.o \
- $(MESABUILDDIR)debugger/imaging.o \
+ $(MESABUILDDIR)debugger/imports.o \
$(MESABUILDDIR)debugger/light.o \
$(MESABUILDDIR)debugger/lines.o \
- $(MESABUILDDIR)debugger/logic.o \
- $(MESABUILDDIR)debugger/masking.o \
$(MESABUILDDIR)debugger/matrix.o \
$(MESABUILDDIR)debugger/mem.o \
$(MESABUILDDIR)debugger/mmath.o \
- $(MESABUILDDIR)debugger/pb.o \
- $(MESABUILDDIR)debugger/pipeline.o \
$(MESABUILDDIR)debugger/pixel.o \
- $(MESABUILDDIR)debugger/pixeltex.o \
$(MESABUILDDIR)debugger/points.o \
$(MESABUILDDIR)debugger/polygon.o \
- $(MESABUILDDIR)debugger/quads.o \
$(MESABUILDDIR)debugger/rastpos.o \
- $(MESABUILDDIR)debugger/readpix.o \
- $(MESABUILDDIR)debugger/rect.o \
- $(MESABUILDDIR)debugger/scissor.o \
- $(MESABUILDDIR)debugger/shade.o \
- $(MESABUILDDIR)debugger/span.o \
- $(MESABUILDDIR)debugger/stages.o \
$(MESABUILDDIR)debugger/state.o \
$(MESABUILDDIR)debugger/stencil.o \
$(MESABUILDDIR)debugger/texformat.o \
$(MESABUILDDIR)debugger/teximage.o \
$(MESABUILDDIR)debugger/texobj.o \
$(MESABUILDDIR)debugger/texstate.o \
- $(MESABUILDDIR)debugger/texture.o \
+ $(MESABUILDDIR)debugger/texstore.o \
$(MESABUILDDIR)debugger/texutil.o \
- $(MESABUILDDIR)debugger/translate.o \
- $(MESABUILDDIR)debugger/triangle.o \
$(MESABUILDDIR)debugger/varray.o \
- $(MESABUILDDIR)debugger/vb.o \
- $(MESABUILDDIR)debugger/vbcull.o \
- $(MESABUILDDIR)debugger/vbfill.o \
- $(MESABUILDDIR)debugger/vbindirect.o \
- $(MESABUILDDIR)debugger/vbrender.o \
- $(MESABUILDDIR)debugger/vbxform.o \
- $(MESABUILDDIR)debugger/vector.o \
- $(MESABUILDDIR)debugger/vertices.o \
- $(MESABUILDDIR)debugger/winpos.o \
- $(MESABUILDDIR)debugger/xform.o \
- $(MESABUILDDIR)debugger/zoom.o
+ $(MESABUILDDIR)debugger/vtxfmt.o \
+ $(MESABUILDDIR)array_cache/debugger/ac_context.o \
+ $(MESABUILDDIR)array_cache/debugger/ac_import.o \
+ $(MESABUILDDIR)math/debugger/m_debug_clip.o \
+ $(MESABUILDDIR)math/debugger/m_debug_norm.o \
+ $(MESABUILDDIR)math/debugger/m_debug_vertex.o \
+ $(MESABUILDDIR)math/debugger/m_debug_xform.o \
+ $(MESABUILDDIR)math/debugger/m_eval.o \
+ $(MESABUILDDIR)math/debugger/m_matrix.o \
+ $(MESABUILDDIR)math/debugger/m_translate.o \
+ $(MESABUILDDIR)math/debugger/m_vector.o \
+ $(MESABUILDDIR)math/debugger/m_vertices.o \
+ $(MESABUILDDIR)math/debugger/m_xform.o \
+ $(MESABUILDDIR)swrast/debugger/s_aaline.o \
+ $(MESABUILDDIR)swrast/debugger/s_aatriangle.o \
+ $(MESABUILDDIR)swrast/debugger/s_accum.o \
+ $(MESABUILDDIR)swrast/debugger/s_alpha.o \
+ $(MESABUILDDIR)swrast/debugger/s_alphabuf.o \
+ $(MESABUILDDIR)swrast/debugger/s_bitmap.o \
+ $(MESABUILDDIR)swrast/debugger/s_blend.o \
+ $(MESABUILDDIR)swrast/debugger/s_buffers.o \
+ $(MESABUILDDIR)swrast/debugger/s_copypix.o \
+ $(MESABUILDDIR)swrast/debugger/s_context.o \
+ $(MESABUILDDIR)swrast/debugger/s_depth.o \
+ $(MESABUILDDIR)swrast/debugger/s_drawpix.o \
+ $(MESABUILDDIR)swrast/debugger/s_feedback.o \
+ $(MESABUILDDIR)swrast/debugger/s_fog.o \
+ $(MESABUILDDIR)swrast/debugger/s_histogram.o \
+ $(MESABUILDDIR)swrast/debugger/s_imaging.o \
+ $(MESABUILDDIR)swrast/debugger/s_lines.o \
+ $(MESABUILDDIR)swrast/debugger/s_logic.o \
+ $(MESABUILDDIR)swrast/debugger/s_masking.o \
+ $(MESABUILDDIR)swrast/debugger/s_pb.o \
+ $(MESABUILDDIR)swrast/debugger/s_pixeltex.o \
+ $(MESABUILDDIR)swrast/debugger/s_points.o \
+ $(MESABUILDDIR)swrast/debugger/s_readpix.o \
+ $(MESABUILDDIR)swrast/debugger/s_scissor.o \
+ $(MESABUILDDIR)swrast/debugger/s_span.o \
+ $(MESABUILDDIR)swrast/debugger/s_stencil.o \
+ $(MESABUILDDIR)swrast/debugger/s_texture.o \
+ $(MESABUILDDIR)swrast/debugger/s_texstore.o \
+ $(MESABUILDDIR)swrast/debugger/s_triangle.o \
+ $(MESABUILDDIR)swrast/debugger/s_zoom.o \
+ $(MESABUILDDIR)swrast_setup/debugger/ss_context.o \
+ $(MESABUILDDIR)swrast_setup/debugger/ss_triangle.o \
+ $(MESABUILDDIR)swrast_setup/debugger/ss_vb.o \
+ $(MESABUILDDIR)tnl/debugger/t_array_api.o \
+ $(MESABUILDDIR)tnl/debugger/t_array_import.o \
+ $(MESABUILDDIR)tnl/debugger/t_context.o \
+ $(MESABUILDDIR)tnl/debugger/t_eval_api.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_alloc.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_api.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_debug.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_dlist.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_elt.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_eval.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_exec.o \
+ $(MESABUILDDIR)tnl/debugger/t_imm_fixup.o \
+ $(MESABUILDDIR)tnl/debugger/t_pipeline.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_fog.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_light.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_normals.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_points.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_render.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_texgen.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_texmat.o \
+ $(MESABUILDDIR)tnl/debugger/t_vb_vertex.o
#ifdef NeedAllMesaSrc
DISPATCHPOBJS = $(MESABUILDDIR)profiled/dispatch.o
@@ -437,22 +588,21 @@ GLAPINOOPPOBJS = $(MESABUILDDIR)profiled/glapinoop.o
GLTHREADPOBJS = $(MESABUILDDIR)profiled/glthread.o
#endif
-COREMESAPOBJS = $(MESABUILDDIR)profiled/aatriangle.o \
- $(MESABUILDDIR)profiled/unshared/accum.o \
- $(MESABUILDDIR)profiled/alpha.o \
- $(MESABUILDDIR)profiled/alphabuf.o \
+COREMESAPOBJS = $(MESABUILDDIR)profiled/accum.o \
+ $(MESABUILDDIR)profiled/api_arrayelt.o \
+ $(MESABUILDDIR)profiled/api_eval.o \
+ $(MESABUILDDIR)profiled/api_loopback.o \
+ $(MESABUILDDIR)profiled/api_noop.o \
+ $(MESABUILDDIR)profiled/api_validate.o \
$(MESABUILDDIR)profiled/attrib.o \
- $(MESABUILDDIR)profiled/bbox.o \
- $(MESABUILDDIR)profiled/bitmap.o \
$(MESABUILDDIR)profiled/blend.o \
$(MESABUILDDIR)profiled/buffers.o \
$(MESABUILDDIR)profiled/clip.o \
$(MESABUILDDIR)profiled/colortab.o \
$(MESABUILDDIR)profiled/config.o \
$(MESABUILDDIR)profiled/context.o \
- $(MESABUILDDIR)profiled/copypix.o \
- $(MESABUILDDIR)profiled/cva.o \
- $(MESABUILDDIR)profiled/debug_xform.o \
+ $(MESABUILDDIR)profiled/convolve.o \
+ $(MESABUILDDIR)profiled/debug.o \
$(MESABUILDDIR)profiled/depth.o \
$(DISPATCHPOBJS) \
$(MESABUILDDIR)profiled/dlist.o \
@@ -465,53 +615,95 @@ COREMESAPOBJS = $(MESABUILDDIR)profiled/aatriangle.o \
$(MESABUILDDIR)profiled/fog.o \
$(MESABUILDDIR)profiled/get.o \
$(GLAPIPOBJS) \
- $(GLAPINOOPPOBJS) \
$(GLTHREADPOBJS) \
$(MESABUILDDIR)profiled/hash.o \
$(MESABUILDDIR)profiled/hint.o \
+ $(MESABUILDDIR)profiled/histogram.o \
$(MESABUILDDIR)profiled/image.o \
- $(MESABUILDDIR)profiled/imaging.o \
+ $(MESABUILDDIR)profiled/imports.o \
$(MESABUILDDIR)profiled/light.o \
$(MESABUILDDIR)profiled/lines.o \
- $(MESABUILDDIR)profiled/logic.o \
- $(MESABUILDDIR)profiled/masking.o \
$(MESABUILDDIR)profiled/matrix.o \
$(MESABUILDDIR)profiled/mem.o \
$(MESABUILDDIR)profiled/mmath.o \
- $(MESABUILDDIR)profiled/pb.o \
- $(MESABUILDDIR)profiled/pipeline.o \
$(MESABUILDDIR)profiled/pixel.o \
- $(MESABUILDDIR)profiled/pixeltex.o \
$(MESABUILDDIR)profiled/points.o \
$(MESABUILDDIR)profiled/polygon.o \
- $(MESABUILDDIR)profiled/quads.o \
$(MESABUILDDIR)profiled/rastpos.o \
- $(MESABUILDDIR)profiled/readpix.o \
- $(MESABUILDDIR)profiled/rect.o \
- $(MESABUILDDIR)profiled/scissor.o \
- $(MESABUILDDIR)profiled/shade.o \
- $(MESABUILDDIR)profiled/span.o \
- $(MESABUILDDIR)profiled/stages.o \
$(MESABUILDDIR)profiled/state.o \
$(MESABUILDDIR)profiled/stencil.o \
$(MESABUILDDIR)profiled/texformat.o \
$(MESABUILDDIR)profiled/teximage.o \
$(MESABUILDDIR)profiled/texobj.o \
$(MESABUILDDIR)profiled/texstate.o \
- $(MESABUILDDIR)profiled/texture.o \
+ $(MESABUILDDIR)profiled/texstore.o \
$(MESABUILDDIR)profiled/texutil.o \
- $(MESABUILDDIR)profiled/translate.o \
- $(MESABUILDDIR)profiled/triangle.o \
$(MESABUILDDIR)profiled/varray.o \
- $(MESABUILDDIR)profiled/vb.o \
- $(MESABUILDDIR)profiled/vbcull.o \
- $(MESABUILDDIR)profiled/vbfill.o \
- $(MESABUILDDIR)profiled/vbindirect.o \
- $(MESABUILDDIR)profiled/vbrender.o \
- $(MESABUILDDIR)profiled/vbxform.o \
- $(MESABUILDDIR)profiled/vector.o \
- $(MESABUILDDIR)profiled/vertices.o \
- $(MESABUILDDIR)profiled/winpos.o \
- $(MESABUILDDIR)profiled/xform.o \
- $(MESABUILDDIR)profiled/zoom.o
+ $(MESABUILDDIR)profiled/vtxfmt.o \
+ $(MESABUILDDIR)array_cache/profiled/ac_context.o \
+ $(MESABUILDDIR)array_cache/profiled/ac_import.o \
+ $(MESABUILDDIR)math/profiled/m_debug_clip.o \
+ $(MESABUILDDIR)math/profiled/m_debug_norm.o \
+ $(MESABUILDDIR)math/profiled/m_debug_vertex.o \
+ $(MESABUILDDIR)math/profiled/m_debug_xform.o \
+ $(MESABUILDDIR)math/profiled/m_eval.o \
+ $(MESABUILDDIR)math/profiled/m_matrix.o \
+ $(MESABUILDDIR)math/profiled/m_translate.o \
+ $(MESABUILDDIR)math/profiled/m_vector.o \
+ $(MESABUILDDIR)math/profiled/m_vertices.o \
+ $(MESABUILDDIR)math/profiled/m_xform.o \
+ $(MESABUILDDIR)swrast/profiled/s_aaline.o \
+ $(MESABUILDDIR)swrast/profiled/s_aatriangle.o \
+ $(MESABUILDDIR)swrast/profiled/s_accum.o \
+ $(MESABUILDDIR)swrast/profiled/s_alpha.o \
+ $(MESABUILDDIR)swrast/profiled/s_alphabuf.o \
+ $(MESABUILDDIR)swrast/profiled/s_bitmap.o \
+ $(MESABUILDDIR)swrast/profiled/s_blend.o \
+ $(MESABUILDDIR)swrast/profiled/s_buffers.o \
+ $(MESABUILDDIR)swrast/profiled/s_copypix.o \
+ $(MESABUILDDIR)swrast/profiled/s_context.o \
+ $(MESABUILDDIR)swrast/profiled/s_depth.o \
+ $(MESABUILDDIR)swrast/profiled/s_drawpix.o \
+ $(MESABUILDDIR)swrast/profiled/s_feedback.o \
+ $(MESABUILDDIR)swrast/profiled/s_fog.o \
+ $(MESABUILDDIR)swrast/profiled/s_histogram.o \
+ $(MESABUILDDIR)swrast/profiled/s_imaging.o \
+ $(MESABUILDDIR)swrast/profiled/s_lines.o \
+ $(MESABUILDDIR)swrast/profiled/s_logic.o \
+ $(MESABUILDDIR)swrast/profiled/s_masking.o \
+ $(MESABUILDDIR)swrast/profiled/s_pb.o \
+ $(MESABUILDDIR)swrast/profiled/s_pixeltex.o \
+ $(MESABUILDDIR)swrast/profiled/s_points.o \
+ $(MESABUILDDIR)swrast/profiled/s_readpix.o \
+ $(MESABUILDDIR)swrast/profiled/s_scissor.o \
+ $(MESABUILDDIR)swrast/profiled/s_span.o \
+ $(MESABUILDDIR)swrast/profiled/s_stencil.o \
+ $(MESABUILDDIR)swrast/profiled/s_texture.o \
+ $(MESABUILDDIR)swrast/profiled/s_texstore.o \
+ $(MESABUILDDIR)swrast/profiled/s_triangle.o \
+ $(MESABUILDDIR)swrast/profiled/s_zoom.o \
+ $(MESABUILDDIR)swrast_setup/profiled/ss_context.o \
+ $(MESABUILDDIR)swrast_setup/profiled/ss_triangle.o \
+ $(MESABUILDDIR)swrast_setup/profiled/ss_vb.o \
+ $(MESABUILDDIR)tnl/profiled/t_array_api.o \
+ $(MESABUILDDIR)tnl/profiled/t_array_import.o \
+ $(MESABUILDDIR)tnl/profiled/t_context.o \
+ $(MESABUILDDIR)tnl/profiled/t_eval_api.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_alloc.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_api.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_debug.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_dlist.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_elt.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_eval.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_exec.o \
+ $(MESABUILDDIR)tnl/profiled/t_imm_fixup.o \
+ $(MESABUILDDIR)tnl/profiled/t_pipeline.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_fog.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_light.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_normals.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_points.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_render.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_texgen.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_texmat.o \
+ $(MESABUILDDIR)tnl/profiled/t_vb_vertex.o
diff --git a/xc/lib/GL/mesa/src/OSmesa/Imakefile b/xc/lib/GL/mesa/src/OSmesa/Imakefile
index be2c790d4..374807548 100644
--- a/xc/lib/GL/mesa/src/OSmesa/Imakefile
+++ b/xc/lib/GL/mesa/src/OSmesa/Imakefile
@@ -12,6 +12,9 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/OSmesa/Imakefile,v 1.11 2001/06/04 20:43:30 d
#ifdef i386Architecture
#include "../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../SPARC/Imakefile.inc"
+#endif
LinkSourceFile(osmesa.c, $(MESASRCDIR)/src/OSmesa)
@@ -20,10 +23,11 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
MESA_INCLUDES = -I$(MESASRCDIR)/src/OSmesa -I$(MESASRCDIR)/src \
- -I$(MESASRCDIR)/include
+ -I$(MESASRCDIR)/include
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES)
- INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES)
+ INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC) $(MESA_INCLUDES) \
+ $(DRI_INCLUDES) -I$(GLXLIBSRC)/include
MESAOBJS = $(COREMESAOBJS) $(MESA_ASM_OBJS)
MESAUOBJS = $(COREMESAUOBJS) $(MESA_ASM_UOBJS)
@@ -56,7 +60,7 @@ SubdirLibraryRule($(OBJS))
NormalLintTarget($(SRCS))
LIBNAME = OSMesa
-SOREV = 3.3
+SOREV = 4.0
#if DoNormalLib
diff --git a/xc/lib/GL/mesa/src/SPARC/Imakefile b/xc/lib/GL/mesa/src/SPARC/Imakefile
new file mode 100644
index 000000000..f2201099b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/SPARC/Imakefile
@@ -0,0 +1,52 @@
+XCOMM $XFree86$
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#define MesaSPARCBuildDir /**/
+#define NeedToLinkMesaSrc
+#include "Imakefile.inc"
+
+ DEFINES = $(ALLOC_DEFINES) GlxDefines $(MESA_ASM_DEFINES)
+ INCLUDES = -I$(INCLUDESRC) -I$(EXTINCSRC) -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/SPARC \
+ -I../../../include
+
+ SRCS = $(MESA_ASM_SRCS)
+ OBJS = $(MESA_ASM_OBJS)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+STD_CPP_DEFINES = StandardDefines $(PROJECT_DEFINES)
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+ObjectFromAsmSource(xform, NullParameter)
+ObjectFromAsmSource(clip, NullParameter)
+ObjectFromAsmSource(norm, NullParameter)
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/SPARC/Imakefile.inc b/xc/lib/GL/mesa/src/SPARC/Imakefile.inc
new file mode 100644
index 000000000..13834409b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/SPARC/Imakefile.inc
@@ -0,0 +1,58 @@
+XCOMM $XFree86$
+
+#ifndef MesaSPARCBuildDir
+#define MesaSPARCBuildDir $(GLXLIBSRC)/mesa/src/SPARC/
+#endif
+
+MESASPARCBUILDDIR = MesaSPARCBuildDir
+
+MESA_SPARC_SRCS = $(MESASPARCBUILDDIR)sparc.c \
+ $(MESASPARCBUILDDIR)xform.S \
+ $(MESASPARCBUILDDIR)clip.S
+
+#ifdef NeedToLinkMesaSrc
+/* If $(MESASRCDIR)/src/SPARC isn't in the INCLUDES, it should be. */
+LinkSourceFile(sparc.c, $(MESASRCDIR)/src/SPARC)
+LinkSourceFile(xform.S, $(MESASRCDIR)/src/SPARC)
+LinkSourceFile(clip.S, $(MESASRCDIR)/src/SPARC)
+LinkSourceFile(norm.S, $(MESASRCDIR)/src/SPARC)
+#endif
+
+MESA_SPARC_OBJS = $(MESASPARCBUILDDIR)sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+
+#if DoSharedLib
+MESA_SPARC_UOBJS = $(MESASPARCBUILDDIR)unshared/sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+#else
+MESA_SPARC_UOBJS = $(MESA_SPARC_OBJS)
+#endif
+
+MESA_SPARC_DOBJS = $(MESASPARCBUILDDIR)debugger/sparc.o \
+ $(MESASPARCBUILDDIR)xform.o \
+ $(MESASPARCBUILDDIR)clip.o \
+ $(MESASPARCBUILDDIR)norm.o
+
+MESA_SPARC_POBJS = $(MESAX86BUILDDIR)profiled/sparc.o \
+ $(MESAX86BUILDDIR)xform.o \
+ $(MESAX86BUILDDIR)clip.o \
+ $(MESAX86BUILDDIR)norm.o
+
+MESA_SPARC_DEFS = -DUSE_SPARC_ASM
+
+MESA_ASM_SRCS = $(MESA_SPARC_SRCS)
+
+MESA_ASM_OBJS = $(MESA_SPARC_OBJS)
+
+MESA_ASM_UOBJS = $(MESA_SPARC_UOBJS)
+
+MESA_ASM_DOBJS = $(MESA_SPARC_DOBJS)
+
+MESA_ASM_POBJS = $(MESA_SPARC_POBJS)
+
+MESA_ASM_DEFINES = $(MESA_SPARC_DEFS)
+
diff --git a/xc/lib/GL/mesa/src/X/Imakefile b/xc/lib/GL/mesa/src/X/Imakefile
new file mode 100644
index 000000000..14ed71d02
--- /dev/null
+++ b/xc/lib/GL/mesa/src/X/Imakefile
@@ -0,0 +1,75 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+#include "Imakefile.inc"
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(fakeglx.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(glxapi.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(glxapi.h, $(MESASRCDIR)/src/X)
+LinkSourceFile(realglx.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xfonts.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xm_api.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xm_dd.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xm_line.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xm_span.c, $(MESASRCDIR)/src/X)
+LinkSourceFile(xm_tri.c, $(MESASRCDIR)/src/X)
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/X \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+#if GlxBuiltInXMesa
+ XMESA_DEFINES = -DGLX_BUILT_IN_XMESA
+#endif
+
+ SRCS = $(XMESA_SRCS)
+ OBJS = $(XMESA_OBJS)
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MATHDEF) $(XMESA_DEFINES)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(XMESA_OBJS))
+NormalLintTarget($(XMESA_SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/X/Imakefile.inc b/xc/lib/GL/mesa/src/X/Imakefile.inc
new file mode 100644
index 000000000..3eff4375d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/X/Imakefile.inc
@@ -0,0 +1,57 @@
+XCOMM $XFree86$
+
+#ifndef MesaBuildDir
+#define MesaBuildDir $(GLXLIBSRC)/mesa/src
+#endif
+
+MESABUILDDIR = MesaBuildDir
+
+ XMESA_SRCS = $(MESABUILDDIR)/X/fakeglx.c \
+ $(MESABUILDDIR)/X/glxapi.c \
+ $(MESABUILDDIR)/X/realglx.c \
+ $(MESABUILDDIR)/X/xfonts.c \
+ $(MESABUILDDIR)/X/xm_api.c \
+ $(MESABUILDDIR)/X/xm_dd.c \
+ $(MESABUILDDIR)/X/xm_line.c \
+ $(MESABUILDDIR)/X/xm_span.c \
+ $(MESABUILDDIR)/X/xm_tri.c
+
+ XMESA_OBJS = $(MESABUILDDIR)/X/fakeglx.o \
+ $(MESABUILDDIR)/X/glxapi.o \
+ $(MESABUILDDIR)/X/realglx.o \
+ $(MESABUILDDIR)/X/xfonts.o \
+ $(MESABUILDDIR)/X/xm_api.o \
+ $(MESABUILDDIR)/X/xm_dd.o \
+ $(MESABUILDDIR)/X/xm_line.o \
+ $(MESABUILDDIR)/X/xm_span.o \
+ $(MESABUILDDIR)/X/xm_tri.o
+
+ XMESA_DOBJS = $(MESABUILDDIR)/X/debugger/fakeglx.o \
+ $(MESABUILDDIR)/X/debugger/glxapi.o \
+ $(MESABUILDDIR)/X/debugger/realglx.o \
+ $(MESABUILDDIR)/X/debugger/xfonts.o \
+ $(MESABUILDDIR)/X/debugger/xm_api.o \
+ $(MESABUILDDIR)/X/debugger/xm_dd.o \
+ $(MESABUILDDIR)/X/debugger/xm_line.o \
+ $(MESABUILDDIR)/X/debugger/xm_span.o \
+ $(MESABUILDDIR)/X/debugger/xm_tri.o
+
+ XMESA_POBJS = $(MESABUILDDIR)/X/profiled/fakeglx.o \
+ $(MESABUILDDIR)/X/profiled/glxapi.o \
+ $(MESABUILDDIR)/X/profiled/realglx.o \
+ $(MESABUILDDIR)/X/profiled/xfonts.o \
+ $(MESABUILDDIR)/X/profiled/xm_api.o \
+ $(MESABUILDDIR)/X/profiled/xm_dd.o \
+ $(MESABUILDDIR)/X/profiled/xm_line.o \
+ $(MESABUILDDIR)/X/profiled/xm_span.o \
+ $(MESABUILDDIR)/X/profiled/xm_tri.o
+
+ XMESA_UOBJS = $(MESABUILDDIR)/X/unshared/fakeglx.o \
+ $(MESABUILDDIR)/X/unshared/glxapi.o \
+ $(MESABUILDDIR)/X/unshared/realglx.o \
+ $(MESABUILDDIR)/X/unshared/xfonts.o \
+ $(MESABUILDDIR)/X/unshared/xm_api.o \
+ $(MESABUILDDIR)/X/unshared/xm_dd.o \
+ $(MESABUILDDIR)/X/unshared/xm_line.o \
+ $(MESABUILDDIR)/X/unshared/xm_span.o \
+ $(MESABUILDDIR)/X/unshared/xm_tri.o
diff --git a/xc/lib/GL/mesa/src/X/xdri.c b/xc/lib/GL/mesa/src/X/xdri.c
deleted file mode 100644
index 9adf0bf2c..000000000
--- a/xc/lib/GL/mesa/src/X/xdri.c
+++ /dev/null
@@ -1,111 +0,0 @@
-
-#if defined(GLX_DIRECT_RENDERING)
-
-/* Mesa includes
- */
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#include "GL/xmesa.h"
-#include "xmesaP.h"
-#include "context.h"
-#include "macros.h"
-#include "matrix.h"
-#include "types.h"
-
-/* Direct rendering includes
- */
-#include "dri_mesaint.h"
-
-
-void XMesaDriSwapBuffers( XMesaBuffer b )
-{
- __DRIdrawablePrivate *pdp = b->driDrawPriv;
- __DRIscreenPrivate *psp = pdp->driScreenPriv;
- drmContext hHWContext = pdp->driContextPriv->hHWContext;
-
- /*
- ** Grab the lock and make sure drawable info is still
- ** up to date.
- */
- DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, hHWContext);
- XMESA_VALIDATE_DRAWABLE_INFO(b->display, psp, pdp);
-
- /* Copy back image to front buffer */
- if (pdp->numClipRects) {
- int numClipRects = pdp->numClipRects;
- XF86DRIClipRectPtr pRect = pdp->pClipRects;
- int y;
- GLbyte *s8, *d8;
- GLuint *s32, *d32;
-
- while (numClipRects--) {
- int w = pRect->x2-pRect->x1;
-
- switch (psp->fbBPP) {
- case 8:
- for (y = pRect->y1; y < pRect->y2; y++) {
- s8 = (GLbyte *)b->backimage->data +
- y*b->backimage->bytes_per_line +
- pRect->x1;
- d8 = (GLbyte *)psp->pFB + psp->fbOrigin +
- (pdp->y + y)*psp->fbStride +
- pdp->x + pRect->x1;
- memcpy(d8, s8, w);
- }
- break;
- case 15:
- case 16:
- break;
- case 24:
- break;
- case 32:
- for (y = pRect->y1; y < pRect->y2; y++) {
- /* These are calculated in GLbytes */
- s8 = (GLbyte *)b->backimage->data +
- (y - pdp->y)*b->backimage->bytes_per_line;
- d8 = (GLbyte *)psp->pFB + psp->fbOrigin +
- y*psp->fbStride;
- s32 = (GLuint *)s8;
- d32 = (GLuint *)d8;
- /* These are calculated in GLuints */
- s32 += (pRect->x1 - pdp->x);
- d32 += pRect->x1;
- memcpy(d32, s32, w<<2);
- }
- break;
- }
-
- pRect++;
- }
- }
- /* Unlock the screen */
- DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, hHWContext);
-}
-
-
-
-/*
- * Initialize the XMesa driver.
- */
-GLboolean XMesaInitDriver( __DRIscreenPrivate *driScrnPriv )
-{
- return GL_TRUE;
-}
-
-/*
- * Reset the XMesa driver when the X server resets.
- */
-void XMesaResetDriver( __DRIscreenPrivate *driScrnPriv )
-{
-}
-
-#else
-
-extern void i_hate_these_stupid_dummy_functions();
-void i_hate_these_stupid_dummy_functions()
-{
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/X/xdriP.h b/xc/lib/GL/mesa/src/X/xdriP.h
deleted file mode 100644
index 484ee7f23..000000000
--- a/xc/lib/GL/mesa/src/X/xdriP.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef _XDRI_P_H
-#define _XDRI_P_H
-
-/* Direct rendering includes
- */
-#include "dri_mesaint.h"
-
-
-/*
- * Direct rendering macros:
- */
-#define XMESA_VALIDATE_DRAWABLE_INFO(dpy, psp, pdp) \
-do { \
- while (*(pdp->pStamp) != pdp->lastStamp) { \
- DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \
- pdp->driContextPriv->hHWContext); \
- \
- DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
- DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy, psp->myNum, pdp); \
- DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
- \
- DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \
- pdp->driContextPriv->hHWContext); \
- } \
-} while (0)
-
-
-
-#define DRI_DRAWABLE_ARG , __DRIdrawablePrivate *driDrawPriv
-#define DRI_DRAWABLE_PARM , driDrawPriv
-
-#define DRI_CTX_ARG , __DRIcontextPrivate *driContextPriv
-
-
-extern void XMesaDriSwapBuffers( XMesaBuffer b );
-
-#endif
diff --git a/xc/lib/GL/mesa/src/X86/Imakefile b/xc/lib/GL/mesa/src/X86/Imakefile
index 3ca61bd0d..799a7b9c1 100644
--- a/xc/lib/GL/mesa/src/X86/Imakefile
+++ b/xc/lib/GL/mesa/src/X86/Imakefile
@@ -30,9 +30,10 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
DEFINES = $(ALLOC_DEFINES) GlxDefines $(MESA_ASM_DEFINES)
INCLUDES = -I$(INCLUDESRC) -I$(EXTINCSRC) -I$(MESASRCDIR)/src \
- -I$(MESASRCDIR)/src/X86
+ -I$(MESASRCDIR)/src/X86 \
+ -I../../../include
- SRCS = $(MESA_ASM_SRCS)
+ SRCS = $(MESA_ASM_SRCS) gen_matypes.c
OBJS = $(MESA_ASM_OBJS)
#include <Library.tmpl>
@@ -48,41 +49,45 @@ ObjectFromAsmSource(common_x86_asm, NullParameter)
ObjectFromAsmSource(x86_cliptest, NullParameter)
ObjectFromAsmSource(x86_vertex, NullParameter)
-ObjectFromAsmSource(x86_xform_masked2, NullParameter)
-ObjectFromAsmSource(x86_xform_masked3, NullParameter)
-ObjectFromAsmSource(x86_xform_masked4, NullParameter)
-ObjectFromAsmSource(x86_xform_raw2, NullParameter)
-ObjectFromAsmSource(x86_xform_raw3, NullParameter)
-ObjectFromAsmSource(x86_xform_raw4, NullParameter)
+ObjectFromAsmSource(x86_xform2, NullParameter)
+ObjectFromAsmSource(x86_xform3, NullParameter)
+ObjectFromAsmSource(x86_xform4, NullParameter)
#if MesaUseMMX
ObjectFromAsmSource(mmx_blend, NullParameter)
#endif
#if MesaUse3DNow
-ObjectFromAsmSource(3dnow_norm_raw, NullParameter)
+ObjectFromAsmSource(3dnow_normal, NullParameter)
ObjectFromAsmSource(3dnow_vertex, NullParameter)
-ObjectFromAsmSource(3dnow_xform_masked1, NullParameter)
-ObjectFromAsmSource(3dnow_xform_masked2, NullParameter)
-ObjectFromAsmSource(3dnow_xform_masked3, NullParameter)
-ObjectFromAsmSource(3dnow_xform_masked4, NullParameter)
-ObjectFromAsmSource(3dnow_xform_raw1, NullParameter)
-ObjectFromAsmSource(3dnow_xform_raw2, NullParameter)
-ObjectFromAsmSource(3dnow_xform_raw3, NullParameter)
-ObjectFromAsmSource(3dnow_xform_raw4, NullParameter)
+ObjectFromAsmSource(3dnow_xform1, NullParameter)
+ObjectFromAsmSource(3dnow_xform2, NullParameter)
+ObjectFromAsmSource(3dnow_xform3, NullParameter)
+ObjectFromAsmSource(3dnow_xform4, NullParameter)
#endif
#if MesaUseKatmai
-ObjectFromAsmSource(katmai_norm_raw, NullParameter)
-ObjectFromAsmSource(katmai_vertex, NullParameter)
-ObjectFromAsmSource(katmai_xform_masked1, NullParameter)
-ObjectFromAsmSource(katmai_xform_masked2, NullParameter)
-ObjectFromAsmSource(katmai_xform_masked3, NullParameter)
-ObjectFromAsmSource(katmai_xform_masked4, NullParameter)
-ObjectFromAsmSource(katmai_xform_raw1, NullParameter)
-ObjectFromAsmSource(katmai_xform_raw2, NullParameter)
-ObjectFromAsmSource(katmai_xform_raw3, NullParameter)
-ObjectFromAsmSource(katmai_xform_raw4, NullParameter)
+ObjectFromAsmSource(sse_normal, NullParameter)
+ObjectFromAsmSource(sse_vertex, NullParameter)
+ObjectFromAsmSource(sse_xform1, NullParameter)
+ObjectFromAsmSource(sse_xform2, NullParameter)
+ObjectFromAsmSource(sse_xform3, NullParameter)
+ObjectFromAsmSource(sse_xform4, NullParameter)
#endif
+LinkSourceFile(gen_matypes.c, $(MESASRCDIR)/src/X86)
+
+MATYPES = ./gen_matypes
+
+matypes.h: gen_matypes.c
+ RemoveFiles($@ ProgramTargetName(gen_matypes))
+ -HostLinkRule(ProgramTargetName(gen_matypes),$(CFLAGS) $(LOCAL_LDFLAGS),gen_matypes.c,$(LDLIBS))
+ RunProgram(MATYPES,> matypes_h)
+ $(MV) matypes_h $@
+ RemoveFiles(ProgramTargetName(gen_matypes))
+
+includes:: matypes.h
+
+depend:: matypes.h
+
DependTarget()
diff --git a/xc/lib/GL/mesa/src/X86/Imakefile.inc b/xc/lib/GL/mesa/src/X86/Imakefile.inc
index 01d6348b1..df57677c9 100644
--- a/xc/lib/GL/mesa/src/X86/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/X86/Imakefile.inc
@@ -12,12 +12,9 @@ MESA_X86_SRCS = $(MESAX86BUILDDIR)common_x86.c \
$(MESAX86BUILDDIR)x86.c \
$(MESAX86BUILDDIR)x86_cliptest.S \
$(MESAX86BUILDDIR)x86_vertex.S \
- $(MESAX86BUILDDIR)x86_xform_masked2.S \
- $(MESAX86BUILDDIR)x86_xform_masked3.S \
- $(MESAX86BUILDDIR)x86_xform_masked4.S \
- $(MESAX86BUILDDIR)x86_xform_raw2.S \
- $(MESAX86BUILDDIR)x86_xform_raw3.S \
- $(MESAX86BUILDDIR)x86_xform_raw4.S
+ $(MESAX86BUILDDIR)x86_xform2.S \
+ $(MESAX86BUILDDIR)x86_xform3.S \
+ $(MESAX86BUILDDIR)x86_xform4.S
#ifdef NeedToLinkMesaSrc
LinkSourceFile(common_x86.c, $(MESASRCDIR)/src/X86)
@@ -26,12 +23,9 @@ LinkSourceFile(glapi_x86.S, $(MESASRCDIR)/src/X86)
LinkSourceFile(x86.c, $(MESASRCDIR)/src/X86)
LinkSourceFile(x86_cliptest.S, $(MESASRCDIR)/src/X86)
LinkSourceFile(x86_vertex.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_masked2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_masked3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_masked4.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_raw2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_raw3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(x86_xform_raw4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(x86_xform4.S, $(MESASRCDIR)/src/X86)
#endif
MESA_X86_OBJS = $(MESAX86BUILDDIR)common_x86.o \
@@ -39,12 +33,9 @@ MESA_X86_OBJS = $(MESAX86BUILDDIR)common_x86.o \
$(MESAX86BUILDDIR)x86.o \
$(MESAX86BUILDDIR)x86_cliptest.o \
$(MESAX86BUILDDIR)x86_vertex.o \
- $(MESAX86BUILDDIR)x86_xform_masked2.o \
- $(MESAX86BUILDDIR)x86_xform_masked3.o \
- $(MESAX86BUILDDIR)x86_xform_masked4.o \
- $(MESAX86BUILDDIR)x86_xform_raw2.o \
- $(MESAX86BUILDDIR)x86_xform_raw3.o \
- $(MESAX86BUILDDIR)x86_xform_raw4.o
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o
#if DoSharedLib
MESA_X86_UOBJS = $(MESAX86BUILDDIR)unshared/common_x86.o \
@@ -52,12 +43,9 @@ MESA_X86_UOBJS = $(MESAX86BUILDDIR)unshared/common_x86.o \
$(MESAX86BUILDDIR)unshared/x86.o \
$(MESAX86BUILDDIR)x86_cliptest.o \
$(MESAX86BUILDDIR)x86_vertex.o \
- $(MESAX86BUILDDIR)x86_xform_masked2.o \
- $(MESAX86BUILDDIR)x86_xform_masked3.o \
- $(MESAX86BUILDDIR)x86_xform_masked4.o \
- $(MESAX86BUILDDIR)x86_xform_raw2.o \
- $(MESAX86BUILDDIR)x86_xform_raw3.o \
- $(MESAX86BUILDDIR)x86_xform_raw4.o
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o
#else
MESA_X86_UOBJS = $(MESA_X86_OBJS)
#endif
@@ -67,24 +55,18 @@ MESA_X86_DOBJS = $(MESAX86BUILDDIR)debugger/common_x86.o \
$(MESAX86BUILDDIR)debugger/x86.o \
$(MESAX86BUILDDIR)x86_cliptest.o \
$(MESAX86BUILDDIR)x86_vertex.o \
- $(MESAX86BUILDDIR)x86_xform_masked2.o \
- $(MESAX86BUILDDIR)x86_xform_masked3.o \
- $(MESAX86BUILDDIR)x86_xform_masked4.o \
- $(MESAX86BUILDDIR)x86_xform_raw2.o \
- $(MESAX86BUILDDIR)x86_xform_raw3.o \
- $(MESAX86BUILDDIR)x86_xform_raw4.o
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o
MESA_X86_POBJS = $(MESAX86BUILDDIR)profiled/common_x86.o \
$(MESAX86BUILDDIR)common_x86_asm.o \
$(MESAX86BUILDDIR)profiled/x86.o \
$(MESAX86BUILDDIR)x86_cliptest.o \
$(MESAX86BUILDDIR)x86_vertex.o \
- $(MESAX86BUILDDIR)x86_xform_masked2.o \
- $(MESAX86BUILDDIR)x86_xform_masked3.o \
- $(MESAX86BUILDDIR)x86_xform_masked4.o \
- $(MESAX86BUILDDIR)x86_xform_raw2.o \
- $(MESAX86BUILDDIR)x86_xform_raw3.o \
- $(MESAX86BUILDDIR)x86_xform_raw4.o
+ $(MESAX86BUILDDIR)x86_xform2.o \
+ $(MESAX86BUILDDIR)x86_xform3.o \
+ $(MESAX86BUILDDIR)x86_xform4.o
MESA_X86_DEFS = -DUSE_X86_ASM
@@ -107,181 +89,133 @@ MESA_MMX_DEFS = -DUSE_MMX_ASM
#if MesaUse3DNow
MESA_3DNOW_SRCS = $(MESAX86BUILDDIR)3dnow.c \
- $(MESAX86BUILDDIR)3dnow_norm_raw.S \
+ $(MESAX86BUILDDIR)3dnow_normal.S \
$(MESAX86BUILDDIR)3dnow_vertex.S \
- $(MESAX86BUILDDIR)3dnow_xform_masked1.S \
- $(MESAX86BUILDDIR)3dnow_xform_masked2.S \
- $(MESAX86BUILDDIR)3dnow_xform_masked3.S \
- $(MESAX86BUILDDIR)3dnow_xform_masked4.S \
- $(MESAX86BUILDDIR)3dnow_xform_raw1.S \
- $(MESAX86BUILDDIR)3dnow_xform_raw2.S \
- $(MESAX86BUILDDIR)3dnow_xform_raw3.S \
- $(MESAX86BUILDDIR)3dnow_xform_raw4.S
+ $(MESAX86BUILDDIR)3dnow_xform1.S \
+ $(MESAX86BUILDDIR)3dnow_xform2.S \
+ $(MESAX86BUILDDIR)3dnow_xform3.S \
+ $(MESAX86BUILDDIR)3dnow_xform4.S
#ifdef NeedToLinkMesaSrc
LinkSourceFile(3dnow.c, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_norm_raw.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_normal.S, $(MESASRCDIR)/src/X86)
LinkSourceFile(3dnow_vertex.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_masked1.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_masked2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_masked3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_masked4.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_raw1.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_raw2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_raw3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(3dnow_xform_raw4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(3dnow_xform4.S, $(MESASRCDIR)/src/X86)
#endif
MESA_3DNOW_OBJS = $(MESAX86BUILDDIR)3dnow.o \
- $(MESAX86BUILDDIR)3dnow_norm_raw.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
$(MESAX86BUILDDIR)3dnow_vertex.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked1.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked2.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked3.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked4.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw1.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw2.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw3.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw4.o
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
#ifdef DoSharedLib
MESA_3DNOW_UOBJS = $(MESAX86BUILDDIR)unshared/3dnow.o \
- $(MESAX86BUILDDIR)3dnow_norm_raw.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
$(MESAX86BUILDDIR)3dnow_vertex.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked1.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked2.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked3.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked4.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw1.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw2.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw3.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw4.o
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
#else
MESA_3DNOW_UOBJS = $(MESA_3DNOW_OBJS)
#endif
MESA_3DNOW_DOBJS = $(MESAX86BUILDDIR)debugger/3dnow.o \
- $(MESAX86BUILDDIR)3dnow_norm_raw.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
$(MESAX86BUILDDIR)3dnow_vertex.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked1.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked2.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked3.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked4.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw1.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw2.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw3.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw4.o
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
MESA_3DNOW_POBJS = $(MESAX86BUILDDIR)profiled/3dnow.o \
- $(MESAX86BUILDDIR)3dnow_norm_raw.o \
+ $(MESAX86BUILDDIR)3dnow_normal.o \
$(MESAX86BUILDDIR)3dnow_vertex.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked1.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked2.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked3.o \
- $(MESAX86BUILDDIR)3dnow_xform_masked4.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw1.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw2.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw3.o \
- $(MESAX86BUILDDIR)3dnow_xform_raw4.o
+ $(MESAX86BUILDDIR)3dnow_xform1.o \
+ $(MESAX86BUILDDIR)3dnow_xform2.o \
+ $(MESAX86BUILDDIR)3dnow_xform3.o \
+ $(MESAX86BUILDDIR)3dnow_xform4.o
MESA_3DNOW_DEFS = -DUSE_3DNOW_ASM
#endif
#if MesaUseKatmai
-MESA_KATMAI_SRCS = $(MESAX86BUILDDIR)katmai.c \
- $(MESAX86BUILDDIR)katmai_norm_raw.S \
- $(MESAX86BUILDDIR)katmai_vertex.S \
- $(MESAX86BUILDDIR)katmai_xform_masked1.S \
- $(MESAX86BUILDDIR)katmai_xform_masked2.S \
- $(MESAX86BUILDDIR)katmai_xform_masked3.S \
- $(MESAX86BUILDDIR)katmai_xform_masked4.S \
- $(MESAX86BUILDDIR)katmai_xform_raw1.S \
- $(MESAX86BUILDDIR)katmai_xform_raw2.S \
- $(MESAX86BUILDDIR)katmai_xform_raw3.S \
- $(MESAX86BUILDDIR)katmai_xform_raw4.S
+MESA_SSE_SRCS = $(MESAX86BUILDDIR)sse.c \
+ $(MESAX86BUILDDIR)sse_normal.S \
+ $(MESAX86BUILDDIR)sse_vertex.S \
+ $(MESAX86BUILDDIR)sse_xform1.S \
+ $(MESAX86BUILDDIR)sse_xform2.S \
+ $(MESAX86BUILDDIR)sse_xform3.S \
+ $(MESAX86BUILDDIR)sse_xform4.S
#ifdef NeedToLinkMesaSrc
-LinkSourceFile(katmai.c, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_norm_raw.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_vertex.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_masked1.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_masked2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_masked3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_masked4.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_raw1.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_raw2.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_raw3.S, $(MESASRCDIR)/src/X86)
-LinkSourceFile(katmai_xform_raw4.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse.c, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_normal.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_vertex.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_xform1.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_xform2.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_xform3.S, $(MESASRCDIR)/src/X86)
+LinkSourceFile(sse_xform4.S, $(MESASRCDIR)/src/X86)
#endif
-MESA_KATMAI_OBJS = $(MESAX86BUILDDIR)katmai.o \
- $(MESAX86BUILDDIR)katmai_norm_raw.o \
- $(MESAX86BUILDDIR)katmai_vertex.o \
- $(MESAX86BUILDDIR)katmai_xform_masked1.o \
- $(MESAX86BUILDDIR)katmai_xform_masked2.o \
- $(MESAX86BUILDDIR)katmai_xform_masked3.o \
- $(MESAX86BUILDDIR)katmai_xform_masked4.o \
- $(MESAX86BUILDDIR)katmai_xform_raw1.o \
- $(MESAX86BUILDDIR)katmai_xform_raw2.o \
- $(MESAX86BUILDDIR)katmai_xform_raw3.o \
- $(MESAX86BUILDDIR)katmai_xform_raw4.o
+MESA_SSE_OBJS = $(MESAX86BUILDDIR)sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_vertex.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
#if DoSharedLib
-MESA_KATMAI_UOBJS = $(MESAX86BUILDDIR)unshared/katmai.o \
- $(MESAX86BUILDDIR)katmai_norm_raw.o \
- $(MESAX86BUILDDIR)katmai_vertex.o \
- $(MESAX86BUILDDIR)katmai_xform_masked1.o \
- $(MESAX86BUILDDIR)katmai_xform_masked2.o \
- $(MESAX86BUILDDIR)katmai_xform_masked3.o \
- $(MESAX86BUILDDIR)katmai_xform_masked4.o \
- $(MESAX86BUILDDIR)katmai_xform_raw1.o \
- $(MESAX86BUILDDIR)katmai_xform_raw2.o \
- $(MESAX86BUILDDIR)katmai_xform_raw3.o \
- $(MESAX86BUILDDIR)katmai_xform_raw4.o
+MESA_SSE_UOBJS = $(MESAX86BUILDDIR)unshared/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_vertex.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
#else
-MESA_KATMAI_UOBJS = $(MESA_KATMAI_OBJS)
+MESA_SSE_UOBJS = $(MESA_SSE_OBJS)
#endif
-MESA_KATMAI_DOBJS = $(MESAX86BUILDDIR)debugger/katmai.o \
- $(MESAX86BUILDDIR)katmai_norm_raw.o \
- $(MESAX86BUILDDIR)katmai_vertex.o \
- $(MESAX86BUILDDIR)katmai_xform_masked1.o \
- $(MESAX86BUILDDIR)katmai_xform_masked2.o \
- $(MESAX86BUILDDIR)katmai_xform_masked3.o \
- $(MESAX86BUILDDIR)katmai_xform_masked4.o \
- $(MESAX86BUILDDIR)katmai_xform_raw1.o \
- $(MESAX86BUILDDIR)katmai_xform_raw2.o \
- $(MESAX86BUILDDIR)katmai_xform_raw3.o \
- $(MESAX86BUILDDIR)katmai_xform_raw4.o
-
-MESA_KATMAI_POBJS = $(MESAX86BUILDDIR)profiled/katmai.o \
- $(MESAX86BUILDDIR)katmai_norm_raw.o \
- $(MESAX86BUILDDIR)katmai_vertex.o \
- $(MESAX86BUILDDIR)katmai_xform_masked1.o \
- $(MESAX86BUILDDIR)katmai_xform_masked2.o \
- $(MESAX86BUILDDIR)katmai_xform_masked3.o \
- $(MESAX86BUILDDIR)katmai_xform_masked4.o \
- $(MESAX86BUILDDIR)katmai_xform_raw1.o \
- $(MESAX86BUILDDIR)katmai_xform_raw2.o \
- $(MESAX86BUILDDIR)katmai_xform_raw3.o \
- $(MESAX86BUILDDIR)katmai_xform_raw4.o
-
-MESA_KATMAI_DEFS = -DUSE_KATMAI_ASM
+MESA_SSE_DOBJS = $(MESAX86BUILDDIR)debugger/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_vertex.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+
+MESA_SSE_POBJS = $(MESAX86BUILDDIR)profiled/sse.o \
+ $(MESAX86BUILDDIR)sse_normal.o \
+ $(MESAX86BUILDDIR)sse_vertex.o \
+ $(MESAX86BUILDDIR)sse_xform1.o \
+ $(MESAX86BUILDDIR)sse_xform2.o \
+ $(MESAX86BUILDDIR)sse_xform3.o \
+ $(MESAX86BUILDDIR)sse_xform4.o
+
+MESA_SSE_DEFS = -DUSE_SSE_ASM
#endif
MESA_ASM_SRCS = $(MESA_X86_SRCS) $(MESA_MMX_SRCS) $(MESA_3DNOW_SRCS) \
- $(MESA_KATMAI_SRCS)
+ $(MESA_SSE_SRCS)
MESA_ASM_OBJS = $(MESA_X86_OBJS) $(MESA_MMX_OBJS) $(MESA_3DNOW_OBJS) \
- $(MESA_KATMAI_OBJS)
+ $(MESA_SSE_OBJS)
MESA_ASM_UOBJS = $(MESA_X86_UOBJS) $(MESA_MMX_UOBJS) $(MESA_3DNOW_UOBJS) \
- $(MESA_KATMAI_UOBJS)
+ $(MESA_SSE_UOBJS)
MESA_ASM_DOBJS = $(MESA_X86_DOBJS) $(MESA_MMX_DOBJS) $(MESA_3DNOW_DOBJS) \
- $(MESA_KATMAI_DOBJS)
+ $(MESA_SSE_DOBJS)
MESA_ASM_POBJS = $(MESA_X86_POBJS) $(MESA_MMX_POBJS) $(MESA_3DNOW_POBJS) \
- $(MESA_KATMAI_POBJS)
+ $(MESA_SSE_POBJS)
-MESA_ASM_DEFINES = -DUSE_X86_ASM $(MESA_MMX_DEFS) $(MESA_3DNOW_DEFS) $(MESA_KATMAI_DEFS)
+MESA_ASM_DEFINES = -DUSE_X86_ASM $(MESA_MMX_DEFS) $(MESA_3DNOW_DEFS) $(MESA_SSE_DEFS)
diff --git a/xc/lib/GL/mesa/src/array_cache/Imakefile b/xc/lib/GL/mesa/src/array_cache/Imakefile
new file mode 100644
index 000000000..00e5eea04
--- /dev/null
+++ b/xc/lib/GL/mesa/src/array_cache/Imakefile
@@ -0,0 +1,86 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(ac_context.c, $(MESASRCDIR)/src/array_cache)
+LinkSourceFile(ac_import.c, $(MESASRCDIR)/src/array_cache)
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/array_cache \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = ac_context.c ac_import.c
+ OBJS = ac_context.o ac_import.o
+
+
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/common/spantmp.h b/xc/lib/GL/mesa/src/drv/common/spantmp.h
index 4cac09bd0..888be0465 100644
--- a/xc/lib/GL/mesa/src/drv/common/spantmp.h
+++ b/xc/lib/GL/mesa/src/drv/common/spantmp.h
@@ -140,8 +140,9 @@ static void TAG(WriteRGBAPixels)( const GLcontext *ctx,
}
-static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
- GLuint n, GLint x, GLint y,
+static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLchan color[4],
const GLubyte mask[] )
{
HW_WRITE_LOCK()
@@ -149,7 +150,7 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
GLint x1;
GLint n1;
LOCAL_VARS;
- INIT_MONO_PIXEL(p);
+ INIT_MONO_PIXEL(p, color);
y = Y_FLIP( y );
@@ -172,13 +173,14 @@ static void TAG(WriteMonoRGBASpan)( const GLcontext *ctx,
static void TAG(WriteMonoRGBAPixels)( const GLcontext *ctx,
GLuint n,
const GLint x[], const GLint y[],
- const GLubyte mask[] )
+ const GLchan color[],
+ const GLubyte mask[] )
{
HW_WRITE_LOCK()
{
GLint i;
LOCAL_VARS;
- INIT_MONO_PIXEL(p);
+ INIT_MONO_PIXEL(p, color);
if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
diff --git a/xc/lib/GL/mesa/src/drv/ffb/Imakefile b/xc/lib/GL/mesa/src/drv/ffb/Imakefile
index 5b87af422..991d213ee 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/ffb/Imakefile
@@ -2,7 +2,6 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.12 2001/05/10 16:56:10
#include <Threads.tmpl>
-
#if GlxUseBuiltInDRIDriver
#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
@@ -23,32 +22,52 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/ffb/Imakefile,v 1.12 2001/05/10 16:56:10
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
- INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
+ INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES) \
+ -I$(XF86DRIVERSRC)/sunffb
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
$(GLXLIBSRC)/dri/drm/xf86drmRandom.o \
$(GLXLIBSRC)/dri/drm/xf86drmSL.o
+#ifdef GlxSoProf
+ LOSRCS = ../../../../lowpc.c
+ HISRCS = ../../../../highpc.c
+
+ LOOBJS = ../../../../lowpc.o
+ HIOBJS = ../../../../highpc.o
+#endif
+
SRCS = $(FFBSRCS)
- OBJS = $(FFBOBJS) $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS)
+ OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(FFBOBJS) $(HIOBJS)
REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB)
#include <Library.tmpl>
-SubdirLibraryRule($(OBJS))
+LibraryObjectRule()
+
+SubdirLibraryRule($(FFBOBJS))
NormalLintTarget($(SRCS))
#if !GlxUseBuiltInDRIDriver
LIBNAME = ffb_dri.so
SharedDriModuleTarget($(LIBNAME),DONE $(OBJS),$(OBJS))
InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
+
+#ifdef GlxSoProf
+SOPROF_LIBNAME = _ffb_dri_p
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
+InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
+#endif
#endif
DependTarget()
diff --git a/xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc b/xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc
index 72db80797..1a9c4886c 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/ffb/Imakefile.inc
@@ -9,105 +9,119 @@ MESADRVSRCDIR = MesaDrvSrcDir
#ifndef MesaDrvFfbBuildDir
#define MesaDrvFfbBuildDir /**/
#endif
-MESADRVFFBBUILDDIR = MesaDrvFfbBuildDir
+MESADRVRADEONBUILDDIR = MesaDrvFfbBuildDir
#if Malloc0ReturnsNull
ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
- DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \
- -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(GLXLIBSRC)/glx \
+ -I$(INCLUDESRC) \
+ -I$(INCLUDESRC)/GL \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
- -I$(XF86DRIVERSRC)/sunffb \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(XF86DRIVERSRC)/ati \
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
-MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESADRVSRCDIR)/common \
-I$(MESADRVSRCDIR)/ffb
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
+ FFBSRCS = $(MESADRVRADEONBUILDDIR)ffb_bitmap.c \
+ $(MESADRVRADEONBUILDDIR)ffb_clear.c \
+ $(MESADRVRADEONBUILDDIR)ffb_dd.c \
+ $(MESADRVRADEONBUILDDIR)ffb_depth.c \
+ $(MESADRVRADEONBUILDDIR)ffb_fog.c \
+ $(MESADRVRADEONBUILDDIR)ffb_lines.c \
+ $(MESADRVRADEONBUILDDIR)ffb_points.c \
+ $(MESADRVRADEONBUILDDIR)ffb_span.c \
+ $(MESADRVRADEONBUILDDIR)ffb_state.c \
+ $(MESADRVRADEONBUILDDIR)ffb_stencil.c \
+ $(MESADRVRADEONBUILDDIR)ffb_tex.c \
+ $(MESADRVRADEONBUILDDIR)ffb_tris.c \
+ $(MESADRVRADEONBUILDDIR)ffb_vb.c \
+ $(MESADRVRADEONBUILDDIR)ffb_xmesa.c
- FFBSRCS = $(MESADRVFFBBUILDDIR)ffb_dd.c \
- $(MESADRVFFBBUILDDIR)ffb_span.c \
- $(MESADRVFFBBUILDDIR)ffb_depth.c \
- $(MESADRVFFBBUILDDIR)ffb_state.c \
- $(MESADRVFFBBUILDDIR)ffb_clear.c \
- $(MESADRVFFBBUILDDIR)ffb_vb.c \
- $(MESADRVFFBBUILDDIR)ffb_lines.c \
- $(MESADRVFFBBUILDDIR)ffb_points.c \
- $(MESADRVFFBBUILDDIR)ffb_tris.c \
- $(MESADRVFFBBUILDDIR)ffb_pipeline.c \
- $(MESADRVFFBBUILDDIR)ffb_stencil.c \
- $(MESADRVFFBBUILDDIR)ffb_xmesa.c
+ FFBOBJS = $(MESADRVRADEONBUILDDIR)ffb_bitmap.o \
+ $(MESADRVRADEONBUILDDIR)ffb_clear.o \
+ $(MESADRVRADEONBUILDDIR)ffb_dd.o \
+ $(MESADRVRADEONBUILDDIR)ffb_depth.o \
+ $(MESADRVRADEONBUILDDIR)ffb_fog.o \
+ $(MESADRVRADEONBUILDDIR)ffb_lines.o \
+ $(MESADRVRADEONBUILDDIR)ffb_points.o \
+ $(MESADRVRADEONBUILDDIR)ffb_span.o \
+ $(MESADRVRADEONBUILDDIR)ffb_state.o \
+ $(MESADRVRADEONBUILDDIR)ffb_stencil.o \
+ $(MESADRVRADEONBUILDDIR)ffb_tex.o \
+ $(MESADRVRADEONBUILDDIR)ffb_tris.o \
+ $(MESADRVRADEONBUILDDIR)ffb_vb.o \
+ $(MESADRVRADEONBUILDDIR)ffb_xmesa.o
- FFBOBJS = $(MESADRVFFBBUILDDIR)ffb_dd.o \
- $(MESADRVFFBBUILDDIR)ffb_span.o \
- $(MESADRVFFBBUILDDIR)ffb_depth.o \
- $(MESADRVFFBBUILDDIR)ffb_state.o \
- $(MESADRVFFBBUILDDIR)ffb_clear.o \
- $(MESADRVFFBBUILDDIR)ffb_vb.o \
- $(MESADRVFFBBUILDDIR)ffb_lines.o \
- $(MESADRVFFBBUILDDIR)ffb_points.o \
- $(MESADRVFFBBUILDDIR)ffb_tris.o \
- $(MESADRVFFBBUILDDIR)ffb_pipeline.o \
- $(MESADRVFFBBUILDDIR)ffb_stencil.o \
- $(MESADRVFFBBUILDDIR)ffb_xmesa.o
+ FFBUOBJS = $(MESADRVRADEONBUILDDIR)unshared/ffb_bitmap.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_clear.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_dd.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_depth.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_fog.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_lines.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_points.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_span.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_state.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_stencil.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_tex.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_tris.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_vb.o \
+ $(MESADRVRADEONBUILDDIR)unshared/ffb_xmesa.o
- FFBUOBJS = $(MESADRVFFBBUILDDIR)unshared/ffb_dd.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_span.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_depth.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_state.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_clear.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_vb.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_lines.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_points.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_tris.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_pipeline.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_stencil.o \
- $(MESADRVFFBBUILDDIR)unshared/ffb_xmesa.o
+ FFBDOBJS = $(MESADRVRADEONBUILDDIR)debugger/ffb_bitmap.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_clear.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_dd.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_depth.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_fog.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_lines.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_points.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_span.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_state.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_stencil.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_tex.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_tris.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_vb.o \
+ $(MESADRVRADEONBUILDDIR)debugger/ffb_xmesa.o
- FFBDOBJS = $(MESADRVFFBBUILDDIR)debugger/ffb_dd.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_span.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_depth.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_state.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_clear.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_vb.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_lines.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_points.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_tris.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_pipeline.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_stencil.o \
- $(MESADRVFFBBUILDDIR)debugger/ffb_xmesa.o
-
- FFBPOBJS = $(MESADRVFFBBUILDDIR)profiled/ffb_dd.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_span.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_depth.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_state.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_clear.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_vb.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_lines.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_points.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_tris.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_pipeline.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_stencil.o \
- $(MESADRVFFBBUILDDIR)profiled/ffb_xmesa.o
+ FFBPOBJS = $(MESADRVRADEONBUILDDIR)profiled/ffb_bitmap.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_clear.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_dd.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_depth.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_fog.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_lines.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_points.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_span.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_state.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_stencil.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_tex.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_tris.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_vb.o \
+ $(MESADRVRADEONBUILDDIR)profiled/ffb_xmesa.o
#ifdef NeedToLinkMesaSrc
+LinkSourceFile(ffb_bitmap.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_clear.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_dd.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_span.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_depth.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_state.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_clear.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_vb.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_fog.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_lines.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_points.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_tris.c, $(MESADRVSRCDIR)/ffb)
-LinkSourceFile(ffb_pipeline.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_span.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_state.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_stencil.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tex.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_tris.c, $(MESADRVSRCDIR)/ffb)
+LinkSourceFile(ffb_vb.c, $(MESADRVSRCDIR)/ffb)
LinkSourceFile(ffb_xmesa.c, $(MESADRVSRCDIR)/ffb)
#endif
-
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.c
new file mode 100644
index 000000000..51f7719c6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.c
@@ -0,0 +1,156 @@
+/* $XFree86$
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_context.h"
+#include "ffb_state.h"
+#include "ffb_lock.h"
+#include "ffb_bitmap.h"
+#include "swrast/swrast.h"
+#include "image.h"
+#include "macros.h"
+
+#undef FFB_BITMAP_TRACE
+
+static void
+ffb_bitmap(GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ unsigned int ppc, pixel;
+ GLint row, col, row_stride;
+ const GLubyte *src;
+ char *buf;
+
+ if (fmesa->bad_fragment_attrs != 0)
+ _swrast_Bitmap(ctx, px, py, width,
+ height, unpack, bitmap);
+
+ pixel = (((((GLuint)(ctx->Current.RasterColor[0] * 255.0f)) & 0xff) << 0) |
+ ((((GLuint)(ctx->Current.RasterColor[1] * 255.0f)) & 0xff) << 8) |
+ ((((GLuint)(ctx->Current.RasterColor[2] * 255.0f)) & 0xff) << 16) |
+ ((((GLuint)(ctx->Current.RasterColor[3] * 255.0f)) & 0xff) << 24));
+
+#ifdef FFB_BITMAP_TRACE
+ fprintf(stderr, "ffb_bitmap: ppc(%08x) fbc(%08x) cmp(%08x) pixel(%08x)\n",
+ fmesa->ppc, fmesa->fbc, fmesa->cmp, pixel);
+#endif
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty)
+ ffbSyncHardware(fmesa);
+
+ ppc = fmesa->ppc;
+
+ FFBFifo(fmesa, 4);
+ ffb->ppc = ((ppc &
+ ~(FFB_PPC_TBE_MASK | FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK))
+ | (FFB_PPC_TBE_TRANSPARENT | FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST |
+ (ctx->Color.BlendEnabled ? FFB_PPC_XS_CONST : FFB_PPC_XS_WID)));
+ ffb->constz = ((GLuint) (ctx->Current.RasterPos[2] * 0x0fffffff));
+ ffb->fg = pixel;
+ ffb->fontinc = (0 << 16) | 32;
+
+ buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));
+
+ row_stride = (unpack->Alignment * CEILING(width, 8 * unpack->Alignment));
+ src = (const GLubyte *) (bitmap +
+ (unpack->SkipRows * row_stride) +
+ (unpack->SkipPixels / 8));
+ if (unpack->LsbFirst == GL_TRUE) {
+ for (row = 0; row < height; row++, src += row_stride) {
+ const GLubyte *row_src = src;
+ GLuint base_x, base_y;
+
+ base_x = dPriv->x + px;
+ base_y = dPriv->y + (dPriv->h - (py + row));
+
+ FFBFifo(fmesa, 1);
+ ffb->fontxy = (base_y << 16) | base_x;
+
+ for (col = 0; col < width; col += 32, row_src += 4) {
+ GLint bitnum, font_w = (width - col);
+ GLuint font_data;
+
+ if (font_w > 32)
+ font_w = 32;
+ font_data = 0;
+ for (bitnum = 0; bitnum < 32; bitnum++) {
+ const GLubyte val = row_src[bitnum >> 3];
+
+ if (val & (1 << (bitnum & (8 - 1))))
+ font_data |= (1 << (31 - bitnum));
+ }
+
+ FFBFifo(fmesa, 2);
+ ffb->fontw = font_w;
+ ffb->font = font_data;
+ }
+ }
+ } else {
+ for (row = 0; row < height; row++, src += row_stride) {
+ const GLubyte *row_src = src;
+ GLuint base_x, base_y;
+
+ base_x = dPriv->x + px;
+ base_y = dPriv->y + (dPriv->h - (py + row));
+
+ FFBFifo(fmesa, 1);
+ ffb->fontxy = (base_y << 16) | base_x;
+
+ for (col = 0; col < width; col += 32, row_src += 4) {
+ GLint font_w = (width - col);
+
+ if (font_w > 32)
+ font_w = 32;
+ FFBFifo(fmesa, 2);
+ ffb->fontw = font_w;
+ ffb->font = (((unsigned int)row_src[0]) << 24 |
+ ((unsigned int)row_src[1]) << 16 |
+ ((unsigned int)row_src[2]) << 8 |
+ ((unsigned int)row_src[3]) << 0);
+ }
+ }
+ }
+
+ FFBFifo(fmesa, 1);
+ ffb->ppc = ppc;
+ fmesa->ffbScreen->rp_active = 1;
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+void ffbDDInitBitmapFuncs(GLcontext *ctx)
+{
+ ctx->Driver.Bitmap = ffb_bitmap;
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.h
new file mode 100644
index 000000000..7a893acb1
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.h
@@ -0,0 +1,8 @@
+/* $XFree86$ */
+
+#ifndef _FFB_BITMAP_H
+#define _FFB_BITMAP_H
+
+extern void ffbDDInitBitmapFuncs(GLcontext *);
+
+#endif /* !(_FFB_BITMAP_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c
index 3f3097327..da0670b30 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c
@@ -25,8 +25,8 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
+#include "extensions.h"
#include "mm.h"
#include "ffb_dd.h"
@@ -37,9 +37,8 @@
#include "ffb_tris.h"
#include "ffb_clear.h"
#include "ffb_lock.h"
-#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
+
+#undef CLEAR_TRACE
#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h))
@@ -263,13 +262,18 @@ ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
}
}
-GLbitfield ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cwidth, GLint cheight)
+void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
unsigned int stcmask = DD_STENCIL_BIT;
+#ifdef CLEAR_TRACE
+ fprintf(stderr, "ffbDDClear: mask(%08x) all(%d) "
+ "[x(%x)y(%x)w(%x)h(%x)]\n",
+ mask, (int) all, cx, cy, cwidth, cheight);
+#endif
if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
stcmask = 0;
@@ -344,5 +348,7 @@ GLbitfield ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
DD_DEPTH_BIT | stcmask);
}
- return mask;
+ if (mask)
+ _swrast_Clear(ctx, mask, all, cx, cy, cwidth, cheight);
}
+
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h
index 29f197399..d91ace3b7 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h
@@ -3,7 +3,7 @@
#ifndef _FFB_CLEAR_H
#define _FFB_CLEAR_H
-extern GLbitfield ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cwidth, GLint cheight);
+extern void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight);
#endif /* !(_FFB_CLEAR_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
index af0d0e2c6..cb04531f6 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_context.h
@@ -1,47 +1,157 @@
+/* $XFree86$ */
+
#ifndef _FFB_CONTEXT_H
#define _FFB_CONTEXT_H
#include <X11/Xlibint.h>
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
+#include "dri_util.h"
-#include "types.h"
+#include "mtypes.h"
#include "ffb_xmesa.h"
+typedef struct {
+ GLfloat alpha;
+ GLfloat red;
+ GLfloat green;
+ GLfloat blue;
+} ffb_color;
+
+#define FFB_GET_ALPHA(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].alpha)
+#define FFB_GET_RED(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].red)
+#define FFB_GET_GREEN(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].green)
+#define FFB_GET_BLUE(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].blue)
+
+typedef struct {
+ GLfloat x, y, z;
+ ffb_color color[2];
+} ffb_vertex;
+
+#define FFB_DELAYED_VIEWPORT_VARS \
+ GLfloat VP_SX = fmesa->hw_viewport[MAT_SX]; \
+ GLfloat VP_TX = fmesa->hw_viewport[MAT_TX]; \
+ GLfloat VP_SY = fmesa->hw_viewport[MAT_SY]; \
+ GLfloat VP_TY = fmesa->hw_viewport[MAT_TY]; \
+ GLfloat VP_SZ = fmesa->hw_viewport[MAT_SZ]; \
+ GLfloat VP_TZ = fmesa->hw_viewport[MAT_TZ]; \
+ (void) VP_SX; (void) VP_SY; (void) VP_SZ; \
+ (void) VP_TX; (void) VP_TY; (void) VP_TZ
+
+#define FFB_GET_Z(VTX) \
+ FFB_Z_FROM_FLOAT(VP_SZ * (VTX)->z + VP_TZ)
+#define FFB_GET_Y(VTX) \
+ FFB_XY_FROM_FLOAT(VP_SY * (VTX)->y + VP_TY)
+#define FFB_GET_X(VTX) \
+ FFB_XY_FROM_FLOAT(VP_SX * (VTX)->x + VP_TX)
+
+typedef void (*ffb_point_func)(GLcontext *, ffb_vertex *);
+typedef void (*ffb_line_func)(GLcontext *, ffb_vertex *, ffb_vertex *);
+typedef void (*ffb_tri_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
+ ffb_vertex *);
+typedef void (*ffb_quad_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
+ ffb_vertex *, ffb_vertex *);
+
+/* Immediate mode fast-path support. */
+typedef struct {
+ GLfloat obj[4];
+ GLfloat normal[4];
+ GLfloat clip[4];
+ GLuint mask;
+ GLfloat color[4];
+ GLfloat win[4];
+ GLfloat eye[4];
+} ffbTnlVertex, *ffbTnlVertexPtr;
+
+typedef void (*ffb_interp_func)(GLfloat t,
+ ffbTnlVertex *O,
+ const ffbTnlVertex *I,
+ const ffbTnlVertex *J);
+
+struct ffb_current_state {
+ GLfloat color[4];
+ GLfloat normal[4];
+ GLfloat specular[4];
+};
+
+struct ffb_light_state {
+ GLfloat base_color[3];
+ GLfloat base_alpha;
+};
+
+struct ffb_vertex_state {
+ struct ffb_current_state current;
+ struct ffb_light_state light;
+};
+
+struct ffb_imm_vertex {
+ ffbTnlVertex vertices[8];
+ ffbTnlVertex *v0;
+ ffbTnlVertex *v1;
+ ffbTnlVertex *v2;
+ ffbTnlVertex *v3;
+
+ void (*save_vertex)(GLcontext *ctx, ffbTnlVertex *v);
+ void (*flush_vertex)(GLcontext *ctx, ffbTnlVertex *v);
+
+ ffb_interp_func interp;
+
+ GLuint prim, format;
+
+ GLvertexformat vtxfmt;
+};
+
typedef struct ffb_context_t {
GLcontext *glCtx;
- GLuint MonoColor;
GLframebuffer *glBuffer;
+ /* Temporaries for translating to float colors. */
+ struct gl_client_array FloatColor;
+ struct gl_client_array FloatSecondaryColor;
+
ffb_fbcPtr regs;
volatile char *sfb32;
int hw_locked;
- int SWrender;
int back_buffer; /* 0 = bufferA, 1 = bufferB */
- /* Because MESA does not send us the raw primitives,
- * we send everything to the chip as independant lines,
- * points, tris, and quads. If we could get the real
- * primitive being used by the user, we can optimize
- * things a lot. This is particularly useful for
- * tri strips/fans, and quad strips/fans as FFB
- * specifically can optimize these cases.
- *
- * I suspect MESA does not preserve things to make it's
- * transformation/clip/cull optimizations simpler.
- *
- * Anyways, to try and get around this, we record the
- * vertices used in the most recent primitive and we
- * detect tri strips/fans and quad strips/fans this
- * way. Actually, we only need to record the ffb_vertex
- * pointers, and this makes the tests cheaper and the
- * flushing faster (at VB updates and reduced primitive
- * changes).
- */
- void *vtx_cache[4];
+ /* Viewport matrix. */
+ GLfloat hw_viewport[16];
+#define SUBPIXEL_X (-0.5F)
+#define SUBPIXEL_Y (-0.5F + 0.125)
+
+ /* Vertices in driver format. */
+ ffb_vertex *verts;
+
+ /* Rasterization functions. */
+ ffb_point_func draw_point;
+ ffb_line_func draw_line;
+ ffb_tri_func draw_tri;
+ ffb_quad_func draw_quad;
+
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ GLfloat backface_sign;
+ GLfloat depth_scale;
+
+ GLfloat ffb_2_30_fixed_scale;
+ GLfloat ffb_one_over_2_30_fixed_scale;
+ GLfloat ffb_16_16_fixed_scale;
+ GLfloat ffb_one_over_16_16_fixed_scale;
+ GLfloat ffb_ubyte_color_scale;
+ GLfloat ffb_zero;
+
+ /* Immediate mode state. */
+ struct ffb_vertex_state vtx_state;
+ struct ffb_imm_vertex imm;
+
+ /* Debugging knobs. */
+ GLboolean debugFallbacks;
/* This records state bits when a per-fragment attribute has
* been set which prevents us from rendering in hardware.
@@ -56,6 +166,8 @@ typedef struct ffb_context_t {
#define FFB_BADATTR_BLENDROP 0x00000004 /* Blend enabled and LogicOP != GL_COPY */
#define FFB_BADATTR_BLENDEQN 0x00000008 /* Blend equation other than ADD */
#define FFB_BADATTR_STENCIL 0x00000010 /* Stencil enabled when < FFB2+ */
+#define FFB_BADATTR_TEXTURE 0x00000020 /* Texture enabled */
+#define FFB_BADATTR_SWONLY 0x00000040 /* Environment var set */
unsigned int state_dirty;
unsigned int state_fifo_ents;
@@ -84,6 +196,13 @@ typedef struct ffb_context_t {
unsigned int state_all_fifo_ents;
+#define FFB_MAKE_DIRTY(FMESA, STATE_MASK, FIFO_ENTS) \
+do { if ((STATE_MASK) & ~((FMESA)->state_dirty)) { \
+ (FMESA)->state_dirty |= (STATE_MASK); \
+ (FMESA)->state_fifo_ents += FIFO_ENTS; \
+ } \
+} while (0)
+
/* General hw reg state. */
unsigned int fbc;
unsigned int ppc;
@@ -92,7 +211,7 @@ typedef struct ffb_context_t {
unsigned int lpat;
#define FFB_LPAT_BAD 0xffffffff
-
+
unsigned int wid;
unsigned int pmask;
unsigned int xpmask;
@@ -157,13 +276,8 @@ typedef struct ffb_context_t {
unsigned int clear_stencil;
unsigned int setupindex;
- unsigned int setupdone;
-
- /* Rendering functions. */
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
+ unsigned int setupnewinputs;
+ unsigned int new_gl_state;
__DRIdrawablePrivate *driDrawable;
__DRIscreenPrivate *driScreen;
@@ -192,6 +306,6 @@ typedef struct ffb_context_t {
* we tell the hw to discard those top 4 bits).
*/
#define Z_TO_MESA(VAL) ((GLdepth)(((VAL) & 0x0fffffff) << (32 - 28)))
-#define Z_FROM_MESA(VAL) (((GLuint)(VAL)) >> (32 - 28))
+#define Z_FROM_MESA(VAL) (((GLuint)((GLdouble)(VAL))) >> (32 - 28))
#endif /* !(_FFB_CONTEXT_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
index eb32c8a24..1afa042a4 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c
@@ -1,7 +1,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c,v 1.2 2001/04/10 16:07:50 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,7 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
#include <stdio.h>
#include <stdlib.h>
@@ -39,50 +38,54 @@
#include "ffb_vb.h"
#include "ffb_tris.h"
#include "ffb_clear.h"
-#include "ffb_pipeline.h"
#include "ffb_lock.h"
#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
+
+#define FFB_DATE "20010624"
/* Mesa's Driver Functions */
static const GLubyte *ffbDDGetString(GLcontext *ctx, GLenum name)
{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ static char buffer[128];
+
switch (name) {
case GL_VENDOR:
return (GLubyte *) "David S. Miller";
+
case GL_RENDERER:
- return (GLubyte *) "Mesa DRI FFB 20010321";
+ sprintf(buffer, "Mesa DRI FFB " FFB_DATE);
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2)
+ strncat(buffer, " FFB2", 5);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)
+ strncat(buffer, " FFB2PLUS", 9);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1)
+ strncat(buffer, " PAC1", 5);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC2)
+ strncat(buffer, " PAC2", 5);
+
+#ifdef USE_SPARC_ASM
+ strncat(buffer, " Sparc", 6);
+#endif
+
+ return (GLubyte *) buffer;
+
default:
return NULL;
};
}
-static GLint ffbGetParameteri(const GLcontext *ctx, GLint param)
-{
- switch (param) {
- case DD_HAVE_HARDWARE_FOG:
- /* XXX We have per-fragment fog, once fog code is done,
- * XXX set this.
- */
- return 0;
- default:
-#if 0
- ffbError("ffbGetParameteri(): unknown parameter!\n");
-#endif
- return 0;
- };
-}
static void ffbBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-/* LOCK_HARDWARE(fmesa); */
+ LOCK_HARDWARE(fmesa);
*width = fmesa->driDrawable->w;
*height = fmesa->driDrawable->h;
-/* UNLOCK_HARDWARE(fmesa); */
+ UNLOCK_HARDWARE(fmesa);
}
void ffbDDExtensionsInit(GLcontext *ctx)
@@ -110,14 +113,7 @@ void ffbDDInitDriverFuncs(GLcontext *ctx)
{
ctx->Driver.GetBufferSize = ffbBufferSize;
ctx->Driver.GetString = ffbDDGetString;
- ctx->Driver.GetParameteri = ffbGetParameteri;
ctx->Driver.Clear = ffbDDClear;
ctx->Driver.Finish = ffbDDFinish;
-
- /* VB hooks */
- ctx->Driver.RegisterVB = ffbDDRegisterVB;
- ctx->Driver.UnregisterVB = ffbDDUnregisterVB;
-
- ctx->Driver.BuildPrecalcPipeline = ffbDDBuildPrecalcPipeline;
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c
index 678dfff7f..509d3a02c 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c
@@ -25,17 +25,26 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
+#include "mtypes.h"
+#include "swrast/swrast.h"
#include "ffb_dd.h"
#include "ffb_span.h"
#include "ffb_context.h"
#include "ffb_depth.h"
#include "ffb_lock.h"
+#include "swrast/swrast.h"
+
+#undef DEPTH_TRACE
+
static void
FFBWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth depth[], const GLubyte mask[])
{
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
if (ctx->Depth.Mask) {
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
@@ -76,6 +85,9 @@ static void
FFBWriteDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
const GLdepth depth[], const GLubyte mask[])
{
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBWriteDepthPixels: n(%d)\n", (int) n);
+#endif
if (ctx->Depth.Mask) {
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
@@ -122,6 +134,10 @@ FFBReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth depth[])
GLuint *zptr;
GLuint i;
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
if (!fmesa->hw_locked)
LOCK_HARDWARE(fmesa);
FFBFifo(fmesa, 1);
@@ -156,6 +172,9 @@ FFBReadDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
char *zbase;
GLuint i;
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBReadDepthPixels: n(%d)\n", (int) n);
+#endif
if (!fmesa->hw_locked)
LOCK_HARDWARE(fmesa);
FFBFifo(fmesa, 1);
@@ -185,8 +204,11 @@ FFBReadDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
void ffbDDInitDepthFuncs(GLcontext *ctx)
{
- ctx->Driver.WriteDepthSpan = FFBWriteDepthSpan;
- ctx->Driver.ReadDepthSpan = FFBReadDepthSpan;
- ctx->Driver.WriteDepthPixels = FFBWriteDepthPixels;
- ctx->Driver.ReadDepthPixels = FFBReadDepthPixels;
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->WriteDepthSpan = FFBWriteDepthSpan;
+ swdd->ReadDepthSpan = FFBReadDepthSpan;
+ swdd->WriteDepthPixels = FFBWriteDepthPixels;
+ swdd->ReadDepthPixels = FFBReadDepthPixels;
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h
index b78c7e5b6..794fd6dc2 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h
@@ -17,7 +17,7 @@ do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
if (__fScrn->rp_active) { \
unsigned int __regval = (__ffb)->ucsr; \
- while((__regval & FFB_UCSR_RP_BUSY) != 0) { \
+ while((__regval & FFB_UCSR_ALL_BUSY) != 0) { \
__regval = (__ffb)->ucsr; \
} \
__fScrn->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
index 180f10422..3c8def2db 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c
@@ -1,7 +1,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c,v 1.1 2000/06/20 05:08:38 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,7 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
#include <stdio.h>
#include <stdlib.h>
@@ -38,29 +37,20 @@
#include "ffb_context.h"
#include "ffb_vb.h"
#include "ffb_lines.h"
+#include "ffb_tris.h"
#include "ffb_lock.h"
#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
-#include "pipeline.h"
+
+#undef FFB_LINE_TRACE
#define FFB_LINE_FLAT_BIT 0x01
-#define FFB_LINE_TWOSIDE_BIT 0x02
-#define FFB_LINE_OFFSET_BIT 0x04
-#define FFB_LINE_WIDE_BIT 0x08
-#define FFB_LINE_ALPHA_BIT 0x10
-#define FFB_LINE_FALLBACK_BIT 0x20
+#define FFB_LINE_ALPHA_BIT 0x02
+#define MAX_FFB_LINE_FUNCS 0x04
-static line_func ffb_line_tab[0x40];
+static ffb_line_func ffb_line_tab[MAX_FFB_LINE_FUNCS];
/* If the line is not wide, we can support all of the line
* patterning and smooth shading features of OpenGL fully.
- * If it is wide we use triangles to render them and as such
- * we lose the capability to do the patterning+shading in HW.
- *
- * XXX Actually, with the triangle method we can probably do
- * XXX the shading/antialiasing too if we are careful. It might
- * XXX not work, need to investigate this. -DaveM
*/
#define IND (0)
@@ -71,62 +61,6 @@ static line_func ffb_line_tab[0x40];
#define TAG(x) x##_flat
#include "ffb_linetmp.h"
-#define IND (FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT)
-#define TAG(x) x##_wide
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_wide_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_wide_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_wide_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT)
-#define TAG(x) x##_wide_twoside
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_wide_twoside_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_wide_twoside_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_wide_twoside_offset_flat
-#include "ffb_linetmp.h"
-
#define IND (FFB_LINE_ALPHA_BIT)
#define TAG(x) x##_alpha
#include "ffb_linetmp.h"
@@ -135,132 +69,38 @@ static line_func ffb_line_tab[0x40];
#define TAG(x) x##_alpha_flat
#include "ffb_linetmp.h"
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_alpha_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT)
-#define TAG(x) x##_alpha_twoside
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_twoside_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_alpha_twoside_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_twoside_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT)
-#define TAG(x) x##_alpha_wide
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_wide_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_alpha_wide_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_wide_offset_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT)
-#define TAG(x) x##_alpha_wide_twoside
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_wide_twoside_flat
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT)
-#define TAG(x) x##_alpha_wide_twoside_offset
-#include "ffb_linetmp.h"
-
-#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_WIDE_BIT|FFB_LINE_TWOSIDE_BIT|FFB_LINE_OFFSET_BIT|FFB_LINE_FLAT_BIT)
-#define TAG(x) x##_alpha_wide_twoside_offset_flat
-#include "ffb_linetmp.h"
-
void ffbDDLinefuncInit(void)
{
init();
init_flat();
- init_offset();
- init_offset_flat();
- init_twoside();
- init_twoside_flat();
- init_twoside_offset();
- init_twoside_offset_flat();
- init_wide();
- init_wide_flat();
- init_wide_offset();
- init_wide_offset_flat();
- init_wide_twoside();
- init_wide_twoside_flat();
- init_wide_twoside_offset();
- init_wide_twoside_offset_flat();
init_alpha();
init_alpha_flat();
- init_alpha_offset();
- init_alpha_offset_flat();
- init_alpha_twoside();
- init_alpha_twoside_flat();
- init_alpha_twoside_offset();
- init_alpha_twoside_offset_flat();
- init_alpha_wide();
- init_alpha_wide_flat();
- init_alpha_wide_offset();
- init_alpha_wide_offset_flat();
- init_alpha_wide_twoside();
- init_alpha_wide_twoside_flat();
- init_alpha_wide_twoside_offset();
- init_alpha_wide_twoside_offset_flat();
}
-/* Our caller makes sure TriangleCaps is non-zero and that
- * we are not doing feedback/selection (Mesa handles those
- * cases).
- */
-void ffbDDChooseLineRenderState(GLcontext *ctx)
+static void ffb_dd_line( GLcontext *ctx, GLuint e0, GLuint e1 )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
+ ffb_vertex *v0 = &fmesa->verts[e0];
+ ffb_vertex *v1 = &fmesa->verts[e1];
+ fmesa->draw_line( ctx, v0, v1 );
+}
+
+void ffbChooseLineState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
GLuint ind = 0;
- if (!flags) {
- fmesa->LineFunc = ffb_line_tab[0];
- return;
- }
+ tnl->Driver.Render.Line = ffb_dd_line;
if (flags & DD_FLATSHADE)
ind |= FFB_LINE_FLAT_BIT;
- if (flags & DD_TRI_OFFSET)
- ind |= FFB_LINE_OFFSET_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE)
- ind |= FFB_LINE_TWOSIDE_BIT;
- if (flags & DD_LINE_WIDTH) {
- /* We cannot currently do wide lines with stipples
- * or antialiased in HW.
- */
- if ((flags & DD_LINE_STIPPLE) != 0 ||
- ctx->Line.SmoothFlag)
- ind |= FFB_LINE_FALLBACK_BIT;
- else
- ind |= FFB_LINE_WIDE_BIT;
- } else {
- if ((flags & DD_LINE_STIPPLE) != 0 &&
- fmesa->lpat == FFB_LPAT_BAD)
- ind |= FFB_LINE_FALLBACK_BIT;
+
+ if ((flags & DD_LINE_STIPPLE) != 0 &&
+ fmesa->lpat == FFB_LPAT_BAD) {
+ fmesa->draw_line = ffb_fallback_line;
+ return;
}
/* If blending or the alpha test is enabled we need to
@@ -271,5 +111,5 @@ void ffbDDChooseLineRenderState(GLcontext *ctx)
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
ind |= FFB_LINE_ALPHA_BIT;
- fmesa->LineFunc = ffb_line_tab[ind];
+ fmesa->draw_line = ffb_line_tab[ind];
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h
index 7c5e0b284..9582da9b1 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h
@@ -3,7 +3,16 @@
#ifndef _FFB_LINES_H
#define _FFB_LINES_H
+#include "ffb_context.h"
+
+#define _FFB_NEW_LINE (_DD_NEW_FLATSHADE | \
+ _DD_NEW_LINE_WIDTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _NEW_COLOR)
+
extern void ffbDDLinefuncInit(void);
-extern void ffbDDChooseLineRenderState(GLcontext *);
+extern void ffbChooseLineState(GLcontext *);
+extern void ffb_fallback_line( GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1 );
#endif /* !(_FFB_LINES_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h
index 593637008..29dca4cb9 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h
@@ -1,85 +1,38 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
-static void TAG(ffb_line)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint pv)
+static __inline void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1 )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
ffb_fbcPtr ffb = fmesa->regs;
- struct vertex_buffer *VB = ctx->VB;
- ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
- const ffb_vertex *v0 = &ffbVB[e0];
- const ffb_vertex *v1 = &ffbVB[e1];
-#if (IND & FFB_LINE_OFFSET_BIT)
- GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->LineZoffset);
-#endif
-#if (IND & FFB_LINE_TWOSIDE_BIT)
- const int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
-#else
- const int which_color = 0;
-#endif
-#if (IND & FFB_LINE_FLAT_BIT)
- const GLuint const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
- ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
- ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
- ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
-#endif
-
#if (IND & FFB_LINE_FLAT_BIT)
- FFBFifo(fmesa, 1);
- ffb->fg = const_fg;
+ const GLuint const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v1->color[0] );
#endif
+ FFB_DELAYED_VIEWPORT_VARS;
-#if !(IND & FFB_LINE_WIDE_BIT)
- /* We actually need to do the LINE_LOOP/LINE_STRIP optimization
- * in this case so that the line pattern works out correctly.
- * Really, Mesa should be fixed so it sends us the real primitive.
- */
- if (v0 == fmesa->vtx_cache[1] &&
- v1 != fmesa->vtx_cache[0]) {
+#ifdef FFB_LINE_TRACE
+ fprintf(stderr, "FFB: ffb_line ["
#if (IND & FFB_LINE_FLAT_BIT)
- FFBFifo(fmesa, 3);
-#else
-#if (IND & FFB_LINE_ALPHA_BIT)
- FFBFifo(fmesa, 7);
-#else
- FFBFifo(fmesa, 6);
-#endif
+ " FLAT"
#endif
-#if !(IND & FFB_LINE_FLAT_BIT)
#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
+ " ALPHA"
#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
+ " ]\n");
#endif
- ffb->y = v1->y;
- ffb->x = v1->x;
- fmesa->vtx_cache[0] = (void *)v0;
- fmesa->vtx_cache[1] = (void *)v1;
- fmesa->ffbScreen->rp_active = 1;
- return;
- } else {
- fmesa->vtx_cache[0] = (void *)v0;
- fmesa->vtx_cache[1] = (void *)v1;
- }
+#if (IND & FFB_LINE_FLAT_BIT)
+ FFBFifo(fmesa, 1);
+ ffb->fg = const_fg;
+#ifdef FFB_LINE_TRACE
+ fprintf(stderr, "FFB: ffb_line confg_fg[%08x]\n", const_fg);
+#endif
#endif
#if (IND & FFB_LINE_FLAT_BIT)
-#if !(IND & FFB_LINE_WIDE_BIT)
/* (2 * 3) + 1 */
FFBFifo(fmesa, 7);
#else
- /* (4 * 3) */
- FFBFifo(fmesa, 12);
-#endif
-#else
-#if !(IND & FFB_LINE_WIDE_BIT)
#if (IND & FFB_LINE_ALPHA_BIT)
/* (2 * 7) + 1 */
FFBFifo(fmesa, 15);
@@ -87,167 +40,34 @@ static void TAG(ffb_line)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint pv)
/* (2 * 6) + 1 */
FFBFifo(fmesa, 13);
#endif
-#else
-#if (IND & FFB_LINE_ALPHA_BIT)
- /* (4 * 7) */
- FFBFifo(fmesa, 28);
-#else
- /* (4 * 6) */
- FFBFifo(fmesa, 24);
-#endif
-#endif
#endif
-#if !(IND & FFB_LINE_WIDE_BIT)
/* Using DDLINE or AALINE, init the line pattern state. */
ffb->lpat = fmesa->lpat;
#if !(IND & FFB_LINE_FLAT_BIT)
#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v0->color[which_color].alpha;
+ ffb->alpha = FFB_GET_ALPHA(v0);
#endif
- ffb->red = v0->color[which_color].red;
- ffb->green = v0->color[which_color].green;
- ffb->blue = v0->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v0->z + ffb_zoffset;
-#else
- ffb->z = v0->z;
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
#endif
- ffb->ryf = v0->y;
- ffb->rxf = v0->x;
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
#if !(IND & FFB_LINE_FLAT_BIT)
#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
+ ffb->alpha = FFB_GET_ALPHA(v1);
#endif
- ffb->y = v1->y;
- ffb->x = v1->x;
-
-#else /* FFB_LINE_WIDE_BIT */
- /* Doing wide lines via triangles. */
- {
- float width = ctx->Line.Width;
- float dx, dy;
- GLuint ix, iy;
-
- /* It might be possible to precalculate this stuff in
- * our vertex-buffer code. That code works with
- * screen coordinates so it might work. One problem
- * could be that due to potentially drawing polygons
- * as lines, it would be very difficult to really
- * determine if the calculations were necessary or not.
- */
- dx = VB->Win.data[e0][0] - VB->Win.data[e1][0];
- dy = VB->Win.data[e0][1] - VB->Win.data[e1][1];
- ix = FFB_COORD_FROM_FLOAT(width * 0.5f);
- iy = 0;
- if ((dx * dx) > (dy * dy)) {
- iy = ix;
- ix = 0;
- }
-
- /* The vertex sequence using isolated triangles would
- * be:
- *
- * Vertex0: line vertex0 - I RXF/RYF
- * Vertex1: line vertex1 + I DOXF/DOYF
- * Vertex2: line vertex0 + I DOXF/DOYF
- * Vertex3: line vertex0 - I RXF/RYF
- * Vertex4: line vertex1 - I DOXF/DOYF
- * Vertex5: line vertex1 + I DOXF/DOYF
- *
- * Using star chaining we can optimize this into a
- * four vertex sequence, as follows:
- *
- * Vertex0: line vertex0 - I RXF/RYF
- * Vertex1: line vertex0 + I DOXF/DOYF
- * Vertex2: line vertex1 + I DOXF/DOYF
- * Vertex3: line vertex1 - I DMXF/DMYF
- *
- * The DMXF/DMYF vertex means "replace middle vertex
- * with new vertex and draw".
- */
-
- /* Vertex0: line vertex0 - I, RXF/RYF */
-#if !(IND & FFB_LINE_FLAT_BIT)
-#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v0->color[which_color].alpha;
-#endif
- ffb->red = v0->color[which_color].red;
- ffb->green = v0->color[which_color].green;
- ffb->blue = v0->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v0->z + ffb_zoffset;
-#else
- ffb->z = v0->z;
-#endif
- ffb->ryf = v0->y - iy;
- ffb->rxf = v0->x - ix;
-
- /* Vertex1: line vertex0 + I, DOXF/DOYF */
-#if !(IND & FFB_LINE_FLAT_BIT)
-#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v0->color[which_color].alpha;
-#endif
- ffb->red = v0->color[which_color].red;
- ffb->green = v0->color[which_color].green;
- ffb->blue = v0->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v0->z + ffb_zoffset;
-#else
- ffb->z = v0->z;
-#endif
- ffb->y = v0->y + iy;
- ffb->x = v0->x + ix;
-
- /* Vertex2: line vertex1 + I, DOXF/DOYF */
-#if !(IND & FFB_LINE_FLAT_BIT)
-#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
-#endif
- ffb->y = v1->y + iy;
- ffb->x = v1->x + ix;
-
- /* Vertex3: line vertex1 - I, DMXF/DMYF */
-#if !(IND & FFB_LINE_FLAT_BIT)
-#if (IND & FFB_LINE_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
-#endif
-#if (IND & FFB_LINE_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
#endif
- ffb->dmyf = v1->y - iy;
- ffb->dmxf = v1->x - ix;
- }
-#endif /* !(FFB_LINE_WIDE_BIT) */
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
fmesa->ffbScreen->rp_active = 1;
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h
index 1042ee407..86014caf8 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h
@@ -9,6 +9,10 @@ extern void ffbXMesaUpdateState(ffbContextPtr fmesa);
#define FFB_UPDATE_STATE(fmesa) ffbXMesaUpdateState(fmesa)
/* Lock the hardware and validate our state. */
+#if defined(__i386__)
+#define LOCK_HARDWARE(fmesa)
+#define UNLOCK_HARDWARE(fmesa)
+#else
#define LOCK_HARDWARE(fmesa) \
do { \
int __ret=0; \
@@ -24,5 +28,6 @@ extern void ffbXMesaUpdateState(ffbContextPtr fmesa);
/* Unlock the hardware. */
#define UNLOCK_HARDWARE(fmesa) \
DRM_UNLOCK(fmesa->driFd, fmesa->driHwLock, fmesa->hHWContext);
+#endif
#endif /* !(_FFB_LOCK_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c
deleted file mode 100644
index 88c5b3dd3..000000000
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
- *
- * GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * David S. Miller <davem@redhat.com>
- */
-
-#include "ffb_xmesa.h"
-#include "ffb_context.h"
-#include "ffb_vb.h"
-#include "ffb_pipeline.h"
-
-#include "stages.h"
-#include "pipeline.h"
-
-GLboolean ffbDDBuildPrecalcPipeline(GLcontext *ctx)
-{
- /* This doesn't do anything interesting yet. */
- return 0;
-}
-
-static void ffbDDCheckRasterSetup(GLcontext *ctx, struct gl_pipeline_stage *d)
-{
- d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
- d->inputs = ctx->RenderFlags;
- d->outputs = VERT_SETUP_FULL;
-
- if (ctx->IndirectTriangles & DD_SW_SETUP)
- d->type = PIPE_IMMEDIATE;
-}
-
-GLuint ffbDDRegisterPipelineStages(struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr)
-{
- GLuint i, o;
-
- for (i = o = 0 ; i < nr ; i++) {
- switch (in[i].ops) {
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change =
- NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
- out[o].state_change = ~0;
- out[o].check = ffbDDCheckPartialRasterSetup;
- out[o].run = ffbDDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].check = ffbDDCheckRasterSetup;
- out[o].run = ffbDDDoRasterSetup;
- o++;
- break;
-
- default:
- out[o++] = in[i];
- break;
- };
- }
-
- return o;
-}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h
deleted file mode 100644
index b7910d288..000000000
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pipeline.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
-
-#ifndef _FFB_PIPELINE_H
-#define _FFB_PIPELINE_H
-
-extern GLboolean ffbDDBuildPrecalcPipeline(GLcontext *);
-extern GLuint ffbDDRegisterPipelineStages(struct gl_pipeline_stage *,
- const struct gl_pipeline_stage *,
- GLuint);
-
-#endif /* !(_FFB_PIPELINE_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
index d459ed3f3..23fcb9a1d 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.c
@@ -1,7 +1,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_points.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,7 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
#include <stdio.h>
#include <stdlib.h>
@@ -39,117 +38,64 @@
#include "ffb_vb.h"
#include "ffb_lines.h"
#include "ffb_points.h"
+#include "ffb_tris.h"
#include "ffb_lock.h"
#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
-#include "pipeline.h"
-#define FFB_POINT_OFFSET_BIT 0x01
-#define FFB_POINT_AA_BIT 0x02
-#define FFB_POINT_BIG_BIT 0x04
-#define FFB_POINT_ALPHA_BIT 0x08
-#define FFB_POINT_FALLBACK_BIT 0x10
+#undef FFB_POINT_TRACE
-static points_func ffb_points_tab[0x20];
+#define FFB_POINT_AA_BIT 0x01
+
+static ffb_point_func ffb_point_tab[0x08];
#define IND (0)
#define TAG(x) x
#include "ffb_pointtmp.h"
-#define IND (FFB_POINT_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "ffb_pointtmp.h"
-
#define IND (FFB_POINT_AA_BIT)
#define TAG(x) x##_aa
#include "ffb_pointtmp.h"
-#define IND (FFB_POINT_OFFSET_BIT|FFB_POINT_AA_BIT)
-#define TAG(x) x##_offset_aa
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_BIG_BIT)
-#define TAG(x) x##_big
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_BIG_BIT|FFB_POINT_OFFSET_BIT)
-#define TAG(x) x##_big_offset
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT)
-#define TAG(x) x##_alpha
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_OFFSET_BIT)
-#define TAG(x) x##_alpha_offset
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_AA_BIT)
-#define TAG(x) x##_alpha_aa
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_OFFSET_BIT|FFB_POINT_AA_BIT)
-#define TAG(x) x##_alpha_offset_aa
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_BIG_BIT)
-#define TAG(x) x##_alpha_big
-#include "ffb_pointtmp.h"
-
-#define IND (FFB_POINT_ALPHA_BIT|FFB_POINT_BIG_BIT|FFB_POINT_OFFSET_BIT)
-#define TAG(x) x##_alpha_big_offset
-#include "ffb_pointtmp.h"
-
void ffbDDPointfuncInit(void)
{
init();
- init_offset();
init_aa();
- init_offset_aa();
- init_big();
- init_big_offset();
- init_alpha();
- init_alpha_offset();
- init_alpha_aa();
- init_alpha_offset_aa();
- init_alpha_big();
- init_alpha_big_offset();
}
-/* Our caller makes sure TriangleCaps is non-zero and that
- * we are not doing feedback/selection (Mesa handles those
- * cases).
- */
-void ffbDDChoosePointRenderState(GLcontext *ctx)
+static void ffb_dd_points( GLcontext *ctx, GLuint first, GLuint last )
{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
+ ffb_vertex *fverts = fmesa->verts;
+ int i;
+
+ if (VB->Elts == 0) {
+ for ( i = first ; i < last ; i++ ) {
+ if ( VB->ClipMask[i] == 0 ) {
+ fmesa->draw_point( ctx, &fverts[i] );
+ }
+ }
+ } else {
+ for ( i = first ; i < last ; i++ ) {
+ GLuint e = VB->Elts[i];
+ if ( VB->ClipMask[e] == 0 ) {
+ fmesa->draw_point( ctx, &fverts[e] );
+ }
+ }
+ }
+}
+
+void ffbChoosePointState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
GLuint ind = 0;
- if (!flags) {
- fmesa->PointsFunc = ffb_points_tab[0];
- return;
- }
+ tnl->Driver.Render.Points = ffb_dd_points;
- if (flags & DD_TRI_OFFSET)
- ind |= FFB_POINT_OFFSET_BIT;
- if (flags & DD_POINT_SIZE) {
- if (ctx->Point.SmoothFlag)
- ind |= FFB_POINT_FALLBACK_BIT;
- else
- ind |= FFB_POINT_BIG_BIT;
- } else if (ctx->Point.SmoothFlag) {
+ if (flags & DD_POINT_SMOOTH)
ind |= FFB_POINT_AA_BIT;
- }
-
- /* If blending or the alpha test is enabled we need to
- * provide alpha components to the chip, else we can
- * do without it and thus feed vertex data to the chip
- * more efficiently.
- */
- if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
- ind |= FFB_POINT_ALPHA_BIT;
- fmesa->PointsFunc = ffb_points_tab[ind];
+ fmesa->draw_point = ffb_point_tab[ind];
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h
index b3a078e8a..29920afbf 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_points.h
@@ -4,6 +4,12 @@
#define _FFB_POINTS_H
extern void ffbDDPointfuncInit(void);
-extern void ffbDDChoosePointRenderState(GLcontext *);
+
+#define _FFB_NEW_POINT (_DD_NEW_POINT_SIZE | \
+ _DD_NEW_POINT_SMOOTH | \
+ _NEW_COLOR)
+
+extern void ffbChoosePointState(GLcontext *);
+extern void ffb_fallback_point( GLcontext *ctx, ffb_vertex *v0 );
#endif /* !(_FFB_POINTS_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
index 7b42098cd..661373eae 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h
@@ -1,113 +1,54 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h,v 1.2 2000/12/05 21:18:33 dawes Exp $ */
-static void TAG(ffb_points)(GLcontext *ctx, GLuint first, GLuint last)
+static __inline void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
ffb_fbcPtr ffb = fmesa->regs;
- struct vertex_buffer *VB = ctx->VB;
- ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
-#if (IND & FFB_POINT_OFFSET_BIT)
-#if (IND & FFB_POINT_AA_BIT)
- GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PointZoffset);
-#else
- GLuint ffb_zoffset = Z_FROM_MESA(ctx->PointZoffset);
-#endif
-#endif
-#if (IND & FFB_POINT_BIG_BIT)
- GLuint sz = FFB_COORD_FROM_FLOAT(ctx->Point.Size * 0.5f);
-#endif
- int i;
+ FFB_DELAYED_VIEWPORT_VARS;
- for (i = first; i < last; i++) {
- if (VB->ClipMask[i] == 0) {
- ffb_vertex *tmp = &ffbVB[i];
-#if !(IND & FFB_POINT_BIG_BIT)
+#ifdef FFB_POINT_TRACE
+ fprintf(stderr, "FFB: ffb_point ["
#if (IND & FFB_POINT_AA_BIT)
- FFBFifo(fmesa, 4);
- ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
- ((GLuint)VB->Color[0]->data[i][1] << 8) |
- ((GLuint)VB->Color[0]->data[i][2] << 16) |
- ((GLuint)VB->Color[0]->data[i][3] << 24));
-#if (IND & FFB_POINT_OFFSET_BIT)
- ffb->z = tmp->z + ffb_zoffset;
-#else
- ffb->z = tmp->z;
-#endif
- ffb->y = tmp->y + 0x8000;
- ffb->x = tmp->x + 0x8000;
-#else
- FFBFifo(fmesa, 4);
- ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
- ((GLuint)VB->Color[0]->data[i][1] << 8) |
- ((GLuint)VB->Color[0]->data[i][2] << 16) |
- ((GLuint)VB->Color[0]->data[i][3] << 24));
-#if (IND & FFB_POINT_OFFSET_BIT)
- ffb->constz =
- (Z_FROM_MESA(VB->Win.data[i][2]) + ffb_zoffset);
-#else
- ffb->constz = Z_FROM_MESA(VB->Win.data[i][2]);
+ "AA"
#endif
- ffb->bh = tmp->y >> 16;
- ffb->bw = tmp->x >> 16;
+ "] X(%f) Y(%f) Z(%f)\n",
+ tmp->x, tmp->y, tmp->z);
#endif
-#else /* FFB_POINT_BIG_BIT */
- /* Doing big points via triangles. */
- FFBFifo(fmesa, 10);
- ffb->fg = (((GLuint)VB->Color[0]->data[i][0] << 0) |
- ((GLuint)VB->Color[0]->data[i][1] << 8) |
- ((GLuint)VB->Color[0]->data[i][2] << 16) |
- ((GLuint)VB->Color[0]->data[i][3] << 24));
-#if (IND & FFB_POINT_OFFSET_BIT)
- ffb->constz =
- (Z_FROM_MESA(VB->Win.data[i][2]) + ffb_zoffset);
+#if (IND & FFB_POINT_AA_BIT)
+ FFBFifo(fmesa, 4);
+
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
+ ffb->z = FFB_GET_Z(tmp);
+ ffb->y = FFB_GET_Y(tmp) + 0x8000 /* FIX ME */;
+ ffb->x = FFB_GET_X(tmp) + 0x8000 /* FIX ME */;
#else
- ffb->constz = Z_FROM_MESA(VB->Win.data[i][2]);
+ {
+ unsigned int const_fg, const_z, h, w;
+
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
+ const_z = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(tmp)));
+ h = FFB_GET_Y(tmp) >> 16;
+ w = FFB_GET_X(tmp) >> 16;
+#ifdef FFB_POINT_TRACE
+ fprintf(stderr, "FFB: ffb_point fg(%08x) z(%08x) h(%08x) w(%08x)\n",
+ const_fg, const_z, h, w);
#endif
-
- /* The vertex sequence using isolated triangles would
- * be:
- * Vertex0: VX - sz, VY - sz RXF/RYF
- * Vertex1: VX + sz, VY - sz DOXF/DOYF
- * Vertex2: VX + sz, VY + sz DOXF/DOYF
- * Vertex3: VX + sz, VY + sz RXF/RYF
- * Vertex4: VX - sz, VY + sz DOXF/DOYF
- * Vertex5: VX - sz, VY - sz DOXF/DOYF
- *
- * Using star chaining we can optimize this into a
- * four vertex sequence, as follows:
- *
- * Vertex0: VX - sz, VY - sz RXF/RYF
- * Vertex1: VX + sz, VY - sz DOXF/DOYF
- * Vertex2: VX + sz, VY + sz DOXF/DOYF
- * Vertex3: VX - sz, VY + sz DMXF/DMYF
- */
-
- /* Vertex0: VX - sz, VY - sz, RXF/RYF */
- ffb->ryf = tmp->y - sz;
- ffb->rxf = tmp->x - sz;
-
- /* Vertex1: VX + sz, VY - sz, DOXF/DOYF */
- ffb->y = tmp->y - sz;
- ffb->x = tmp->x + sz;
-
- /* Vertex2: VX + sz, VY + sz, DOXF/DOYF */
- ffb->y = tmp->y + sz;
- ffb->x = tmp->x + sz;
-
- /* Vertex3: VX - sz, VY + sz, DMXF/DMYF */
- ffb->dmyf = tmp->y + sz;
- ffb->dmxf = tmp->x - sz;
-#endif /* !(FFB_POINT_BIG_BIT) */
- }
+ FFBFifo(fmesa, 4);
+ ffb->fg = const_fg;
+ ffb->constz = const_z;
+ ffb->bh = h;
+ ffb->bw = w;
}
+#endif
fmesa->ffbScreen->rp_active = 1;
}
+
static void TAG(init)(void)
{
- ffb_points_tab[IND] = TAG(ffb_points);
+ ffb_point_tab[IND] = TAG(ffb_draw_point);
}
#undef IND
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_rendertmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_rendertmp.h
new file mode 100644
index 000000000..92f172916
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_rendertmp.h
@@ -0,0 +1,648 @@
+/* $XFree86$ */
+
+#define IMPL_LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffb_fbcPtr ffb = fmesa->regs; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ FFB_DELAYED_VIEWPORT_VARS; \
+ (void) fmesa; (void) ffb; (void) elt
+
+#if (IND & FFB_FLAT_BIT)
+#define FFB_DECLARE_CACHED_COLOR(NAME) \
+ unsigned int NAME;
+#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) \
+ NAME = FFB_PACK_CONST_UBYTE_ARGB_COLOR((VTX)->color[0])
+#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) \
+ ((NAME1) == (NAME2))
+#define FFB_CACHED_COLOR_SET(NAME) \
+ ffb->fg = (NAME)
+#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) \
+ ffb->fg = (NAME1) = (NAME2)
+#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) \
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR((COLOR_VERTEX)->color[0])
+#define FFB_PRIM_COLOR_COST 1
+#define FFB_SET_VERTEX_COLOR(VTX) /**/
+#define FFB_VERTEX_COLOR_COST 0
+#else
+#define FFB_DECLARE_CACHED_COLOR(NAME) /**/
+#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) /**/
+#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) 0
+#define FFB_CACHED_COLOR_SET(NAME1) /**/
+#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) /**/
+#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) /**/
+#define FFB_PRIM_COLOR_COST 0
+#if (IND & FFB_ALPHA_BIT)
+#define FFB_SET_VERTEX_COLOR(VTX) \
+ ffb->alpha = FFB_GET_ALPHA(VTX); \
+ ffb->red = FFB_GET_RED(VTX); \
+ ffb->green = FFB_GET_GREEN(VTX); \
+ ffb->blue = FFB_GET_BLUE(VTX)
+#define FFB_VERTEX_COLOR_COST 4
+#else
+#define FFB_SET_VERTEX_COLOR(VTX) \
+ ffb->red = FFB_GET_RED(VTX); \
+ ffb->green = FFB_GET_GREEN(VTX); \
+ ffb->blue = FFB_GET_BLUE(VTX)
+#define FFB_VERTEX_COLOR_COST 3
+#endif
+#endif
+
+#define RESET_STIPPLE ffb->lpat = fmesa->lpat;
+
+#if !(IND & (FFB_TRI_CULL_BIT))
+static void TAG(ffb_vb_points)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_POINTS);
+ if (ctx->_TriangleCaps & DD_POINT_SMOOTH) {
+ for (i = start; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+
+ FFBFifo(fmesa, 4);
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0) + 0x8000 /* FIX ME */;
+ ffb->x = FFB_GET_X(v0) + 0x8000 /* FIX ME */;
+ }
+ } else {
+ for (i = start; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+ FFBFifo(fmesa, 4);
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
+ ffb->constz = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(v0)));
+ ffb->bh = FFB_GET_Y(v0) >> 16;
+ ffb->bw = FFB_GET_X(v0) >> 16;
+ }
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_lines)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINES);
+ for (i = start + 1; i < count; i += 2) {
+ ffb_vertex *v0 = &fmesa->verts[i - 1];
+ ffb_vertex *v1 = &fmesa->verts[i - 0];
+
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 2) + 6));
+
+ RESET_STIPPLE;
+
+ FFB_SET_PRIM_COLOR(v1);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+}
+
+static void TAG(ffb_vb_line_loop)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINE_LOOP);
+ if ((flags & PRIM_BEGIN) != 0) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
+
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
+
+ RESET_STIPPLE;
+
+ FFB_SET_PRIM_COLOR(v1);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST + 3)));
+
+ FFB_SET_PRIM_COLOR(v0);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0);
+ ffb->x = FFB_GET_X(v0);
+ }
+ if ((flags & PRIM_END) != 0) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST + 3)));
+
+ FFB_SET_PRIM_COLOR(v0);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0);
+ ffb->x = FFB_GET_X(v0);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_line_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ FFB_DECLARE_CACHED_COLOR(cached_fg)
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINE_STRIP);
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
+
+ RESET_STIPPLE;
+
+ {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
+
+ FFB_COMPUTE_CACHED_COLOR(cached_fg, v0);
+ FFB_CACHED_COLOR_SET(cached_fg);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 0)];
+ FFB_DECLARE_CACHED_COLOR(new_fg)
+
+ FFB_COMPUTE_CACHED_COLOR(new_fg, v1);
+ if (FFB_CACHED_COLOR_SAME(cached_fg, new_fg)) {
+ FFBFifo(fmesa, ((FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
+ } else {
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
+ FFB_CACHED_COLOR_UPDATE(cached_fg, new_fg);
+ }
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+#endif /* !(IND & (FFB_TRI_CULL_BIT)) */
+
+/* OK, now things start getting fun :-) */
+#if (IND & (FFB_TRI_CULL_BIT))
+#define FFB_AREA_DECLARE GLfloat cc, ex, ey, fx, fy;
+#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) \
+{ ex = (V1)->x - (V0)->x; \
+ ey = (V1)->y - (V0)->y; \
+ fx = (V2)->x - (V0)->x; \
+ fy = (V2)->y - (V0)->y; \
+ cc = ex*fy-ey*fx; \
+}
+#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) \
+{ ex = (V2)->x - (V0)->x; \
+ ey = (V2)->y - (V0)->y; \
+ fx = (V3)->x - (V1)->x; \
+ fy = (V3)->y - (V1)->y; \
+ cc = ex*fy-ey*fx; \
+}
+#else
+#define FFB_AREA_DECLARE /**/
+#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) do { } while(0)
+#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) do { } while(0)
+#endif
+
+#if (IND & FFB_TRI_CULL_BIT)
+#define FFB_CULL_TRI(CULL_ACTION) \
+ if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
+ CULL_ACTION \
+ }
+#define FFB_CULL_QUAD(CULL_ACTION) \
+ if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
+ CULL_ACTION \
+ }
+#else
+#define FFB_CULL_TRI(CULL_ACTION) do { } while (0)
+#define FFB_CULL_QUAD(CULL_ACTION) do { } while (0)
+#endif
+
+static void TAG(ffb_vb_triangles)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLES);
+ for (i = start + 2; i < count; i += 3) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_tri_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ GLint parity = 0;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLE_STRIP);
+ if ((flags & PRIM_PARITY) != 0)
+ parity = 1;
+
+ i = start + 2;
+ goto something_clipped;
+
+ something_clipped:
+ for (; i < count; i++, parity ^= 1) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ i++;
+ parity ^= 1;
+ break;
+ }
+
+ for (; i < count; i++, parity ^= 1) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+ (void) v0; (void) v1;
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(i++; parity^=1; goto something_clipped;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + 3));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_tri_fan)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLE_FAN);
+
+ i = start + 2;
+ goto something_clipped;
+
+ something_clipped:
+ for ( ; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ i++;
+ break;
+ }
+
+ for (; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+ (void) v0; (void) v1;
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(i++; goto something_clipped;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + 3));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->dmyf = FFB_GET_Y(v2);
+ ffb->dmxf = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_poly)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_POLYGON);
+
+ /* XXX Optimize XXX */
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(start)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_quads)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_QUADS);
+
+ for (i = start + 3; i < count; i += 4) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 3)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
+ FFB_CULL_QUAD(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 4) + 12));
+ FFB_SET_PRIM_COLOR(v3);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ FFB_SET_VERTEX_COLOR(v3);
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_quad_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, __FUNCTION__ ": start(%d) count(%d) flags(%x)\n",
+ start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_QUAD_STRIP);
+
+ /* XXX Optimize XXX */
+ for (i = start + 3; i < count; i += 2) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 3)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
+ FFB_CULL_QUAD(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 4) + 12));
+ FFB_SET_PRIM_COLOR(v3);
+
+ FFB_DUMP_VERTEX(v0);
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_DUMP_VERTEX(v1);
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_DUMP_VERTEX(v2);
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ FFB_DUMP_VERTEX(v3);
+ FFB_SET_VERTEX_COLOR(v3);
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void (*TAG(render_tab)[GL_POLYGON + 2])(GLcontext *, GLuint, GLuint, GLuint) =
+{
+#if !(IND & (FFB_TRI_CULL_BIT))
+ TAG(ffb_vb_points),
+ TAG(ffb_vb_lines),
+ TAG(ffb_vb_line_loop),
+ TAG(ffb_vb_line_strip),
+#else
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+#endif
+ TAG(ffb_vb_triangles),
+ TAG(ffb_vb_tri_strip),
+ TAG(ffb_vb_tri_fan),
+ TAG(ffb_vb_quads),
+ TAG(ffb_vb_quad_strip),
+ TAG(ffb_vb_poly),
+ ffb_vb_noop,
+};
+
+#undef IND
+#undef TAG
+
+#undef IMPL_LOCAL_VARS
+#undef FFB_DECLARE_CACHED_COLOR
+#undef FFB_COMPUTE_CACHED_COLOR
+#undef FFB_CACHED_COLOR_SAME
+#undef FFB_CACHED_COLOR_SET
+#undef FFB_CACHED_COLOR_UPDATE
+#undef FFB_SET_PRIM_COLOR
+#undef FFB_PRIM_COLOR_COST
+#undef FFB_SET_VERTEX_COLOR
+#undef FFB_VERTEX_COLOR_COST
+#undef RESET_STIPPLE
+#undef FFB_AREA_DECLARE
+#undef FFB_COMPUTE_AREA_TRI
+#undef FFB_COMPUTE_AREA_QUAD
+#undef FFB_CULL_TRI
+#undef FFB_CULL_QUAD
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c
index dbae8df6b..e9aedbd2a 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_span.c
@@ -25,12 +25,14 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
+#include "mtypes.h"
#include "ffb_dd.h"
#include "ffb_span.h"
#include "ffb_context.h"
#include "ffb_lock.h"
+#include "swrast/swrast.h"
+
#define DBG 0
#define HW_LOCK() \
@@ -45,10 +47,14 @@
#define LOCAL_VARS \
__DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
GLuint height = dPriv->h; \
- char *buf
+ GLuint p; \
+ char *buf; \
+ (void) p
-#define INIT_MONO_PIXEL(p) \
- GLuint p = fmesa->MonoColor;
+#define INIT_MONO_PIXEL(p, color) \
+ p = ((color[0] << 0) | \
+ (color[1] << 8) | \
+ (color[2] << 16))
/* We use WID clipping, so this test always passes. */
#define CLIPPIXEL(__x, __y) (1)
@@ -112,22 +118,25 @@ do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
void ffbDDInitSpanFuncs(GLcontext *ctx)
{
- ctx->Driver.WriteRGBASpan = ffbWriteRGBASpan_888;
- ctx->Driver.WriteRGBSpan = ffbWriteRGBSpan_888;
- ctx->Driver.WriteRGBAPixels = ffbWriteRGBAPixels_888;
- ctx->Driver.WriteMonoRGBASpan = ffbWriteMonoRGBASpan_888;
- ctx->Driver.WriteMonoRGBAPixels = ffbWriteMonoRGBAPixels_888;
- ctx->Driver.ReadRGBASpan = ffbReadRGBASpan_888;
- ctx->Driver.ReadRGBAPixels = ffbReadRGBAPixels_888;
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->WriteRGBASpan = ffbWriteRGBASpan_888;
+ swdd->WriteRGBSpan = ffbWriteRGBSpan_888;
+ swdd->WriteRGBAPixels = ffbWriteRGBAPixels_888;
+ swdd->WriteMonoRGBASpan = ffbWriteMonoRGBASpan_888;
+ swdd->WriteMonoRGBAPixels = ffbWriteMonoRGBAPixels_888;
+ swdd->ReadRGBASpan = ffbReadRGBASpan_888;
+ swdd->ReadRGBAPixels = ffbReadRGBAPixels_888;
/* We don't support color index mode yet, but it will be
* very easy to do. -DaveM
*/
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
index b083533e3..ffa3b75a8 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v 1.1 2000/06/20 05:08:39 dawes Exp $
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v 1.1.4.1 2001/05/24 16:35:38 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,8 +25,7 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
#include <stdio.h>
#include <stdlib.h>
@@ -43,11 +42,14 @@
#include "ffb_state.h"
#include "ffb_lock.h"
#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
#include "enums.h"
-#include "pipeline.h"
-#include "pb.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
#undef STATE_TRACE
@@ -57,7 +59,7 @@ static unsigned int ffbComputeAlphaFunc(GLcontext *ctx)
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDAlphaFunc: func(%s) ref(%02x)\n",
- gl_lookup_enum_by_nr(ctx->Color.AlphaFunc),
+ _mesa_lookup_enum_by_nr(ctx->Color.AlphaFunc),
ctx->Color.AlphaRef & 0xff);
#endif
@@ -80,7 +82,7 @@ static unsigned int ffbComputeAlphaFunc(GLcontext *ctx)
return xclip;
}
-static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLchan ref)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
@@ -89,23 +91,18 @@ static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
if (fmesa->xclip != xclip) {
fmesa->xclip = xclip;
- fmesa->state_dirty |= FFB_STATE_XCLIP;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1);
}
}
}
static void ffbDDBlendEquation(GLcontext *ctx, GLenum mode)
{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
#ifdef STATE_TRACE
- fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", gl_lookup_enum_by_nr(mode));
+ fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n", _mesa_lookup_enum_by_nr(mode));
#endif
- if (mode != GL_FUNC_ADD_EXT)
- fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDEQN;
- else
- fmesa->bad_fragment_attrs &= ~FFB_BADATTR_BLENDEQN;
+ FALLBACK( ctx, (mode != GL_FUNC_ADD_EXT), FFB_BADATTR_BLENDEQN);
}
static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
@@ -115,7 +112,7 @@ static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDBlendFunc: sfactor(%s) dfactor(%s)\n",
- gl_lookup_enum_by_nr(sfactor), gl_lookup_enum_by_nr(dfactor));
+ _mesa_lookup_enum_by_nr(sfactor), _mesa_lookup_enum_by_nr(dfactor));
#endif
switch (ctx->Color.BlendSrcRGB) {
case GL_ZERO:
@@ -136,7 +133,7 @@ static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
default:
if (ctx->Color.BlendEnabled)
- fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDFUNC;
+ FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE );
return;
};
@@ -159,7 +156,7 @@ static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
default:
if (ctx->Color.BlendEnabled)
- fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDFUNC;
+ FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE );
return;
};
@@ -173,17 +170,15 @@ static void ffbDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
* also it would add more state tracking to a lot
* of the code in this file.
*/
- fmesa->bad_fragment_attrs |= FFB_BADATTR_BLENDROP;
+ FALLBACK(ctx, FFB_BADATTR_BLENDROP, GL_TRUE);
return;
}
- fmesa->bad_fragment_attrs &= ~(FFB_BADATTR_BLENDFUNC |
- FFB_BADATTR_BLENDROP);
+ FALLBACK( ctx, (FFB_BADATTR_BLENDFUNC|FFB_BADATTR_BLENDROP), GL_FALSE );
if (blendc != fmesa->blendc) {
fmesa->blendc = blendc;
- fmesa->state_dirty |= FFB_STATE_BLEND;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_BLEND, 1);
}
}
@@ -193,10 +188,10 @@ static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
{
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n",
- gl_lookup_enum_by_nr(sfactorRGB),
- gl_lookup_enum_by_nr(dfactorRGB),
- gl_lookup_enum_by_nr(sfactorA),
- gl_lookup_enum_by_nr(dfactorA));
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
#endif
ffbDDBlendFunc(ctx, sfactorRGB, dfactorRGB);
@@ -209,7 +204,7 @@ static void ffbDDDepthFunc(GLcontext *ctx, GLenum func)
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDDepthFunc: func(%s)\n",
- gl_lookup_enum_by_nr(func));
+ _mesa_lookup_enum_by_nr(func));
#endif
switch (func) {
@@ -248,8 +243,7 @@ static void ffbDDDepthFunc(GLcontext *ctx, GLenum func)
cmp = (fmesa->cmp & ~(0xff<<16)) | cmp;
if (cmp != fmesa->cmp) {
fmesa->cmp = cmp;
- fmesa->state_dirty |= FFB_STATE_CMP;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_CMP, 1);
}
}
@@ -277,8 +271,7 @@ static void ffbDDDepthMask(GLcontext *ctx, GLboolean flag)
fbc &= ~FFB_FBC_WB_C;
}
fmesa->fbc = fbc;
- fmesa->state_dirty |= FFB_STATE_FBC;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
}
}
@@ -322,8 +315,7 @@ static void ffbDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask
fmesa->stencil = stencil;
fmesa->stencilctl = stencilctl;
fmesa->consty = consty;
- fmesa->state_dirty |= FFB_STATE_STENCIL;
- fmesa->state_fifo_ents += 6;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
}
}
@@ -334,8 +326,7 @@ static void ffbDDStencilMask(GLcontext *ctx, GLuint mask)
mask &= 0xf;
if (fmesa->ypmask != mask) {
fmesa->ypmask = mask;
- fmesa->state_dirty |= FFB_STATE_YPMASK;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_YPMASK, 1);
}
}
@@ -391,37 +382,92 @@ static void ffbDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpa
if (fmesa->stencilctl != stencilctl) {
fmesa->stencilctl = stencilctl;
- fmesa->state_dirty |= FFB_STATE_STENCIL;
- fmesa->state_fifo_ents += 6;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
}
}
-void ffbDDScissor(GLcontext *ctx, GLint cx, GLint cy,
- GLsizei cw, GLsizei ch)
+static void ffbCalcViewportRegs(GLcontext *ctx)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
- GLint x, y;
+ GLuint xmin, xmax, ymin, ymax, zmin, zmax;
unsigned int vcmin, vcmax;
-#ifdef STATE_TRACE
- fprintf(stderr, "ffbDDScissor: x(%x) y(%x) w(%x) h(%x)\n",
- cx, cy, cw, ch);
-#endif
- x = cx + dPriv->x;
- y = dPriv->y + (cy - ch);
- vcmin = ((y & 0xffff) << 16) | (x & 0xffff);
- vcmax = ((((y + ch) & 0xffff) << 16) |
- (((x + cw) & 0xffff)));
+ xmin = ctx->Viewport.X + dPriv->x;
+ xmax = xmin + ctx->Viewport.Width;
+ ymax = dPriv->y + dPriv->h - ctx->Viewport.Y;
+ ymin = ymax - ctx->Viewport.Height;
+ if (ctx->Scissor.Enabled) {
+ GLuint sc_xmin, sc_xmax, sc_ymin, sc_ymax;
+
+ sc_xmin = ctx->Viewport.X + dPriv->x;
+ sc_xmax = sc_xmin + ctx->Viewport.Width;
+ sc_ymax = dPriv->y + dPriv->h - ctx->Viewport.Y;
+ sc_ymin = sc_ymax - ctx->Viewport.Height;
+ if (sc_xmin > xmin)
+ xmin = sc_xmin;
+ if (sc_xmax < xmax)
+ xmax = sc_xmax;
+ if (sc_ymin > ymin)
+ ymin = sc_ymin;
+ if (sc_ymax < ymax)
+ ymax = sc_ymax;
+ }
+ zmin = ((GLdouble)ctx->Viewport.Near * 0x0fffffff);
+ zmax = ((GLdouble)ctx->Viewport.Far * 0x0fffffff);
+
+ vcmin = ((ymin & 0xffff) << 16) | (xmin & 0xffff);
+ vcmax = ((ymax & 0xffff) << 16) | (xmax & 0xffff);
if (fmesa->vclipmin != vcmin ||
- fmesa->vclipmax != vcmax) {
+ fmesa->vclipmax != vcmax ||
+ fmesa->vclipzmin != zmin ||
+ fmesa->vclipzmax != zmax) {
fmesa->vclipmin = vcmin;
fmesa->vclipmax = vcmax;
- fmesa->state_dirty |= FFB_STATE_CLIP;
- fmesa->state_fifo_ents += 4 + (4 * 2);
+ fmesa->vclipzmin = zmin;
+ fmesa->vclipzmax = zmax;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_CLIP, (4 + (4 * 2)));
}
}
+void ffbCalcViewport(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = fmesa->hw_viewport;
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + dPriv->x + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + dPriv->h + dPriv->y + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+ m[MAT_TZ] = v[MAT_TZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+
+ fmesa->depth_scale = ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+
+ ffbCalcViewportRegs(ctx);
+
+ fmesa->setupnewinputs |= VERT_CLIP;
+}
+
+static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ ffbCalcViewport(ctx);
+}
+
+static void ffbDDDepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
+{
+ ffbCalcViewport(ctx);
+}
+
+static void ffbDDScissor(GLcontext *ctx, GLint cx, GLint cy,
+ GLsizei cw, GLsizei ch)
+{
+ ffbCalcViewport(ctx);
+}
+
static GLboolean ffbDDSetDrawBuffer(GLcontext *ctx, GLenum buffer)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
@@ -429,7 +475,7 @@ static GLboolean ffbDDSetDrawBuffer(GLcontext *ctx, GLenum buffer)
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDSetDrawBuffer: mode(%s)\n",
- gl_lookup_enum_by_nr(buffer));
+ _mesa_lookup_enum_by_nr(buffer));
#endif
fbc &= ~(FFB_FBC_WB_AB);
switch (buffer) {
@@ -457,8 +503,7 @@ static GLboolean ffbDDSetDrawBuffer(GLcontext *ctx, GLenum buffer)
if (fbc != fmesa->fbc) {
fmesa->fbc = fbc;
- fmesa->state_dirty |= FFB_STATE_FBC;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
}
return GL_TRUE;
@@ -472,7 +517,7 @@ static void ffbDDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDSetReadBuffer: mode(%s)\n",
- gl_lookup_enum_by_nr(buffer));
+ _mesa_lookup_enum_by_nr(buffer));
#endif
fbc &= ~(FFB_FBC_RB_MASK);
switch (buffer) {
@@ -496,27 +541,17 @@ static void ffbDDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
if (fbc != fmesa->fbc) {
fmesa->fbc = fbc;
- fmesa->state_dirty |= FFB_STATE_FBC;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
}
}
-static void ffbDDSetColor(GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-
- fmesa->MonoColor = ((r << 0) |
- (g << 8) |
- (b << 16));
-}
-
-static void ffbDDClearColor(GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+static void ffbDDClearColor(GLcontext *ctx, const GLchan color[4])
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- fmesa->clear_pixel = ((r << 0) |
- (g << 8) |
- (b << 16));
+ fmesa->clear_pixel = ((color[0] << 0) |
+ (color[1] << 8) |
+ (color[2] << 16));
}
static void ffbDDClearDepth(GLcontext *ctx, GLclampd depth)
@@ -533,147 +568,10 @@ static void ffbDDClearStencil(GLcontext *ctx, GLint stencil)
fmesa->clear_stencil = stencil & 0xf;
}
-static void ffbDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- GLuint drawop, fbc, ppc;
- int do_sw = 0;
-
- drawop = fmesa->drawop;
- fbc = fmesa->fbc;
- ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK);
-
-#ifdef STATE_TRACE
- fprintf(stderr,
- "ffbDDReducedPrimitiveChange: prim(%d) ", prim);
-#endif
- switch(prim) {
- case GL_POINTS:
-#ifdef STATE_TRACE
- fprintf(stderr, "GL_POINTS ");
-#endif
- if (ctx->IndirectTriangles & DD_POINT_SW_RASTERIZE) {
- do_sw = 1;
- break;
- }
-
- if (ctx->TriangleCaps & DD_POINT_SIZE) {
- ppc |= FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST;
- drawop = FFB_DRAWOP_TRIANGLE;
- } else {
- if (ctx->Point.SmoothFlag) {
- ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST);
- drawop = FFB_DRAWOP_AADOT;
- } else {
- ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
- drawop = FFB_DRAWOP_DOT;
- }
- }
- break;
-
- case GL_LINES:
-#ifdef STATE_TRACE
- fprintf(stderr, "GL_LINES ");
-#endif
- if (ctx->IndirectTriangles & DD_LINE_SW_RASTERIZE) {
- do_sw = 1;
- break;
- }
-
- if (ctx->TriangleCaps & DD_FLATSHADE) {
- ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
- } else {
- ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
- }
- if (ctx->TriangleCaps & DD_LINE_WIDTH) {
- drawop = FFB_DRAWOP_TRIANGLE;
- } else {
- if (ctx->Line.SmoothFlag)
- drawop = FFB_DRAWOP_AALINE;
- else
- drawop = FFB_DRAWOP_DDLINE;
- }
- break;
-
- case GL_POLYGON:
-#ifdef STATE_TRACE
- fprintf(stderr, "GL_POLYGON ");
-#endif
- if (ctx->IndirectTriangles & DD_TRI_SW_RASTERIZE) {
- do_sw = 1;
- break;
- }
-
- ppc &= ~FFB_PPC_APE_MASK;
- if (ctx->Polygon.StippleFlag)
- ppc |= FFB_PPC_APE_ENABLE;
- else
- ppc |= FFB_PPC_APE_DISABLE;
-
- if (ctx->TriangleCaps & DD_FLATSHADE) {
- ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
- } else {
- ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
- }
- drawop = FFB_DRAWOP_TRIANGLE;
- break;
-
- default:
-#ifdef STATE_TRACE
- fprintf(stderr, "unknown %d!\n", prim);
-#endif
- return;
- };
-
-#ifdef STATE_TRACE
- fprintf(stderr, "do_sw(%d) ", do_sw);
-#endif
- if (do_sw != 0) {
- fbc &= ~(FFB_FBC_WB_C);
- fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK);
- fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK;
- ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK |
- FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK);
- ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID |
- FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE |
- FFB_PPC_APE_DISABLE);
- } else {
- fbc |= FFB_FBC_WB_C;
- fbc &= ~(FFB_FBC_RGBE_MASK);
- fbc |= FFB_FBC_RGBE_MASK;
- ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK);
- if (ctx->Color.BlendEnabled) {
- ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR;
- } else {
- ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID;
- }
- }
-#ifdef STATE_TRACE
- fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc);
-#endif
-
- FFBFifo(fmesa, 4);
- if (fmesa->drawop != drawop)
- fmesa->regs->drawop = fmesa->drawop = drawop;
- if (fmesa->fbc != fbc)
- fmesa->regs->fbc = fmesa->fbc = fbc;
- if (fmesa->ppc != ppc)
- fmesa->regs->ppc = fmesa->ppc = ppc;
- if (do_sw != 0) {
- fmesa->regs->cmp =
- (fmesa->cmp & ~(0xff<<16)) | (0x80 << 16);
- } else
- fmesa->regs->cmp = fmesa->cmp;
-
- /* Flush the vertex cache. */
- fmesa->vtx_cache[0] = fmesa->vtx_cache[1] =
- fmesa->vtx_cache[2] = fmesa->vtx_cache[3] = NULL;
-}
-
/* XXX Actually, should I be using FBC controls for this? -DaveM */
-static GLboolean ffbDDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a)
+static void ffbDDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
unsigned int new_pmask = 0x0;
@@ -691,21 +589,18 @@ static GLboolean ffbDDColorMask(GLcontext *ctx,
if (fmesa->pmask != new_pmask) {
fmesa->pmask = new_pmask;
- fmesa->state_dirty |= FFB_STATE_PMASK;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_PMASK, 1);
}
-
- return GL_TRUE;
}
-static GLboolean ffbDDLogicOp(GLcontext *ctx, GLenum op)
+static void ffbDDLogicOp(GLcontext *ctx, GLenum op)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
unsigned int rop;
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDLogicOp: op(%s)\n",
- gl_lookup_enum_by_nr(op));
+ _mesa_lookup_enum_by_nr(op));
#endif
switch (op) {
case GL_CLEAR: rop = FFB_ROP_ZERO; break;
@@ -726,20 +621,17 @@ static GLboolean ffbDDLogicOp(GLcontext *ctx, GLenum op)
case GL_OR_INVERTED: rop = FFB_ROP_NNEW_OR_OLD; break;
default:
- return GL_FALSE;
+ return;
};
rop |= fmesa->rop & ~0xff;
if (rop != fmesa->rop) {
fmesa->rop = rop;
- fmesa->state_dirty |= FFB_STATE_ROP;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_ROP, 1);
if (op == GL_COPY)
- fmesa->bad_fragment_attrs &= ~FFB_BADATTR_BLENDROP;
+ FALLBACK( ctx, FFB_BADATTR_BLENDROP, GL_FALSE );
}
-
- return GL_TRUE;
}
#if 0
@@ -822,7 +714,7 @@ static void ffb_fog_linear(GLcontext *ctx, ffbContextPtr fmesa)
static void ffbDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
#ifdef STATE_TRACE
- fprintf(stderr, "ffbDDFogfv: pname(%s)\n", gl_lookup_enum_by_nr(pname));
+ fprintf(stderr, "ffbDDFogfv: pname(%s)\n", _mesa_lookup_enum_by_nr(pname));
#endif
}
@@ -837,11 +729,9 @@ static void ffbDDLineStipple(GLcontext *ctx, GLint factor, GLushort pattern)
if (ctx->Line.StippleFlag) {
factor = ctx->Line.StippleFactor;
pattern = ctx->Line.StipplePattern;
- if ((GLuint) factor > 15) {
- ctx->Driver.TriangleCaps &= ~DD_LINE_STIPPLE;
+ if ((GLuint) factor > 15) {
fmesa->lpat = FFB_LPAT_BAD;
} else {
- ctx->Driver.TriangleCaps |= DD_LINE_STIPPLE;
fmesa->lpat = ((factor << FFB_LPAT_SCALEVAL_SHIFT) |
(0 << FFB_LPAT_PATLEN_SHIFT) |
((pattern & 0xffff) << FFB_LPAT_PATTERN_SHIFT));
@@ -872,8 +762,7 @@ void ffbXformAreaPattern(ffbContextPtr fmesa, const GLubyte *mask)
mask += 4;
}
- fmesa->state_dirty |= FFB_STATE_APAT;
- fmesa->state_fifo_ents += 32;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_APAT, 32);
}
static void ffbDDPolygonStipple(GLcontext *ctx, const GLubyte *mask)
@@ -884,11 +773,6 @@ static void ffbDDPolygonStipple(GLcontext *ctx, const GLubyte *mask)
fprintf(stderr, "ffbDDPolygonStipple: state(%d)\n",
ctx->Polygon.StippleFlag);
#endif
- if (ctx->Polygon.StippleFlag) {
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
- } else {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- }
ffbXformAreaPattern(fmesa, mask);
}
@@ -899,7 +783,7 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
#ifdef STATE_TRACE
fprintf(stderr, "ffbDDEnable: %s state(%d)\n",
- gl_lookup_enum_by_nr(cap), state);
+ _mesa_lookup_enum_by_nr(cap), state);
#endif
switch (cap) {
case GL_ALPHA_TEST:
@@ -910,8 +794,7 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
if (tmp != fmesa->xclip) {
fmesa->xclip = tmp;
- fmesa->state_dirty |= FFB_STATE_XCLIP;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1);
}
break;
@@ -924,8 +807,7 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
}
if (fmesa->ppc != tmp) {
fmesa->ppc = tmp;
- fmesa->state_dirty |= FFB_STATE_PPC;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_PPC, 1);
ffbDDBlendFunc(ctx, 0, 0);
}
break;
@@ -945,29 +827,18 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
fmesa->fbc = fbc;
ffbDDDepthFunc(ctx, ctx->Depth.Func);
fmesa->magnc = tmp;
- fmesa->state_dirty |= FFB_STATE_MAGNC | FFB_STATE_FBC;
- fmesa->state_fifo_ents += 2;
+ FFB_MAKE_DIRTY(fmesa, (FFB_STATE_MAGNC | FFB_STATE_FBC), 2);
}
break;
case GL_SCISSOR_TEST:
- tmp = fmesa->ppc & ~FFB_PPC_VCE_MASK;
- if (state) {
- ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height);
- tmp |= FFB_PPC_VCE_2D;
- } else {
- tmp |= FFB_PPC_VCE_DISABLE;
- }
+ ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
break;
case GL_STENCIL_TEST:
if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {
- if (state)
- fmesa->bad_fragment_attrs |= FFB_BADATTR_STENCIL;
- else
- fmesa->bad_fragment_attrs &= ~FFB_BADATTR_STENCIL;
- break;
+ FALLBACK( ctx, FFB_BADATTR_STENCIL, state );
}
tmp = fmesa->fbc & ~FFB_FBC_YE_MASK;
@@ -985,23 +856,18 @@ static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
} else {
fmesa->stencil = 0xf0000000;
fmesa->stencilctl = 0x33300000;
- fmesa->state_dirty |= FFB_STATE_STENCIL;
- fmesa->state_fifo_ents += 6;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
tmp |= FFB_FBC_YE_OFF;
}
if (tmp != fmesa->fbc) {
fmesa->fbc = tmp;
- fmesa->state_dirty |= FFB_STATE_FBC;
- fmesa->state_fifo_ents += 1;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
}
break;
case GL_FOG:
/* Until I implement the fog support... */
- if (state)
- fmesa->bad_fragment_attrs |= FFB_BADATTR_FOG;
- else
- fmesa->bad_fragment_attrs &= ~FFB_BADATTR_FOG;
+ FALLBACK( ctx, FFB_BADATTR_FOG, state );
break;
case GL_LINE_STIPPLE:
@@ -1135,59 +1001,36 @@ void ffbSyncHardware(ffbContextPtr fmesa)
fmesa->ffbScreen->rp_active = 1;
}
-static void ffbDDRenderStart(GLcontext *ctx)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-
- LOCK_HARDWARE(fmesa);
- fmesa->hw_locked = 1;
-
- if (fmesa->state_dirty != 0)
- ffbSyncHardware(fmesa);
-}
-
-static void ffbDDRenderFinish(GLcontext *ctx)
+static void ffbDDUpdateState(GLcontext *ctx, GLuint newstate)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- UNLOCK_HARDWARE(fmesa);
- fmesa->hw_locked = 0;
-}
+ /* When we are hw rendering, changing certain kinds of
+ * state does not require flushing all of our context.
+ */
+ if (fmesa->bad_fragment_attrs == 0 &&
+ (newstate & ~_NEW_COLOR) == 0)
+ return;
-#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
- NEW_TEXTURE_MATRIX|\
- NEW_USER_CLIP|NEW_CLIENT_STATE|\
- NEW_TEXTURE_ENABLE))
+ _swrast_InvalidateState( ctx, newstate );
+ _swsetup_InvalidateState( ctx, newstate );
+ _ac_InvalidateState( ctx, newstate );
+ _tnl_InvalidateState( ctx, newstate );
-static void ffbDDUpdateState(GLcontext *ctx)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- unsigned int flags;
-
- if (ctx->NewState & INTERESTED) {
- if (fmesa->SWrender ||
- fmesa->bad_fragment_attrs != 0) {
- /* Force SW rendering. */
- fmesa->PointsFunc = NULL;
- fmesa->LineFunc = NULL;
- fmesa->TriangleFunc = NULL;
- fmesa->QuadFunc = NULL;
- } else {
- ffbDDChooseTriRenderState(ctx);
- ffbDDChooseLineRenderState(ctx);
- ffbDDChoosePointRenderState(ctx);
- }
+ if (newstate & _NEW_TEXTURE)
+ FALLBACK( ctx, FFB_BADATTR_TEXTURE,
+ (ctx->Texture._ReallyEnabled != 0));
- if (0)
- gl_print_tri_caps("tricaps", ctx->TriangleCaps);
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDUpdateState: newstate(%08x)\n", newstate);
+#endif
- ffbChooseRasterSetupFunc(ctx);
+ fmesa->new_gl_state |= newstate;
- /* Force a reduced primitive change next rendering
- * pass.
- */
- ctx->PB->primitive = GL_POLYGON + 1;
- }
+ /* Force a reduced primitive change next rendering
+ * pass.
+ */
+ fmesa->raster_primitive = GL_POLYGON + 1;
#if 0
/* When the modelview matrix changes, this changes what
@@ -1196,45 +1039,18 @@ static void ffbDDUpdateState(GLcontext *ctx)
*
* XXX DD_HAVE_HARDWARE_FOG.
*/
- if (ctx->Fog.Enabled && (ctx->NewState & NEW_MODELVIEW))
+ if (ctx->Fog.Enabled && (newstate & _NEW_MODELVIEW))
ffb_update_fog();
#endif
-
- /* XXX It may be possible to eliminate all of Mesa's sw clip
- * XXX processing using the hw clip registers we have. If
- * XXX this is correct, it is just a matter of verifying the
- * XXX FFB coordinate overflow rules in ffb_vb.c and if they
- * XXX are not violated we clear CLIP_MASK_ACTIVE in
- * XXX VB->CullMode.
- * XXX
- * XXX We would specify the xyz min/max values in the primary
- * XXX viewport clip registers, and the user specified
- * XXX scissor clip can go into one of the auxilliary viewport
- * XXX clips.
- */
- flags = ctx->IndirectTriangles;
- if (fmesa->PointsFunc != NULL) {
- ctx->Driver.PointsFunc = fmesa->PointsFunc;
- flags &= ~DD_POINT_SW_RASTERIZE;
- }
- if (fmesa->LineFunc != NULL) {
- ctx->Driver.LineFunc = fmesa->LineFunc;
- flags &= ~DD_LINE_SW_RASTERIZE;
- }
- if (fmesa->TriangleFunc != NULL) {
- ctx->Driver.TriangleFunc = fmesa->TriangleFunc;
- ctx->Driver.QuadFunc = fmesa->QuadFunc;
- flags &= ~(DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- }
- ctx->IndirectTriangles = flags;
}
+
void ffbDDInitStateFuncs(GLcontext *ctx)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
ctx->Driver.UpdateState = ffbDDUpdateState;
+
ctx->Driver.Enable = ffbDDEnable;
ctx->Driver.LightModelfv = NULL;
ctx->Driver.AlphaFunc = ffbDDAlphaFunc;
@@ -1250,10 +1066,9 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
ctx->Driver.CullFace = NULL;
ctx->Driver.FrontFace = NULL;
ctx->Driver.ColorMask = ffbDDColorMask;
- ctx->Driver.LogicOp = ffbDDLogicOp;
- ctx->Driver.ReducedPrimitiveChange = ffbDDReducedPrimitiveChange;
- ctx->Driver.RenderStart = ffbDDRenderStart;
- ctx->Driver.RenderFinish = ffbDDRenderFinish;
+ ctx->Driver.LogicOpcode = ffbDDLogicOp;
+ ctx->Driver.Viewport = ffbDDViewport;
+ ctx->Driver.DepthRange = ffbDDDepthRange;
if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
ctx->Driver.StencilFunc = ffbDDStencilFunc;
@@ -1266,17 +1081,38 @@ void ffbDDInitStateFuncs(GLcontext *ctx)
}
ctx->Driver.SetDrawBuffer = ffbDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = ffbDDSetReadBuffer;
- ctx->Driver.Color = ffbDDSetColor;
ctx->Driver.ClearColor = ffbDDClearColor;
ctx->Driver.ClearDepth = ffbDDClearDepth;
ctx->Driver.ClearStencil = ffbDDClearStencil;
- ctx->Driver.Dither = NULL;
/* We will support color index modes later... -DaveM */
- ctx->Driver.Index = 0;
ctx->Driver.ClearIndex = 0;
ctx->Driver.IndexMask = 0;
+
+
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+ {
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+ swdd->SetReadBuffer = ffbDDSetReadBuffer;
+ }
+
+
}
void ffbDDInitContextHwState(GLcontext *ctx)
@@ -1289,13 +1125,14 @@ void ffbDDInitContextHwState(GLcontext *ctx)
fmesa->bad_fragment_attrs = 0;
fmesa->state_dirty = FFB_STATE_ALL;
+ fmesa->new_gl_state = ~0;
fifo_count = 1;
fmesa->fbc = (FFB_FBC_WE_FORCEON | FFB_FBC_WM_COMBINED |
FFB_FBC_SB_BOTH | FFB_FBC_ZE_MASK |
FFB_FBC_YE_OFF | FFB_FBC_XE_OFF |
FFB_FBC_RGBE_MASK);
- if (ctx->Visual->DBflag) {
+ if (ctx->Visual.doubleBufferMode) {
/* Buffer B is the initial back buffer. */
fmesa->back_buffer = 1;
fmesa->fbc |= FFB_FBC_WB_BC | FFB_FBC_RB_B;
@@ -1306,7 +1143,7 @@ void ffbDDInitContextHwState(GLcontext *ctx)
fifo_count += 1;
fmesa->ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
- FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_3D |
FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE |
FFB_PPC_ZS_CONST | FFB_PPC_YS_CONST |
FFB_PPC_XS_WID | FFB_PPC_CS_VAR);
@@ -1376,9 +1213,9 @@ void ffbDDInitContextHwState(GLcontext *ctx)
/* ViewPort clip state. */
fifo_count += 4 + (4 * 2);
fmesa->vclipmin = 0x00000000;
- fmesa->vclipmax = 0x00000000;
+ fmesa->vclipmax = 0xffffffff;
fmesa->vclipzmin = 0x00000000;
- fmesa->vclipzmax = 0x00000000;
+ fmesa->vclipzmax = 0x0fffffff;
for (i = 0; i < 4; i++) {
fmesa->aux_clips[0].min = 0x00000000;
fmesa->aux_clips[0].max = 0x00000000;
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h
index 4221b503a..e20c727d3 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_state.h
@@ -6,7 +6,7 @@
extern void ffbDDInitStateFuncs(GLcontext *);
extern void ffbDDInitContextHwState(GLcontext *);
-extern void ffbDDScissor(GLcontext *, GLint, GLint, GLint, GLint);
+extern void ffbCalcViewport(GLcontext *);
extern void ffbXformAreaPattern(ffbContextPtr, const GLubyte *);
extern void ffbSyncHardware(ffbContextPtr fmesa);
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c
index 5292973c4..abd001de7 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c
@@ -25,17 +25,25 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
+#include "mtypes.h"
#include "ffb_dd.h"
#include "ffb_span.h"
#include "ffb_context.h"
#include "ffb_stencil.h"
#include "ffb_lock.h"
+#include "swrast/swrast.h"
+
+#undef STENCIL_TRACE
+
static void
FFBWriteStencilSpan(GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLstencil stencil[], const GLubyte mask[])
{
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
if (ctx->Depth.Mask) {
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
@@ -75,6 +83,9 @@ static void
FFBWriteStencilPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
const GLstencil stencil[], const GLubyte mask[])
{
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBWriteStencilPixels: n(%d)\n", (int) n);
+#endif
if (ctx->Depth.Mask) {
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = fmesa->driDrawable;
@@ -121,6 +132,10 @@ FFBReadStencilSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, GLstencil stencil
GLuint *zptr;
GLuint i;
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
if (!fmesa->hw_locked)
LOCK_HARDWARE(fmesa);
FFBFifo(fmesa, 1);
@@ -155,6 +170,9 @@ FFBReadStencilPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[],
char *zbase;
GLuint i;
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBReadStencilPixels: n(%d)\n", (int) n);
+#endif
if (!fmesa->hw_locked)
LOCK_HARDWARE(fmesa);
FFBFifo(fmesa, 1);
@@ -186,15 +204,18 @@ void ffbDDInitStencilFuncs(GLcontext *ctx)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+
if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
- ctx->Driver.WriteStencilSpan = FFBWriteStencilSpan;
- ctx->Driver.ReadStencilSpan = FFBReadStencilSpan;
- ctx->Driver.WriteStencilPixels = FFBWriteStencilPixels;
- ctx->Driver.ReadStencilPixels = FFBReadStencilPixels;
+ swdd->WriteStencilSpan = FFBWriteStencilSpan;
+ swdd->ReadStencilSpan = FFBReadStencilSpan;
+ swdd->WriteStencilPixels = FFBWriteStencilPixels;
+ swdd->ReadStencilPixels = FFBReadStencilPixels;
} else {
- ctx->Driver.WriteStencilSpan = NULL;
- ctx->Driver.ReadStencilSpan = NULL;
- ctx->Driver.WriteStencilPixels = NULL;
- ctx->Driver.ReadStencilPixels = NULL;
+ swdd->WriteStencilSpan = NULL;
+ swdd->ReadStencilSpan = NULL;
+ swdd->WriteStencilPixels = NULL;
+ swdd->ReadStencilPixels = NULL;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tex.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_tex.c
new file mode 100644
index 000000000..94358622e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tex.c
@@ -0,0 +1,51 @@
+/* $XFree86$
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include <GL/gl.h>
+#include "texformat.h"
+#include "texstore.h"
+#include "swrast/swrast.h"
+
+#include "ffb_tex.h"
+
+/* No texture unit, all software. */
+void ffbDDInitTexFuncs(GLcontext *ctx)
+{
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = _mesa_store_teximage2d;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dd.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_tex.h
index 86a8618d0..e2d9a8557 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810dd.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tex.h
@@ -1,6 +1,7 @@
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
+/* $XFree86$
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D.
+ * Copyright (C) 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -15,19 +16,19 @@
* THE SOFTWARE IS PROVIDED "AS 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ *
+ * David S. Miller <davem@redhat.com>
*/
-#ifndef I810DD_INC
-#define I810DD_INC
+#ifndef _FFB_TEX_H
+#define _FFB_TEX_H
-#include "context.h"
+extern void ffbDDInitTexFuncs(GLcontext *ctx);
-void i810DDExtensionsInit( GLcontext *ctx );
-void i810DDInitDriverFuncs( GLcontext *ctx );
+#endif /* !(_FFB_DD_H) */
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
index 1e60b4d5d..4b8654e93 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c
@@ -1,7 +1,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c,v 1.1 2000/06/20 05:08:40 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,66 +25,65 @@
* David S. Miller <davem@redhat.com>
*/
-#include "types.h"
-#include "vbrender.h"
-
#include <stdio.h>
#include <stdlib.h>
-#include "mm.h"
-#include "ffb_dd.h"
-#include "ffb_span.h"
-#include "ffb_depth.h"
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast_setup/ss_context.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
#include "ffb_context.h"
-#include "ffb_vb.h"
#include "ffb_tris.h"
+#include "ffb_lines.h"
#include "ffb_lock.h"
-#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
+#include "ffb_points.h"
+#include "ffb_state.h"
+#include "ffb_vb.h"
#undef TRI_DEBUG
+#undef FFB_RENDER_TRACE
+#undef STATE_TRACE
#ifdef TRI_DEBUG
-#define FFB_DUMP_PRIM(name) \
- fprintf(stderr, "FFB: Begin primitive %s%s%s" #name ".\n", \
- (IND & FFB_TRI_OFFSET_BIT) ? "OFFSET " : "", \
- (IND & FFB_TRI_FLAT_BIT) ? "FLAT " : "", \
- (IND & FFB_TRI_TWOSIDE_BIT) ? "TWOSIDE " : "")
-#define FFB_DUMP_VERTEX(V) \
- fprintf(stderr, "FFB: VERTEX ARGB(%c%x.%08x:%c%x.%08x:%c%x.%08x:%c%x.%08x) " \
- "XYZ(%04x.%04x:%04x.%04x:%c%x.%08x)\n", \
- (((V)->color[which_color].alpha & (1 << 31)) ? '-' : ' '), \
- (((V)->color[which_color].alpha & (1 << 30)) >> 30), \
- (((V)->color[which_color].alpha & ((1 << 30) - 1))), \
- (((V)->color[which_color].red & (1 << 31)) ? '-' : ' '), \
- (((V)->color[which_color].red & (1 << 30)) >> 30), \
- (((V)->color[which_color].red & ((1 << 30) - 1))), \
- (((V)->color[which_color].green & (1 << 31)) ? '-' : ' '), \
- (((V)->color[which_color].green & (1 << 30)) >> 30), \
- (((V)->color[which_color].green & ((1 << 30) - 1))), \
- (((V)->color[which_color].blue & (1 << 31)) ? '-' : ' '), \
- (((V)->color[which_color].blue & (1 << 30)) >> 30), \
- (((V)->color[which_color].blue & ((1 << 30) - 1))), \
- (((V)->x >> 16)), (((V)->x & ((1 << 16) - 1))), \
- (((V)->y >> 16)), (((V)->y & ((1 << 16) - 1))), \
- (((V)->z & (1 << 31)) ? '-' : ' '), \
- (((V)->z & (1 << 30)) >> 30), \
- (((V)->z & ((1 << 30) - 1))))
+static void ffb_print_vertex(const ffb_vertex *v)
+{
+ fprintf(stderr, "Vertex @(%p): "
+ "X[%f] Y[%f] Z[%f]\n",
+ v, v->x, v->y, v->z);
+ fprintf(stderr, "Vertex @(%p): "
+ "A[%f] R[%f] G[%f] B[%f]\n",
+ v,
+ v->color[0].alpha,
+ v->color[0].red,
+ v->color[0].green,
+ v->color[0].blue);
+}
+#define FFB_DUMP_VERTEX(V) ffb_print_vertex(V)
#else
-#define FFB_DUMP_PRIM(name) do { } while(0)
#define FFB_DUMP_VERTEX(V) do { } while(0)
#endif
+#define FFB_ALPHA_BIT 0x01
+#define FFB_FLAT_BIT 0x02
+#define FFB_TRI_CULL_BIT 0x04
+#define MAX_FFB_RENDER_FUNCS 0x08
+
+/***********************************************************************
+ * Build low-level triangle/quad rasterize functions *
+ ***********************************************************************/
+
#define FFB_TRI_FLAT_BIT 0x01
-#define FFB_TRI_TWOSIDE_BIT 0x02
-#define FFB_TRI_OFFSET_BIT 0x04
-#define FFB_TRI_CULL_BIT 0x08
-#define FFB_TRI_ALPHA_BIT 0x10
-#define FFB_TRI_FALLBACK_BIT 0x20
+#define FFB_TRI_ALPHA_BIT 0x02
+/*#define FFB_TRI_CULL_BIT 0x04*/
-static triangle_func ffb_tri_tab[0x40];
-static quad_func ffb_quad_tab[0x40];
+static ffb_tri_func ffb_tri_tab[0x8];
+static ffb_quad_func ffb_quad_tab[0x8];
#define IND (0)
#define TAG(x) x
@@ -94,30 +93,6 @@ static quad_func ffb_quad_tab[0x40];
#define TAG(x) x##_flat
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "ffb_tritmp.h"
-
-#define IND (FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "ffb_tritmp.h"
-
-#define IND (FFB_TRI_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "ffb_tritmp.h"
-
-#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "ffb_tritmp.h"
-
-#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "ffb_tritmp.h"
-
-#define IND (FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "ffb_tritmp.h"
-
#define IND (FFB_TRI_CULL_BIT)
#define TAG(x) x##_cull
#include "ffb_tritmp.h"
@@ -126,159 +101,177 @@ static quad_func ffb_quad_tab[0x40];
#define TAG(x) x##_cull_flat
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_cull_offset
+#define IND (FFB_TRI_ALPHA_BIT)
+#define TAG(x) x##_alpha
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_cull_offset_flat
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT)
-#define TAG(x) x##_cull_twoside
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_cull
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_cull_twoside_flat
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_flat
#include "ffb_tritmp.h"
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_cull_twoside_offset
-#include "ffb_tritmp.h"
+static void init_tri_tab(void)
+{
+ ffb_init();
+ ffb_init_flat();
+ ffb_init_cull();
+ ffb_init_cull_flat();
+ ffb_init_alpha();
+ ffb_init_alpha_flat();
+ ffb_init_alpha_cull();
+ ffb_init_alpha_cull_flat();
+}
-#define IND (FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_cull_twoside_offset_flat
-#include "ffb_tritmp.h"
+/* Build a SWvertex from a hardware vertex. */
+static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
+ SWvertex *dst)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLfloat *m = ctx->Viewport._WindowMap.m;
+ const GLfloat sx = m[0];
+ const GLfloat sy = m[5];
+ const GLfloat sz = m[10];
+ const GLfloat tx = m[12];
+ const GLfloat ty = m[13];
+ const GLfloat tz = m[14];
+
+ dst->win[0] = sx * src->x + tx;
+ dst->win[1] = sy * src->y + ty;
+ dst->win[2] = sz * src->z + tz;
+ dst->win[3] = 1.0;
+
+ dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
+ dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);
+ dst->color[2] = FFB_UBYTE_FROM_COLOR(src->color[0].blue);
+ dst->color[3] = FFB_UBYTE_FROM_COLOR(src->color[0].alpha);
+}
-#define IND (FFB_TRI_ALPHA_BIT)
-#define TAG(x) x##_alpha
-#include "ffb_tritmp.h"
+/***********************************************************************
+ * Build fallback triangle/quad rasterize functions *
+ ***********************************************************************/
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_flat
-#include "ffb_tritmp.h"
+static void ffb_fallback_triangle(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1, ffb_vertex *v2)
+{
+ SWvertex v[3];
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_alpha_offset
-#include "ffb_tritmp.h"
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
+ ffb_translate_vertex(ctx, v2, &v[2]);
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_offset_flat
-#include "ffb_tritmp.h"
+ _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
+}
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT)
-#define TAG(x) x##_alpha_twoside
-#include "ffb_tritmp.h"
+static void ffb_fallback_quad(GLcontext *ctx,
+ ffb_vertex *v0, ffb_vertex *v1,
+ ffb_vertex *v2, ffb_vertex *v3)
+{
+ SWvertex v[4];
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_twoside_flat
-#include "ffb_tritmp.h"
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
+ ffb_translate_vertex(ctx, v2, &v[2]);
+ ffb_translate_vertex(ctx, v3, &v[3]);
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_alpha_twoside_offset
-#include "ffb_tritmp.h"
+ _swrast_Quad(ctx, &v[0], &v[1], &v[2], &v[3]);
+}
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_twoside_offset_flat
-#include "ffb_tritmp.h"
+void ffb_fallback_line(GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1)
+{
+ SWvertex v[2];
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT)
-#define TAG(x) x##_alpha_cull
-#include "ffb_tritmp.h"
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_cull_flat
-#include "ffb_tritmp.h"
+ _swrast_Line(ctx, &v[0], &v[1]);
+}
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_alpha_cull_offset
-#include "ffb_tritmp.h"
+void ffb_fallback_point(GLcontext *ctx, ffb_vertex *v0)
+{
+ SWvertex v[1];
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_cull_offset_flat
-#include "ffb_tritmp.h"
+ ffb_translate_vertex(ctx, v0, &v[0]);
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT)
-#define TAG(x) x##_alpha_cull_twoside
-#include "ffb_tritmp.h"
+ _swrast_Point(ctx, &v[0]);
+}
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_cull_twoside_flat
-#include "ffb_tritmp.h"
+/***********************************************************************
+ * Rasterization functions for culled tris/quads *
+ ***********************************************************************/
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT)
-#define TAG(x) x##_alpha_cull_twoside_offset
-#include "ffb_tritmp.h"
+static void ffb_nodraw_triangle(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1, ffb_vertex *v2)
+{
+ (void) (ctx && v0 && v1 && v2);
+}
-#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_TWOSIDE_BIT|FFB_TRI_OFFSET_BIT|FFB_TRI_FLAT_BIT)
-#define TAG(x) x##_alpha_cull_twoside_offset_flat
-#include "ffb_tritmp.h"
+static void ffb_nodraw_quad(GLcontext *ctx,
+ ffb_vertex *v0, ffb_vertex *v1,
+ ffb_vertex *v2, ffb_vertex *v3)
+{
+ (void) (ctx && v0 && v1 && v2 && v3);
+}
-void ffbDDTrifuncInit()
+static void ffb_update_cullsign(GLcontext *ctx)
{
- init();
- init_flat();
- init_offset();
- init_offset_flat();
- init_twoside();
- init_twoside_flat();
- init_twoside_offset();
- init_twoside_offset_flat();
- init_cull();
- init_cull_flat();
- init_cull_offset();
- init_cull_offset_flat();
- init_cull_twoside();
- init_cull_twoside_flat();
- init_cull_twoside_offset();
- init_cull_twoside_offset_flat();
- init_alpha();
- init_alpha_flat();
- init_alpha_offset();
- init_alpha_offset_flat();
- init_alpha_twoside();
- init_alpha_twoside_flat();
- init_alpha_twoside_offset();
- init_alpha_twoside_offset_flat();
- init_alpha_cull();
- init_alpha_cull_flat();
- init_alpha_cull_offset();
- init_alpha_cull_offset_flat();
- init_alpha_cull_twoside();
- init_alpha_cull_twoside_flat();
- init_alpha_cull_twoside_offset();
- init_alpha_cull_twoside_offset_flat();
+ GLfloat backface_sign = 1;
+
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace==GL_CCW)
+ backface_sign = -1;
+ break;
+
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace!=GL_CCW)
+ backface_sign = -1;
+ break;
+
+ default:
+ break;
+ };
+
+ FFB_CONTEXT(ctx)->backface_sign = backface_sign;
}
-void ffbDDChooseTriRenderState(GLcontext *ctx)
+/***********************************************************************
+ * Choose triangle/quad rasterize functions *
+ ***********************************************************************/
+
+void ffbChooseTriangleState(GLcontext *ctx)
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
+ GLuint flags = ctx->_TriangleCaps;
GLuint ind = 0;
- if (!flags) {
- fmesa->TriangleFunc = ffb_tri_tab[0];
- fmesa->QuadFunc = ffb_quad_tab[0];
- return;
- }
-
- if (ctx->Texture.ReallyEnabled) {
- fmesa->TriangleFunc = NULL;
- fmesa->QuadFunc = NULL;
+ if (flags & DD_TRI_SMOOTH) {
+ fmesa->draw_tri = ffb_fallback_triangle;
+ fmesa->draw_quad = ffb_fallback_quad;
return;
}
if (flags & DD_FLATSHADE)
ind |= FFB_TRI_FLAT_BIT;
- if (flags & DD_TRI_CULL)
- ind |= FFB_TRI_CULL_BIT;
- if (ctx->Polygon.SmoothFlag)
- ind |= FFB_TRI_FALLBACK_BIT;
- if (flags & DD_TRI_OFFSET)
- ind |= FFB_TRI_OFFSET_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE)
- ind |= FFB_TRI_TWOSIDE_BIT;
+ if (ctx->Polygon.CullFlag) {
+ if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
+ fmesa->draw_tri = ffb_nodraw_triangle;
+ fmesa->draw_quad = ffb_nodraw_quad;
+ return;
+ }
+
+ ind |= FFB_TRI_CULL_BIT;
+ ffb_update_cullsign(ctx);
+ } else
+ FFB_CONTEXT(ctx)->backface_sign = 0;
+
/* If blending or the alpha test is enabled we need to
* provide alpha components to the chip, else we can
* do without it and thus feed vertex data to the chip
@@ -287,6 +280,670 @@ void ffbDDChooseTriRenderState(GLcontext *ctx)
if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
ind |= FFB_TRI_ALPHA_BIT;
- fmesa->TriangleFunc = ffb_tri_tab[ind];
- fmesa->QuadFunc = ffb_quad_tab[ind];
+ fmesa->draw_tri = ffb_tri_tab[ind];
+ fmesa->draw_quad = ffb_quad_tab[ind];
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim);
+static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim);
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define FFB_OFFSET_BIT 0x01
+#define FFB_TWOSIDE_BIT 0x02
+#define FFB_UNFILLED_BIT 0x04
+#define FFB_MAX_TRIFUNC 0x08
+
+static struct {
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[FFB_MAX_TRIFUNC];
+
+#define DO_OFFSET (IND & FFB_OFFSET_BIT)
+#define DO_UNFILLED (IND & FFB_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & FFB_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_QUAD 1
+#define DO_FULL_QUAD 1
+#define DO_TRI 1
+#define DO_LINE 0
+#define DO_POINTS 0
+
+#define QUAD( a, b, c, d ) fmesa->draw_quad( ctx, a, b, c, d )
+#define TRI( a, b, c ) fmesa->draw_tri( ctx, a, b, c )
+#define LINE( a, b ) fmesa->draw_line( ctx, a, b )
+#define POINT( a ) fmesa->draw_point( ctx, a )
+
+#define HAVE_BACK_COLORS 1
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX ffb_vertex
+#define TAB rast_tab
+
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define DEPTH_SCALE (fmesa->depth_scale)
+#define VERT_X(_v) (_v->x)
+#define VERT_Y(_v) (_v->y)
+#define VERT_Z(_v) (_v->z)
+#define AREA_IS_CCW( a ) (a < fmesa->ffb_zero)
+#define GET_VERTEX(e) (&fmesa->verts[e])
+#define INSANE_VERTICES
+#define VERT_SET_Z(v,val) ((v)->z = (val))
+#define VERT_Z_ADD(v,val) ((v)->z += (val))
+
+#define VERT_COPY_RGBA1( _v ) _v->color[0] = _v->color[1]
+#define VERT_COPY_RGBA( v0, v1 ) v0->color[0] = v1->color[0]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->color[0]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->color[0] = color[idx]
+
+#define LOCAL_VARS(n) \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
+ ffb_color color[n]; \
+ (void) color; (void) dPriv;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fmesa->raster_primitive != reduced_prim[x]) \
+ ffbRasterPrimitive( ctx, reduced_prim[x] )
+#define RENDER_PRIMITIVE fmesa->render_primitive
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+}
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void ffbRenderClippedPolygon(GLcontext *ctx, const GLuint *elts, GLuint n)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon. */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n, PRIM_BEGIN|PRIM_END);
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive. */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify(ctx, prim);
+}
+
+static void ffbRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line(ctx, ii, jj);
+}
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+static void ffb_vb_noop(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ (void)(ctx && start && count && flags);
+}
+
+#define ELT(x) x
+
+#define IND 0
+#define TAG(x) x
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
+#define TAG(x) x##_flat_alpha
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_alpha_tricull
+#include "ffb_rendertmp.h"
+
+#undef ELT
+#define ELT(x) elt[x]
+
+#define IND 0
+#define TAG(x) x##_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT)
+#define TAG(x) x##_flat_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT)
+#define TAG(x) x##_alpha_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
+#define TAG(x) x##_flat_alpha_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_alpha_tricull_elt
+#include "ffb_rendertmp.h"
+
+static void *render_tabs[MAX_FFB_RENDER_FUNCS];
+static void *render_tabs_elt[MAX_FFB_RENDER_FUNCS];
+
+static void init_render_tab(void)
+{
+ int i;
+
+ render_tabs[0] = render_tab;
+ render_tabs[FFB_FLAT_BIT] = render_tab_flat;
+ render_tabs[FFB_ALPHA_BIT] = render_tab_alpha;
+ render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha;
+ render_tabs[FFB_TRI_CULL_BIT] = render_tab_tricull;
+ render_tabs[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull;
+ render_tabs[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull;
+ render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
+ render_tab_flat_alpha_tricull;
+
+ render_tabs_elt[0] = render_tab_elt;
+ render_tabs_elt[FFB_FLAT_BIT] = render_tab_flat_elt;
+ render_tabs_elt[FFB_ALPHA_BIT] = render_tab_alpha_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha_elt;
+ render_tabs_elt[FFB_TRI_CULL_BIT] = render_tab_tricull_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull_elt;
+ render_tabs_elt[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
+ render_tab_flat_alpha_tricull_elt;
+
+ for (i = 0; i < MAX_FFB_RENDER_FUNCS; i++) {
+ render_func *rf = render_tabs[i];
+ render_func *rfe = render_tabs_elt[i];
+
+ if (i & FFB_TRI_CULL_BIT) {
+ int from_idx = (i & ~FFB_TRI_CULL_BIT);
+ render_func *rf_from = render_tabs[from_idx];
+ render_func *rfe_from = render_tabs_elt[from_idx];
+ int j;
+
+ for (j = GL_POINTS; j < GL_TRIANGLES; j++) {
+ rf[j] = rf_from[j];
+ rfe[j] = rfe_from[j];
+ }
+ }
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#ifdef FFB_RENDER_TRACE
+static void ffbPrintRenderFlags(GLuint index, GLuint render_index)
+{
+ fprintf(stderr,
+ "ffbChooseRenderState: "
+ "index(%s%s%s) "
+ "render_index(%s%s%s)\n",
+ ((index & FFB_TWOSIDE_BIT) ? "twoside " : ""),
+ ((index & FFB_OFFSET_BIT) ? "offset " : ""),
+ ((index & FFB_UNFILLED_BIT) ? "unfilled " : ""),
+ ((render_index & FFB_FLAT_BIT) ? "flat " : ""),
+ ((render_index & FFB_ALPHA_BIT) ? "alpha " : ""),
+ ((render_index & FFB_TRI_CULL_BIT) ? "tricull " : ""));
+}
+#endif
+
+void ffbChooseRenderState(GLcontext *ctx)
+{
+ GLuint flags = ctx->_TriangleCaps;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint index = 0;
+
+ /* Per-primitive fallbacks and the selection of fmesa->draw_* are
+ * handled elsewhere.
+ */
+ if (flags & DD_TRI_LIGHT_TWOSIDE)
+ index |= FFB_TWOSIDE_BIT;
+
+ if (flags & DD_TRI_OFFSET)
+ index |= FFB_OFFSET_BIT;
+
+ if (flags & DD_TRI_UNFILLED)
+ index |= FFB_UNFILLED_BIT;
+
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ GLuint render_index = 0;
+
+ if (flags & DD_FLATSHADE)
+ render_index |= FFB_FLAT_BIT;
+
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ render_index |= FFB_ALPHA_BIT;
+
+ if (ctx->Polygon.CullFlag)
+ render_index |= FFB_TRI_CULL_BIT;
+
+#ifdef FFB_RENDER_TRACE
+ ffbPrintRenderFlags(index, render_index);
+#endif
+ tnl->Driver.Render.PrimTabVerts = render_tabs[render_index];
+ tnl->Driver.Render.PrimTabElts = render_tabs_elt[render_index];
+ } else {
+#ifdef FFB_RENDER_TRACE
+ ffbPrintRenderFlags(index, 0);
+#endif
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ }
+
+ tnl->Driver.Render.ClippedPolygon = ffbRenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = ffbRenderClippedLine;
+}
+
+static void ffbRunPipeline(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (fmesa->bad_fragment_attrs == 0 &&
+ fmesa->new_gl_state) {
+ if (fmesa->new_gl_state & _FFB_NEW_TRIANGLE)
+ ffbChooseTriangleState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_LINE)
+ ffbChooseLineState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_POINT)
+ ffbChoosePointState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_RENDER)
+ ffbChooseRenderState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_VERTEX)
+ ffbChooseVertexState(ctx);
+
+ fmesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline(ctx);
+}
+
+static void ffbRenderStart(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty != 0)
+ ffbSyncHardware(fmesa);
+}
+
+static void ffbRenderFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+/* Even when doing full software rendering we need to
+ * wrap render{start,finish} so that the hardware is kept
+ * in sync (because multipass rendering changes the write
+ * buffer etc.)
+ */
+static void ffbSWRenderStart(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty != 0)
+ ffbSyncHardware(fmesa);
+}
+
+static void ffbSWRenderFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint drawop, fbc, ppc;
+ int do_sw = 0;
+
+ fmesa->raster_primitive = rprim;
+
+ drawop = fmesa->drawop;
+ fbc = fmesa->fbc;
+ ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK);
+
+#ifdef STATE_TRACE
+ fprintf(stderr,
+ "ffbReducedPrimitiveChange: rprim(%d) ", rprim);
+#endif
+ switch(rprim) {
+ case GL_POINTS:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POINTS ");
+#endif
+ if (fmesa->draw_point == ffb_fallback_point) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->Point.SmoothFlag) {
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_AADOT;
+ } else {
+ ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_DOT;
+ }
+ break;
+
+ case GL_LINES:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_LINES ");
+#endif
+ if (fmesa->draw_line == ffb_fallback_line) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ if (ctx->Line.SmoothFlag)
+ drawop = FFB_DRAWOP_AALINE;
+ else
+ drawop = FFB_DRAWOP_DDLINE;
+ break;
+
+ case GL_TRIANGLES:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POLYGON ");
+#endif
+ if (fmesa->draw_tri == ffb_fallback_triangle) {
+ do_sw = 1;
+ break;
+ }
+
+ ppc &= ~FFB_PPC_APE_MASK;
+ if (ctx->Polygon.StippleFlag)
+ ppc |= FFB_PPC_APE_ENABLE;
+ else
+ ppc |= FFB_PPC_APE_DISABLE;
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ drawop = FFB_DRAWOP_TRIANGLE;
+ break;
+
+ default:
+#ifdef STATE_TRACE
+ fprintf(stderr, "unknown %d!\n", rprim);
+#endif
+ return;
+ };
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "do_sw(%d) ", do_sw);
+#endif
+ if (do_sw != 0) {
+ fbc &= ~(FFB_FBC_WB_C);
+ fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK |
+ FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK);
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_APE_DISABLE);
+ } else {
+ fbc |= FFB_FBC_WB_C;
+ fbc &= ~(FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK);
+ if (ctx->Color.BlendEnabled) {
+ if ((rprim == GL_POINTS && !ctx->Point.SmoothFlag) ||
+ (rprim != GL_POINTS && ctx->_TriangleCaps & DD_FLATSHADE))
+ ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_CONST;
+ else
+ ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR;
+ } else {
+ ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID;
+ }
+ }
+#ifdef STATE_TRACE
+ fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc);
+#endif
+
+ FFBFifo(fmesa, 4);
+ if (fmesa->drawop != drawop)
+ fmesa->regs->drawop = fmesa->drawop = drawop;
+ if (fmesa->fbc != fbc)
+ fmesa->regs->fbc = fmesa->fbc = fbc;
+ if (fmesa->ppc != ppc)
+ fmesa->regs->ppc = fmesa->ppc = ppc;
+ if (do_sw != 0) {
+ fmesa->regs->cmp =
+ (fmesa->cmp & ~(0xff<<16)) | (0x80 << 16);
+ } else
+ fmesa->regs->cmp = fmesa->cmp;
+}
+
+static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ fmesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (fmesa->raster_primitive != rprim) {
+ ffbRasterPrimitive( ctx, rprim );
+ }
+}
+
+
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "Fog enabled",
+ "Blend function",
+ "Blend ROP",
+ "Blend equation",
+ "Stencil",
+ "Texture",
+ "LIBGL_SOFTWARE_RENDERING"
+};
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = fmesa->bad_fragment_attrs;
+
+ if (mode) {
+ fmesa->bad_fragment_attrs |= bit;
+ if (oldfallback == 0) {
+/* FFB_FIREVERTICES(fmesa); */
+ _swsetup_Wakeup( ctx );
+ if (fmesa->debugFallbacks)
+ fprintf(stderr, "FFB begin software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ } else {
+ fmesa->bad_fragment_attrs &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+
+ tnl->Driver.Render.Start = ffbRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
+ tnl->Driver.Render.Finish = ffbRenderFinish;
+ fmesa->new_gl_state = ~0;
+
+ /* Just re-choose everything:
+ */
+ ffbChooseVertexState(ctx);
+ ffbChooseRenderState(ctx);
+ ffbChooseTriangleState(ctx);
+ ffbChooseLineState(ctx);
+ ffbChoosePointState(ctx);
+
+ if (fmesa->debugFallbacks)
+ fprintf(stderr, "FFB end software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+}
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void ffbDDInitRenderFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ init_tri_tab();
+ init_render_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = ffbRunPipeline;
+ tnl->Driver.Render.Start = ffbRenderStart;
+ tnl->Driver.Render.Finish = ffbRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+
+ swsetup->Driver.Start = ffbSWRenderStart;
+ swsetup->Driver.Finish = ffbSWRenderFinish;
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h
index 0fffb3d79..b30afb8ac 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h
@@ -3,7 +3,27 @@
#ifndef _FFB_TRIS_H
#define _FFB_TRIS_H
-extern void ffbDDTrifuncInit(void);
-extern void ffbDDChooseTriRenderState(GLcontext *);
+extern void ffbDDInitRenderFuncs( GLcontext *ctx );
+
+
+#define _FFB_NEW_RENDER (_DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_UNFILLED)
+
+extern void ffbChooseRenderState(GLcontext *ctx);
+
+
+#define _FFB_NEW_TRIANGLE (_DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _NEW_POLYGON | \
+ _NEW_COLOR)
+
+extern void ffbChooseTriangleState(GLcontext *ctx);
+
+extern void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( ctx, bit, mode ) ffbFallback( ctx, bit, mode )
+
+extern void ffb_fallback_line(GLcontext *, ffb_vertex *, ffb_vertex *);
+extern void ffb_fallback_point(GLcontext *, ffb_vertex *);
#endif /* !(_FFB_TRIS_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h
index ba7312238..e21945b6f 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h
@@ -1,121 +1,62 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h,v 1.1 2000/06/20 05:08:40 dawes Exp $ */
-static void TAG(ffb_triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, GLuint pv)
+static void TAG(ffb_triangle)( GLcontext *ctx,
+ ffb_vertex *v0,
+ ffb_vertex *v1,
+ ffb_vertex *v2 )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
ffb_fbcPtr ffb = fmesa->regs;
- struct vertex_buffer *VB = ctx->VB;
- ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
- const ffb_vertex *v0 = &ffbVB[e0];
- const ffb_vertex *v1 = &ffbVB[e1];
- const ffb_vertex *v2 = &ffbVB[e2];
-#if (IND & FFB_TRI_OFFSET_BIT)
- GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PolygonZoffset);
-#endif
#if (IND & FFB_TRI_FLAT_BIT)
GLuint const_fg;
#endif
-#if (IND & FFB_TRI_TWOSIDE_BIT)
- int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
-#else
- const int which_color = 0;
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB: ffb_triangle ["
+#if (IND & FFB_TRI_CULL_BIT)
+ " CULL"
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ " FLAT"
+#endif
+#if (IND & FFB_TRI_ALPHA_BIT)
+ " ALPHA"
+#endif
+ " ]\n");
#endif
#if (IND & FFB_TRI_CULL_BIT)
- {
- GLfloat (*win)[4] = VB->Win.data;
- GLfloat ex = win[e1][0] - win[e0][0];
- GLfloat ey = win[e1][1] - win[e0][1];
- GLfloat fx = win[e2][0] - win[e0][0];
- GLfloat fy = win[e2][1] - win[e0][1];
+ { /* NOTE: These are not viewport transformed yet. */
+ GLfloat ex = v1->x - v0->x;
+ GLfloat ey = v1->y - v0->y;
+ GLfloat fx = v2->x - v0->x;
+ GLfloat fy = v2->y - v0->y;
GLfloat c = ex*fy-ey*fx;
/* Culled... */
- if (c * ctx->backface_sign > 0)
+ if (c * fmesa->backface_sign > fmesa->ffb_zero)
return;
}
#endif
#if (IND & FFB_TRI_FLAT_BIT)
- const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
- ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
- ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
- ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v2->color[0] );
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB_tri: const_fg %08x (B[%f] G[%f] R[%f])\n",
+ const_fg,
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].blue),
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].green),
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].red));
+#endif
#endif
- FFB_DUMP_PRIM(TRIANGLE);
#if (IND & FFB_TRI_FLAT_BIT)
FFBFifo(fmesa, 1);
ffb->fg = const_fg;
#endif
- /* First, check for a triangle strip/fan sequences.
- * These checks rely on how MESA sends these primitives
- * down to us in render_tmp.h
- */
- if (v0 == fmesa->vtx_cache[1] &&
- v1 == fmesa->vtx_cache[2] &&
- v2 != fmesa->vtx_cache[0]) {
-#if (IND & FFB_TRI_FLAT_BIT)
- FFBFifo(fmesa, 3);
-#else
-#if (IND & FFB_TRI_ALPHA_BIT)
- FFBFifo(fmesa, 7);
-#else
- FFBFifo(fmesa, 6);
-#endif
-#endif
- FFB_DUMP_VERTEX(v2);
-#if !(IND & FFB_TRI_FLAT_BIT)
-#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v2->color[which_color].alpha;
-#endif
- ffb->red = v2->color[which_color].red;
- ffb->green = v2->color[which_color].green;
- ffb->blue = v2->color[which_color].blue;
-#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v2->z + ffb_zoffset;
-#else
- ffb->z = v2->z;
-#endif
- ffb->y = v2->y;
- ffb->x = v2->x;
-
- goto update_vcache;
- } else if (v0 == fmesa->vtx_cache[0] &&
- v1 == fmesa->vtx_cache[2] &&
- v2 != fmesa->vtx_cache[1]) {
-#if (IND & FFB_TRI_FLAT_BIT)
- FFBFifo(fmesa, 3);
-#else
-#if (IND & FFB_TRI_ALPHA_BIT)
- FFBFifo(fmesa, 7);
-#else
- FFBFifo(fmesa, 6);
-#endif
-#endif
- FFB_DUMP_VERTEX(v2);
-#if !(IND & FFB_TRI_FLAT_BIT)
-#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v2->color[which_color].alpha;
-#endif
- ffb->red = v2->color[which_color].red;
- ffb->green = v2->color[which_color].green;
- ffb->blue = v2->color[which_color].blue;
-#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v2->z + ffb_zoffset;
-#else
- ffb->z = v2->z;
-#endif
- ffb->dmyf = v2->y;
- ffb->dmxf = v2->x;
-
- goto update_vcache;
- }
-
#if (IND & FFB_TRI_FLAT_BIT)
FFBFifo(fmesa, 9);
#else
@@ -129,108 +70,98 @@ static void TAG(ffb_triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, G
FFB_DUMP_VERTEX(v0);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v0->color[which_color].alpha;
-#endif
- ffb->red = v0->color[which_color].red;
- ffb->green = v0->color[which_color].green;
- ffb->blue = v0->color[which_color].blue;
+ ffb->alpha = FFB_GET_ALPHA(v0);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v0->z + ffb_zoffset;
-#else
- ffb->z = v0->z;
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
#endif
- ffb->ryf = v0->y;
- ffb->rxf = v0->x;
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
FFB_DUMP_VERTEX(v1);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
+ ffb->alpha = FFB_GET_ALPHA(v1);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
#endif
- ffb->y = v1->y;
- ffb->x = v1->x;
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
FFB_DUMP_VERTEX(v2);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v2->color[which_color].alpha;
-#endif
- ffb->red = v2->color[which_color].red;
- ffb->green = v2->color[which_color].green;
- ffb->blue = v2->color[which_color].blue;
+ ffb->alpha = FFB_GET_ALPHA(v2);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v2->z + ffb_zoffset;
-#else
- ffb->z = v2->z;
+ ffb->red = FFB_GET_RED(v2);
+ ffb->green = FFB_GET_GREEN(v2);
+ ffb->blue = FFB_GET_BLUE(v2);
#endif
- ffb->y = v2->y;
- ffb->x = v2->x;
-
-update_vcache:
- fmesa->vtx_cache[0] = (void *)v0;
- fmesa->vtx_cache[1] = (void *)v1;
- fmesa->vtx_cache[2] = (void *)v2;
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
fmesa->ffbScreen->rp_active = 1;
}
-static void TAG(ffb_quad)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, GLuint e3, GLuint pv)
+static void TAG(ffb_quad)(GLcontext *ctx,
+ ffb_vertex *v0,
+ ffb_vertex *v1,
+ ffb_vertex *v2,
+ ffb_vertex *v3 )
{
ffbContextPtr fmesa = FFB_CONTEXT(ctx);
ffb_fbcPtr ffb = fmesa->regs;
- struct vertex_buffer *VB = ctx->VB;
- ffb_vertex *ffbVB = FFB_DRIVER_DATA(VB)->verts;
- const ffb_vertex *v0 = &ffbVB[e0];
- const ffb_vertex *v1 = &ffbVB[e1];
- const ffb_vertex *v2 = &ffbVB[e2];
- const ffb_vertex *v3 = &ffbVB[e3];
-#if (IND & FFB_TRI_OFFSET_BIT)
- GLuint ffb_zoffset = FFB_Z_FROM_FLOAT(ctx->PolygonZoffset);
-#endif
#if (IND & FFB_TRI_FLAT_BIT)
GLuint const_fg;
#endif
-#if (IND & FFB_TRI_TWOSIDE_BIT)
- int which_color = (VB->ColorPtr == VB->Color[0]) ? 0 : 1;
-#else
- const int which_color = 0;
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB: ffb_quad ["
+#if (IND & FFB_TRI_CULL_BIT)
+ " CULL"
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ " FLAT"
#endif
+#if (IND & FFB_TRI_ALPHA_BIT)
+ " ALPHA"
+#endif
+ " ]\n");
+#endif /* TRI_DEBUG */
#if (IND & FFB_TRI_CULL_BIT)
- {
- GLfloat (*win)[4] = VB->Win.data;
- GLfloat ex = win[e2][0] - win[e0][0];
- GLfloat ey = win[e2][1] - win[e0][1];
- GLfloat fx = win[e3][0] - win[e1][0];
- GLfloat fy = win[e3][1] - win[e1][1];
+ { /* NOTE: These are not viewport transformed yet. */
+ GLfloat ex = v2->x - v0->x;
+ GLfloat ey = v2->y - v0->y;
+ GLfloat fx = v3->x - v1->x;
+ GLfloat fy = v3->y - v1->y;
GLfloat c = ex*fy-ey*fx;
/* Culled... */
- if (c * ctx->backface_sign > 0)
+ if (c * fmesa->backface_sign > fmesa->ffb_zero)
return;
}
#endif
#if (IND & FFB_TRI_FLAT_BIT)
- const_fg = (((GLuint)VB->Color[which_color]->data[pv][0] << 0) |
- ((GLuint)VB->Color[which_color]->data[pv][1] << 8) |
- ((GLuint)VB->Color[which_color]->data[pv][2] << 16) |
- ((GLuint)VB->Color[which_color]->data[pv][3] << 24));
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v3->color[0] );
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB_quad: const_fg %08x (B[%f] G[%f] R[%f])\n",
+ const_fg,
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].blue),
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].green),
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].red));
+#endif
#endif
- FFB_DUMP_PRIM(QUAD);
#if (IND & FFB_TRI_FLAT_BIT)
FFBFifo(fmesa, 13);
@@ -246,75 +177,59 @@ static void TAG(ffb_quad)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2, GLuin
FFB_DUMP_VERTEX(v0);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v0->color[which_color].alpha;
+ ffb->alpha = FFB_GET_ALPHA(v0);
#endif
- ffb->red = v0->color[which_color].red;
- ffb->green = v0->color[which_color].green;
- ffb->blue = v0->color[which_color].blue;
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v0->z + ffb_zoffset;
-#else
- ffb->z = v0->z;
-#endif
- ffb->ryf = v0->y;
- ffb->rxf = v0->x;
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
FFB_DUMP_VERTEX(v1);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v1->color[which_color].alpha;
-#endif
- ffb->red = v1->color[which_color].red;
- ffb->green = v1->color[which_color].green;
- ffb->blue = v1->color[which_color].blue;
+ ffb->alpha = FFB_GET_ALPHA(v1);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v1->z + ffb_zoffset;
-#else
- ffb->z = v1->z;
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
#endif
- ffb->y = v1->y;
- ffb->x = v1->x;
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
FFB_DUMP_VERTEX(v2);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v2->color[which_color].alpha;
+ ffb->alpha = FFB_GET_ALPHA(v2);
#endif
- ffb->red = v2->color[which_color].red;
- ffb->green = v2->color[which_color].green;
- ffb->blue = v2->color[which_color].blue;
+ ffb->red = FFB_GET_RED(v2);
+ ffb->green = FFB_GET_GREEN(v2);
+ ffb->blue = FFB_GET_BLUE(v2);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v2->z + ffb_zoffset;
-#else
- ffb->z = v2->z;
-#endif
- ffb->y = v2->y;
- ffb->x = v2->x;
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
FFB_DUMP_VERTEX(v3);
#if !(IND & FFB_TRI_FLAT_BIT)
#if (IND & FFB_TRI_ALPHA_BIT)
- ffb->alpha = v3->color[which_color].alpha;
-#endif
- ffb->red = v3->color[which_color].red;
- ffb->green = v3->color[which_color].green;
- ffb->blue = v3->color[which_color].blue;
+ ffb->alpha = FFB_GET_ALPHA(v3);
#endif
-#if (IND & FFB_TRI_OFFSET_BIT)
- ffb->z = v3->z + ffb_zoffset;
-#else
- ffb->z = v3->z;
+ ffb->red = FFB_GET_RED(v3);
+ ffb->green = FFB_GET_GREEN(v3);
+ ffb->blue = FFB_GET_BLUE(v3);
#endif
- ffb->dmyf = v3->y;
- ffb->dmxf = v3->x;
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
fmesa->ffbScreen->rp_active = 1;
}
-static void TAG(init)(void)
+static void TAG(ffb_init)(void)
{
ffb_tri_tab[IND] = TAG(ffb_triangle);
ffb_quad_tab[IND] = TAG(ffb_quad);
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
index 9053a58d0..f4072a0f9 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c
@@ -1,7 +1,7 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c,v 1.3 2001/11/08 04:00:12 tsi Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -29,292 +29,212 @@
#include "ffb_context.h"
#include "ffb_vb.h"
#include "mem.h"
-#include "stages.h"
-
-#define COL { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->color[0].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
- v->color[0].red = FFB_COLOR_FROM_UBYTE(col[0]); \
- v->color[0].green = FFB_COLOR_FROM_UBYTE(col[1]); \
- v->color[0].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
-}
+#include "tnl/t_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
-#define COL2 { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->color[0].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
- v->color[0].red = FFB_COLOR_FROM_UBYTE(col[0]); \
- v->color[0].green = FFB_COLOR_FROM_UBYTE(col[1]); \
- v->color[0].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
- \
- col = &(VB->Color[1]->data[i][0]); \
- v->color[1].alpha = FFB_COLOR_FROM_UBYTE(col[3]); \
- v->color[1].red = FFB_COLOR_FROM_UBYTE(col[0]); \
- v->color[1].green = FFB_COLOR_FROM_UBYTE(col[1]); \
- v->color[1].blue = FFB_COLOR_FROM_UBYTE(col[2]); \
-}
+#undef VB_DEBUG
-#define COORD { \
- GLfloat *win = VB->Win.data[i]; \
- GLfloat tmp; \
- tmp = win[0] + ffbxoff; \
- v->x = FFB_COORD_FROM_FLOAT(tmp); \
- tmp = - win[1] + ffbyoff; \
- v->y = FFB_COORD_FROM_FLOAT(tmp); \
- tmp = win[2] * (1.0f / 65536.0f); \
- v->z = FFB_Z_FROM_FLOAT(tmp); \
-}
-
-#define NOP
-
-#define SETUPFUNC(name,win,col) \
-static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
-{ \
- ffbContextPtr fmesa = FFB_CONTEXT(VB->ctx); \
- __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
- ffb_vertex *v; \
- GLfloat ffbxoff = dPriv->x - 0.5; \
- GLfloat ffbyoff = dPriv->h - 0.5 + dPriv->y; \
- int i; \
- (void) fmesa; (void) ffbxoff; (void) ffbyoff; \
- \
- if (0) \
- fprintf(stderr, #name ": VB(%p) start(%d) end(%d)\n", \
- VB, start, end); \
- /* Flush the vertex cache. */ \
- fmesa->vtx_cache[0] = fmesa->vtx_cache[1] = \
- fmesa->vtx_cache[2] = fmesa->vtx_cache[3] = NULL; \
- gl_import_client_data(VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE | VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE)); \
- \
- v = &(FFB_DRIVER_DATA(VB)->verts[start]); \
- \
- if (VB->ClipOrMask == 0) { \
- for (i = start; i < end; i++, v++) { \
- win; \
- col; \
- } \
- } else { \
- for (i = start; i < end; i++, v++) { \
- if (VB->ClipMask[i] == 0) { \
- win; \
- } \
- col; \
- } \
- } \
-}
+static void ffb_copy_pv_oneside(GLcontext *ctx, GLuint edst, GLuint esrc)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *dst = &fmesa->verts[edst];
+ ffb_vertex *src = &fmesa->verts[esrc];
-SETUPFUNC(rs_w, COORD,NOP)
-SETUPFUNC(rs_g, NOP,COL)
-SETUPFUNC(rs_g2, NOP,COL2)
-SETUPFUNC(rs_wg, COORD,COL)
-SETUPFUNC(rs_wg2, COORD,COL2)
+#ifdef VB_DEBUG
+ fprintf(stderr, "ffb_copy_pv_oneside: edst(%d) esrc(%d)\n", edst, esrc);
+#endif
+ dst->color[0].alpha = src->color[0].alpha;
+ dst->color[0].red = src->color[0].red;
+ dst->color[0].green = src->color[0].green;
+ dst->color[0].blue = src->color[0].blue;
+}
-static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
+static void ffb_copy_pv_twoside(GLcontext *ctx, GLuint edst, GLuint esrc)
{
- fprintf(stderr, "ffbRasterSetup(): invalid setup function\n");
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *dst = &fmesa->verts[edst];
+ ffb_vertex *src = &fmesa->verts[esrc];
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "ffb_copy_pv_twoside: edst(%d) esrc(%d)\n", edst, esrc);
+#endif
+ dst->color[0].alpha = src->color[0].alpha;
+ dst->color[0].red = src->color[0].red;
+ dst->color[0].green = src->color[0].green;
+ dst->color[0].blue = src->color[0].blue;
+ dst->color[1].alpha = src->color[1].alpha;
+ dst->color[1].red = src->color[1].red;
+ dst->color[1].green = src->color[1].green;
+ dst->color[1].blue = src->color[1].blue;
}
-typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint);
+#define FFB_VB_RGBA_BIT 0x01
+#define FFB_VB_XYZ_BIT 0x02
+#define FFB_VB_TWOSIDE_BIT 0x04
+#define FFB_VB_MAX 0x08
+
+typedef void (*emit_func)(GLcontext *, GLuint, GLuint);
-static setupFunc setup_func[8];
+static struct {
+ emit_func emit;
+ interp_func interp;
+} setup_tab[FFB_VB_MAX];
-void ffbDDSetupInit(void)
+static void do_import(struct vertex_buffer *VB,
+ struct gl_client_array *to,
+ struct gl_client_array *from)
{
- int i;
+ GLuint count = VB->Count;
- for (i = 0; i < 4; i++)
- setup_func[i] = rs_invalid;
+ if (!to->Ptr) {
+ to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLfloat), 32 );
+ to->Type = GL_FLOAT;
+ }
- setup_func[FFB_VB_WIN_BIT] = rs_w;
- setup_func[FFB_VB_RGBA_BIT] = rs_g;
- setup_func[FFB_VB_RGBA_BIT|FFB_VB_TWOSIDE_BIT] = rs_g2;
- setup_func[FFB_VB_WIN_BIT|FFB_VB_RGBA_BIT] = rs_wg;
- setup_func[FFB_VB_WIN_BIT|FFB_VB_RGBA_BIT|FFB_VB_TWOSIDE_BIT] = rs_wg2;
+ /* No need to transform the same value 3000 times. */
+ if (!from->StrideB) {
+ to->StrideB = 0;
+ count = 1;
+ } else
+ to->StrideB = 4 * sizeof(GLfloat);
+
+ _math_trans_4f((GLfloat (*)[4]) to->Ptr,
+ from->Ptr, from->StrideB,
+ from->Type, from->Size,
+ 0, count);
}
-static void ffbPrintSetupFlags(char *msg, GLuint flags)
+static __inline__ void ffbImportColors(ffbContextPtr fmesa, GLcontext *ctx, int index)
{
- fprintf(stderr, "%s: %x %s%s%s\n",
- msg, flags,
- (flags & FFB_VB_WIN_BIT) ? " xyz," : "",
- (flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "",
- (flags & FFB_VB_RGBA_BIT) ? " rgba," : "");
+ struct gl_client_array *to = &fmesa->FloatColor;
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ do_import(VB, to, VB->ColorPtr[index]);
+ VB->ColorPtr[index] = to;
}
-void ffbChooseRasterSetupFunc(GLcontext *ctx)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- int funcindex;
-
- /* Currently just one full vertex setup type. */
- funcindex = FFB_VB_WIN_BIT | FFB_VB_RGBA_BIT;
+#define IND (FFB_VB_XYZ_BIT)
+#define TAG(x) x##_w
+#include "ffb_vbtmp.h"
- if (ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
- funcindex |= FFB_VB_TWOSIDE_BIT;
+#define IND (FFB_VB_RGBA_BIT)
+#define TAG(x) x##_g
+#include "ffb_vbtmp.h"
- if (MESA_VERBOSE)
- ffbPrintSetupFlags("ffb: full setup function", funcindex);
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "ffb_vbtmp.h"
- fmesa->setupindex = funcindex;
- ctx->Driver.RasterSetup = setup_func[funcindex];
-}
+#define IND (FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_t
+#include "ffb_vbtmp.h"
-void ffbDDCheckPartialRasterSetup(GLcontext *ctx, struct gl_pipeline_stage *d)
-{
- ffbContextPtr fmesa = FFB_CONTEXT(ctx);
- GLuint tmp = fmesa->setupdone;
-
- d->type = 0;
- fmesa->setupdone = 0;
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_wt
+#include "ffb_vbtmp.h"
- if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
- return;
+#define IND (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_gt
+#include "ffb_vbtmp.h"
- if (ctx->IndirectTriangles)
- return;
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_wgt
+#include "ffb_vbtmp.h"
- fmesa->setupdone = tmp;
+static void init_setup_tab( void )
+{
+ init_w();
+ init_g();
+ init_wg();
+ init_t();
+ init_wt();
+ init_gt();
+ init_wgt();
}
-void ffbDDPartialRasterSetup(struct vertex_buffer *VB)
+#ifdef VB_DEBUG
+static void ffbPrintSetupFlags(char *msg, GLuint flags)
{
-#if 0
- ffbContextPtr fmesa = FFB_CONTEXT(VB->ctx);
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
+ fprintf(stderr, "%s(%x): %s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & FFB_VB_XYZ_BIT) ? " xyz," : "",
+ (flags & FFB_VB_RGBA_BIT) ? " rgba," : "",
+ (flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "");
+}
#endif
- GLuint ind = 0;
-#if 1
- ind = FFB_VB_WIN_BIT | FFB_VB_RGBA_BIT;
- if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
- ind |= FFB_VB_TWOSIDE_BIT;
-#else
- if (new & VERT_WIN) {
- new = available;
- ind |= FFB_VB_WIN_BIT;
- }
- if (new & VERT_RGBA)
- ind |= FFB_VB_RGBA_BIT;
-#endif
+static void ffbDDBuildVertices(GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
-#if 0
- fmesa->setupdone &= ~ind;
- ind &= fmesa->setupindex;
- fmesa->setupdone |= ind;
-#endif
+ newinputs |= fmesa->setupnewinputs;
+ fmesa->setupnewinputs = 0;
- if (MESA_VERBOSE)
- ffbPrintSetupFlags("ffb: partial setup function", ind);
+ if (!newinputs)
+ return;
- if (ind)
- setup_func[ind](VB, VB->Start, VB->Count);
-}
+ if (newinputs & VERT_CLIP) {
+ setup_tab[fmesa->setupindex].emit(ctx, start, count);
+ } else {
+ GLuint ind = 0;
-void ffbDDDoRasterSetup(struct vertex_buffer *VB)
-{
- GLcontext *ctx = VB->ctx;
+ if (newinputs & VERT_RGBA)
+ ind |= (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT);
+
+ ind &= fmesa->setupindex;
- if (VB->Type == VB_CVA_PRECALC)
- ffbDDPartialRasterSetup(VB);
- else if (ctx->Driver.RasterSetup)
- ctx->Driver.RasterSetup(VB, VB->CopyStart, VB->Count);
+ if (ind)
+ setup_tab[ind].emit(ctx, start, count);
+ }
}
-void ffbDDResizeVB(struct vertex_buffer *VB, GLuint size)
+void ffbChooseVertexState( GLcontext *ctx )
{
- FFBVertexBufferPtr mvb = FFB_DRIVER_DATA(VB);
-
- while (mvb->size < size)
- mvb->size *= 2;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ int ind = FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT;
- free(mvb->verts);
- mvb->verts = (ffb_vertex *)malloc(sizeof(ffb_vertex) * mvb->size);
- if (!mvb->verts) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
+ if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+ ind |= FFB_VB_TWOSIDE_BIT;
- gl_vector1ui_free(&mvb->clipped_elements);
- gl_vector1ui_alloc(&mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32);
- if (!mvb->clipped_elements.start) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
+#ifdef VB_DEBUG
+ ffbPrintSetupFlags("ffb: full setup function", ind);
+#endif
- ALIGN_FREE(VB->ClipMask);
- VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
- if (!VB->ClipMask) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
+ fmesa->setupindex = ind;
- if (VB->Type == VB_IMMEDIATE) {
- free(mvb->primitive);
- free(mvb->next_primitive);
- mvb->primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
- mvb->next_primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
- if (!mvb->primitive || !mvb->next_primitive) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
- }
+ tnl->Driver.Render.BuildVertices = ffbDDBuildVertices;
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ if (ind & FFB_VB_TWOSIDE_BIT)
+ tnl->Driver.Render.CopyPV = ffb_copy_pv_twoside;
+ else
+ tnl->Driver.Render.CopyPV = ffb_copy_pv_oneside;
}
-void ffbDDRegisterVB(struct vertex_buffer *VB)
+void ffbInitVB( GLcontext *ctx )
{
- FFBVertexBufferPtr mvb;
-
- mvb = (FFBVertexBufferPtr) calloc(1, sizeof(*mvb));
- if (!mvb) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
- mvb->size = VB->Size * 2;
- mvb->verts = (ffb_vertex *) malloc(sizeof(ffb_vertex) * mvb->size);
- if (!mvb->verts) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
-
- gl_vector1ui_alloc(&mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32);
- if (!mvb->clipped_elements.start) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- ALIGN_FREE(VB->ClipMask);
- VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
- if (!VB->ClipMask) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
- }
+ fmesa->verts = (ffb_vertex *)ALIGN_MALLOC(size * sizeof(ffb_vertex), 32);
- mvb->primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
- mvb->next_primitive = (GLuint *)malloc(sizeof(GLuint) * mvb->size);
- if (!mvb->primitive || !mvb->next_primitive) {
- fprintf(stderr, "ffb-glx: out of memory !\n");
- exit(1);
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
}
-
- VB->driver_data = mvb;
}
-void ffbDDUnregisterVB(struct vertex_buffer *VB)
+
+void ffbFreeVB( GLcontext *ctx )
{
- FFBVertexBufferPtr mvb = FFB_DRIVER_DATA(VB);
-
- if (mvb) {
- if (mvb->verts)
- free(mvb->verts);
- if (mvb->primitive)
- free(mvb->primitive);
- if (mvb->next_primitive)
- free(mvb->next_primitive);
- gl_vector1ui_free(&mvb->clipped_elements);
- free(mvb);
- VB->driver_data = 0;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ if (fmesa->verts) {
+ ALIGN_FREE(fmesa->verts);
+ fmesa->verts = 0;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h
index 29051bdb7..fb4da39af 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h
@@ -3,61 +3,44 @@
#ifndef _FFB_VB_H
#define _FFB_VB_H
-#include "vb.h"
-#include "types.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "mmath.h"
+#include "tnl/t_context.h"
+#include "swrast/swrast.h"
-/* Use this to disable ffb VB processing, presumable to try
- * and isolate bugs.
- */
-#undef FFB_VB_DISABLE
+#define __FFB_2_30_FIXED_SCALE 1073741824.0f
+#define FFB_2_30_FLOAT_TO_FIXED(X) \
+ (IROUND((X) * fmesa->ffb_2_30_fixed_scale))
+#define FFB_2_30_FIXED_TO_FLOAT(X) \
+ (((GLfloat)(X)) * fmesa->ffb_one_over_2_30_fixed_scale)
-/* These are all in 2:30 signed fixed point format. */
-typedef struct {
- GLuint alpha;
- GLuint red;
- GLuint green;
- GLuint blue;
-} ffb_color;
+#define __FFB_16_16_FIXED_SCALE 65536.0f
+#define FFB_16_16_FLOAT_TO_FIXED(X) \
+ (IROUND((X) * fmesa->ffb_16_16_fixed_scale))
+#define FFB_16_16_FIXED_TO_FLOAT(X) \
+ (((GLfloat)(X)) * fmesa->ffb_one_over_16_16_fixed_scale)
-#define FFB_COLOR_FROM_UBYTE(VAL) (((((GLuint)(VAL)) + 1) & (255 << 1)) << (30 - 8))
+#define FFB_Z_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
+#define FFB_Z_TO_FLOAT(VAL) FFB_2_30_FIXED_TO_FLOAT(VAL)
+#define FFB_XY_FROM_FLOAT(VAL) FFB_16_16_FLOAT_TO_FIXED(VAL)
+#define FFB_XY_TO_FLOAT(VAL) FFB_16_16_FIXED_TO_FLOAT(VAL)
-typedef struct {
- /* As for colors, this is in 2:30 signed fixed point. */
- GLint z;
+#define FFB_UBYTE_FROM_COLOR(VAL) ((IROUND((VAL) * fmesa->ffb_ubyte_color_scale)))
- /* These are in 16:16 fixed point. */
- GLuint y, x;
+#define FFB_PACK_CONST_UBYTE_ARGB_COLOR(C) \
+ ((FFB_UBYTE_FROM_COLOR(C.alpha) << 24) | \
+ (FFB_UBYTE_FROM_COLOR(C.blue) << 16) | \
+ (FFB_UBYTE_FROM_COLOR(C.green) << 8) | \
+ (FFB_UBYTE_FROM_COLOR(C.red) << 0))
- ffb_color color[2];
-} ffb_vertex;
+#define FFB_COLOR_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
-#define FFB_Z_FROM_FLOAT(VAL) ((GLint)((VAL) * 1073741824.0f))
-#define FFB_COORD_FROM_FLOAT(VAL) ((GLuint)((VAL) * 65536.0f))
-
-struct ffb_vertex_buffer_t {
- GLvector1ui clipped_elements;
- ffb_vertex *verts;
- int last_virt;
- GLuint *primitive;
- GLuint *next_primitive;
- GLuint size;
-};
-
-typedef struct ffb_vertex_buffer_t *FFBVertexBufferPtr;
-
-#define FFB_DRIVER_DATA(vb) ((FFBVertexBufferPtr)((vb)->driver_data))
-
-#define FFB_VB_RGBA_BIT 0x01
-#define FFB_VB_WIN_BIT 0x02
-#define FFB_VB_TWOSIDE_BIT 0x04
+#define _FFB_NEW_VERTEX (_DD_NEW_TRI_LIGHT_TWOSIDE)
extern void ffbDDSetupInit(void);
-extern void ffbChooseRasterSetupFunc(GLcontext *);
-extern void ffbDDCheckPartialRasterSetup(GLcontext *, struct gl_pipeline_stage *);
-extern void ffbDDPartialRasterSetup(struct vertex_buffer *);
-extern void ffbDDDoRasterSetup(struct vertex_buffer *);
-extern void ffbDDResizeVB(struct vertex_buffer *, GLuint);
-extern void ffbDDRegisterVB(struct vertex_buffer *);
-extern void ffbDDUnregisterVB(struct vertex_buffer *);
+extern void ffbChooseVertexState(GLcontext *);
+extern void ffbInitVB( GLcontext *ctx );
+extern void ffbFreeVB( GLcontext *ctx );
#endif /* !(_FFB_VB_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h
new file mode 100644
index 000000000..dc0fd2a3f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h
@@ -0,0 +1,177 @@
+/* $XFree86$ */
+
+static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+#if (IND & (FFB_VB_RGBA_BIT))
+ GLfloat (*col0)[4];
+ GLuint col0_stride;
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ GLfloat (*col1)[4];
+ GLuint col1_stride;
+#endif
+#endif
+#if (IND & FFB_VB_XYZ_BIT)
+ GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLuint proj_stride = VB->ProjectedClipPtr->stride;
+ const GLubyte *mask = VB->ClipMask;
+#endif
+ ffb_vertex *v = &fmesa->verts[start];
+ int i;
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "FFB: ffb_emit ["
+#if (IND & (FFB_VB_XYZ_BIT))
+ " XYZ"
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ " RGBA"
+#endif
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ " TWOSIDE"
+#endif
+ "] start(%d) end(%d) import(%d)\n",
+ start, end,
+ VB->importable_data);
+#endif
+
+#if (IND & (FFB_VB_RGBA_BIT))
+ if (VB->ColorPtr[0]->Type != GL_FLOAT)
+ ffbImportColors(fmesa, ctx, 0);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ if (VB->ColorPtr[1]->Type != GL_FLOAT)
+ ffbImportColors(fmesa, ctx, 1);
+#endif
+ col0 = (GLfloat (*)[4]) VB->ColorPtr[0]->Ptr;
+ col0_stride = VB->ColorPtr[0]->StrideB;
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ col1 = (GLfloat (*)[4]) VB->ColorPtr[1]->Ptr;
+ col1_stride = VB->ColorPtr[1]->StrideB;
+#endif
+#endif
+
+ if (VB->importable_data) {
+ if (start) {
+#if (IND & (FFB_VB_XYZ_BIT))
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ col0 = (GLfloat (*)[4])((GLubyte *)col0 + start * col0_stride);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ col1 = (GLfloat (*)[4])((GLubyte *)col1 + start * col1_stride);
+#endif
+#endif
+ }
+ for (i = start; i < end; i++, v++) {
+#if (IND & (FFB_VB_XYZ_BIT))
+ if (mask[i] == 0) {
+ v->x = proj[0][0];
+ v->y = proj[0][1];
+ v->z = proj[0][2];
+ }
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ v->color[0].alpha = CLAMP(col0[0][3], 0.0f, 1.0f);
+ v->color[0].red = CLAMP(col0[0][0], 0.0f, 1.0f);
+ v->color[0].green = CLAMP(col0[0][1], 0.0f, 1.0f);
+ v->color[0].blue = CLAMP(col0[0][2], 0.0f, 1.0f);
+ col0 = (GLfloat (*)[4])((GLubyte *)col0 + col0_stride);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ v->color[1].alpha = CLAMP(col1[0][3], 0.0f, 1.0f);
+ v->color[1].red = CLAMP(col1[0][0], 0.0f, 1.0f);
+ v->color[1].green = CLAMP(col1[0][1], 0.0f, 1.0f);
+ v->color[1].blue = CLAMP(col1[0][2], 0.0f, 1.0f);
+ col1 = (GLfloat (*)[4])((GLubyte *)col1 + col1_stride);
+#endif
+#endif
+ }
+ } else {
+ for (i = start; i < end; i++, v++) {
+#if (IND & (FFB_VB_XYZ_BIT))
+ if (mask[i] == 0) {
+ v->x = proj[i][0];
+ v->y = proj[i][1];
+ v->z = proj[i][2];
+ }
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ v->color[0].alpha = CLAMP(col0[i][3], 0.0f, 1.0f);
+ v->color[0].red = CLAMP(col0[i][0], 0.0f, 1.0f);
+ v->color[0].green = CLAMP(col0[i][1], 0.0f, 1.0f);
+ v->color[0].blue = CLAMP(col0[i][2], 0.0f, 1.0f);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ v->color[1].alpha = CLAMP(col1[i][3], 0.0f, 1.0f);
+ v->color[1].red = CLAMP(col1[i][0], 0.0f, 1.0f);
+ v->color[1].green = CLAMP(col1[i][1], 0.0f, 1.0f);
+ v->color[1].blue = CLAMP(col1[i][2], 0.0f, 1.0f);
+#endif
+#endif
+ }
+ }
+}
+
+static void TAG(interp)(GLcontext *ctx, GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary)
+{
+#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+#endif
+#if (IND & (FFB_VB_XYZ_BIT))
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat oow = 1.0 / dstclip[3];
+#endif
+#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
+ ffb_vertex *dst = &fmesa->verts[edst];
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ ffb_vertex *in = &fmesa->verts[eout];
+ ffb_vertex *out = &fmesa->verts[ein];
+#endif
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "FFB: ffb_interp ["
+#if (IND & (FFB_VB_XYZ_BIT))
+ " XYZ"
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ " RGBA"
+#endif
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ " TWOSIDE"
+#endif
+ "] edst(%d) eout(%d) ein(%d)\n",
+ edst, eout, ein);
+#endif
+
+#if (IND & (FFB_VB_XYZ_BIT))
+ dst->x = dstclip[0] * oow;
+ dst->y = dstclip[1] * oow;
+ dst->z = dstclip[2] * oow;
+#endif
+
+#if (IND & (FFB_VB_RGBA_BIT))
+ INTERP_F(t, dst->color[0].alpha, out->color[0].alpha, in->color[0].alpha);
+ INTERP_F(t, dst->color[0].red, out->color[0].red, in->color[0].red);
+ INTERP_F(t, dst->color[0].green, out->color[0].green, in->color[0].green);
+ INTERP_F(t, dst->color[0].blue, out->color[0].blue, in->color[0].blue);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ INTERP_F(t, dst->color[1].alpha, out->color[1].alpha, in->color[1].alpha);
+ INTERP_F(t, dst->color[1].red, out->color[1].red, in->color[1].red);
+ INTERP_F(t, dst->color[1].green, out->color[1].green, in->color[1].green);
+ INTERP_F(t, dst->color[1].blue, out->color[1].blue, in->color[1].blue);
+#endif
+#endif
+}
+
+static void TAG(init)(void)
+{
+ setup_tab[IND].emit = TAG(emit);
+ setup_tab[IND].interp = TAG(interp);
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.c
new file mode 100644
index 000000000..ab5bd933b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.c
@@ -0,0 +1,429 @@
+/* $XFree86$
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "glheader.h"
+#include "api_noop.h"
+#include "context.h"
+#include "light.h"
+#include "macros.h"
+#include "mem.h"
+#include "mmath.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "vtxfmt.h"
+#include "ffb_xmesa.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "ffb_vtxfmt.h"
+
+#ifndef __GNUC__
+#define __inline /**/
+#endif
+
+#define TNL_VERTEX ffbTnlVertex
+
+#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
+
+#define INTERP_RGBA(t, out, a, b) \
+do { \
+ GLint i; \
+ for ( i = 0 ; i < 4 ; i++ ) { \
+ GLfloat fa = a[i]; \
+ GLfloat fb = b[i]; \
+ out[i] = LINTERP( t, fa, fb ); \
+ } \
+} while (0)
+
+/* Color functions: */
+
+static __inline void ffb_recalc_base_color(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct gl_light *light;
+
+ COPY_3V(fmesa->vtx_state.light.base_color, ctx->Light._BaseColor[0]);
+ foreach (light, &ctx->Light.EnabledList) {
+ ACC_3V(fmesa->vtx_state.light.base_color,
+ light->_MatAmbient[0]);
+ }
+
+ fmesa->vtx_state.light.base_alpha = ctx->Light._BaseAlpha[0];
+}
+
+#define GET_CURRENT \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define CURRENT_COLOR(COMP) fmesa->vtx_state.current.color[COMP]
+#define CURRENT_SPECULAR(COMP) fmesa->vtx_state.current.specular[COMP]
+#define COLOR_IS_FLOAT
+#define RECALC_BASE_COLOR(ctx) ffb_recalc_base_color(ctx)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_capi.h"
+
+/* Normal functions: */
+
+struct ffb_norm_tab {
+ void (*normal3f_multi)(GLfloat x, GLfloat y, GLfloat z);
+ void (*normal3fv_multi)(const GLfloat *v);
+ void (*normal3f_single)(GLfloat x, GLfloat y, GLfloat z);
+ void (*normal3fv_single)(const GLfloat *v);
+};
+
+static struct ffb_norm_tab norm_tab[0x4];
+
+#define HAVE_HW_LIGHTING 0
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffbTnlVertexPtr v = fmesa->imm.v0
+
+#define CURRENT_NORMAL fmesa->vtx_state.current.normal
+#define BASE_COLOR fmesa->vtx_state.light.base_color
+#define BASE_ALPHA fmesa->vtx_state.light.base_alpha
+#define VERT_COLOR( COMP ) v->color[COMP]
+#define VERT_COLOR_IS_FLOAT
+
+#define IND (0)
+#define TAG(x) ffb_##x
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_RESCALE)
+#define TAG(x) ffb_##x##_rescale
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_NORMALIZE)
+#define TAG(x) ffb_##x##_normalize
+#include "tnl_dd/t_dd_imm_napi.h"
+
+static void ffb_init_norm_funcs(void)
+{
+ ffb_init_norm();
+ ffb_init_norm_rescale();
+ ffb_init_norm_normalize();
+}
+
+static void choose_normals(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint index;
+
+ if (ctx->Light.Enabled) {
+ if (ctx->Transform.Normalize) {
+ index = NORM_NORMALIZE;
+ } else if (!ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ index = NORM_RESCALE;
+ } else {
+ index = 0;
+ }
+
+ if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) {
+ ctx->Exec->Normal3f = norm_tab[index].normal3f_single;
+ ctx->Exec->Normal3fv = norm_tab[index].normal3fv_single;
+ } else {
+ ctx->Exec->Normal3f = norm_tab[index].normal3f_multi;
+ ctx->Exec->Normal3fv = norm_tab[index].normal3fv_multi;
+ }
+ } else {
+ ctx->Exec->Normal3f = _mesa_noop_Normal3f;
+ ctx->Exec->Normal3fv = _mesa_noop_Normal3fv;
+ }
+}
+
+static void ffb_choose_Normal3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ choose_normals();
+ glNormal3f(x, y, z);
+}
+
+static void ffb_choose_Normal3fv(const GLfloat *v)
+{
+ choose_normals();
+ glNormal3fv(v);
+}
+
+/* Vertex functions: */
+
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffbTnlVertexPtr v = fmesa->imm.v0
+
+#define CURRENT_VERTEX v->obj
+#define SAVE_VERTEX fmesa->imm.save_vertex(ctx, v)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_vapi.h"
+
+struct ffb_vert_tab {
+ void (*save_vertex)(GLcontext *ctx, ffbTnlVertexPtr v);
+ void (*interpolate_vertex)(GLfloat t,
+ ffbTnlVertex *O,
+ const ffbTnlVertex *I,
+ const ffbTnlVertex *J);
+};
+
+static struct ffb_vert_tab vert_tab[0xf];
+
+#define VTX_NORMAL 0x0
+#define VTX_RGBA 0x1
+
+#define LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define CURRENT_COLOR fmesa->vtx_state.current.color
+#define COLOR_IS_FLOAT
+#define FLUSH_VERTEX fmesa->imm.flush_vertex( ctx, v );
+
+#define IND (VTX_NORMAL)
+#define TAG(x) ffb_##x##_NORMAL
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_RGBA)
+#define TAG(x) ffb_##x##_RGBA
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+static void ffb_init_vert_funcs( void )
+{
+ ffb_init_vert_NORMAL();
+ ffb_init_vert_RGBA();
+}
+
+#define LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define GET_INTERP_FUNC \
+ ffb_interp_func interp = fmesa->imm.interp
+
+#define FLUSH_VERTEX fmesa->imm.flush_vertex
+#define IMM_VERTEX( V ) fmesa->imm.V
+#define IMM_VERTICES( n ) fmesa->imm.vertices[n]
+
+#define EMIT_VERTEX_USES_HWREGS
+
+/* XXX Implement me XXX */
+#define EMIT_VERTEX_TRI(VTX0, VTX1, VTX2) \
+ do { } while (0)
+#define EMIT_VERTEX_LINE(VTX0, VTX1) \
+ do { } while (0)
+#define EMIT_VERTEX_POINT(VTX0) \
+ do { } while (0)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+/* Bzzt: Material changes are lost on fallback. */
+static void ffb_Materialfv(GLenum face, GLenum pname,
+ const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ _mesa_noop_Materialfv( face, pname, params );
+ ffb_recalc_base_color( ctx );
+}
+
+/* Fallback functions: */
+
+static void ffb_do_fallback(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct ffb_current_state *current = &fmesa->vtx_state.current;
+
+ /* Tell tnl to restore its exec vtxfmt, rehook its driver callbacks
+ * and revive internal state that depended on those callbacks:
+ */
+ _tnl_wakeup_exec(ctx);
+
+ /* Replay enough vertices that the current primitive is continued
+ * correctly:
+ */
+ if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END )
+ glBegin(fmesa->imm.prim);
+
+ if (ctx->Light.Enabled) {
+ glColor4fv(ctx->Current.Color); /* Catch ColorMaterial */
+ glNormal3fv(current->normal);
+ } else {
+ glColor4fv(current->color);
+ }
+}
+
+#define PRE_LOOPBACK( FUNC ) do { \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffb_do_fallback( ctx ); \
+} while (0)
+
+#define TAG(x) ffb_fallback_##x
+#include "vtxfmt_tmp.h"
+
+static void ffb_Begin(GLenum prim)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (prim > GL_POLYGON) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ ctx->Driver.NeedFlush |= (FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+
+ fmesa->imm.prim = prim;
+ fmesa->imm.v0 = &fmesa->imm.vertices[0];
+ fmesa->imm.save_vertex = ffb_save_vertex_RGBA;
+ fmesa->imm.flush_vertex = ffb_flush_tab[prim];
+
+ /* XXX Lock hardware, update FBC, PPC, DRAWOP, etc. XXX */
+}
+
+static void ffb_End(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (fmesa->imm.prim == PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ ctx->Driver.NeedFlush &= ~(FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+
+ /* XXX Unlock hardware, etc. */
+}
+
+void ffbInitTnlModule(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLvertexformat *vfmt = &(fmesa->imm.vtxfmt);
+
+ /* Work in progress... */
+ return;
+
+ ffb_init_norm_funcs();
+ ffb_init_vert_funcs();
+
+ MEMSET(vfmt, 0, sizeof(GLvertexformat));
+
+ /* Handled fully in supported states: */
+ vfmt->ArrayElement = NULL; /* FIXME: ... */
+ vfmt->Color3f = ffb_choose_Color3f;
+ vfmt->Color3fv = ffb_choose_Color3fv;
+ vfmt->Color3ub = ffb_choose_Color3ub;
+ vfmt->Color3ubv = ffb_choose_Color3ubv;
+ vfmt->Color4f = ffb_choose_Color4f;
+ vfmt->Color4fv = ffb_choose_Color4fv;
+ vfmt->Color4ub = ffb_choose_Color4ub;
+ vfmt->Color4ubv = ffb_choose_Color4ubv;
+ vfmt->FogCoordfvEXT = ffb_FogCoordfvEXT;
+ vfmt->FogCoordfEXT = ffb_FogCoordfEXT;
+ vfmt->Materialfv = ffb_Materialfv;
+ vfmt->MultiTexCoord1fARB = ffb_fallback_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = ffb_fallback_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = ffb_fallback_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = ffb_fallback_MultiTexCoord2fvARB;
+ vfmt->MultiTexCoord3fARB = ffb_fallback_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = ffb_fallback_MultiTexCoord3fvARB;
+ vfmt->MultiTexCoord4fARB = ffb_fallback_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = ffb_fallback_MultiTexCoord4fvARB;
+ vfmt->Normal3f = ffb_choose_Normal3f;
+ vfmt->Normal3fv = ffb_choose_Normal3fv;
+ vfmt->SecondaryColor3ubEXT = ffb_SecondaryColor3ubEXT;
+ vfmt->SecondaryColor3ubvEXT = ffb_SecondaryColor3ubvEXT;
+ vfmt->SecondaryColor3fEXT = ffb_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = ffb_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = ffb_fallback_TexCoord1f;
+ vfmt->TexCoord1fv = ffb_fallback_TexCoord1fv;
+ vfmt->TexCoord2f = ffb_fallback_TexCoord2f;
+ vfmt->TexCoord2fv = ffb_fallback_TexCoord2fv;
+ vfmt->TexCoord3f = ffb_fallback_TexCoord3f;
+ vfmt->TexCoord3fv = ffb_fallback_TexCoord3fv;
+ vfmt->TexCoord4f = ffb_fallback_TexCoord4f;
+ vfmt->TexCoord4fv = ffb_fallback_TexCoord4fv;
+
+ vfmt->Vertex2f = ffb_Vertex2f;
+ vfmt->Vertex2fv = ffb_Vertex2fv;
+ vfmt->Vertex3f = ffb_Vertex3f;
+ vfmt->Vertex3fv = ffb_Vertex3fv;
+ vfmt->Vertex4f = ffb_Vertex4f;
+ vfmt->Vertex4fv = ffb_Vertex4fv;
+
+ vfmt->Begin = ffb_Begin;
+ vfmt->End = ffb_End;
+
+ vfmt->Rectf = _mesa_noop_Rectf; /* generic helper */
+
+ vfmt->DrawArrays = NULL;
+ vfmt->DrawElements = NULL;
+ vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; /* discard range */
+
+
+ /* Not active in supported states; just keep ctx->Current uptodate: */
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->Indexi = _mesa_noop_Indexi;
+ vfmt->Indexiv = _mesa_noop_Indexiv;
+
+ /* Active but unsupported -- fallback if we receive these:
+ *
+ * All of these fallbacks can be fixed with additional code, except
+ * CallList, unless we build a play_immediate_noop() command which
+ * turns an immediate back into glBegin/glEnd commands...
+ */
+ vfmt->CallList = ffb_fallback_CallList;
+ vfmt->EvalCoord1f = ffb_fallback_EvalCoord1f;
+ vfmt->EvalCoord1fv = ffb_fallback_EvalCoord1fv;
+ vfmt->EvalCoord2f = ffb_fallback_EvalCoord2f;
+ vfmt->EvalCoord2fv = ffb_fallback_EvalCoord2fv;
+ vfmt->EvalMesh1 = ffb_fallback_EvalMesh1;
+ vfmt->EvalMesh2 = ffb_fallback_EvalMesh2;
+ vfmt->EvalPoint1 = ffb_fallback_EvalPoint1;
+ vfmt->EvalPoint2 = ffb_fallback_EvalPoint2;
+
+ vfmt->prefer_float_colors = GL_TRUE;
+
+ fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ /* THIS IS A HACK! */
+ _mesa_install_exec_vtxfmt( ctx, vfmt );
+}
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.h
new file mode 100644
index 000000000..00d8c6599
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.h
@@ -0,0 +1,8 @@
+/* $XFree86$ */
+
+#ifndef _FFB_VTXFMT_H
+#define _FFB_VTXFMT_H
+
+extern void ffbInitTnlModule(GLcontext *);
+
+#endif /* !(_FFB_VTXFMT_H) */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
index 9412038bc..ba88ccb9c 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c
@@ -1,7 +1,7 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.3 2001/05/29 22:24:01 dawes Exp $
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.2.4.1 2001/05/29 22:28:17 dawes Exp $
*
* GLX Hardware Device Driver for Sun Creator/Creator3D
- * Copyright (C) 2000 David S. Miller
+ * Copyright (C) 2000, 2001 David S. Miller
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,10 +32,17 @@
#include "ffb_xmesa.h"
#include "context.h"
-#include "vbxform.h"
#include "matrix.h"
#include "simple_list.h"
#include "mmath.h"
+#include "mem.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "array_cache/acache.h"
+
#include "xf86dri.h"
@@ -50,41 +57,20 @@
#include "ffb_lines.h"
#include "ffb_points.h"
#include "ffb_state.h"
-#include "ffb_pipeline.h"
+#include "ffb_tex.h"
#include "ffb_lock.h"
+#include "ffb_vtxfmt.h"
+#include "ffb_bitmap.h"
-#if 0
-#include "xmesaP.h"
-#endif
-
-static ffbContextPtr ffbCtx = NULL;
-
-/* These functions are accessed by dlsym from dri_mesa_init.c:
- *
- * XMesaInitDriver
- * XMesaResetDriver
- * XMesaCreateVisual
- * XMesaDestroyVisual
- * XMesaCreateContext
- * XMesaDestroyContext
- * XMesaCreateWindowBuffer
- * XMesaCreatePixmapBuffer
- * XMesaDestroyBuffer
- * XMesaSwapBuffers
- * XMesaMakeCurrent
- *
- * So this is kind of the public interface to the driver. The driver
- * uses the X11 mesa driver context as a kind of wrapper around its
- * own driver context - but there isn't much justificiation for doing
- * it that way - the DRI might as well use a (void *) to refer to the
- * driver contexts. Nothing in the X context really gets used.
- */
-
-GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+static GLboolean
+ffbInitDriver(__DRIscreenPrivate *sPriv)
{
ffbScreenPrivate *ffbScreen;
FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
+ if (getenv("LIBGL_FORCE_XSERVER"))
+ return GL_FALSE;
+
/* Allocate the private area. */
ffbScreen = (ffbScreenPrivate *) Xmalloc(sizeof(ffbScreenPrivate));
if (!ffbScreen)
@@ -154,16 +140,15 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
ffbScreen->sPriv = sPriv;
sPriv->private = (void *) ffbScreen;
- ffbDDSetupInit();
- ffbDDTrifuncInit();
ffbDDLinefuncInit();
ffbDDPointfuncInit();
return GL_TRUE;
}
-/* Accessed by dlsym from dri_mesa_init.c */
-void XMesaResetDriver(__DRIscreenPrivate *sPriv)
+
+static void
+ffbDestroyScreen(__DRIscreenPrivate *sPriv)
{
ffbScreenPrivate *ffbScreen = sPriv->private;
FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
@@ -177,56 +162,51 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv)
Xfree(ffbScreen);
}
-/* Accessed by dlsym from dri_mesa_init.c */
-GLvisual *XMesaCreateVisual(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config)
-{
- /* Only RGB visuals (for now) in this FFB driver. */
- if (!config->rgba)
- return NULL;
-
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual(config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount(visinfo->red_mask),
- _mesa_bitcount(visinfo->green_mask),
- _mesa_bitcount(visinfo->blue_mask),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */);
-}
+static const struct gl_pipeline_stage *ffb_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ /* REMOVE: fog coord stage */
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+ &_tnl_render_stage,
+ 0,
+};
/* Create and initialize the Mesa and driver specific context data */
-GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv)
+static GLboolean
+ffbCreateContext(Display *dpy, const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
{
ffbContextPtr fmesa;
- GLcontext *glCtx;
+ GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv;
ffbScreenPrivate *ffbScreen;
+ char *debug;
- fmesa = (ffbContextPtr) Xmalloc(sizeof(ffbContextRec));
+ /* Allocate ffb context */
+ fmesa = (ffbContextPtr) CALLOC(sizeof(ffbContextRec));
if (!fmesa)
return GL_FALSE;
- glCtx = driContextPriv->mesaContext;
+ /* Allocate Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((ffbContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, fmesa, GL_TRUE);
+ if (!fmesa->glCtx) {
+ FREE(fmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = fmesa;
+ ctx = fmesa->glCtx;
+
sPriv = driContextPriv->driScreenPriv;
ffbScreen = (ffbScreenPrivate *) sPriv->private;
- fmesa->glCtx = glCtx;
- glCtx->DriverCtx = (void *) fmesa;
-
/* Dri stuff. */
fmesa->display = dpy;
fmesa->hHWContext = driContextPriv->hHWContext;
@@ -241,114 +221,155 @@ GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis,
fmesa->regs = ffbScreen->regs;
fmesa->sfb32 = ffbScreen->sfb32;
- fmesa->SWrender = 0;
- if (getenv("LIBGL_SOFTWARE_RENDERING"))
- fmesa->SWrender = 1;
-
- ffbDDInitContextHwState(glCtx);
+ ffbDDInitContextHwState(ctx);
/* Default clear and depth colors. */
{
- GLubyte r = (GLint) (glCtx->Color.ClearColor[0] * 255.0F);
- GLubyte g = (GLint) (glCtx->Color.ClearColor[1] * 255.0F);
- GLubyte b = (GLint) (glCtx->Color.ClearColor[2] * 255.0F);
+ GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F);
+ GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F);
+ GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F);
fmesa->clear_pixel = ((r << 0) |
(g << 8) |
(b << 16));
}
- fmesa->clear_depth = Z_FROM_MESA(glCtx->Depth.Clear * 4294967295.0f);
- fmesa->clear_stencil = glCtx->Stencil.Clear & 0xf;
-
- /* All of this need only be done once for a new context. */
- ffbDDExtensionsInit(glCtx);
- ffbDDInitDriverFuncs(glCtx);
- ffbDDInitStateFuncs(glCtx);
- ffbDDInitSpanFuncs(glCtx);
- ffbDDInitDepthFuncs(glCtx);
- ffbDDInitStencilFuncs(glCtx);
-
- /* Actually we do the culling in software. The problem is
- * that there is apparently some bug in generic MESA if you
- * provide a driver triangle rendering function when culling
- * is enabled.
- *
- * Generic MESA in such a case does the culling in it's very
- * own software triangle rasterizers (ie. when the driver indicates
- * it cannot do it). Perhaps this is a clue.
- */
- glCtx->Driver.TriangleCaps = DD_TRI_CULL;
+ fmesa->clear_depth = Z_FROM_MESA(ctx->Depth.Clear * 4294967295.0f);
+ fmesa->clear_stencil = ctx->Stencil.Clear & 0xf;
- if (glCtx->VB)
- ffbDDRegisterVB(glCtx->VB);
+ /* No wide points. */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
- if (glCtx->NrPipelineStages)
- glCtx->NrPipelineStages =
- ffbDDRegisterPipelineStages(glCtx->PipelineStage,
- glCtx->PipelineStage,
- glCtx->NrPipelineStages);
+ /* Disable wide lines as we can't antialias them correctly in
+ * hardware.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ /* Instead of having GCC emit these constants a zillion times
+ * everywhere in the driver, put them here.
+ */
+ fmesa->ffb_2_30_fixed_scale = __FFB_2_30_FIXED_SCALE;
+ fmesa->ffb_one_over_2_30_fixed_scale = (1.0 / __FFB_2_30_FIXED_SCALE);
+ fmesa->ffb_16_16_fixed_scale = __FFB_16_16_FIXED_SCALE;
+ fmesa->ffb_one_over_16_16_fixed_scale = (1.0 / __FFB_16_16_FIXED_SCALE);
+ fmesa->ffb_ubyte_color_scale = 255.0f;
+ fmesa->ffb_zero = 0.0f;
+
+ fmesa->debugFallbacks = GL_FALSE;
+ debug = getenv("LIBGL_DEBUG");
+ if (debug && strstr(debug, "fallbacks"))
+ fmesa->debugFallbacks = GL_TRUE;
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
- driContextPriv->driverPrivate = (void *) fmesa;
+ /* All of this need only be done once for a new context. */
+ ffbDDExtensionsInit(ctx);
+ ffbDDInitDriverFuncs(ctx);
+ ffbDDInitStateFuncs(ctx);
+ ffbDDInitSpanFuncs(ctx);
+ ffbDDInitDepthFuncs(ctx);
+ ffbDDInitStencilFuncs(ctx);
+ ffbDDInitRenderFuncs(ctx);
+ ffbDDInitTexFuncs(ctx);
+ ffbDDInitBitmapFuncs(ctx);
+ ffbInitVB(ctx);
+
+ ffbInitTnlModule(ctx);
+
+ _tnl_destroy_pipeline(ctx);
+ _tnl_install_pipeline(ctx, ffb_pipeline);
return GL_TRUE;
}
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+static void
+ffbDestroyContext(__DRIcontextPrivate *driContextPriv)
{
ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
- if (fmesa == ffbCtx)
- ffbCtx = NULL;
+ if (fmesa) {
+ ffbFreeVB(fmesa->glCtx);
- if (fmesa)
- Xfree(fmesa);
+ _swsetup_DestroyContext( fmesa->glCtx );
+ _tnl_DestroyContext( fmesa->glCtx );
+ _ac_DestroyContext( fmesa->glCtx );
+ _swrast_DestroyContext( fmesa->glCtx );
+
+ /* free the Mesa context */
+ fmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(fmesa->glCtx);
+
+ FREE(fmesa);
+ }
}
/* Create and initialize the Mesa and driver specific pixmap buffer data */
-GLframebuffer *XMesaCreateWindowBuffer(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
+static GLboolean
+ffbCreateBuffer(Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
{
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0);
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0);
+ return (driDrawPriv->driverPrivate != NULL);
+ }
}
-/* Create and initialize the Mesa and driver specific pixmap buffer data */
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
+
+static void
+ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
- return NULL; /* not implemented yet */
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
}
+
#define USE_FAST_SWAP
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+static void
+ffbSwapBuffers(Display *dpy, void *drawablePrivate)
{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate;
unsigned int fbc, wid, wid_reg_val, dac_db_bit;
unsigned int shadow_dac_addr, active_dac_addr;
ffb_fbcPtr ffb;
ffb_dacPtr dac;
- if (ffbCtx == NULL ||
- ffbCtx->glCtx->Visual->DBflag == 0)
+ if (fmesa == NULL ||
+ fmesa->glCtx->Visual.doubleBufferMode == 0)
return;
- FLUSH_VB(ffbCtx->glCtx, "swap buffers");
+ /* Flush pending rendering commands */
+ _mesa_swapbuffers(fmesa->glCtx);
- ffb = ffbCtx->regs;
- dac = ffbCtx->ffbScreen->dac;
+ ffb = fmesa->regs;
+ dac = fmesa->ffbScreen->dac;
- fbc = ffbCtx->fbc;
- wid = ffbCtx->wid;
+ fbc = fmesa->fbc;
+ wid = fmesa->wid;
/* Swap the buffer we render into and read pixels from. */
- ffbCtx->back_buffer ^= 1;
+ fmesa->back_buffer ^= 1;
/* If we are writing into both buffers, don't mess with
* the WB setting.
@@ -366,16 +387,16 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
else
fbc = (fbc & ~FFB_FBC_RB_B) | FFB_FBC_RB_A;
- LOCK_HARDWARE(ffbCtx);
+ LOCK_HARDWARE(fmesa);
- if (ffbCtx->fbc != fbc) {
- FFBFifo(ffbCtx, 1);
- ffb->fbc = ffbCtx->fbc = fbc;
- ffbCtx->ffbScreen->rp_active = 1;
+ if (fmesa->fbc != fbc) {
+ FFBFifo(fmesa, 1);
+ ffb->fbc = fmesa->fbc = fbc;
+ fmesa->ffbScreen->rp_active = 1;
}
/* And swap the buffer displayed in the WID. */
- if (ffbCtx->ffb_sarea->flags & FFB_DRI_PAC1) {
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
dac_db_bit = FFBDAC_PAC1_WLUT_DB;
@@ -385,10 +406,10 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
dac_db_bit = FFBDAC_PAC2_WLUT_DB;
}
- FFBWait(ffbCtx, ffb);
+ FFBWait(fmesa, ffb);
wid_reg_val = DACCFG_READ(dac, active_dac_addr);
- if (ffbCtx->back_buffer == 0)
+ if (fmesa->back_buffer == 0)
wid_reg_val |= dac_db_bit;
else
wid_reg_val &= ~dac_db_bit;
@@ -412,16 +433,16 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
}
#endif
- UNLOCK_HARDWARE(ffbCtx);
+ UNLOCK_HARDWARE(fmesa);
}
-static void ffb_init_wid(unsigned int wid)
+static void ffb_init_wid(ffbContextPtr fmesa, unsigned int wid)
{
- ffb_dacPtr dac = ffbCtx->ffbScreen->dac;
+ ffb_dacPtr dac = fmesa->ffbScreen->dac;
unsigned int wid_reg_val, dac_db_bit, active_dac_addr;
unsigned int shadow_dac_addr;
- if (ffbCtx->ffb_sarea->flags & FFB_DRI_PAC1) {
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
dac_db_bit = FFBDAC_PAC1_WLUT_DB;
@@ -456,77 +477,76 @@ static void ffb_init_wid(unsigned int wid)
/* Force the context `c' to be the current context and associate with it
buffer `b' */
-GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv)
+static GLboolean
+ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
{
if (driContextPriv) {
ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
int first_time;
- if (ffbCtx != NULL &&
- fmesa == ffbCtx &&
- driDrawPriv == fmesa->driDrawable)
- return GL_TRUE;
-
- ffbCtx = fmesa;
fmesa->driDrawable = driDrawPriv;
- gl_make_current2(ffbCtx->glCtx,
- driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
-
- if (!ffbCtx->glCtx->Viewport.Width)
- gl_Viewport(ffbCtx->glCtx,
- 0, 0,
- driDrawPriv->w, driDrawPriv->h);
+ _mesa_make_current2(fmesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+ if (!fmesa->glCtx->Viewport.Width)
+ _mesa_set_viewport(fmesa->glCtx,
+ 0, 0,
+ driDrawPriv->w,
+ driDrawPriv->h);
+
first_time = 0;
- if (ffbCtx->wid == ~0)
+ if (fmesa->wid == ~0) {
first_time = 1;
+ if (getenv("LIBGL_SOFTWARE_RENDERING"))
+ FALLBACK( fmesa->glCtx, FFB_BADATTR_SWONLY, GL_TRUE );
+ }
- LOCK_HARDWARE(ffbCtx);
+ LOCK_HARDWARE(fmesa);
if (first_time) {
- ffbCtx->wid = ffbCtx->ffb_sarea->wid_table[driDrawPriv->index];
- ffbCtx->state_dirty |= FFB_STATE_WID;
- ffb_init_wid(ffbCtx->wid);
+ fmesa->wid = fmesa->ffb_sarea->wid_table[driDrawPriv->index];
+ ffb_init_wid(fmesa, fmesa->wid);
}
- ffbCtx->state_dirty |= FFB_STATE_ALL;
- ffbCtx->state_fifo_ents = ffbCtx->state_all_fifo_ents;
- ffbSyncHardware(ffbCtx);
- UNLOCK_HARDWARE(ffbCtx);
+ fmesa->state_dirty |= FFB_STATE_ALL;
+ fmesa->state_fifo_ents = fmesa->state_all_fifo_ents;
+ ffbSyncHardware(fmesa);
+ UNLOCK_HARDWARE(fmesa);
if (first_time) {
/* Also, at the first switch to a new context,
* we need to clear all the hw buffers.
*/
- ffbDDClear(ffbCtx->glCtx,
+ ffbDDClear(fmesa->glCtx,
(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT |
DD_DEPTH_BIT | DD_STENCIL_BIT),
1, 0, 0, 0, 0);
}
} else {
- gl_make_current(0,0);
- ffbCtx = NULL;
+ _mesa_make_current(NULL, NULL);
}
return GL_TRUE;
}
/* Force the context `c' to be unbound from its buffer */
-GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+ffbUnbindContext(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
-GLboolean
-XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+ffbOpenFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
-GLboolean
-XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+ffbCloseFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
@@ -537,14 +557,12 @@ void ffbXMesaUpdateState(ffbContextPtr fmesa)
__DRIscreenPrivate *sPriv = fmesa->driScreen;
int stamp = dPriv->lastStamp;
- XMESA_VALIDATE_DRAWABLE_INFO(fmesa->display, sPriv, dPriv);
+ DRI_VALIDATE_DRAWABLE_INFO(fmesa->display, sPriv, dPriv);
if (dPriv->lastStamp != stamp) {
GLcontext *ctx = fmesa->glCtx;
- if (ctx->Scissor.Enabled)
- ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height);
+ ffbCalcViewport(ctx);
if (ctx->Polygon.StippleFlag)
ffbXformAreaPattern(fmesa,
(const GLubyte *)ctx->PolygonStipple);
@@ -558,4 +576,35 @@ void __driRegisterExtensions(void)
{
}
+
+static struct __DriverAPIRec ffbAPI = {
+ ffbInitDriver,
+ ffbDestroyScreen,
+ ffbCreateContext,
+ ffbDestroyContext,
+ ffbCreateBuffer,
+ ffbDestroyBuffer,
+ ffbSwapBuffers,
+ ffbMakeCurrent,
+ ffbUnbindContext,
+ ffbOpenFullScreen,
+ ffbCloseFullScreen
+};
+
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &ffbAPI);
+ return (void *) psp;
+}
+
+
#endif /* GLX_DIRECT_RENDERING */
diff --git a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h
index 4eb8ff4f0..e3c030230 100644
--- a/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h
+++ b/xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h
@@ -6,9 +6,8 @@
#ifdef GLX_DIRECT_RENDERING
#include <sys/time.h>
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "types.h"
+#include "dri_util.h"
+#include "mtypes.h"
#include "ffb_drishare.h"
#include "ffb_regs.h"
#include "ffb_dac.h"
diff --git a/xc/lib/GL/mesa/src/drv/gamma/Imakefile b/xc/lib/GL/mesa/src/drv/gamma/Imakefile
index bb19ea55e..7515867e7 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/gamma/Imakefile
@@ -22,12 +22,14 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.23 2001/05/10 16:56:1
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
@@ -43,8 +45,8 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.23 2001/05/10 16:56:1
#endif
SRCS = $(GAMMASRCS)
- OBJS = $(LOWOBJS) $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \
- $(MESA_ASM_OBJS) $(GAMMAOBJS) $(HIOBJS)
+ OBJS = $(LOOBJS) $(DRIOBJS) $(DRMOBJS) $(COREMESAOBJS) \
+ $(MESA_ASM_OBJS) $(COMMONOBJS) $(GAMMAOBJS) $(HIOBJS)
REQUIREDLIBS = MathLibrary $(LDPRELIB) $(GLXLIB)
diff --git a/xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc b/xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc
index 69fb17703..b907aa9e4 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/gamma/Imakefile.inc
@@ -16,58 +16,99 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
- DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \
- -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(GLXLIBSRC)/glx \
+ -I$(INCLUDESRC) \
+ -I$(INCLUDESRC)/GL \
-I$(SERVERSRC)/GL/dri \
+ -I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/glint \
- -I$(XF86OSSRC)
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
-MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/gamma
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESADRVSRCDIR)/common \
+ -I$(MESADRVSRCDIR)/gamma
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
- GAMMASRCS = $(MESADRVGAMMABUILDDIR)gamma_gl.c \
- $(MESADRVGAMMABUILDDIR)gamma_xmesa.c \
- $(MESADRVGAMMABUILDDIR)gamma_init.c \
- $(MESADRVGAMMABUILDDIR)gamma_matrix.c \
+ GAMMASRCS = $(MESADRVGAMMABUILDDIR)gamma_context.c \
+ $(MESADRVGAMMABUILDDIR)gamma_dd.c \
$(MESADRVGAMMABUILDDIR)gamma_inithw.c \
- $(MESADRVGAMMABUILDDIR)gamma_texture.c \
- $(MESADRVGAMMABUILDDIR)gamma_dlist.c
+ $(MESADRVGAMMABUILDDIR)gamma_lock.c \
+ $(MESADRVGAMMABUILDDIR)gamma_render.c \
+ $(MESADRVGAMMABUILDDIR)gamma_screen.c \
+ $(MESADRVGAMMABUILDDIR)gamma_span.c \
+ $(MESADRVGAMMABUILDDIR)gamma_state.c \
+ $(MESADRVGAMMABUILDDIR)gamma_tex.c \
+ $(MESADRVGAMMABUILDDIR)gamma_texmem.c \
+ $(MESADRVGAMMABUILDDIR)gamma_texstate.c \
+ $(MESADRVGAMMABUILDDIR)gamma_tris.c \
+ $(MESADRVGAMMABUILDDIR)gamma_vb.c \
+ $(MESADRVGAMMABUILDDIR)gamma_xmesa.c
- GAMMAOBJS = $(MESADRVGAMMABUILDDIR)gamma_gl.o \
- $(MESADRVGAMMABUILDDIR)gamma_xmesa.o \
- $(MESADRVGAMMABUILDDIR)gamma_init.o \
- $(MESADRVGAMMABUILDDIR)gamma_matrix.o \
+ GAMMAOBJS = $(MESADRVGAMMABUILDDIR)gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)gamma_dd.o \
$(MESADRVGAMMABUILDDIR)gamma_inithw.o \
- $(MESADRVGAMMABUILDDIR)gamma_texture.o \
- $(MESADRVGAMMABUILDDIR)gamma_dlist.o
+ $(MESADRVGAMMABUILDDIR)gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)gamma_xmesa.o
- GAMMAUOBJS = $(MESADRVGAMMABUILDDIR)unshared/gamma_gl.o \
- $(MESADRVGAMMABUILDDIR)unshared/gamma_xmesa.o \
- $(MESADRVGAMMABUILDDIR)unshared/gamma_init.o \
- $(MESADRVGAMMABUILDDIR)unshared/gamma_matrix.o \
+ GAMMAUOBJS = $(MESADRVGAMMABUILDDIR)unshared/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_dd.o \
$(MESADRVGAMMABUILDDIR)unshared/gamma_inithw.o \
- $(MESADRVGAMMABUILDDIR)unshared/gamma_texture.o \
- $(MESADRVGAMMABUILDDIR)unshared/gamma_dlist.o
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)unshared/gamma_xmesa.o
- GAMMADOBJS = $(MESADRVGAMMABUILDDIR)debugger/gamma_gl.o \
- $(MESADRVGAMMABUILDDIR)debugger/gamma_xmesa.o \
- $(MESADRVGAMMABUILDDIR)debugger/gamma_init.o \
- $(MESADRVGAMMABUILDDIR)debugger/gamma_matrix.o \
+ GAMMADOBJS = $(MESADRVGAMMABUILDDIR)debugger/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_dd.o \
$(MESADRVGAMMABUILDDIR)debugger/gamma_inithw.o \
- $(MESADRVGAMMABUILDDIR)debugger/gamma_texture.o \
- $(MESADRVGAMMABUILDDIR)debugger/gamma_dlist.o
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)debugger/gamma_xmesa.o
- GAMMAPOBJS = $(MESADRVGAMMABUILDDIR)profiled/gamma_gl.o \
- $(MESADRVGAMMABUILDDIR)profiled/gamma_xmesa.o \
- $(MESADRVGAMMABUILDDIR)profiled/gamma_init.o \
- $(MESADRVGAMMABUILDDIR)profiled/gamma_matrix.o \
+ GAMMAPOBJS = $(MESADRVGAMMABUILDDIR)profiled/gamma_context.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_dd.o \
$(MESADRVGAMMABUILDDIR)profiled/gamma_inithw.o \
- $(MESADRVGAMMABUILDDIR)profiled/gamma_texture.o \
- $(MESADRVGAMMABUILDDIR)profiled/gamma_dlist.o
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_lock.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_render.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_screen.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_span.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_state.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_tex.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_texmem.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_texstate.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_tris.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_vb.o \
+ $(MESADRVGAMMABUILDDIR)profiled/gamma_xmesa.o
#ifdef NeedToLinkMesaSrc
LinkSourceFile(gamma_gl.c, $(MESADRVSRCDIR)/gamma)
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_client.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_client.h
index 36521c9ab..a09dd4f9f 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_client.h
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_client.h
@@ -31,13 +31,13 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_client.h,v 1.2 2000/02/23 04:46:41 martin Exp $
+ * $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_client.h,v 1.1 1999/06/14 07:31:12 dawes Exp $
*
*/
#define AreaStippleEnable 0x00001
#define LineStippleEnable 0x00002
-#define ResetLineStipple 0x00004
+#define GResetLineStipple 0x00004
#define FastFillEnable 0x00008
#define PrimitiveLine 0x00000
#define PrimitiveTrapezoid 0x00040
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c
new file mode 100644
index 000000000..4365505b1
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * 3DLabs Gamma driver.
+ *
+ */
+#include "gamma_context.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "context.h"
+#include "simple_list.h"
+#include "mem.h"
+#include "matrix.h"
+#include "extensions.h"
+#if defined(USE_X86_ASM)
+#include "X86/common_x86_asm.h"
+#endif
+#include "simple_list.h"
+#include "mem.h"
+#include "mm.h"
+
+
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+extern const struct gl_pipeline_stage _gamma_render_stage;
+
+static const struct gl_pipeline_stage *gamma_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_gamma_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+GLboolean gammaCreateContext( Display *dpy, const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ gammaContextPtr gmesa;
+ gammaScreenPtr gammascrn;
+ drm_gamma_sarea_t *saPriv=(drm_gamma_sarea_t *)(((char*)sPriv->pSAREA)+
+ sizeof(XF86DRISAREARec));
+
+ gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
+ if ( !gmesa ) return GL_FALSE;
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ gmesa->glCtx = _mesa_create_context(glVisual, shareCtx, gmesa, GL_TRUE);
+ if (!gmesa->glCtx) {
+ FREE(gmesa);
+ return GL_FALSE;
+ }
+
+ gmesa->display = dpy;
+
+ gmesa->driContext = driContextPriv;
+ gmesa->driScreen = sPriv;
+ gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+ gmesa->hHWContext = driContextPriv->hHWContext;
+ gmesa->driHwLock = &sPriv->pSAREA->lock;
+ gmesa->driFd = sPriv->fd;
+ gmesa->sarea = saPriv;
+
+ gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private);
+
+ ctx = gmesa->glCtx;
+
+ ctx->Const.MaxTextureLevels = 13; /* 4K by 4K? Is that right? */
+ ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
+
+ ctx->Const.MinLineWidth = 0.0;
+ ctx->Const.MaxLineWidth = 255.0;
+
+ ctx->Const.MinLineWidthAA = 0.0;
+ ctx->Const.MaxLineWidthAA = 65536.0;
+
+ ctx->Const.MinPointSize = 0.0;
+ ctx->Const.MaxPointSize = 255.0;
+
+ ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
+ ctx->Const.MaxPointSizeAA = 16.0;
+ ctx->Const.PointSizeGranularity = 0.25;
+
+ gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize );
+
+ make_empty_list(&gmesa->TexObjList);
+ make_empty_list(&gmesa->SwappedOut);
+
+ gmesa->CurrentTexObj[0] = 0;
+ gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
+
+ gmesa->RenderIndex = ~0;
+
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, gamma_pipeline );
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+
+ gammaInitVB( ctx );
+ gammaDDInitExtensions( ctx );
+ gammaDDInitDriverFuncs( ctx );
+ gammaDDInitStateFuncs( ctx );
+ gammaDDInitSpanFuncs( ctx );
+ gammaDDInitTextureFuncs( ctx );
+ gammaDDInitTriFuncs( ctx );
+ gammaDDInitState( gmesa );
+
+ driContextPriv->driverPrivate = (void *)gmesa;
+
+ GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
+ 1, &gmesa->bufIndex, &gmesa->bufSize,
+ &gmesa->buf, &gmesa->bufCount, gammascrn);
+
+#ifdef DO_VALIDATE
+ GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
+ 1, &gmesa->WCbufIndex, &gmesa->WCbufSize,
+ &gmesa->WCbuf, &gmesa->WCbufCount, gammascrn);
+#endif
+
+ switch (glVisual->depthBits) {
+ case 16:
+ gmesa->DeltaMode = DM_Depth16;
+ gmesa->depth_scale = 1.0f / 0xffff;
+ break;
+ case 24:
+ gmesa->DeltaMode = DM_Depth24;
+ gmesa->depth_scale = 1.0f / 0xffffff;
+ break;
+ case 32:
+ gmesa->DeltaMode = DM_Depth32;
+ gmesa->depth_scale = 1.0f / 0xffffffff;
+ break;
+ default:
+ break;
+ }
+
+ gmesa->DepthSize = glVisual->depthBits;
+ gmesa->Flags = GAMMA_FRONT_BUFFER;
+ gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
+ gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);
+
+ gmesa->EnabledFlags = GAMMA_FRONT_BUFFER;
+ gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
+
+
+ if (gmesa->Flags & GAMMA_BACK_BUFFER) {
+ gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ } else {
+ gmesa->readOffset = gmesa->drawOffset = 0;
+ }
+
+ gammaInitHW( gmesa );
+
+ driContextPriv->driverPrivate = (void *)gmesa;
+
+ return GL_TRUE;
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h
new file mode 100644
index 000000000..63a694742
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_context.h
@@ -0,0 +1,406 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ */
+
+#ifndef _GAMMA_CONTEXT_H_
+#define _GAMMA_CONTEXT_H_
+
+#include "dri_util.h"
+
+#include "gamma_regs.h"
+#include "gamma_macros.h"
+#include "gamma_screen.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+
+typedef union {
+ unsigned int i;
+ float f;
+} dmaBufRec, *dmaBuf;
+
+/* Flags for context */
+#define GAMMA_FRONT_BUFFER 0x00000001
+#define GAMMA_BACK_BUFFER 0x00000002
+#define GAMMA_DEPTH_BUFFER 0x00000004
+#define GAMMA_STENCIL_BUFFER 0x00000008
+#define GAMMA_ACCUM_BUFFER 0x00000010
+
+#define GAMMA_MAX_TEXTURE_SIZE 2048
+
+/* These are the minimum requirements and should probably be increased */
+#define MAX_MODELVIEW_STACK 16
+#define MAX_PROJECTION_STACK 2
+#define MAX_TEXTURE_STACK 2
+
+extern void gammaDDUpdateHWState(GLcontext *ctx);
+extern gammaScreenPtr gammaCreateScreen(__DRIscreenPrivate *sPriv);
+extern void gammaDestroyScreen(__DRIscreenPrivate *sPriv);
+extern GLboolean gammaCreateContext( Display *dpy,
+ const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+#define GAMMA_UPLOAD_ALL 0xffffffff
+#define GAMMA_UPLOAD_CLIPRECTS 0x00000002
+#define GAMMA_UPLOAD_ALPHA 0x00000004
+#define GAMMA_UPLOAD_BLEND 0x00000008
+#define GAMMA_UPLOAD_DEPTH 0x00000010
+#define GAMMA_UPLOAD_VIEWPORT 0x00000020
+#define GAMMA_UPLOAD_SHADE 0x00000040
+#define GAMMA_UPLOAD_CLIP 0x00000080
+#define GAMMA_UPLOAD_MASKS 0x00000100
+#define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */
+#define GAMMA_UPLOAD_GEOMETRY 0x00000400
+#define GAMMA_UPLOAD_POLYGON 0x00000800
+#define GAMMA_UPLOAD_DITHER 0x00001000
+#define GAMMA_UPLOAD_LOGICOP 0x00002000
+#define GAMMA_UPLOAD_FOG 0x00004000
+#define GAMMA_UPLOAD_LIGHT 0x00008000
+#define GAMMA_UPLOAD_CONTEXT 0x00010000
+#define GAMMA_UPLOAD_TEX0 0x00020000
+#define GAMMA_UPLOAD_STIPPLE 0x00040000
+#define GAMMA_UPLOAD_TRANSFORM 0x00080000
+#define GAMMA_UPLOAD_LINEMODE 0x00100000
+#define GAMMA_UPLOAD_POINTMODE 0x00200000
+#define GAMMA_UPLOAD_TRIMODE 0x00400000
+
+#define GAMMA_NEW_CLIP 0x00000001
+#define GAMMA_NEW_WINDOW 0x00000002
+#define GAMMA_NEW_CONTEXT 0x00000004
+#define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */
+#define GAMMA_NEW_ALPHA 0x00000010
+#define GAMMA_NEW_DEPTH 0x00000020
+#define GAMMA_NEW_MASKS 0x00000040
+#define GAMMA_NEW_POLYGON 0x00000080
+#define GAMMA_NEW_CULL 0x00000100
+#define GAMMA_NEW_LOGICOP 0x00000200
+#define GAMMA_NEW_FOG 0x00000400
+#define GAMMA_NEW_LIGHT 0x00000800
+#define GAMMA_NEW_STIPPLE 0x00001000
+#define GAMMA_NEW_ALL 0xffffffff
+
+#define GAMMA_FALLBACK_TRI 0x00000001
+#define GAMMA_FALLBACK_TEXTURE 0x00000002
+
+#define FLUSH_BATCH(gmesa) do { \
+ /*FLUSH_DMA_BUFFER(gmesa);*/ \
+} while(0)
+
+struct gamma_context;
+typedef struct gamma_context gammaContextRec;
+typedef struct gamma_context *gammaContextPtr;
+typedef struct gamma_texture_object_t *gammaTextureObjectPtr;
+
+#define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj)
+
+#define GAMMA_TEX_MAXLEVELS 12
+
+/* For shared texture space managment, these texture objects may also
+ * be used as proxies for regions of texture memory containing other
+ * client's textures. Such proxy textures (not to be confused with GL
+ * proxy textures) are subject to the same LRU aging we use for our
+ * own private textures, and thus we have a mechanism where we can
+ * fairly decide between kicking out our own textures and those of
+ * other clients.
+ *
+ * Non-local texture objects have a valid MemBlock to describe the
+ * region managed by the other client, and can be identified by
+ * 't->globj == 0'
+ */
+struct gamma_texture_object_t {
+ struct gamma_texture_object_t *next, *prev;
+
+ GLuint age;
+ struct gl_texture_object *globj;
+
+ int Pitch;
+ int Height;
+ int texelBytes;
+ int totalSize;
+ int bound;
+
+ PMemBlock MemBlock;
+ GLuint BufAddr;
+
+ GLuint min_level;
+ GLuint max_level;
+ GLuint dirty_images;
+
+ GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
+
+ struct {
+ const struct gl_texture_image *image;
+ int offset; /* into BufAddr */
+ int height;
+ int internalFormat;
+ } image[GAMMA_TEX_MAXLEVELS];
+
+ CARD32 TextureBaseAddr[GAMMA_TEX_MAXLEVELS];
+ CARD32 TextureAddressMode;
+ CARD32 TextureColorMode;
+ CARD32 TextureFilterMode;
+ CARD32 TextureFormat;
+ CARD32 TextureReadMode;
+ CARD32 TextureBorderColor;
+};
+
+#define GAMMA_NO_PALETTE 0x0
+#define GAMMA_USE_PALETTE 0x1
+#define GAMMA_UPDATE_PALETTE 0x2
+#define GAMMA_FALLBACK_PALETTE 0x4
+
+void gammaUpdateTextureState( GLcontext *ctx );
+
+void gammaDestroyTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t);
+void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t );
+
+void gammaResetGlobalLRU( gammaContextPtr gmesa );
+void gammaTexturesGone( gammaContextPtr gmesa,
+ GLuint start, GLuint end,
+ GLuint in_use );
+
+void gammaEmitHwState( gammaContextPtr gmesa );
+void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
+void gammaDDInitExtensions( GLcontext *ctx );
+void gammaDDInitDriverFuncs( GLcontext *ctx );
+void gammaDDInitSpanFuncs( GLcontext *ctx );
+void gammaDDInitState( gammaContextPtr gmesa );
+void gammaInitHW( gammaContextPtr gmesa );
+void gammaDDInitStateFuncs( GLcontext *ctx );
+void gammaDDInitTextureFuncs( GLcontext *ctx );
+void gammaDDInitTriFuncs( GLcontext *ctx );
+
+void gammaUpdateWindow( GLcontext *ctx );
+void gammaUpdateViewportOffset( GLcontext *ctx );
+
+void gammaPrintLocalLRU( gammaContextPtr gmesa );
+void gammaPrintGlobalLRU( gammaContextPtr gmesa );
+
+extern void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode )
+
+/* Use the templated vertex formats. Only one of these is used in gamma.
+ */
+#define TAG(x) gamma##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*gamma_quad_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_tri_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_line_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_point_func)( gammaContextPtr,
+ const gammaVertex * );
+
+
+struct gamma_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ __DRIcontextPrivate *driContext;
+ __DRIscreenPrivate *driScreen;
+ __DRIdrawablePrivate *driDrawable;
+
+ GLuint new_gl_state;
+ GLuint new_state;
+ GLuint dirty;
+
+ drm_gamma_sarea_t *sarea;
+
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
+
+ /* Mirrors of some DRI state
+ */
+ Display *display; /* X server display */
+
+ drmContext hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ XF86DRIClipRectPtr pClipRects;
+
+ dmaBuf buf; /* DMA buffer for regular cmds */
+ int bufIndex;
+ int bufSize;
+ int bufCount;
+
+ dmaBuf WCbuf; /* DMA buffer for window changed cmds */
+ int WCbufIndex;
+ int WCbufSize;
+ int WCbufCount;
+
+ gammaScreenPtr gammaScreen; /* Screen private DRI data */
+
+ int drawOffset;
+ int readOffset;
+
+ gamma_point_func draw_point;
+ gamma_line_func draw_line;
+ gamma_tri_func draw_tri;
+ gamma_quad_func draw_quad;
+
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+
+ GLuint vertex_format;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ char *verts;
+
+ GLfloat hw_viewport[16];
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ GLfloat depth_scale;
+
+ gammaTextureObjectPtr CurrentTexObj[2];
+ struct gamma_texture_object_t TexObjList;
+ struct gamma_texture_object_t SwappedOut;
+ GLenum TexEnvImageFmt[2];
+
+ memHeap_t *texHeap;
+
+ int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ int lastStamp;
+
+
+ CARD32 ClearColor;
+ CARD32 Color;
+ CARD32 DitherMode;
+ CARD32 ClearDepth;
+ CARD32 FogMode;
+ CARD32 AreaStippleMode;
+ CARD32 LBReadFormat;
+ CARD32 LBWriteFormat;
+ CARD32 LineMode;
+ CARD32 PointMode;
+ CARD32 TriangleMode;
+ CARD32 AntialiasMode;
+ GLfloat ViewportScaleX;
+ GLfloat ViewportScaleY;
+ GLfloat ViewportScaleZ;
+ GLfloat ViewportOffsetX;
+ GLfloat ViewportOffsetY;
+ GLfloat ViewportOffsetZ;
+ int MatrixMode;
+ int DepthMode;
+ int TransformMode;
+ int LBReadMode;
+ int FBReadMode;
+ int FBWindowBase;
+ int LBWindowBase;
+ int ColorDDAMode;
+ int GeometryMode;
+ int AlphaTestMode;
+ int AlphaBlendMode;
+ int AB_FBReadMode;
+ int AB_FBReadMode_Save;
+ int DeltaMode;
+ int ColorMaterialMode;
+ int FBHardwareWriteMask;
+ int MaterialMode;
+ int NormalizeMode;
+ int LightingMode;
+ int Light0Mode;
+ int Light1Mode;
+ int Light2Mode;
+ int Light3Mode;
+ int Light4Mode;
+ int Light5Mode;
+ int Light6Mode;
+ int Light7Mode;
+ int Light8Mode;
+ int Light9Mode;
+ int Light10Mode;
+ int Light11Mode;
+ int Light12Mode;
+ int Light13Mode;
+ int Light14Mode;
+ int Light15Mode;
+ int LogicalOpMode;
+ int ScissorMode;
+ int ScissorMaxXY;
+ int ScissorMinXY;
+ int Window; /* GID part probably should be in draw priv */
+ int WindowOrigin;
+ int x, y, w, h; /* Probably should be in drawable priv */
+ int FrameCount; /* Probably should be in drawable priv */
+ int NotClipped; /* Probably should be in drawable priv */
+ int WindowChanged; /* Probably should be in drawabl... */
+ int Flags;
+ int EnabledFlags;
+ int DepthSize;
+ int Begin;
+ GLenum ErrorValue;
+ int Texture1DEnabled;
+ int Texture2DEnabled;
+
+ float ModelView[16];
+ float Proj[16];
+ float ModelViewProj[16];
+ float Texture[16];
+
+ float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
+ int ModelViewCount;
+ float ProjStack[(MAX_PROJECTION_STACK-1)*16];
+ int ProjCount;
+ float TextureStack[(MAX_TEXTURE_STACK-1)*16];
+ int TextureCount;
+};
+
+static __inline GLuint gammaPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+#define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx))
+
+#endif /* _GAMMA_CONTEXT_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_dd.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_dd.c
new file mode 100644
index 000000000..bb85672b2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_dd.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_lock.h"
+#if defined(USE_X86_ASM)
+#include "X86/common_x86_asm.h"
+#endif
+
+#include "swrast/swrast.h"
+
+#define GAMMA_DATE "20010624"
+
+
+/* Return the width and height of the current color buffer.
+ */
+static void gammaDDGetBufferSize( GLcontext *ctx,
+ GLuint *width, GLuint *height )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ GAMMAHW_LOCK( gmesa );
+ *width = gmesa->driDrawable->w;
+ *height = gmesa->driDrawable->h;
+ GAMMAHW_UNLOCK( gmesa );
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name )
+{
+ static char buffer[128];
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"VA Linux Systems, Inc.";
+
+ case GL_RENDERER:
+ sprintf( buffer, "Mesa DRI Gamma " GAMMA_DATE );
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+ }
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+#endif
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+/* Enable the extensions supported by this driver.
+ */
+void gammaDDInitExtensions( GLcontext *ctx )
+{
+ /* None... */
+}
+
+/* Initialize the driver's misc functions.
+ */
+void gammaDDInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = gammaDDGetBufferSize;
+ ctx->Driver.GetString = gammaDDGetString;
+
+ ctx->Driver.Error = NULL;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.c
deleted file mode 100644
index f0e39a678..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.c
+++ /dev/null
@@ -1,3314 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.0
- * Copyright (C) 1995-1998 Brian Paul
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/*
- * Pinched from Mesa v3.0 to glue into gamma driver
- * then glued up, to match some of the Mesa v3.3 back end.
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
- */
-
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.c,v 1.3 2001/02/12 01:11:24 tsi Exp $*/
-
-#ifdef PC_HEADER
-#include "all.h"
-#else
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "accum.h"
-#include "alpha.h"
-#include "attrib.h"
-#include "bitmap.h"
-#include "blend.h"
-#include "clip.h"
-#include "colortab.h"
-#include "context.h"
-#include "copypix.h"
-#include "depth.h"
-#include "drawpix.h"
-#include "enable.h"
-#include "eval.h"
-#include "feedback.h"
-#include "fog.h"
-#include "hash.h"
-#include "image.h"
-#include "light.h"
-#include "lines.h"
-#include "logic.h"
-#include "macros.h"
-#include "masking.h"
-#include "matrix.h"
-#include "mem.h"
-#include "pixel.h"
-#include "points.h"
-#include "polygon.h"
-#include "rastpos.h"
-#include "rect.h"
-#include "scissor.h"
-#include "stencil.h"
-#include "texobj.h"
-#include "teximage.h"
-#include "texstate.h"
-#include "types.h"
-#include "vb.h"
-#include "vbfill.h"
-#include "winpos.h"
-#endif
-
-#include "gamma_gl.h"
-#include "gamma_init.h"
-#include "gamma_dlist.h"
-
-
-/*
-Functions which aren't compiled but executed immediately:
- glIsList
- glGenLists
- glDeleteLists
- glEndList
- glFeedbackBuffer
- glSelectBuffer
- glRenderMode
- glReadPixels
- glPixelStore
- glFlush
- glFinish
- glIsEnabled
- glGet*
-
-Functions which cause errors if called while compiling a display list:
- glNewList
-*/
-
-
-
-/*
- * Display list instructions are stored as sequences of "nodes". Nodes
- * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
- * are linked together with a pointer.
- */
-
-
-/* How many nodes to allocate at a time: */
-#define BLOCK_SIZE 500
-
-
-/*
- * Display list opcodes.
- *
- * The fact that these identifiers are assigned consecutive
- * integer values starting at 0 is very important, see InstSize array usage)
- */
-typedef enum {
- OPCODE_ACCUM,
- OPCODE_ALPHA_FUNC,
- OPCODE_BEGIN,
- OPCODE_BIND_TEXTURE,
- OPCODE_BITMAP,
- OPCODE_BLEND_FUNC,
- OPCODE_CALL_LIST,
- OPCODE_CALL_LIST_OFFSET,
- OPCODE_CLEAR,
- OPCODE_CLEAR_ACCUM,
- OPCODE_CLEAR_COLOR,
- OPCODE_CLEAR_DEPTH,
- OPCODE_CLEAR_INDEX,
- OPCODE_CLEAR_STENCIL,
- OPCODE_CLIP_PLANE,
- OPCODE_COLOR_3F,
- OPCODE_COLOR_4F,
- OPCODE_COLOR_4UB,
- OPCODE_COLOR_MASK,
- OPCODE_COLOR_MATERIAL,
- OPCODE_COPY_PIXELS,
- OPCODE_COPY_TEX_IMAGE1D,
- OPCODE_COPY_TEX_IMAGE2D,
- OPCODE_COPY_TEX_SUB_IMAGE1D,
- OPCODE_COPY_TEX_SUB_IMAGE2D,
- OPCODE_CULL_FACE,
- OPCODE_DEPTH_FUNC,
- OPCODE_DEPTH_MASK,
- OPCODE_DEPTH_RANGE,
- OPCODE_DISABLE,
- OPCODE_DRAW_BUFFER,
- OPCODE_DRAW_PIXELS,
- OPCODE_EDGE_FLAG,
- OPCODE_ENABLE,
- OPCODE_END,
- OPCODE_EVALCOORD1,
- OPCODE_EVALCOORD2,
- OPCODE_EVALMESH1,
- OPCODE_EVALMESH2,
- OPCODE_EVALPOINT1,
- OPCODE_EVALPOINT2,
- OPCODE_FOG,
- OPCODE_FRONT_FACE,
- OPCODE_FRUSTUM,
- OPCODE_HINT,
- OPCODE_INDEX,
- OPCODE_INDEX_MASK,
- OPCODE_INIT_NAMES,
- OPCODE_LIGHT,
- OPCODE_LIGHT_MODEL,
- OPCODE_LINE_STIPPLE,
- OPCODE_LINE_WIDTH,
- OPCODE_LIST_BASE,
- OPCODE_LOAD_IDENTITY,
- OPCODE_LOAD_MATRIX,
- OPCODE_LOAD_NAME,
- OPCODE_LOGIC_OP,
- OPCODE_MAP1,
- OPCODE_MAP2,
- OPCODE_MAPGRID1,
- OPCODE_MAPGRID2,
- OPCODE_MATERIAL,
- OPCODE_MATRIX_MODE,
- OPCODE_MULT_MATRIX,
- OPCODE_NORMAL,
- OPCODE_ORTHO,
- OPCODE_PASSTHROUGH,
- OPCODE_PIXEL_MAP,
- OPCODE_PIXEL_TRANSFER,
- OPCODE_PIXEL_ZOOM,
- OPCODE_POINT_SIZE,
- OPCODE_POLYGON_MODE,
- OPCODE_POLYGON_STIPPLE,
- OPCODE_POLYGON_OFFSET,
- OPCODE_POP_ATTRIB,
- OPCODE_POP_MATRIX,
- OPCODE_POP_NAME,
- OPCODE_PRIORITIZE_TEXTURE,
- OPCODE_PUSH_ATTRIB,
- OPCODE_PUSH_MATRIX,
- OPCODE_PUSH_NAME,
- OPCODE_RASTER_POS,
- OPCODE_RECTF,
- OPCODE_READ_BUFFER,
- OPCODE_SCALE,
- OPCODE_SCISSOR,
- OPCODE_SHADE_MODEL,
- OPCODE_STENCIL_FUNC,
- OPCODE_STENCIL_MASK,
- OPCODE_STENCIL_OP,
- OPCODE_TEXCOORD2,
- OPCODE_TEXCOORD4,
- OPCODE_TEXENV,
- OPCODE_TEXGEN,
- OPCODE_TEXPARAMETER,
- OPCODE_TEX_IMAGE1D,
- OPCODE_TEX_IMAGE2D,
- OPCODE_TEX_IMAGE3D,
- OPCODE_TEX_SUB_IMAGE1D,
- OPCODE_TEX_SUB_IMAGE2D,
- OPCODE_TRANSLATE,
- OPCODE_VERTEX2,
- OPCODE_VERTEX3,
- OPCODE_VERTEX4,
- OPCODE_VIEWPORT,
- /* The following two are meta instructions */
- OPCODE_CONTINUE,
- OPCODE_END_OF_LIST
-} OpCode;
-
-
-/*
- * Each instruction in the display list is stored as a sequence of
- * contiguous nodes in memory.
- * Each node is the union of a variety of datatypes.
- */
-union node {
- OpCode opcode;
- GLboolean b;
- GLbitfield bf;
- GLubyte ub;
- GLshort s;
- GLushort us;
- GLint i;
- GLuint ui;
- GLenum e;
- GLfloat f;
- GLvoid *data;
- void *next; /* If prev node's opcode==OPCODE_CONTINUE */
-};
-
-
-
-/* Number of nodes of storage needed for each instruction: */
-static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
-
-
-
-/**********************************************************************/
-/***** Private *****/
-/**********************************************************************/
-
-
-/*
- * Allocate space for a display list instruction.
- * Input: opcode - type of instruction
- * argcount - number of arguments following the instruction
- * Return: pointer to first node in the instruction
- */
-static Node *alloc_instruction( OpCode opcode, GLint argcount )
-{
- Node *n, *newblock;
- GLuint count = InstSize[opcode];
-
- assert( (GLint) count == argcount+1 );
-
- if (gCCPriv->CurrentPos + count + 2 > BLOCK_SIZE) {
- /* This block is full. Allocate a new block and chain to it */
- n = gCCPriv->CurrentBlock + gCCPriv->CurrentPos;
- n[0].opcode = OPCODE_CONTINUE;
- newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
- if (!newblock) {
- gamma_error( GL_OUT_OF_MEMORY, "Building display list" );
- return NULL;
- }
- n[1].next = (Node *) newblock;
- gCCPriv->CurrentBlock = newblock;
- gCCPriv->CurrentPos = 0;
- }
-
- n = gCCPriv->CurrentBlock + gCCPriv->CurrentPos;
- gCCPriv->CurrentPos += count;
-
- n[0].opcode = opcode;
-
- return n;
-}
-
-
-
-/*
- * Make an empty display list. This is used by glGenLists() to
- * reserver display list IDs.
- */
-static Node *make_empty_list( void )
-{
- Node *n = (Node *) malloc( sizeof(Node) );
- n[0].opcode = OPCODE_END_OF_LIST;
- return n;
-}
-
-
-
-/*
- * Destroy all nodes in a display list.
- * Input: list - display list number
- */
-void gamma_destroy_list( GLuint list )
-{
- Node *n, *block;
- GLboolean done;
-
- block = (Node *) _mesa_HashLookup(gCCPriv->DisplayList, list);
- n = block;
-
- done = block ? GL_FALSE : GL_TRUE;
- while (!done) {
- switch (n[0].opcode) {
- /* special cases first */
- case OPCODE_MAP1:
- free( n[6].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_MAP2:
- free( n[10].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_DRAW_PIXELS:
- free( n[5].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_BITMAP:
- free( n[7].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_POLYGON_STIPPLE:
- free( n[1].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_TEX_IMAGE1D:
- free( n[8].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_TEX_IMAGE2D:
- free( n[9].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_TEX_SUB_IMAGE1D:
- free( n[7].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_TEX_SUB_IMAGE2D:
- free( n[9].data );
- n += InstSize[n[0].opcode];
- break;
- case OPCODE_CONTINUE:
- n = (Node *) n[1].next;
- free( block );
- block = n;
- break;
- case OPCODE_END_OF_LIST:
- free( block );
- done = GL_TRUE;
- break;
- default:
- /* Most frequent case */
- n += InstSize[n[0].opcode];
- break;
- }
- }
-
- _mesa_HashRemove(gCCPriv->DisplayList, list);
-}
-
-
-
-/*
- * Translate the nth element of list from type to GLuint.
- */
-static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
-{
- GLbyte *bptr;
- GLubyte *ubptr;
- GLshort *sptr;
- GLushort *usptr;
- GLint *iptr;
- GLuint *uiptr;
- GLfloat *fptr;
-
- switch (type) {
- case GL_BYTE:
- bptr = (GLbyte *) list;
- return (GLuint) *(bptr+n);
- case GL_UNSIGNED_BYTE:
- ubptr = (GLubyte *) list;
- return (GLuint) *(ubptr+n);
- case GL_SHORT:
- sptr = (GLshort *) list;
- return (GLuint) *(sptr+n);
- case GL_UNSIGNED_SHORT:
- usptr = (GLushort *) list;
- return (GLuint) *(usptr+n);
- case GL_INT:
- iptr = (GLint *) list;
- return (GLuint) *(iptr+n);
- case GL_UNSIGNED_INT:
- uiptr = (GLuint *) list;
- return (GLuint) *(uiptr+n);
- case GL_FLOAT:
- fptr = (GLfloat *) list;
- return (GLuint) *(fptr+n);
- case GL_2_BYTES:
- ubptr = ((GLubyte *) list) + 2*n;
- return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
- case GL_3_BYTES:
- ubptr = ((GLubyte *) list) + 3*n;
- return (GLuint) *ubptr * 65536
- + (GLuint) *(ubptr+1) * 256
- + (GLuint) *(ubptr+2);
- case GL_4_BYTES:
- ubptr = ((GLubyte *) list) + 4*n;
- return (GLuint) *ubptr * 16777216
- + (GLuint) *(ubptr+1) * 65536
- + (GLuint) *(ubptr+2) * 256
- + (GLuint) *(ubptr+3);
- default:
- return 0;
- }
-}
-
-
-
-
-/**********************************************************************/
-/***** Public *****/
-/**********************************************************************/
-
-void gamma_init_lists( void )
-{
- static int init_flag = 0;
-
- if (init_flag==0) {
- InstSize[OPCODE_ACCUM] = 3;
- InstSize[OPCODE_ALPHA_FUNC] = 3;
- InstSize[OPCODE_BEGIN] = 2;
- InstSize[OPCODE_BIND_TEXTURE] = 3;
- InstSize[OPCODE_BITMAP] = 8;
- InstSize[OPCODE_BLEND_FUNC] = 3;
- InstSize[OPCODE_CALL_LIST] = 2;
- InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
- InstSize[OPCODE_CLEAR] = 2;
- InstSize[OPCODE_CLEAR_ACCUM] = 5;
- InstSize[OPCODE_CLEAR_COLOR] = 5;
- InstSize[OPCODE_CLEAR_DEPTH] = 2;
- InstSize[OPCODE_CLEAR_INDEX] = 2;
- InstSize[OPCODE_CLEAR_STENCIL] = 2;
- InstSize[OPCODE_CLIP_PLANE] = 6;
- InstSize[OPCODE_COLOR_3F] = 4;
- InstSize[OPCODE_COLOR_4F] = 5;
- InstSize[OPCODE_COLOR_4UB] = 5;
- InstSize[OPCODE_COLOR_MASK] = 5;
- InstSize[OPCODE_COLOR_MATERIAL] = 3;
- InstSize[OPCODE_COPY_PIXELS] = 6;
- InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
- InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
- InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
- InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
- InstSize[OPCODE_CULL_FACE] = 2;
- InstSize[OPCODE_DEPTH_FUNC] = 2;
- InstSize[OPCODE_DEPTH_MASK] = 2;
- InstSize[OPCODE_DEPTH_RANGE] = 3;
- InstSize[OPCODE_DISABLE] = 2;
- InstSize[OPCODE_DRAW_BUFFER] = 2;
- InstSize[OPCODE_DRAW_PIXELS] = 2;
- InstSize[OPCODE_ENABLE] = 2;
- InstSize[OPCODE_EDGE_FLAG] = 2;
- InstSize[OPCODE_END] = 1;
- InstSize[OPCODE_EVALCOORD1] = 2;
- InstSize[OPCODE_EVALCOORD2] = 3;
- InstSize[OPCODE_EVALMESH1] = 4;
- InstSize[OPCODE_EVALMESH2] = 6;
- InstSize[OPCODE_EVALPOINT1] = 2;
- InstSize[OPCODE_EVALPOINT2] = 3;
- InstSize[OPCODE_FOG] = 6;
- InstSize[OPCODE_FRONT_FACE] = 2;
- InstSize[OPCODE_FRUSTUM] = 7;
- InstSize[OPCODE_HINT] = 3;
- InstSize[OPCODE_INDEX] = 2;
- InstSize[OPCODE_INDEX_MASK] = 2;
- InstSize[OPCODE_INIT_NAMES] = 1;
- InstSize[OPCODE_LIGHT] = 7;
- InstSize[OPCODE_LIGHT_MODEL] = 6;
- InstSize[OPCODE_LINE_STIPPLE] = 3;
- InstSize[OPCODE_LINE_WIDTH] = 2;
- InstSize[OPCODE_LIST_BASE] = 2;
- InstSize[OPCODE_LOAD_IDENTITY] = 1;
- InstSize[OPCODE_LOAD_MATRIX] = 17;
- InstSize[OPCODE_LOAD_NAME] = 2;
- InstSize[OPCODE_LOGIC_OP] = 2;
- InstSize[OPCODE_MAP1] = 7;
- InstSize[OPCODE_MAP2] = 11;
- InstSize[OPCODE_MAPGRID1] = 4;
- InstSize[OPCODE_MAPGRID2] = 7;
- InstSize[OPCODE_MATERIAL] = 7;
- InstSize[OPCODE_MATRIX_MODE] = 2;
- InstSize[OPCODE_MULT_MATRIX] = 17;
- InstSize[OPCODE_NORMAL] = 4;
- InstSize[OPCODE_ORTHO] = 7;
- InstSize[OPCODE_PASSTHROUGH] = 2;
- InstSize[OPCODE_PIXEL_MAP] = 4;
- InstSize[OPCODE_PIXEL_TRANSFER] = 3;
- InstSize[OPCODE_PIXEL_ZOOM] = 3;
- InstSize[OPCODE_POINT_SIZE] = 2;
- InstSize[OPCODE_POLYGON_MODE] = 3;
- InstSize[OPCODE_POLYGON_STIPPLE] = 2;
- InstSize[OPCODE_POLYGON_OFFSET] = 3;
- InstSize[OPCODE_POP_ATTRIB] = 1;
- InstSize[OPCODE_POP_MATRIX] = 1;
- InstSize[OPCODE_POP_NAME] = 1;
- InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
- InstSize[OPCODE_PUSH_ATTRIB] = 2;
- InstSize[OPCODE_PUSH_MATRIX] = 1;
- InstSize[OPCODE_PUSH_NAME] = 2;
- InstSize[OPCODE_RASTER_POS] = 5;
- InstSize[OPCODE_RECTF] = 5;
- InstSize[OPCODE_READ_BUFFER] = 2;
- InstSize[OPCODE_SCALE] = 4;
- InstSize[OPCODE_SCISSOR] = 5;
- InstSize[OPCODE_STENCIL_FUNC] = 4;
- InstSize[OPCODE_STENCIL_MASK] = 2;
- InstSize[OPCODE_STENCIL_OP] = 4;
- InstSize[OPCODE_SHADE_MODEL] = 2;
- InstSize[OPCODE_TEXCOORD2] = 3;
- InstSize[OPCODE_TEXCOORD4] = 5;
- InstSize[OPCODE_TEXENV] = 7;
- InstSize[OPCODE_TEXGEN] = 7;
- InstSize[OPCODE_TEXPARAMETER] = 7;
- InstSize[OPCODE_TEX_IMAGE1D] = 9;
- InstSize[OPCODE_TEX_IMAGE2D] = 10;
- InstSize[OPCODE_TEX_IMAGE3D] = 11;
- InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
- InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
- InstSize[OPCODE_TRANSLATE] = 4;
- InstSize[OPCODE_VERTEX2] = 3;
- InstSize[OPCODE_VERTEX3] = 4;
- InstSize[OPCODE_VERTEX4] = 5;
- InstSize[OPCODE_VIEWPORT] = 5;
- InstSize[OPCODE_CONTINUE] = 2;
- InstSize[OPCODE_END_OF_LIST] = 1;
- }
- init_flag = 1;
-}
-
-
-/*
- * Display List compilation functions
- */
-
-
-void gl_save_Accum( GLenum op, GLfloat value )
-{
- Node *n = alloc_instruction( OPCODE_ACCUM, 2 );
- if (n) {
- n[1].e = op;
- n[2].f = value;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Accum( op, value );
- }
-}
-
-
-void gl_save_AlphaFunc( GLenum func, GLclampf ref )
-{
- Node *n = alloc_instruction( OPCODE_ALPHA_FUNC, 2 );
- if (n) {
- n[1].e = func;
- n[2].f = (GLfloat) ref;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_AlphaFunc( func, ref );
- }
-}
-
-void gl_save_ArrayElement( GLint i )
-{
- if (gCCPriv->Array.NormalEnabled) {
- GLbyte *p = (GLbyte*) gCCPriv->Array.NormalPtr
- + i * gCCPriv->Array.NormalStrideB;
- switch (gCCPriv->Array.NormalType) {
- case GL_BYTE:
- (*gCCPriv->API->Normal3bv)( (GLbyte*) p );
- break;
- case GL_SHORT:
- (*gCCPriv->API->Normal3sv)( (GLshort*) p );
- break;
- case GL_INT:
- (*gCCPriv->API->Normal3iv)( (GLint*) p );
- break;
- case GL_FLOAT:
- (*gCCPriv->API->Normal3fv)( (GLfloat*) p );
- break;
- case GL_DOUBLE:
- (*gCCPriv->API->Normal3dv)( (GLdouble*) p );
- break;
- default:
-#if 0
- gl_problem("Bad normal type in gl_save_ArrayElement");
-#endif
- return;
- }
- }
-
- if (gCCPriv->Array.ColorEnabled) {
- GLbyte *p = (GLbyte*) gCCPriv->Array.ColorPtr + i * gCCPriv->Array.ColorStrideB;
- switch (gCCPriv->Array.ColorType) {
- case GL_BYTE:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3bv)( (GLbyte*) p ); break;
- case 4: (*gCCPriv->API->Color4bv)( (GLbyte*) p ); break;
- }
- break;
- case GL_UNSIGNED_BYTE:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3ubv)( (GLubyte*) p ); break;
- case 4: (*gCCPriv->API->Color4ubv)( (GLubyte*) p ); break;
- }
- break;
- case GL_SHORT:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3sv)( (GLshort*) p ); break;
- case 4: (*gCCPriv->API->Color4sv)( (GLshort*) p ); break;
- }
- break;
- case GL_UNSIGNED_SHORT:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3usv)( (GLushort*) p ); break;
- case 4: (*gCCPriv->API->Color4usv)( (GLushort*) p ); break;
- }
- break;
- case GL_INT:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3iv)( (GLint*) p ); break;
- case 4: (*gCCPriv->API->Color4iv)( (GLint*) p ); break;
- }
- break;
- case GL_UNSIGNED_INT:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3uiv)( (GLuint*) p ); break;
- case 4: (*gCCPriv->API->Color4uiv)( (GLuint*) p ); break;
- }
- break;
- case GL_FLOAT:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3fv)( (GLfloat*) p ); break;
- case 4: (*gCCPriv->API->Color4fv)( (GLfloat*) p ); break;
- }
- break;
- case GL_DOUBLE:
- switch (gCCPriv->Array.ColorSize) {
- case 3: (*gCCPriv->API->Color3dv)( (GLdouble*) p ); break;
- case 4: (*gCCPriv->API->Color4dv)( (GLdouble*) p ); break;
- }
- break;
- default:
-#if 0
- gl_problem("Bad color type in gl_save_ArrayElement");
-#endif
- return;
- }
- }
-
- if (gCCPriv->Array.IndexEnabled) {
- GLbyte *p = (GLbyte*) gCCPriv->Array.IndexPtr + i * gCCPriv->Array.IndexStrideB;
- switch (gCCPriv->Array.IndexType) {
- case GL_SHORT:
- (*gCCPriv->API->Indexsv)( (GLshort*) p );
- break;
- case GL_INT:
- (*gCCPriv->API->Indexiv)( (GLint*) p );
- break;
- case GL_FLOAT:
- (*gCCPriv->API->Indexfv)( (GLfloat*) p );
- break;
- case GL_DOUBLE:
- (*gCCPriv->API->Indexdv)( (GLdouble*) p );
- break;
- default:
-#if 0
- gl_problem("Bad index type in gl_save_ArrayElement");
-#endif
- return;
- }
- }
-
- if (gCCPriv->Array.EdgeFlagEnabled) {
- GLbyte *b = (GLbyte*) gCCPriv->Array.EdgeFlagPtr + i * gCCPriv->Array.EdgeFlagStrideB;
- (*gCCPriv->API->EdgeFlagv)( (GLboolean*) b );
- }
-
- if (gCCPriv->Array.VertexEnabled) {
- GLbyte *b = (GLbyte*) gCCPriv->Array.VertexPtr
- + i * gCCPriv->Array.VertexStrideB;
- switch (gCCPriv->Array.VertexType) {
- case GL_SHORT:
- switch (gCCPriv->Array.VertexSize) {
- case 2: (*gCCPriv->API->Vertex2sv)( (GLshort*) b ); break;
- case 3: (*gCCPriv->API->Vertex3sv)( (GLshort*) b ); break;
- case 4: (*gCCPriv->API->Vertex4sv)( (GLshort*) b ); break;
- }
- break;
- case GL_INT:
- switch (gCCPriv->Array.VertexSize) {
- case 2: (*gCCPriv->API->Vertex2iv)( (GLint*) b ); break;
- case 3: (*gCCPriv->API->Vertex3iv)( (GLint*) b ); break;
- case 4: (*gCCPriv->API->Vertex4iv)( (GLint*) b ); break;
- }
- break;
- case GL_FLOAT:
- switch (gCCPriv->Array.VertexSize) {
- case 2: (*gCCPriv->API->Vertex2fv)( (GLfloat*) b ); break;
- case 3: (*gCCPriv->API->Vertex3fv)( (GLfloat*) b ); break;
- case 4: (*gCCPriv->API->Vertex4fv)( (GLfloat*) b ); break;
- }
- break;
- case GL_DOUBLE:
- switch (gCCPriv->Array.VertexSize) {
- case 2: (*gCCPriv->API->Vertex2dv)( (GLdouble*) b ); break;
- case 3: (*gCCPriv->API->Vertex3dv)( (GLdouble*) b ); break;
- case 4: (*gCCPriv->API->Vertex4dv)( (GLdouble*) b ); break;
- }
- break;
- default:
-#if 0
- gl_problem("Bad vertex type in gl_save_ArrayElement");
-#endif
- return;
- }
- }
-}
-
-
-void gl_save_Begin( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_BEGIN, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Begin( mode );
- }
-}
-
-
-void gl_save_BindTexture( GLenum target, GLuint texture )
-{
- Node *n = alloc_instruction( OPCODE_BIND_TEXTURE, 2 );
- if (n) {
- n[1].e = target;
- n[2].ui = texture;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_BindTexture( target, texture );
- }
-}
-
-
-void gl_save_Bitmap(
- GLsizei width, GLsizei height,
- GLfloat xorig, GLfloat yorig,
- GLfloat xmove, GLfloat ymove,
- const GLubyte *bitmap )
-{
- GLvoid *image = _mesa_unpack_bitmap(width, height, bitmap, &gCCPriv->Unpack);
- Node *n = alloc_instruction( OPCODE_BITMAP, 7 );
- if (n) {
- n[1].i = (GLint) width;
- n[2].i = (GLint) height;
- n[3].f = xorig;
- n[4].f = yorig;
- n[5].f = xmove;
- n[6].f = ymove;
- n[7].data = image;
- } else
- if (image) {
- free(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Bitmap( width, height,
- xorig, yorig, xmove, ymove, bitmap );
- }
-}
-
-
-void gl_save_BlendFunc( GLenum sfactor, GLenum dfactor )
-{
- Node *n = alloc_instruction( OPCODE_BLEND_FUNC, 2 );
- if (n) {
- n[1].e = sfactor;
- n[2].e = dfactor;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_BlendFunc( sfactor, dfactor );
- }
-}
-
-void gl_save_CallList( GLuint list )
-{
- Node *n = alloc_instruction( OPCODE_CALL_LIST, 1 );
- if (n) {
- n[1].ui = list;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CallList( list );
- }
-}
-
-
-void gl_save_CallLists(
- GLsizei n, GLenum type, const GLvoid *lists )
-{
- GLint i;
-
- for (i=0;i<n;i++) {
- GLuint list = translate_id( i, type, lists );
- Node *n = alloc_instruction( OPCODE_CALL_LIST_OFFSET, 1 );
- if (n) {
- n[1].ui = list;
- }
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CallLists( n, type, lists );
- }
-}
-
-
-void gl_save_Clear( GLbitfield mask )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR, 1 );
- if (n) {
- n[1].bf = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Clear( mask );
- }
-}
-
-
-void gl_save_ClearAccum( GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR_ACCUM, 4 );
- if (n) {
- n[1].f = red;
- n[2].f = green;
- n[3].f = blue;
- n[4].f = alpha;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClearAccum( red, green, blue, alpha );
- }
-}
-
-
-void gl_save_ClearColor( GLclampf red, GLclampf green,
- GLclampf blue, GLclampf alpha )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR_COLOR, 4 );
- if (n) {
- n[1].f = red;
- n[2].f = green;
- n[3].f = blue;
- n[4].f = alpha;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClearColor( red, green, blue, alpha );
- }
-}
-
-
-void gl_save_ClearDepth( GLclampd depth )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR_DEPTH, 1 );
- if (n) {
- n[1].f = (GLfloat) depth;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClearDepth( depth );
- }
-}
-
-
-void gl_save_ClearIndex( GLfloat c )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR_INDEX, 1 );
- if (n) {
- n[1].f = c;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClearIndex( c );
- }
-}
-
-
-void gl_save_ClearStencil( GLint s )
-{
- Node *n = alloc_instruction( OPCODE_CLEAR_STENCIL, 1 );
- if (n) {
- n[1].i = s;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClearStencil( s );
- }
-}
-
-
-void gl_save_ClipPlane( GLenum plane, const GLdouble *equ )
-{
- Node *n = alloc_instruction( OPCODE_CLIP_PLANE, 5 );
- if (n) {
- n[1].e = plane;
- n[2].f = equ[0];
- n[3].f = equ[1];
- n[4].f = equ[2];
- n[5].f = equ[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ClipPlane( plane, equ );
- }
-}
-
-
-void gl_save_Color3f( GLfloat r, GLfloat g, GLfloat b )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_3F, 3 );
- if (n) {
- n[1].f = r;
- n[2].f = g;
- n[3].f = b;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color3f( r, g, b );
- }
-}
-
-
-void gl_save_Color3fv( const GLfloat *c )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_3F, 3 );
- if (n) {
- n[1].f = c[0];
- n[2].f = c[1];
- n[3].f = c[2];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color3fv( c );
- }
-}
-
-
-void gl_save_Color4f( GLfloat r, GLfloat g,
- GLfloat b, GLfloat a )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_4F, 4 );
- if (n) {
- n[1].f = r;
- n[2].f = g;
- n[3].f = b;
- n[4].f = a;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color4f( r, g, b, a );
- }
-}
-
-
-void gl_save_Color4fv( const GLfloat *c )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_4F, 4 );
- if (n) {
- n[1].f = c[0];
- n[2].f = c[1];
- n[3].f = c[2];
- n[4].f = c[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color4fv( c );
- }
-}
-
-
-void gl_save_Color4ub( GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_4UB, 4 );
- if (n) {
- n[1].ub = r;
- n[2].ub = g;
- n[3].ub = b;
- n[4].ub = a;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color4ub( r, g, b, a );
- }
-}
-
-
-void gl_save_Color4ubv( const GLubyte *c )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_4UB, 4 );
- if (n) {
- n[1].ub = c[0];
- n[2].ub = c[1];
- n[3].ub = c[2];
- n[4].ub = c[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Color4ubv( c );
- }
-}
-
-
-void gl_save_ColorMask( GLboolean red, GLboolean green,
- GLboolean blue, GLboolean alpha )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_MASK, 4 );
- if (n) {
- n[1].b = red;
- n[2].b = green;
- n[3].b = blue;
- n[4].b = alpha;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ColorMask( red, green, blue, alpha );
- }
-}
-
-
-void gl_save_ColorMaterial( GLenum face, GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_COLOR_MATERIAL, 2 );
- if (n) {
- n[1].e = face;
- n[2].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ColorMaterial( face, mode );
- }
-}
-
-
-void gl_save_CopyPixels( GLint x, GLint y,
- GLsizei width, GLsizei height, GLenum type )
-{
- Node *n = alloc_instruction( OPCODE_COPY_PIXELS, 5 );
- if (n) {
- n[1].i = x;
- n[2].i = y;
- n[3].i = (GLint) width;
- n[4].i = (GLint) height;
- n[5].e = type;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CopyPixels( x, y, width, height, type );
- }
-}
-
-
-
-void gl_save_CopyTexImage1D(
- GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y, GLsizei width,
- GLint border )
-{
- Node *n = alloc_instruction( OPCODE_COPY_TEX_IMAGE1D, 7 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].e = internalformat;
- n[4].i = x;
- n[5].i = y;
- n[6].i = width;
- n[7].i = border;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CopyTexImage1D( target, level, internalformat,
- x, y, width, border );
- }
-}
-
-
-void gl_save_CopyTexImage2D(
- GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y, GLsizei width,
- GLsizei height, GLint border )
-{
- Node *n = alloc_instruction( OPCODE_COPY_TEX_IMAGE2D, 8 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].e = internalformat;
- n[4].i = x;
- n[5].i = y;
- n[6].i = width;
- n[7].i = height;
- n[8].i = border;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CopyTexImage2D( target, level, internalformat,
- x, y, width, height, border );
- }
-}
-
-
-
-void gl_save_CopyTexSubImage1D(
- GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y,
- GLsizei width )
-{
- Node *n = alloc_instruction( OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = xoffset;
- n[4].i = x;
- n[5].i = y;
- n[6].i = width;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CopyTexSubImage1D( target, level, xoffset, x, y, width );
- }
-}
-
-
-void gl_save_CopyTexSubImage2D(
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y,
- GLsizei width, GLint height )
-{
- Node *n = alloc_instruction( OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = xoffset;
- n[4].i = yoffset;
- n[5].i = x;
- n[6].i = y;
- n[7].i = width;
- n[8].i = height;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CopyTexSubImage2D( target, level, xoffset, yoffset,
- x, y, width, height );
- }
-}
-
-
-void gl_save_CullFace( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_CULL_FACE, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_CullFace( mode );
- }
-}
-
-
-void gl_save_DepthFunc( GLenum func )
-{
- Node *n = alloc_instruction( OPCODE_DEPTH_FUNC, 1 );
- if (n) {
- n[1].e = func;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_DepthFunc( func );
- }
-}
-
-
-void gl_save_DepthMask( GLboolean mask )
-{
- Node *n = alloc_instruction( OPCODE_DEPTH_MASK, 1 );
- if (n) {
- n[1].b = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_DepthMask( mask );
- }
-}
-
-
-void gl_save_DepthRange( GLclampd nearval, GLclampd farval )
-{
- Node *n = alloc_instruction( OPCODE_DEPTH_RANGE, 2 );
- if (n) {
- n[1].f = (GLfloat) nearval;
- n[2].f = (GLfloat) farval;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_DepthRange( nearval, farval );
- }
-}
-
-
-void gl_save_Disable( GLenum cap )
-{
- Node *n = alloc_instruction( OPCODE_DISABLE, 1 );
- if (n) {
- n[1].e = cap;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Disable( cap );
- }
-}
-
-void gl_save_DrawArrays(
- GLenum mode, GLint first, GLsizei count )
-{
- GLint i;
-
-#if 0
- if (INSIDE_BEGIN_END(ctx)) {
- gamma_error( GL_INVALID_OPERATION, "glDrawArrays" );
- return;
- }
-#endif
- if (count<0) {
- gamma_error( GL_INVALID_VALUE, "glDrawArrays(count)" );
- return;
- }
- switch (mode) {
- case GL_POINTS:
- case GL_LINES:
- case GL_LINE_STRIP:
- case GL_LINE_LOOP:
- case GL_TRIANGLES:
- case GL_TRIANGLE_STRIP:
- case GL_TRIANGLE_FAN:
- case GL_QUADS:
- case GL_QUAD_STRIP:
- case GL_POLYGON:
- /* OK */
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glDrawArrays(mode)" );
- return;
- }
-
- /* Note: this will do compile AND execute if needed */
- gl_save_Begin( mode );
- for (i=0;i<count;i++) {
- gl_save_ArrayElement( first+i );
- }
- gl_save_End( );
-}
-
-
-void gl_save_DrawBuffer( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_DRAW_BUFFER, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_DrawBuffer( mode );
- }
-}
-
-
-void gl_save_DrawElements(
- GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices )
-{
- switch (type) {
- case GL_UNSIGNED_BYTE:
- {
- GLubyte *ub_indices = (GLubyte *) indices;
- GLint i;
- gl_save_Begin( mode );
- for (i=0;i<count;i++) {
- gl_save_ArrayElement( (GLint) ub_indices[i] );
- }
- gl_save_End( );
- }
- break;
- case GL_UNSIGNED_SHORT:
- {
- GLushort *us_indices = (GLushort *) indices;
- GLint i;
- gl_save_Begin( mode );
- for (i=0;i<count;i++) {
- gl_save_ArrayElement( (GLint) us_indices[i] );
- }
- gl_save_End( );
- }
- break;
- case GL_UNSIGNED_INT:
- {
- GLuint *ui_indices = (GLuint *) indices;
- GLint i;
- gl_save_Begin( mode );
- for (i=0;i<count;i++) {
- gl_save_ArrayElement( (GLint) ui_indices[i] );
- }
- gl_save_End( );
- }
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glDrawElements(type)" );
- return;
- }
-}
-
-
-void gl_save_DrawPixels( GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
- pixels, &gCCPriv->Unpack);
- Node *n = alloc_instruction( OPCODE_DRAW_PIXELS, 5 );
- if (n) {
- n[1].i = width;
- n[2].i = height;
- n[3].e = format;
- n[4].e = type;
- n[5].data = image;
- } else
- if (image) {
- free(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_DrawPixels( width, height, format, type, pixels );
- }
-}
-
-
-void gl_save_EdgeFlag( GLboolean flag )
-{
- Node *n = alloc_instruction( OPCODE_EDGE_FLAG, 1 );
- if (n) {
- n[1].b = flag;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EdgeFlag( flag );
- }
-}
-
-
-void gl_save_Enable( GLenum cap )
-{
- Node *n = alloc_instruction( OPCODE_ENABLE, 1 );
- if (n) {
- n[1].e = cap;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Enable( cap );
- }
-}
-
-
-void gl_save_End( void )
-{
- (void) alloc_instruction( OPCODE_END, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_End( );
- }
-}
-
-
-void gl_save_EvalCoord1f( GLfloat u )
-{
- Node *n = alloc_instruction( OPCODE_EVALCOORD1, 1 );
- if (n) {
- n[1].f = u;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalCoord1f( u );
- }
-}
-
-
-void gl_save_EvalCoord2f( GLfloat u, GLfloat v )
-{
- Node *n = alloc_instruction( OPCODE_EVALCOORD2, 2 );
- if (n) {
- n[1].f = u;
- n[2].f = v;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalCoord2f( u, v );
- }
-}
-
-
-void gl_save_EvalMesh1(
- GLenum mode, GLint i1, GLint i2 )
-{
- Node *n = alloc_instruction( OPCODE_EVALMESH1, 3 );
- if (n) {
- n[1].e = mode;
- n[2].i = i1;
- n[3].i = i2;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalMesh1( mode, i1, i2 );
- }
-}
-
-
-void gl_save_EvalMesh2(
- GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
-{
- Node *n = alloc_instruction( OPCODE_EVALMESH2, 5 );
- if (n) {
- n[1].e = mode;
- n[2].i = i1;
- n[3].i = i2;
- n[4].i = j1;
- n[5].i = j2;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalMesh2( mode, i1, i2, j1, j2 );
- }
-}
-
-
-void gl_save_EvalPoint1( GLint i )
-{
- Node *n = alloc_instruction( OPCODE_EVALPOINT1, 1 );
- if (n) {
- n[1].i = i;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalPoint1( i );
- }
-}
-
-
-void gl_save_EvalPoint2( GLint i, GLint j )
-{
- Node *n = alloc_instruction( OPCODE_EVALPOINT2, 2 );
- if (n) {
- n[1].i = i;
- n[2].i = j;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_EvalPoint2( i, j );
- }
-}
-
-
-void gl_save_Fogfv( GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_FOG, 5 );
- if (n) {
- n[1].e = pname;
- n[2].f = params[0];
- n[3].f = params[1];
- n[4].f = params[2];
- n[5].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Fogfv( pname, params );
- }
-}
-
-
-void gl_save_FrontFace( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_FRONT_FACE, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_FrontFace( mode );
- }
-}
-
-
-void gl_save_Frustum( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble nearval, GLdouble farval )
-{
- Node *n = alloc_instruction( OPCODE_FRUSTUM, 6 );
- if (n) {
- n[1].f = left;
- n[2].f = right;
- n[3].f = bottom;
- n[4].f = top;
- n[5].f = nearval;
- n[6].f = farval;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Frustum( left, right, bottom, top, nearval, farval );
- }
-}
-
-
-void gl_save_Hint( GLenum target, GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_HINT, 2 );
- if (n) {
- n[1].e = target;
- n[2].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Hint( target, mode );
- }
-}
-
-
-void gl_save_Indexi( GLint index )
-{
- Node *n = alloc_instruction( OPCODE_INDEX, 1 );
- if (n) {
- n[1].i = index;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Indexi( index );
- }
-}
-
-
-void gl_save_Indexf( GLfloat index )
-{
- Node *n = alloc_instruction( OPCODE_INDEX, 1 );
- if (n) {
- n[1].i = (GLint) index;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Indexf( index );
- }
-}
-
-
-void gl_save_IndexMask( GLuint mask )
-{
- Node *n = alloc_instruction( OPCODE_INDEX_MASK, 1 );
- if (n) {
- n[1].ui = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_IndexMask( mask );
- }
-}
-
-
-void gl_save_InitNames( void )
-{
- (void) alloc_instruction( OPCODE_INIT_NAMES, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_InitNames( );
- }
-}
-
-
-void gl_save_Lightfv( GLenum light, GLenum pname,
- const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_LIGHT, 6 );
- if (OPCODE_LIGHT) {
- GLint i, nParams;
- n[1].e = light;
- n[2].e = pname;
- switch (pname) {
- case GL_AMBIENT:
- nParams = 4;
- break;
- case GL_DIFFUSE:
- nParams = 4;
- break;
- case GL_SPECULAR:
- nParams = 4;
- break;
- case GL_POSITION:
- nParams = 4;
- break;
- case GL_SPOT_DIRECTION:
- nParams = 3;
- break;
- case GL_SPOT_EXPONENT:
- nParams = 1;
- break;
- case GL_SPOT_CUTOFF:
- nParams = 1;
- break;
- case GL_CONSTANT_ATTENUATION:
- nParams = 1;
- break;
- case GL_LINEAR_ATTENUATION:
- nParams = 1;
- break;
- case GL_QUADRATIC_ATTENUATION:
- nParams = 1;
- break;
- default:
- nParams = 0;
- }
- for (i = 0; i < nParams; i++) {
- n[3+i].f = params[i];
- }
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Lightfv( light, pname, params );
- }
-}
-
-
-void gl_save_LightModelfv(
- GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_LIGHT_MODEL, 5 );
- if (n) {
- n[1].e = pname;
- n[2].f = params[0];
- n[3].f = params[1];
- n[4].f = params[2];
- n[5].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LightModelfv( pname, params );
- }
-}
-
-
-void gl_save_LineStipple( GLint factor, GLushort pattern )
-{
- Node *n = alloc_instruction( OPCODE_LINE_STIPPLE, 2 );
- if (n) {
- n[1].i = factor;
- n[2].us = pattern;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LineStipple( factor, pattern );
- }
-}
-
-
-void gl_save_LineWidth( GLfloat width )
-{
- Node *n = alloc_instruction( OPCODE_LINE_WIDTH, 1 );
- if (n) {
- n[1].f = width;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LineWidth( width );
- }
-}
-
-
-void gl_save_ListBase( GLuint base )
-{
- Node *n = alloc_instruction( OPCODE_LIST_BASE, 1 );
- if (n) {
- n[1].ui = base;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ListBase( base );
- }
-}
-
-
-void gl_save_LoadIdentity( void )
-{
- (void) alloc_instruction( OPCODE_LOAD_IDENTITY, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_LoadIdentity( );
- }
-}
-
-
-void gl_save_LoadMatrixf( const GLfloat *m )
-{
- Node *n = alloc_instruction( OPCODE_LOAD_MATRIX, 16 );
- if (n) {
- GLuint i;
- for (i=0;i<16;i++) {
- n[1+i].f = m[i];
- }
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LoadMatrixf( m );
- }
-}
-
-
-void gl_save_LoadName( GLuint name )
-{
- Node *n = alloc_instruction( OPCODE_LOAD_NAME, 1 );
- if (n) {
- n[1].ui = name;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LoadName( name );
- }
-}
-
-
-void gl_save_LogicOp( GLenum opcode )
-{
- Node *n = alloc_instruction( OPCODE_LOGIC_OP, 1 );
- if (n) {
- n[1].e = opcode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_LogicOp( opcode );
- }
-}
-
-
-void gl_save_Map1f(
- GLenum target, GLfloat u1, GLfloat u2, GLint stride,
- GLint order, const GLfloat *points )
-{
- Node *n = alloc_instruction( OPCODE_MAP1, 6 );
- if (n) {
- GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
- n[1].e = target;
- n[2].f = u1;
- n[3].f = u2;
- n[4].i = _mesa_evaluator_components(target); /* stride */
- n[5].i = order;
- n[6].data = (void *) pnts;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Map1f( target, u1, u2, stride, order, points );
- }
-}
-
-
-void gl_save_Map2f( GLenum target,
- GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
- GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
- const GLfloat *points )
-{
- Node *n = alloc_instruction( OPCODE_MAP2, 10 );
- if (n) {
- GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
- vstride, vorder, points );
- n[1].e = target;
- n[2].f = u1;
- n[3].f = u2;
- n[4].f = v1;
- n[5].f = v2;
- /* XXX verify these strides are correct */
- n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
- n[7].i = _mesa_evaluator_components(target); /*vstride*/
- n[8].i = uorder;
- n[9].i = vorder;
- n[10].data = (void *) pnts;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Map2f( target,
- u1, u2, ustride, uorder,
- v1, v2, vstride, vorder, points );
- }
-}
-
-
-void gl_save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
-{
- Node *n = alloc_instruction( OPCODE_MAPGRID1, 3 );
- if (n) {
- n[1].i = un;
- n[2].f = u1;
- n[3].f = u2;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_MapGrid1f( un, u1, u2 );
- }
-}
-
-
-void gl_save_MapGrid2f(
- GLint un, GLfloat u1, GLfloat u2,
- GLint vn, GLfloat v1, GLfloat v2 )
-{
- Node *n = alloc_instruction( OPCODE_MAPGRID2, 6 );
- if (n) {
- n[1].i = un;
- n[2].f = u1;
- n[3].f = u2;
- n[4].i = vn;
- n[5].f = v1;
- n[6].f = v2;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_MapGrid2f( un, u1, u2, vn, v1, v2 );
- }
-}
-
-
-void gl_save_Materialfv(
- GLenum face, GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_MATERIAL, 6 );
- if (n) {
- n[1].e = face;
- n[2].e = pname;
- n[3].f = params[0];
- n[4].f = params[1];
- n[5].f = params[2];
- n[6].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Materialfv( face, pname, params );
- }
-}
-
-
-void gl_save_MatrixMode( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_MATRIX_MODE, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_MatrixMode( mode );
- }
-}
-
-
-void gl_save_MultMatrixf( const GLfloat *m )
-{
- Node *n = alloc_instruction( OPCODE_MULT_MATRIX, 16 );
- if (n) {
- GLuint i;
- for (i=0;i<16;i++) {
- n[1+i].f = m[i];
- }
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_MultMatrixf( m );
- }
-}
-
-
-void gl_save_NewList( GLuint list, GLenum mode )
-{
- /* It's an error to call this function while building a display list */
- gamma_error( GL_INVALID_OPERATION, "glNewList" );
- (void) list;
- (void) mode;
-}
-
-
-void gl_save_Normal3fv( const GLfloat norm[3] )
-{
- Node *n = alloc_instruction( OPCODE_NORMAL, 3 );
- if (n) {
- n[1].f = norm[0];
- n[2].f = norm[1];
- n[3].f = norm[2];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Normal3fv( norm );
- }
-}
-
-
-void gl_save_Normal3f( GLfloat nx, GLfloat ny, GLfloat nz )
-{
- Node *n = alloc_instruction( OPCODE_NORMAL, 3 );
- if (n) {
- n[1].f = nx;
- n[2].f = ny;
- n[3].f = nz;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Normal3f( nx, ny, nz );
- }
-}
-
-
-void gl_save_Ortho( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble nearval, GLdouble farval )
-{
- Node *n = alloc_instruction( OPCODE_ORTHO, 6 );
- if (n) {
- n[1].f = left;
- n[2].f = right;
- n[3].f = bottom;
- n[4].f = top;
- n[5].f = nearval;
- n[6].f = farval;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Ortho( left, right, bottom, top, nearval, farval );
- }
-}
-
-
-void gl_save_PixelMapfv(
- GLenum map, GLint mapsize, const GLfloat *values )
-{
- Node *n = alloc_instruction( OPCODE_PIXEL_MAP, 3 );
- if (n) {
- n[1].e = map;
- n[2].i = mapsize;
- n[3].data = (void *) malloc( mapsize * sizeof(GLfloat) );
- MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PixelMapfv( map, mapsize, values );
- }
-}
-
-
-void gl_save_PixelTransferf( GLenum pname, GLfloat param )
-{
- Node *n = alloc_instruction( OPCODE_PIXEL_TRANSFER, 2 );
- if (n) {
- n[1].e = pname;
- n[2].f = param;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PixelTransferf( pname, param );
- }
-}
-
-
-void gl_save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
-{
- Node *n = alloc_instruction( OPCODE_PIXEL_ZOOM, 2 );
- if (n) {
- n[1].f = xfactor;
- n[2].f = yfactor;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PixelZoom( xfactor, yfactor );
- }
-}
-
-
-void gl_save_PointSize( GLfloat size )
-{
- Node *n = alloc_instruction( OPCODE_POINT_SIZE, 1 );
- if (n) {
- n[1].f = size;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PointSize( size );
- }
-}
-
-
-void gl_save_PolygonMode( GLenum face, GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_POLYGON_MODE, 2 );
- if (n) {
- n[1].e = face;
- n[2].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PolygonMode( face, mode );
- }
-}
-
-
-/*
- * Polygon stipple must have been upacked already!
- */
-void gl_save_PolygonStipple( const GLubyte *pattern )
-{
- Node *n = alloc_instruction( OPCODE_POLYGON_STIPPLE, 1 );
- if (n) {
- void *data;
- n[1].data = malloc( 32 * 4 );
- data = n[1].data; /* This needed for Acorn compiler */
- MEMCPY( data, pattern, 32 * 4 );
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PolygonStipple( pattern );
- }
-}
-
-
-void gl_save_PolygonOffset( GLfloat factor, GLfloat units )
-{
- Node *n = alloc_instruction( OPCODE_POLYGON_OFFSET, 2 );
- if (n) {
- n[1].f = factor;
- n[2].f = units;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PolygonOffset( factor, units );
- }
-}
-
-
-void gl_save_PopAttrib( void )
-{
- (void) alloc_instruction( OPCODE_POP_ATTRIB, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_PopAttrib( );
- }
-}
-
-
-void gl_save_PopMatrix( void )
-{
- (void) alloc_instruction( OPCODE_POP_MATRIX, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_PopMatrix( );
- }
-}
-
-
-void gl_save_PopName( void )
-{
- (void) alloc_instruction( OPCODE_POP_NAME, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_PopName( );
- }
-}
-
-
-void gl_save_PrioritizeTextures(
- GLsizei num, const GLuint *textures,
- const GLclampf *priorities )
-{
- GLint i;
-
- for (i=0;i<num;i++) {
- Node *n = alloc_instruction( OPCODE_PRIORITIZE_TEXTURE, 2 );
- if (n) {
- n[1].ui = textures[i];
- n[2].f = priorities[i];
- }
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PrioritizeTextures( num, textures, priorities );
- }
-}
-
-
-void gl_save_PushAttrib( GLbitfield mask )
-{
- Node *n = alloc_instruction( OPCODE_PUSH_ATTRIB, 1 );
- if (n) {
- n[1].bf = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PushAttrib( mask );
- }
-}
-
-
-void gl_save_PushMatrix( void )
-{
- (void) alloc_instruction( OPCODE_PUSH_MATRIX, 0 );
- if (gCCPriv->ExecuteFlag) {
- _gamma_PushMatrix( );
- }
-}
-
-
-void gl_save_PushName( GLuint name )
-{
- Node *n = alloc_instruction( OPCODE_PUSH_NAME, 1 );
- if (n) {
- n[1].ui = name;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PushName( name );
- }
-}
-
-
-void gl_save_RasterPos4f(
- GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- Node *n = alloc_instruction( OPCODE_RASTER_POS, 4 );
- if (n) {
- n[1].f = x;
- n[2].f = y;
- n[3].f = z;
- n[4].f = w;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_RasterPos4f( x, y, z, w );
- }
-}
-
-
-void gl_save_PassThrough( GLfloat token )
-{
- Node *n = alloc_instruction( OPCODE_PASSTHROUGH, 1 );
- if (n) {
- n[1].f = token;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_PassThrough( token );
- }
-}
-
-
-void gl_save_ReadBuffer( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_READ_BUFFER, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ReadBuffer( mode );
- }
-}
-
-
-void gl_save_Rectf(
- GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- Node *n = alloc_instruction( OPCODE_RECTF, 4 );
- if (n) {
- n[1].f = x1;
- n[2].f = y1;
- n[3].f = x2;
- n[4].f = y2;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Rectf( x1, y1, x2, y2 );
- }
-}
-
-
-void gl_save_Rotatef( GLfloat angle,
- GLfloat x, GLfloat y, GLfloat z )
-{
- GLfloat m[16];
- gl_rotation_matrix( angle, x, y, z, m );
- gl_save_MultMatrixf( m ); /* save and maybe execute */
-}
-
-
-void gl_save_Scalef( GLfloat x, GLfloat y, GLfloat z )
-{
- Node *n = alloc_instruction( OPCODE_SCALE, 3 );
- if (n) {
- n[1].f = x;
- n[2].f = y;
- n[3].f = z;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Scalef( x, y, z );
- }
-}
-
-
-void gl_save_Scissor(
- GLint x, GLint y, GLsizei width, GLsizei height )
-{
- Node *n = alloc_instruction( OPCODE_SCISSOR, 4 );
- if (n) {
- n[1].i = x;
- n[2].i = y;
- n[3].i = width;
- n[4].i = height;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Scissor( x, y, width, height );
- }
-}
-
-
-void gl_save_ShadeModel( GLenum mode )
-{
- Node *n = alloc_instruction( OPCODE_SHADE_MODEL, 1 );
- if (n) {
- n[1].e = mode;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_ShadeModel( mode );
- }
-}
-
-
-void gl_save_StencilFunc( GLenum func, GLint ref, GLuint mask )
-{
- Node *n = alloc_instruction( OPCODE_STENCIL_FUNC, 3 );
- if (n) {
- n[1].e = func;
- n[2].i = ref;
- n[3].ui = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_StencilFunc( func, ref, mask );
- }
-}
-
-
-void gl_save_StencilMask( GLuint mask )
-{
- Node *n = alloc_instruction( OPCODE_STENCIL_MASK, 1 );
- if (n) {
- n[1].ui = mask;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_StencilMask( mask );
- }
-}
-
-
-void gl_save_StencilOp(
- GLenum fail, GLenum zfail, GLenum zpass )
-{
- Node *n = alloc_instruction( OPCODE_STENCIL_OP, 3 );
- if (n) {
- n[1].e = fail;
- n[2].e = zfail;
- n[3].e = zpass;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_StencilOp( fail, zfail, zpass );
- }
-}
-
-
-void gl_save_TexCoord2f( GLfloat s, GLfloat t )
-{
- Node *n = alloc_instruction( OPCODE_TEXCOORD2, 2 );
- if (n) {
- n[1].f = s;
- n[2].f = t;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexCoord2f( s, t );
- }
-}
-
-void gl_save_TexCoord2fv( const GLfloat *v )
-{
- Node *n = alloc_instruction( OPCODE_TEXCOORD2, 2 );
- if (n) {
- n[1].f = v[0];
- n[2].f = v[1];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexCoord2f( n[1].f, n[2].f );
- }
-}
-
-void gl_save_TexCoord3fv( const GLfloat *v )
-{
- Node *n = alloc_instruction( OPCODE_TEXCOORD4, 4 );
- if (n) {
- n[1].f = v[0];
- n[2].f = v[1];
- n[1].f = v[2];
- n[2].f = 1.0f;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexCoord4f( n[1].f, n[2].f, n[3].f, n[4].f );
- }
-}
-
-void gl_save_TexCoord4f( GLfloat s, GLfloat t,
- GLfloat r, GLfloat q )
-{
- Node *n = alloc_instruction( OPCODE_TEXCOORD4, 4 );
- if (n) {
- n[1].f = s;
- n[2].f = t;
- n[3].f = r;
- n[4].f = q;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexCoord4f( s, t, r, q );
- }
-}
-
-
-void gl_save_TexEnvfv(
- GLenum target, GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_TEXENV, 6 );
- if (n) {
- n[1].e = target;
- n[2].e = pname;
- n[3].f = params[0];
- n[4].f = params[1];
- n[5].f = params[2];
- n[6].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexEnvfv( target, pname, params );
- }
-}
-
-
-void gl_save_TexGenfv(
- GLenum coord, GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_TEXGEN, 6 );
- if (n) {
- n[1].e = coord;
- n[2].e = pname;
- n[3].f = params[0];
- n[4].f = params[1];
- n[5].f = params[2];
- n[6].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexGenfv( coord, pname, params );
- }
-}
-
-
-void gl_save_TexParameterfv( GLenum target,
- GLenum pname, const GLfloat *params )
-{
- Node *n = alloc_instruction( OPCODE_TEXPARAMETER, 6 );
- if (n) {
- n[1].e = target;
- n[2].e = pname;
- n[3].f = params[0];
- n[4].f = params[1];
- n[5].f = params[2];
- n[6].f = params[3];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexParameterfv( target, pname, params );
- }
-}
-
-
-void gl_save_TexImage1D( GLenum target,
- GLint level, GLint components,
- GLsizei width, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- if (target == GL_PROXY_TEXTURE_1D) {
- /* don't compile, execute immediately */
- _gamma_TexImage1D( target, level, components, width,
- border, format, type, pixels );
- }
- else {
- GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
- pixels, &gCCPriv->Unpack);
- Node *n;
- n = alloc_instruction( OPCODE_TEX_IMAGE1D, 8 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = components;
- n[4].i = (GLint) width;
- n[5].i = border;
- n[6].e = format;
- n[7].e = type;
- n[8].data = image;
- }
- else if (image) {
- FREE(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexImage1D( target, level, components, width,
- border, format, type, pixels );
- }
- }
-}
-
-
-void gl_save_TexImage2D( GLenum target,
- GLint level, GLint components,
- GLsizei width, GLsizei height, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- if (target == GL_PROXY_TEXTURE_2D) {
- /* don't compile, execute immediately */
- _gamma_TexImage2D( target, level, components, width,
- height, border, format, type, pixels );
- }
- else {
- GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
- pixels, &gCCPriv->Unpack);
- Node *n;
- n = alloc_instruction( OPCODE_TEX_IMAGE2D, 9 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = components;
- n[4].i = (GLint) width;
- n[5].i = (GLint) height;
- n[6].i = border;
- n[7].e = format;
- n[8].e = type;
- n[9].data = image;
- }
- else if (image) {
- FREE(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexImage2D( target, level, components, width,
- height, border, format, type, pixels );
- }
- }
-}
-
-
-void gl_save_TexSubImage1D(
- GLenum target, GLint level, GLint xoffset,
- GLsizei width, GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
- pixels, &gCCPriv->Unpack);
- Node *n = alloc_instruction( OPCODE_TEX_SUB_IMAGE1D, 7 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = xoffset;
- n[4].i = (GLint) width;
- n[5].e = format;
- n[6].e = type;
- n[7].data = image;
- } else
- if (image) {
- free(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexSubImage1D( target, level, xoffset, width,
- format, type, image );
- }
-}
-
-
-void gl_save_TexSubImage2D(
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels )
-{
- GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
- pixels, &gCCPriv->Unpack);
- Node *n = alloc_instruction( OPCODE_TEX_SUB_IMAGE2D, 9 );
- if (n) {
- n[1].e = target;
- n[2].i = level;
- n[3].i = xoffset;
- n[4].i = yoffset;
- n[5].i = (GLint) width;
- n[6].i = (GLint) height;
- n[7].e = format;
- n[8].e = type;
- n[9].data = image;
- } else
- if (image) {
- free(image);
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_TexSubImage2D( target, level, xoffset, yoffset,
- width, height, format, type, image );
- }
-}
-
-
-void gl_save_Translatef( GLfloat x, GLfloat y, GLfloat z )
-{
- Node *n = alloc_instruction( OPCODE_TRANSLATE, 3 );
- if (n) {
- n[1].f = x;
- n[2].f = y;
- n[3].f = z;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Translatef( x, y, z );
- }
-}
-
-
-void gl_save_Vertex2f( GLfloat x, GLfloat y )
-{
- Node *n = alloc_instruction( OPCODE_VERTEX2, 2 );
- if (n) {
- n[1].f = x;
- n[2].f = y;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Vertex2f( x, y );
- }
-}
-
-
-void gl_save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
-{
- Node *n = alloc_instruction( OPCODE_VERTEX3, 3 );
-
- if (n) {
- n[1].f = x;
- n[2].f = y;
- n[3].f = z;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Vertex3f( x, y, z );
- }
-}
-
-
-void gl_save_Vertex4f(
- GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- Node *n = alloc_instruction( OPCODE_VERTEX4, 4 );
- if (n) {
- n[1].f = x;
- n[2].f = y;
- n[3].f = z;
- n[4].f = w;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Vertex4f( x, y, z, w );
- }
-}
-
-
-void gl_save_Vertex3fv( const GLfloat v[3] )
-{
- Node *n = alloc_instruction( OPCODE_VERTEX3, 3 );
- if (n) {
- n[1].f = v[0];
- n[2].f = v[1];
- n[3].f = v[2];
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Vertex3fv( v );
- }
-}
-
-
-void gl_save_Viewport(
- GLint x, GLint y, GLsizei width, GLsizei height )
-{
- Node *n = alloc_instruction( OPCODE_VIEWPORT, 4 );
- if (n) {
- n[1].i = x;
- n[2].i = y;
- n[3].i = (GLint) width;
- n[4].i = (GLint) height;
- }
- if (gCCPriv->ExecuteFlag) {
- _gamma_Viewport( x, y, width, height );
- }
-}
-
-
-/**********************************************************************/
-/* Display list execution */
-/**********************************************************************/
-
-
-/*
- * Execute a display list. Note that the ListBase offset must have already
- * been added before calling this function. I.e. the list argument is
- * the absolute list number, not relative to ListBase.
- * Input: list - display list number
- */
-static void execute_list( GLuint list )
-{
- Node *n;
- GLboolean done;
- OpCode opcode;
-
- if (!_gamma_IsList(list))
- return;
-
- gCCPriv->CallDepth++;
-
- n = (Node *) _mesa_HashLookup(gCCPriv->DisplayList, list);
-
- done = GL_FALSE;
- while (!done) {
- opcode = n[0].opcode;
-
- switch (opcode) {
- /* Frequently called functions: */
- case OPCODE_VERTEX2:
- _gamma_Vertex2f( n[1].f, n[2].f );
- break;
- case OPCODE_VERTEX3:
- _gamma_Vertex3f( n[1].f, n[2].f, n[3].f );
- break;
- case OPCODE_VERTEX4:
- _gamma_Vertex4f( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_NORMAL:
- _gamma_Normal3f( n[1].f, n[2].f, n[3].f );
-#if 0 /* NOT_DONE */
- gCCPriv->VB->MonoNormal = GL_FALSE;
-#endif
- break;
- case OPCODE_COLOR_4UB:
- _gamma_Color4ub( n[1].ub, n[2].ub, n[3].ub, n[4].ub );
- break;
- case OPCODE_COLOR_3F:
- _gamma_Color3f( n[1].f, n[2].f, n[3].f );
- break;
- case OPCODE_COLOR_4F:
- _gamma_Color4f( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_INDEX:
- gCCPriv->Current.Index = n[1].ui;
-#if 0 /* NOT_DONE */
- gCCPriv->VB->MonoColor = GL_FALSE;
-#endif
- break;
- case OPCODE_BEGIN:
- _gamma_Begin( n[1].e );
- break;
- case OPCODE_END:
- _gamma_End( );
- break;
- case OPCODE_TEXCOORD2:
- _gamma_TexCoord2f( n[1].f, n[2].f );
- break;
- case OPCODE_TEXCOORD4:
- _gamma_TexCoord4f( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_ACCUM:
- _gamma_Accum( n[1].e, n[2].f );
- break;
- case OPCODE_ALPHA_FUNC:
- _gamma_AlphaFunc( n[1].e, n[2].f );
- break;
- case OPCODE_BIND_TEXTURE:
- _gamma_BindTexture( n[1].e, n[2].ui );
- break;
- case OPCODE_BITMAP:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_Bitmap( (GLsizei) n[1].i, (GLsizei) n[2].i,
- n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_BLEND_FUNC:
- _gamma_BlendFunc( n[1].e, n[2].e );
- break;
- case OPCODE_CALL_LIST:
- /* Generated by glCallList(), don't add ListBase */
- if (gCCPriv->CallDepth<MAX_LIST_NESTING) {
- execute_list( n[1].ui );
- }
- break;
- case OPCODE_CALL_LIST_OFFSET:
- /* Generated by glCallLists() so we must add ListBase */
- if (gCCPriv->CallDepth<MAX_LIST_NESTING) {
- execute_list( gCCPriv->List.ListBase + n[1].ui );
- }
- break;
- case OPCODE_CLEAR:
- _gamma_Clear( n[1].bf );
- break;
- case OPCODE_CLEAR_COLOR:
- _gamma_ClearColor( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_CLEAR_ACCUM:
- _gamma_ClearAccum( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_CLEAR_DEPTH:
- _gamma_ClearDepth( (GLclampd) n[1].f );
- break;
- case OPCODE_CLEAR_INDEX:
- _gamma_ClearIndex( n[1].ui );
- break;
- case OPCODE_CLEAR_STENCIL:
- _gamma_ClearStencil( n[1].i );
- break;
- case OPCODE_CLIP_PLANE:
- {
- GLdouble equ[4];
- equ[0] = n[2].f;
- equ[1] = n[3].f;
- equ[2] = n[4].f;
- equ[3] = n[5].f;
- _gamma_ClipPlane( n[1].e, equ );
- }
- break;
- case OPCODE_COLOR_MASK:
- _gamma_ColorMask( n[1].b, n[2].b, n[3].b, n[4].b );
- break;
- case OPCODE_COLOR_MATERIAL:
- _gamma_ColorMaterial( n[1].e, n[2].e );
- break;
- case OPCODE_COPY_PIXELS:
- _gamma_CopyPixels( n[1].i, n[2].i,
- (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
- break;
- case OPCODE_COPY_TEX_IMAGE1D:
- _gamma_CopyTexImage1D( n[1].e, n[2].i, n[3].e, n[4].i,
- n[5].i, n[6].i, n[7].i );
- break;
- case OPCODE_COPY_TEX_IMAGE2D:
- _gamma_CopyTexImage2D( n[1].e, n[2].i, n[3].e, n[4].i,
- n[5].i, n[6].i, n[7].i, n[8].i );
- break;
- case OPCODE_COPY_TEX_SUB_IMAGE1D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexSubImage1D( n[1].e, n[2].i, n[3].i,
- n[4].i, n[5].e,
- n[6].e, n[7].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_COPY_TEX_SUB_IMAGE2D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexSubImage2D( n[1].e, n[2].i, n[3].i,
- n[4].i, n[5].e,
- n[6].i, n[7].e, n[8].e, n[9].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_CULL_FACE:
- _gamma_CullFace( n[1].e );
- break;
- case OPCODE_DEPTH_FUNC:
- _gamma_DepthFunc( n[1].e );
- break;
- case OPCODE_DEPTH_MASK:
- _gamma_DepthMask( n[1].b );
- break;
- case OPCODE_DEPTH_RANGE:
- _gamma_DepthRange( (GLclampd) n[1].f, (GLclampd) n[2].f );
- break;
- case OPCODE_DISABLE:
- _gamma_Disable( n[1].e );
- break;
- case OPCODE_DRAW_BUFFER:
- _gamma_DrawBuffer( n[1].e );
- break;
- case OPCODE_DRAW_PIXELS:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_DrawPixels( n[1].i, n[2].i, n[3].e, n[4].e,
- n[5].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_EDGE_FLAG:
- gCCPriv->Current.EdgeFlag = n[1].b;
- break;
- case OPCODE_ENABLE:
- _gamma_Enable( n[1].e );
- break;
- case OPCODE_EVALCOORD1:
- _gamma_EvalCoord1f( n[1].f );
- break;
- case OPCODE_EVALCOORD2:
- _gamma_EvalCoord2f( n[1].f, n[2].f );
- break;
- case OPCODE_EVALMESH1:
- _gamma_EvalMesh1( n[1].e, n[2].i, n[3].i );
- break;
- case OPCODE_EVALMESH2:
- _gamma_EvalMesh2( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
- break;
- case OPCODE_EVALPOINT1:
- _gamma_EvalPoint1( n[1].i );
- break;
- case OPCODE_EVALPOINT2:
- _gamma_EvalPoint2( n[1].i, n[2].i );
- break;
- case OPCODE_FOG:
- {
- GLfloat p[4];
- p[0] = n[2].f;
- p[1] = n[3].f;
- p[2] = n[4].f;
- p[3] = n[5].f;
- _gamma_Fogfv( n[1].e, p );
- }
- break;
- case OPCODE_FRONT_FACE:
- _gamma_FrontFace( n[1].e );
- break;
- case OPCODE_FRUSTUM:
- _gamma_Frustum( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
- break;
- case OPCODE_HINT:
- _gamma_Hint( n[1].e, n[2].e );
- break;
- case OPCODE_INDEX_MASK:
- _gamma_IndexMask( n[1].ui );
- break;
- case OPCODE_INIT_NAMES:
- _gamma_InitNames( );
- break;
- case OPCODE_LIGHT:
- {
- GLfloat p[4];
- p[0] = n[3].f;
- p[1] = n[4].f;
- p[2] = n[5].f;
- p[3] = n[6].f;
- _gamma_Lightfv( n[1].e, n[2].e, p );
- }
- break;
- case OPCODE_LIGHT_MODEL:
- {
- GLfloat p[4];
- p[0] = n[2].f;
- p[1] = n[3].f;
- p[2] = n[4].f;
- p[3] = n[5].f;
- _gamma_LightModelfv( n[1].e, p );
- }
- break;
- case OPCODE_LINE_STIPPLE:
- _gamma_LineStipple( n[1].i, n[2].us );
- break;
- case OPCODE_LINE_WIDTH:
- _gamma_LineWidth( n[1].f );
- break;
- case OPCODE_LIST_BASE:
- _gamma_ListBase( n[1].ui );
- break;
- case OPCODE_LOAD_IDENTITY:
- _gamma_LoadIdentity( );
- break;
- case OPCODE_LOAD_MATRIX:
- if (sizeof(Node)==sizeof(GLfloat)) {
- _gamma_LoadMatrixf( &n[1].f );
- }
- else {
- GLfloat m[16];
- GLuint i;
- for (i=0;i<16;i++) {
- m[i] = n[1+i].f;
- }
- _gamma_LoadMatrixf( m );
- }
- break;
- case OPCODE_LOAD_NAME:
- _gamma_LoadName( n[1].ui );
- break;
- case OPCODE_LOGIC_OP:
- _gamma_LogicOp( n[1].e );
- break;
- case OPCODE_MAP1:
- _gamma_Map1f( n[1].e, n[2].f, n[3].f,
- n[4].i, n[5].i, (GLfloat *) n[6].data );
- break;
- case OPCODE_MAP2:
- _gamma_Map2f( n[1].e,
- n[2].f, n[3].f, /* u1, u2 */
- n[6].i, n[8].i, /* ustride, uorder */
- n[4].f, n[5].f, /* v1, v2 */
- n[7].i, n[9].i, /* vstride, vorder */
- (GLfloat *) n[10].data);
- break;
- case OPCODE_MAPGRID1:
- _gamma_MapGrid1f( n[1].i, n[2].f, n[3].f );
- break;
- case OPCODE_MAPGRID2:
- _gamma_MapGrid2f( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
- break;
- case OPCODE_MATERIAL:
- {
- GLfloat params[4];
- params[0] = n[3].f;
- params[1] = n[4].f;
- params[2] = n[5].f;
- params[3] = n[6].f;
- _gamma_Materialfv( n[1].e, n[2].e, params );
- }
- break;
- case OPCODE_MATRIX_MODE:
- _gamma_MatrixMode( n[1].e );
- break;
- case OPCODE_MULT_MATRIX:
- if (sizeof(Node)==sizeof(GLfloat)) {
- _gamma_MultMatrixf( &n[1].f );
- }
- else {
- GLfloat m[16];
- GLuint i;
- for (i=0;i<16;i++) {
- m[i] = n[1+i].f;
- }
- _gamma_MultMatrixf( m );
- }
- break;
- case OPCODE_ORTHO:
- _gamma_Ortho( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
- break;
- case OPCODE_PASSTHROUGH:
- _gamma_PassThrough( n[1].f );
- break;
- case OPCODE_PIXEL_MAP:
- _gamma_PixelMapfv( n[1].e, n[2].i, (GLfloat *) n[3].data );
- break;
- case OPCODE_PIXEL_TRANSFER:
- _gamma_PixelTransferf( n[1].e, n[2].f );
- break;
- case OPCODE_PIXEL_ZOOM:
- _gamma_PixelZoom( n[1].f, n[2].f );
- break;
- case OPCODE_POINT_SIZE:
- _gamma_PointSize( n[1].f );
- break;
- case OPCODE_POLYGON_MODE:
- _gamma_PolygonMode( n[1].e, n[2].e );
- break;
- case OPCODE_POLYGON_STIPPLE:
- _gamma_PolygonStipple( (GLubyte *) n[1].data );
- break;
- case OPCODE_POLYGON_OFFSET:
- _gamma_PolygonOffset( n[1].f, n[2].f );
- break;
- case OPCODE_POP_ATTRIB:
- _gamma_PopAttrib( );
- break;
- case OPCODE_POP_MATRIX:
- _gamma_PopMatrix( );
- break;
- case OPCODE_POP_NAME:
- _gamma_PopName( );
- break;
- case OPCODE_PRIORITIZE_TEXTURE:
- _gamma_PrioritizeTextures( 1, &n[1].ui, &n[2].f );
- break;
- case OPCODE_PUSH_ATTRIB:
- _gamma_PushAttrib( n[1].bf );
- break;
- case OPCODE_PUSH_MATRIX:
- _gamma_PushMatrix( );
- break;
- case OPCODE_PUSH_NAME:
- _gamma_PushName( n[1].ui );
- break;
- case OPCODE_RASTER_POS:
- _gamma_RasterPos4f( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_READ_BUFFER:
- _gamma_ReadBuffer( n[1].e );
- break;
- case OPCODE_RECTF:
- _gamma_Rectf( n[1].f, n[2].f, n[3].f, n[4].f );
- break;
- case OPCODE_SCALE:
- _gamma_Scalef( n[1].f, n[2].f, n[3].f );
- break;
- case OPCODE_SCISSOR:
- _gamma_Scissor( n[1].i, n[2].i, n[3].i, n[4].i );
- break;
- case OPCODE_SHADE_MODEL:
- _gamma_ShadeModel( n[1].e );
- break;
- case OPCODE_STENCIL_FUNC:
- _gamma_StencilFunc( n[1].e, n[2].i, n[3].ui );
- break;
- case OPCODE_STENCIL_MASK:
- _gamma_StencilMask( n[1].ui );
- break;
- case OPCODE_STENCIL_OP:
- _gamma_StencilOp( n[1].e, n[2].e, n[3].e );
- break;
- case OPCODE_TEXENV:
- {
- GLfloat params[4];
- params[0] = n[3].f;
- params[1] = n[4].f;
- params[2] = n[5].f;
- params[3] = n[6].f;
- _gamma_TexEnvfv( n[1].e, n[2].e, params );
- }
- break;
- case OPCODE_TEXGEN:
- {
- GLfloat params[4];
- params[0] = n[3].f;
- params[1] = n[4].f;
- params[2] = n[5].f;
- params[3] = n[6].f;
- _gamma_TexGenfv( n[1].e, n[2].e, params );
- }
- break;
- case OPCODE_TEXPARAMETER:
- {
- GLfloat params[4];
- params[0] = n[3].f;
- params[1] = n[4].f;
- params[2] = n[5].f;
- params[3] = n[6].f;
- _gamma_TexParameterfv( n[1].e, n[2].e, params );
- }
- break;
- case OPCODE_TEX_IMAGE1D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexImage1D( n[1].e, /* target */
- n[2].i, /* level */
- n[3].i, /* components */
- n[4].i, /* width */
- n[5].e, /* border */
- n[6].e, /* format */
- n[7].e, /* type */
- n[8].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_TEX_IMAGE2D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexImage2D( n[1].e, /* target */
- n[2].i, /* level */
- n[3].i, /* components */
- n[4].i, /* width */
- n[5].i, /* height */
- n[6].e, /* border */
- n[7].e, /* format */
- n[8].e, /* type */
- n[9].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_TEX_SUB_IMAGE1D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexSubImage1D( n[1].e, n[2].i, n[3].i,
- n[4].i, n[5].e,
- n[6].e, n[7].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_TEX_SUB_IMAGE2D:
- {
- struct gl_pixelstore_attrib save = gCCPriv->Unpack;
- gCCPriv->Unpack = _mesa_native_packing;
- _gamma_TexSubImage2D( n[1].e, n[2].i, n[3].i,
- n[4].i, n[5].e,
- n[6].i, n[7].e, n[8].e, n[9].data );
- gCCPriv->Unpack = save; /* restore */
- }
- break;
- case OPCODE_TRANSLATE:
- _gamma_Translatef( n[1].f, n[2].f, n[3].f );
- break;
- case OPCODE_VIEWPORT:
- _gamma_Viewport( n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
- break;
- case OPCODE_CONTINUE:
- n = (Node *) n[1].next;
- break;
- case OPCODE_END_OF_LIST:
- done = GL_TRUE;
- break;
- default:
- {
- char msg[1000];
- sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
-#if 0
- gl_problem( msg );
-#endif
- }
- done = GL_TRUE;
- }
-
- /* increment n to point to next compiled command */
- if (opcode!=OPCODE_CONTINUE) {
- n += InstSize[opcode];
- }
-
- }
- gCCPriv->CallDepth--;
-}
-
-
-
-/**********************************************************************/
-/* GL functions */
-/**********************************************************************/
-
-
-
-/*
- * Test if a display list number is valid.
- */
-GLboolean _gamma_IsList( GLuint list )
-{
- if (list > 0 && _mesa_HashLookup(gCCPriv->DisplayList, list)) {
- return GL_TRUE;
- }
- else {
- return GL_FALSE;
- }
-}
-
-
-
-/*
- * Delete a sequence of consecutive display lists.
- */
-void _gamma_DeleteLists( GLuint list, GLsizei range )
-{
- GLuint i;
-
-#if 0
- if (INSIDE_BEGIN_END(ctx)) {
- gamma_error( GL_INVALID_OPERATION, "glDeleteLists" );
- return;
- }
-#endif
- if (range<0) {
- gamma_error( GL_INVALID_VALUE, "glDeleteLists" );
- return;
- }
- for (i=list;i<list+range;i++) {
- gamma_destroy_list( i );
- }
-}
-
-
-
-/*
- * Return a display list number, n, such that lists n through n+range-1
- * are free.
- */
-GLuint _gamma_GenLists( GLsizei range )
-{
- GLuint base;
-
-#if 0
- if (INSIDE_BEGIN_END(ctx)) {
- gamma_error( GL_INVALID_OPERATION, "glGenLists" );
- return 0;
- }
-#endif
- if (range<0) {
- gamma_error( GL_INVALID_VALUE, "glGenLists" );
- return 0;
- }
- if (range==0) {
- return 0;
- }
-
- base = _mesa_HashFindFreeKeyBlock(gCCPriv->DisplayList, range);
- if (base) {
- /* reserve the list IDs by with empty/dummy lists */
- GLint i;
- for (i=0; i<range; i++) {
- _mesa_HashInsert(gCCPriv->DisplayList, base+i, make_empty_list());
- }
- }
- return base;
-}
-
-
-
-/*
- * Begin a new display list.
- */
-void _gamma_NewList( GLuint list, GLenum mode )
-{
-#if 0
- if (INSIDE_BEGIN_END(ctx)) {
- gamma_error( GL_INVALID_OPERATION, "glNewList" );
- return;
- }
-#endif
- if (list==0) {
- gamma_error( GL_INVALID_VALUE, "glNewList" );
- return;
- }
- if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
- gamma_error( GL_INVALID_ENUM, "glNewList" );
- return;
- }
- if (gCCPriv->CurrentListPtr) {
- /* already compiling a display list */
- gamma_error( GL_INVALID_OPERATION, "glNewList" );
- return;
- }
-
- /* Allocate new display list */
- gCCPriv->CurrentListNum = list;
- gCCPriv->CurrentListPtr = gCCPriv->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
- gCCPriv->CurrentPos = 0;
-
- gCCPriv->CompileFlag = GL_TRUE;
- if (mode==GL_COMPILE) {
- gCCPriv->ExecuteFlag = GL_FALSE;
- }
- else {
- /* Compile and execute */
- gCCPriv->ExecuteFlag = GL_TRUE;
- }
-
- _glapi_set_dispatch(gCCPriv->Save);
- gCCPriv->API = gCCPriv->Save; /* Switch the API function pointers */
-}
-
-
-
-/*
- * End definition of current display list.
- */
-void _gamma_EndList( void )
-{
- /* Check that a list is under construction */
- if (!gCCPriv->CurrentListPtr) {
- gamma_error( GL_INVALID_OPERATION, "glEndList" );
- return;
- }
-
- (void) alloc_instruction( OPCODE_END_OF_LIST, 0 );
-
- /* Destroy old list, if any */
- gamma_destroy_list(gCCPriv->CurrentListNum);
- /* Install the list */
- _mesa_HashInsert(gCCPriv->DisplayList, gCCPriv->CurrentListNum, gCCPriv->CurrentListPtr);
-
- gCCPriv->CurrentListNum = 0;
- gCCPriv->CurrentListPtr = NULL;
- gCCPriv->ExecuteFlag = GL_TRUE;
- gCCPriv->CompileFlag = GL_FALSE;
-
- _glapi_set_dispatch(gCCPriv->Exec);
- gCCPriv->API = gCCPriv->Exec; /* Switch the API function pointers */
-}
-
-
-
-void _gamma_CallList( GLuint list )
-{
- /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
- /* execute the display list, and restore the CompileFlag. */
- GLboolean save_compile_flag;
- save_compile_flag = gCCPriv->CompileFlag;
- gCCPriv->CompileFlag = GL_FALSE;
- execute_list( list );
- gCCPriv->CompileFlag = save_compile_flag;
-
- /* also restore API function pointers to point to "save" versions */
- if (save_compile_flag) {
- _glapi_set_dispatch(gCCPriv->Save);
- gCCPriv->API = gCCPriv->Save;
- }
-}
-
-
-
-/*
- * Execute glCallLists: call multiple display lists.
- */
-void _gamma_CallLists(
- GLsizei n, GLenum type, const GLvoid *lists )
-{
- GLuint list;
- GLint i;
- GLboolean save_compile_flag;
-
- /* Save the CompileFlag status, turn it off, execute display list,
- * and restore the CompileFlag.
- */
- save_compile_flag = gCCPriv->CompileFlag;
- gCCPriv->CompileFlag = GL_FALSE;
-
- for (i=0;i<n;i++) {
- list = translate_id( i, type, lists );
- execute_list( gCCPriv->List.ListBase + list );
- }
-
- gCCPriv->CompileFlag = save_compile_flag;
-
- /* also restore API function pointers to point to "save" versions */
- if (save_compile_flag) {
- _glapi_set_dispatch(gCCPriv->Save);
- gCCPriv->API = gCCPriv->Save;
- }
-}
-
-
-
-/*
- * Set the offset added to list numbers in glCallLists.
- */
-void _gamma_ListBase( GLuint base )
-{
-#if 0
- if (INSIDE_BEGIN_END(ctx)) {
- gamma_error( GL_INVALID_OPERATION, "glListBase" );
- return;
- }
-#endif
- gCCPriv->List.ListBase = base;
-}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.h
deleted file mode 100644
index a8523da2d..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.h
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.0
- * Copyright (C) 1995-1998 Brian Paul
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_dlist.h,v 1.3 2001/02/12 01:11:25 tsi Exp $ */
-
-
-#ifndef DLIST_H
-#define DLIST_H
-
-#include "types.h"
-
-extern void gamma_init_lists( void );
-
-extern void gamma_destroy_list( GLuint list );
-
-
-
-extern void gl_CallList( GLuint list );
-
-extern void gl_CallLists(
- GLsizei n, GLenum type, const GLvoid *lists );
-
-extern void gl_DeleteLists( GLuint list, GLsizei range );
-
-extern void gl_EndList( void );
-
-extern GLuint gl_GenLists( GLsizei range );
-
-extern GLboolean gl_IsList( GLuint list );
-
-extern void gl_ListBase( GLuint base );
-
-extern void gl_NewList( GLuint list, GLenum mode );
-
-extern void gl_save_Accum( GLenum op, GLfloat value );
-
-extern void gl_save_AlphaFunc( GLenum func, GLclampf ref );
-
-extern void gl_save_ArrayElement( GLint i );
-
-extern void gl_save_BlendFunc(
- GLenum sfactor, GLenum dfactor );
-
-extern void gl_save_Begin( GLenum mode );
-
-extern void gl_save_BindTexture(
- GLenum target, GLuint texture );
-
-extern void gl_save_Bitmap( GLsizei width, GLsizei height,
- GLfloat xorig, GLfloat yorig,
- GLfloat xmove, GLfloat ymove,
- const GLubyte *bitmap );
-
-extern void gl_save_CallList( GLuint list );
-
-extern void gl_save_CallLists(
- GLsizei n, GLenum type, const GLvoid *lists );
-
-extern void gl_save_Clear( GLbitfield mask );
-
-extern void gl_save_ClearAccum( GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha );
-
-extern void gl_save_ClearColor( GLclampf red, GLclampf green,
- GLclampf blue, GLclampf alpha );
-
-extern void gl_save_ClearDepth( GLclampd depth );
-
-extern void gl_save_ClearIndex( GLfloat c );
-
-extern void gl_save_ClearStencil( GLint s );
-
-extern void gl_save_ClipPlane(
- GLenum plane, const GLdouble *equ );
-
-extern void gl_save_Color3f( GLfloat r, GLfloat g, GLfloat b );
-
-extern void gl_save_Color3fv( const GLfloat *c );
-
-extern void gl_save_Color4f( GLfloat r, GLfloat g,
- GLfloat b, GLfloat a );
-
-extern void gl_save_Color4fv( const GLfloat *c );
-
-extern void gl_save_Color4ub( GLubyte r, GLubyte g,
- GLubyte b, GLubyte a );
-
-extern void gl_save_Color4ubv( const GLubyte *c );
-
-extern void gl_save_ColorMask( GLboolean red, GLboolean green,
- GLboolean blue, GLboolean alpha );
-
-extern void gl_save_ColorMaterial( GLenum face, GLenum mode );
-
-extern void gl_save_CopyPixels( GLint x, GLint y,
- GLsizei width, GLsizei height, GLenum type );
-
-extern void gl_save_CopyTexImage1D(
- GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y, GLsizei width,
- GLint border );
-
-extern void gl_save_CopyTexImage2D(
- GLenum target, GLint level,
- GLenum internalformat,
- GLint x, GLint y, GLsizei width,
- GLsizei height, GLint border );
-
-extern void gl_save_CopyTexSubImage1D(
- GLenum target, GLint level,
- GLint xoffset, GLint x, GLint y,
- GLsizei width );
-
-extern void gl_save_CopyTexSubImage2D(
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLint x, GLint y,
- GLsizei width, GLint height );
-
-extern void gl_save_CullFace( GLenum mode );
-
-extern void gl_save_DepthFunc( GLenum func );
-
-extern void gl_save_DepthMask( GLboolean mask );
-
-extern void gl_save_DepthRange(
- GLclampd nearval, GLclampd farval );
-
-extern void gl_save_Disable( GLenum cap );
-
-extern void gl_save_DrawArrays(
- GLenum mode, GLint first, GLsizei count );
-
-extern void gl_save_DrawBuffer( GLenum mode );
-
-extern void gl_save_DrawElements(
- GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices );
-
-extern void gl_save_DrawPixels( GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-extern void gl_save_EdgeFlag( GLboolean flag );
-
-extern void gl_save_Enable( GLenum cap );
-
-extern void gl_save_End( void );
-
-extern void gl_save_EvalCoord1f( GLfloat u );
-
-extern void gl_save_EvalCoord2f( GLfloat u, GLfloat v );
-
-extern void gl_save_EvalMesh1(
- GLenum mode, GLint i1, GLint i2 );
-
-extern void gl_save_EvalMesh2( GLenum mode, GLint i1, GLint i2,
- GLint j1, GLint j2 );
-
-extern void gl_save_EvalPoint1( GLint i );
-
-extern void gl_save_EvalPoint2( GLint i, GLint j );
-
-extern void gl_save_Fogfv(
- GLenum pname, const GLfloat *params );
-
-extern void gl_save_FrontFace( GLenum mode );
-
-extern void gl_save_Frustum( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble nearval, GLdouble farval );
-
-extern void gl_save_Hint( GLenum target, GLenum mode );
-
-extern void gl_save_Indexf( GLfloat index );
-
-extern void gl_save_Indexi( GLint index );
-
-extern void gl_save_IndexMask( GLuint mask );
-
-extern void gl_save_InitNames( void );
-
-extern void gl_save_Lightfv( GLenum light, GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_LightModelfv( GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_LineWidth( GLfloat width );
-
-extern void gl_save_LineStipple( GLint factor,
- GLushort pattern );
-
-extern void gl_save_ListBase( GLuint base );
-
-extern void gl_save_LoadIdentity( void );
-
-extern void gl_save_LoadMatrixf( const GLfloat *m );
-
-extern void gl_save_LoadName( GLuint name );
-
-extern void gl_save_LogicOp( GLenum opcode );
-
-extern void gl_save_Map1f( GLenum target,
- GLfloat u1, GLfloat u2, GLint stride,
- GLint order, const GLfloat *points);
-
-extern void gl_save_Map2f( GLenum target,
- GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
- GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
- const GLfloat *points);
-
-extern void gl_save_MapGrid1f( GLint un,
- GLfloat u1, GLfloat u2 );
-
-extern void gl_save_MapGrid2f(
- GLint un, GLfloat u1, GLfloat u2,
- GLint vn, GLfloat v1, GLfloat v2 );
-
-extern void gl_save_Materialfv( GLenum face, GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_MatrixMode( GLenum mode );
-
-extern void gl_save_MultMatrixf( const GLfloat *m );
-
-extern void gl_save_NewList( GLuint list, GLenum mode );
-
-extern void gl_save_Normal3fv( const GLfloat n[3] );
-
-extern void gl_save_Normal3f(
- GLfloat nx, GLfloat ny, GLfloat nz );
-
-extern void gl_save_Ortho( GLdouble left, GLdouble right,
- GLdouble bottom, GLdouble top,
- GLdouble nearval, GLdouble farval );
-
-extern void gl_save_PassThrough( GLfloat token );
-
-extern void gl_save_PixelMapfv( GLenum map, GLint mapsize,
- const GLfloat *values );
-
-extern void gl_save_PixelTransferf(
- GLenum pname, GLfloat param );
-
-extern void gl_save_PixelZoom(
- GLfloat xfactor, GLfloat yfactor );
-
-extern void gl_save_PointParameterfvEXT( GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_PointSize( GLfloat size );
-
-extern void gl_save_PolygonMode( GLenum face, GLenum mode );
-
-extern void gl_save_PolygonStipple( const GLubyte *pattern );
-
-extern void gl_save_PolygonOffset(
- GLfloat factor, GLfloat units );
-
-extern void gl_save_PopAttrib( void );
-
-extern void gl_save_PopMatrix( void );
-
-extern void gl_save_PopName( void );
-
-extern void gl_save_PrioritizeTextures(
- GLsizei n, const GLuint *textures,
- const GLclampf *priorities );
-
-extern void gl_save_PushAttrib( GLbitfield mask );
-
-extern void gl_save_PushMatrix( void );
-
-extern void gl_save_PushName( GLuint name );
-
-extern void gl_save_RasterPos4f(
- GLfloat x, GLfloat y, GLfloat z, GLfloat w );
-
-extern void gl_save_ReadBuffer( GLenum mode );
-
-extern void gl_save_Rectf(
- GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
-
-extern void gl_save_Rotatef( GLfloat angle,
- GLfloat x, GLfloat y, GLfloat z );
-
-extern void gl_save_Scalef( GLfloat x, GLfloat y, GLfloat z );
-
-extern void gl_save_Scissor(
- GLint x, GLint y, GLsizei width, GLsizei height );
-
-extern void gl_save_ShadeModel( GLenum mode );
-
-extern void gl_save_StencilFunc(
- GLenum func, GLint ref, GLuint mask );
-
-extern void gl_save_StencilMask( GLuint mask );
-
-extern void gl_save_StencilOp(
- GLenum fail, GLenum zfail, GLenum zpass );
-
-extern void gl_save_TexCoord2f( GLfloat s, GLfloat t );
-
-extern void gl_save_TexCoord2fv( const GLfloat *v );
-
-extern void gl_save_TexCoord3fv( const GLfloat *v );
-
-extern void gl_save_TexCoord4f( GLfloat s, GLfloat t,
- GLfloat r, GLfloat q );
-
-extern void gl_save_TexEnvfv( GLenum target, GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_TexParameterfv( GLenum target,
- GLenum pname, const GLfloat *params );
-
-extern void gl_save_TexGenfv( GLenum coord, GLenum pname,
- const GLfloat *params );
-
-extern void gl_save_TexImage1D( GLenum target,
- GLint level, GLint components,
- GLsizei width, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-extern void gl_save_TexImage2D( GLenum target,
- GLint level, GLint components,
- GLsizei width, GLsizei height, GLint border,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-extern void gl_save_TexSubImage1D(
- GLenum target, GLint level,
- GLint xoffset, GLsizei width,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-
-extern void gl_save_TexSubImage2D(
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels );
-
-extern void gl_save_Translatef(
- GLfloat x, GLfloat y, GLfloat z );
-
-extern void gl_save_Vertex2f(
- GLfloat x, GLfloat y );
-
-extern void gl_save_Vertex3f(
- GLfloat x, GLfloat y, GLfloat z );
-
-extern void gl_save_Vertex4f(
- GLfloat x, GLfloat y, GLfloat z, GLfloat w );
-
-extern void gl_save_Vertex3fv( const GLfloat *v );
-
-extern void gl_save_Viewport( GLint x, GLint y,
- GLsizei width, GLsizei height );
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
deleted file mode 100644
index 84bdd56ab..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c
+++ /dev/null
@@ -1,5312 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c,v 1.10 2001/08/18 02:51:04 dawes Exp $ */
-/**************************************************************************
-
-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>
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <Xarch.h>
-#include <math.h>
-#include "gamma_gl.h"
-#include "gamma_init.h"
-#include "gamma_dlist.h"
-#include "glint_dri.h"
-
-/* Here for now, will change get.c to move them into macros.h later */
-
-#define FLOAT_TO_BOOL(X) ( (X)==0.0F ? GL_FALSE : GL_TRUE )
-#define INT_TO_BOOL(I) ( (I)==0 ? GL_FALSE : GL_TRUE )
-#define ENUM_TO_BOOL(E) ( (E)==0 ? GL_FALSE : GL_TRUE )
-
-void gamma_error( GLenum error, const char *s )
-{
- GLboolean debug;
-
-#ifdef DEBUG
- debug = GL_TRUE;
-#else
- if (getenv("MESA_DEBUG")) {
- debug = GL_TRUE;
- }
- else {
- debug = GL_FALSE;
- }
-#endif
-
- if (debug) {
- const char *errstr;
-
- switch (error) {
- case GL_NO_ERROR:
- errstr = "GL_NO_ERROR";
- break;
- case GL_INVALID_VALUE:
- errstr = "GL_INVALID_VALUE";
- break;
- case GL_INVALID_ENUM:
- errstr = "GL_INVALID_ENUM";
- break;
- case GL_INVALID_OPERATION:
- errstr = "GL_INVALID_OPERATION";
- break;
- case GL_STACK_OVERFLOW:
- errstr = "GL_STACK_OVERFLOW";
- break;
- case GL_STACK_UNDERFLOW:
- errstr = "GL_STACK_UNDERFLOW";
- break;
- case GL_OUT_OF_MEMORY:
- errstr = "GL_OUT_OF_MEMORY";
- break;
- default:
- errstr = "unknown";
- break;
- }
- fprintf( stderr, "Mesa user error: %s in %s\n", errstr, s );
- }
-
- if (gCCPriv->ErrorValue==GL_NO_ERROR) {
- gCCPriv->ErrorValue = error;
- }
-
- /* _gamma_Error( ); use hwLog or something later */
-}
-
-
-void _gamma_Accum(GLenum op, GLfloat value)
-{
- DEBUG_GLCMDS(("Accum: %d %f\n", (int)op, value));
-
- switch (op) {
- case GL_ACCUM:
- break;
- case GL_LOAD:
- break;
- case GL_ADD:
- break;
- case GL_MULT:
- break;
- case GL_RETURN:
- break;
- default:
- gCCPriv->ErrorValue = GL_INVALID_ENUM;
- return;
- }
-}
-
-void _gamma_AlphaFunc(GLenum func, GLclampf ref)
-{
- unsigned char r = ref * 255.0;
-
- DEBUG_GLCMDS(("AlphaFunc: %d %f\n", (int)func, (float)ref));
-
- gCCPriv->AlphaTestMode &= ~(AT_CompareMask | AT_RefValueMask);
-
- switch (func) {
- case GL_NEVER:
- gCCPriv->AlphaTestMode |= AT_Never;
- break;
- case GL_LESS:
- gCCPriv->AlphaTestMode |= AT_Less;
- break;
- case GL_EQUAL:
- gCCPriv->AlphaTestMode |= AT_Equal;
- break;
- case GL_LEQUAL:
- gCCPriv->AlphaTestMode |= AT_LessEqual;
- break;
- case GL_GREATER:
- gCCPriv->AlphaTestMode |= AT_Greater;
- break;
- case GL_NOTEQUAL:
- gCCPriv->AlphaTestMode |= AT_NotEqual;
- break;
- case GL_GEQUAL:
- gCCPriv->AlphaTestMode |= AT_GreaterEqual;
- break;
- case GL_ALWAYS:
- gCCPriv->AlphaTestMode |= AT_Always;
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- gCCPriv->AlphaTestMode |= r << 4;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, AlphaTestMode, gCCPriv->AlphaTestMode);
-}
-
-GLboolean _gamma_AreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences)
-{
- DEBUG_GLCMDS(("AreTexturesResident: %d\n", (int)n));
-#ifdef DEBUG_VERBOSE_EXTRA
- {
- int t;
- for (t = 0; t < n; t++)
- printf("\t%d\n", (int)textures[t]);
- }
-#endif
-
- return GL_TRUE;
-}
-
-void _gamma_ArrayElement(GLint i)
-{
- DEBUG_GLCMDS(("ArrayElement: %d\n", (int)i));
-}
-
-void _gamma_Begin(GLenum mode)
-{
- DEBUG_GLCMDS(("Begin: %04x\n", (int)mode));
-
- if ((gCCPriv->Begin & B_PrimType_Mask) != B_PrimType_Null) {
- DEBUG_ERROR(("Begin: Error\n"));
- return;
- }
-
- gCCPriv->Begin &= ~B_PrimType_Mask;
- switch (mode) {
- case GL_POINTS:
- gCCPriv->Begin |= B_PrimType_Points;
- break;
- case GL_LINES:
- gCCPriv->Begin |= B_PrimType_Lines;
- break;
- case GL_LINE_LOOP:
- gCCPriv->Begin |= B_PrimType_LineLoop;
- break;
- case GL_LINE_STRIP:
- gCCPriv->Begin |= B_PrimType_LineStrip;
- break;
- case GL_TRIANGLES:
- gCCPriv->Begin |= B_PrimType_Triangles;
- break;
- case GL_TRIANGLE_STRIP:
- gCCPriv->Begin |= B_PrimType_TriangleStrip;
- break;
- case GL_TRIANGLE_FAN:
- gCCPriv->Begin |= B_PrimType_TriangleFan;
- break;
- case GL_QUADS:
- gCCPriv->Begin |= B_PrimType_Quads;
- break;
- case GL_QUAD_STRIP:
- gCCPriv->Begin |= B_PrimType_QuadStrip;
- break;
- case GL_POLYGON:
- gCCPriv->Begin |= B_PrimType_Polygon;
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Begin, gCCPriv->Begin);
-}
-
-void _gamma_BindTexture(GLenum target, GLuint texture)
-{
- unsigned long addrs[MIPMAP_LEVELS];
- int i;
-
- DEBUG_GLCMDS(("BindTexture: %04x %d\n",
- (int)target, (unsigned int)texture));
-
- /* Disable all of the units in the previous bind */
- gCCPriv->curTexObj->TextureAddressMode &= ~TextureAddressModeEnable;
- gCCPriv->curTexObj->TextureReadMode &= ~TextureReadModeEnable;
- gCCPriv->curTexObj->TextureColorMode &= ~TextureColorModeEnable;
- gCCPriv->curTexObj->TextureFilterMode &= ~TextureFilterModeEnable;
-
- /* Find the texture (create it, if necessary) */
- gCCPriv->curTexObj = gammaTOFind(texture);
-
- /* Make the new texture images resident */
- if (driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS,
- gCCPriv->curTexObj->image, addrs) < 0) {
- DEBUG_ERROR(("BindTexture: unable\n"));
- /* NOT_DONE: Handle error */
- }
-
- for (i = 0; i < MIPMAP_LEVELS; i++)
- gCCPriv->curTexObj->TextureBaseAddr[i] = addrs[i] << 5;
-
- /* Set the target */
- gCCPriv->curTexObj->TextureAddressMode &= ~TAM_TexMapType_Mask;
- gCCPriv->curTexObj->TextureReadMode &= ~TRM_TexMapType_Mask;
- switch (target) {
- case GL_TEXTURE_1D:
- gCCPriv->curTexObj1D = gCCPriv->curTexObj;
- gCCPriv->curTexObj->TextureAddressMode |= TAM_TexMapType_1D;
- gCCPriv->curTexObj->TextureReadMode |= TRM_TexMapType_1D;
- break;
- case GL_TEXTURE_2D:
- gCCPriv->curTexObj2D = gCCPriv->curTexObj;
- gCCPriv->curTexObj->TextureAddressMode |= TAM_TexMapType_2D;
- gCCPriv->curTexObj->TextureReadMode |= TRM_TexMapType_2D;
- break;
- default:
- break;
- }
-
- /* Enable the units if texturing is enabled */
- if (target == GL_TEXTURE_1D && gCCPriv->Texture1DEnabled) {
- gCCPriv->curTexObj->TextureAddressMode |= TextureAddressModeEnable;
- gCCPriv->curTexObj->TextureReadMode |= TextureReadModeEnable;
- gCCPriv->curTexObj->TextureColorMode |= TextureColorModeEnable;
- gCCPriv->curTexObj->TextureFilterMode |= TextureFilterModeEnable;
- } else if (target == GL_TEXTURE_2D && gCCPriv->Texture2DEnabled) {
- gCCPriv->curTexObj->TextureAddressMode |= TextureAddressModeEnable;
- gCCPriv->curTexObj->TextureReadMode |= TextureReadModeEnable;
- gCCPriv->curTexObj->TextureColorMode |= TextureColorModeEnable;
- gCCPriv->curTexObj->TextureFilterMode |= TextureFilterModeEnable;
- }
-
- /* Restore the units */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 18);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj->TextureAddressMode);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj->TextureReadMode);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj->TextureColorMode);
- WRITE(gCCPriv->buf, TextureFilterMode,
- gCCPriv->curTexObj->TextureFilterMode);
- WRITE(gCCPriv->buf, TextureFormat,
- gCCPriv->curTexObj->TextureFormat);
- WRITE(gCCPriv->buf, TxBaseAddr0, gCCPriv->curTexObj->TextureBaseAddr[ 0]);
- WRITE(gCCPriv->buf, TxBaseAddr1, gCCPriv->curTexObj->TextureBaseAddr[ 1]);
- WRITE(gCCPriv->buf, TxBaseAddr2, gCCPriv->curTexObj->TextureBaseAddr[ 2]);
- WRITE(gCCPriv->buf, TxBaseAddr3, gCCPriv->curTexObj->TextureBaseAddr[ 3]);
- WRITE(gCCPriv->buf, TxBaseAddr4, gCCPriv->curTexObj->TextureBaseAddr[ 4]);
- WRITE(gCCPriv->buf, TxBaseAddr5, gCCPriv->curTexObj->TextureBaseAddr[ 5]);
- WRITE(gCCPriv->buf, TxBaseAddr6, gCCPriv->curTexObj->TextureBaseAddr[ 6]);
- WRITE(gCCPriv->buf, TxBaseAddr7, gCCPriv->curTexObj->TextureBaseAddr[ 7]);
- WRITE(gCCPriv->buf, TxBaseAddr8, gCCPriv->curTexObj->TextureBaseAddr[ 8]);
- WRITE(gCCPriv->buf, TxBaseAddr9, gCCPriv->curTexObj->TextureBaseAddr[ 9]);
- WRITE(gCCPriv->buf, TxBaseAddr10, gCCPriv->curTexObj->TextureBaseAddr[10]);
- WRITE(gCCPriv->buf, TxBaseAddr11, gCCPriv->curTexObj->TextureBaseAddr[11]);
- WRITE(gCCPriv->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
-}
-
-void _gamma_Bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap)
-{
- DEBUG_GLCMDS(("Bitmap: \n"));
-}
-
-void _gamma_BlendFunc(GLenum sfactor, GLenum dfactor)
-{
- DEBUG_GLCMDS(("BlendFunc: %04x %04x\n", (int)sfactor, (int)dfactor));
-
- gCCPriv->AB_FBReadMode_Save = 0;
- gCCPriv->AlphaBlendMode &= ~(AB_SrcBlendMask | AB_DstBlendMask);
-
- switch (sfactor) {
- case GL_ZERO:
- gCCPriv->AlphaBlendMode |= AB_Src_Zero;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE:
- gCCPriv->AlphaBlendMode |= AB_Src_One;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_DST_COLOR:
- gCCPriv->AlphaBlendMode |= AB_Src_DstColor;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE_MINUS_DST_COLOR:
- gCCPriv->AlphaBlendMode |= AB_Src_OneMinusDstColor;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_SRC_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Src_SrcAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Src_OneMinusSrcAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_DST_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Src_DstAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadSrcEnable | FBReadDstEnable);
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Src_OneMinusDstAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadSrcEnable | FBReadDstEnable);
- break;
- case GL_SRC_ALPHA_SATURATE:
- gCCPriv->AlphaBlendMode |= AB_Src_SrcAlphaSaturate;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- switch (dfactor) {
- case GL_ZERO:
- gCCPriv->AlphaBlendMode |= AB_Dst_Zero;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE:
- gCCPriv->AlphaBlendMode |= AB_Dst_One;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_SRC_COLOR:
- gCCPriv->AlphaBlendMode |= AB_Dst_SrcColor;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE_MINUS_SRC_COLOR:
- gCCPriv->AlphaBlendMode |= AB_Dst_OneMinusSrcColor;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_SRC_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Dst_SrcAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Dst_OneMinusSrcAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadDstEnable);
- break;
- case GL_DST_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Dst_DstAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadSrcEnable | FBReadDstEnable);
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- gCCPriv->AlphaBlendMode |= AB_Dst_OneMinusDstAlpha;
- gCCPriv->AB_FBReadMode_Save |= (FBReadSrcEnable | FBReadDstEnable);
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, AlphaBlendMode, gCCPriv->AlphaBlendMode);
-
- if (gCCPriv->AlphaBlendMode & AlphaBlendModeEnable) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- gCCPriv->AB_FBReadMode = gCCPriv->AB_FBReadMode_Save;
- WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode |
- gCCPriv->AB_FBReadMode));
- }
-}
-
-#if 0 /* Now in dlist.c */
-void _gamma_CallList(GLuint list)
-{
- DEBUG_GLCMDS(("CallList: %d\n", (unsigned int)list));
-}
-
-void _gamma_CallLists(GLsizei n, GLenum type, const GLvoid *lists)
-{
- DEBUG_GLCMDS(("CallLists: %d %04x\n", (int)n, (int)type));
-}
-#endif
-
-void _gamma_Clear(GLbitfield mask)
-{
- int temp;
- unsigned int depth = 0;
- int do_clear = 0;
- GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gCC->driScreenPriv->pDevPriv;
-#ifdef DO_VALIDATE
- __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv;
-#endif
-
- DEBUG_GLCMDS(("Clear: %04x\n", (int)mask));
-
-#ifdef TURN_OFF_CLEARS
- {
- static int done_first_clear = 0;
- if (done_first_clear)
- return;
- done_first_clear = 1;
- }
-#endif
-
-#ifdef DO_VALIDATE
- /* Flush any partially filled buffers */
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-
- DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
- driScrnPriv->drawLockID);
- VALIDATE_DRAWABLE_INFO_NO_LOCK(gCC,gCCPriv);
-#endif
-
- if ((mask & GL_DEPTH_BUFFER_BIT) &&
- (gCCPriv->Flags & GAMMA_DEPTH_BUFFER)) {
- double d = (((double)gCCPriv->ClearDepth-gCCPriv->zNear)/
- (gCCPriv->zFar-gCCPriv->zNear));
-
- if (d > 1.0) d = 1.0;
- else if (d < 0.0) d = 0.0;
-
- switch (gCCPriv->DepthSize) {
- case 16:
- depth = d * 65535.0; /* 2^16-1 */
- break;
- case 24:
- depth = d * 16777215.0; /* 2^24-1 */
- break;
- case 32:
- depth = d * 4294967295.0; /* 2^32-1 */
- break;
- }
-
-#ifdef TURN_OFF_CLEARS
- depth = 0;
-#endif
-
- /* Turn off writes the FB */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, FBWriteMode, FBWriteModeDisable);
-
- /*
- * Turn Rectangle2DControl off when the window is not clipped
- * (i.e., the GID tests are not necessary). This dramatically
- * increases the performance of the depth clears.
- */
- if (!gCCPriv->NotClipped) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Rectangle2DControl, 1);
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, DepthMode, (DepthModeEnable |
- DM_Always |
- DM_SourceDepthRegister |
- DM_WriteMask));
- WRITE(gCCPriv->buf, GLINTDepth, depth);
-
- /* Increment the frame count */
- gCCPriv->FrameCount++;
-#ifdef FAST_CLEAR_4
- gCCPriv->FrameCount &= 0x0f;
-#else
- gCCPriv->FrameCount &= 0xff;
-#endif
-
- temp = (gCCPriv->LBReadMode & LBPartialProdMask) | LBWindowOriginBot;
- /* UGH - move this later ! */
- if (gDRIPriv->numMultiDevices == 2) temp |= LBScanLineInt2;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LBReadMode, temp);
-
- /* Force FCP to be written */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GLINTWindow, (WindowEnable |
- W_PassIfEqual |
- (gCCPriv->Window & W_GIDMask) |
- W_DepthFCP |
- W_LBUpdateFromRegisters |
- W_OverrideWriteFiltering |
- (gCCPriv->FrameCount << 9)));
-
- /* Clear part of the depth and FCP buffers */
- {
- int y = gCCPriv->y;
- int h = gCCPriv->h;
-#ifndef TURN_OFF_FCP
- float hsub = h;
-
- if (gCCPriv->WindowChanged) {
- gCCPriv->WindowChanged = GL_FALSE;
- } else {
-#ifdef FAST_CLEAR_4
- hsub /= 16;
-#else
- hsub /= 256;
-#endif
-
- /* Handle the case where the height < # of FCPs */
- if (hsub < 1.0) {
- if (gCCPriv->FrameCount > h)
- gCCPriv->FrameCount = 0;
- h = 1;
- y += gCCPriv->FrameCount;
- } else {
- h = (gCCPriv->FrameCount+1)*hsub;
- h -= (int)(gCCPriv->FrameCount*hsub);
- y += gCCPriv->FrameCount*hsub;
- }
- }
-#endif
-
- if (h) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 8);
- WRITE(gCCPriv->buf, StartXDom, gCCPriv->x<<16);
- WRITE(gCCPriv->buf, StartY, y<<16);
- WRITE(gCCPriv->buf, StartXSub, (gCCPriv->x+gCCPriv->w)<<16);
- WRITE(gCCPriv->buf, GLINTCount, h);
- WRITE(gCCPriv->buf, dY, 1<<16);
- WRITE(gCCPriv->buf, dXDom, 0<<16);
- WRITE(gCCPriv->buf, dXSub, 0<<16);
- WRITE(gCCPriv->buf, Render, 0x00000040); /* NOT_DONE */
- }
- }
-
- /* Restore modes */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 5);
- WRITE(gCCPriv->buf, FBWriteMode, FBWriteModeEnable);
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
- WRITE(gCCPriv->buf, LBReadMode, gCCPriv->LBReadMode);
- WRITE(gCCPriv->buf, GLINTWindow, gCCPriv->Window);
- WRITE(gCCPriv->buf, FastClearDepth, depth);
-
- /* Turn on Depth FCP */
- if (gCCPriv->Window & W_DepthFCP) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, WindowOr, (gCCPriv->FrameCount << 9));
- }
-
- /* Turn off GID clipping if window is not clipped */
- if (gCCPriv->NotClipped) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Rectangle2DControl, 0);
- }
- }
-
- if (mask & GL_COLOR_BUFFER_BIT) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITE(gCCPriv->buf, ConstantColor,
- (((GLuint)(gCCPriv->ClearColor[3]*255.0) << 24) |
- ((GLuint)(gCCPriv->ClearColor[2]*255.0) << 16) |
- ((GLuint)(gCCPriv->ClearColor[1]*255.0) << 8) |
- ((GLuint)(gCCPriv->ClearColor[0]*255.0))));
- WRITE(gCCPriv->buf, FBBlockColor,
- (((GLuint)(gCCPriv->ClearColor[3]*255.0) << 24) |
- ((GLuint)(gCCPriv->ClearColor[0]*255.0) << 16) |
- ((GLuint)(gCCPriv->ClearColor[1]*255.0) << 8) |
- ((GLuint)(gCCPriv->ClearColor[2]*255.0))));
- WRITE(gCCPriv->buf, ColorDDAMode, (ColorDDAEnable |
- ColorDDAFlat));
- do_clear = 1;
- } else {
- /* Turn off writes the FB */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, FBWriteMode, FBWriteModeDisable);
- }
-
- if (do_clear) {
- /* Turn on GID clipping if window is not clipped */
- if (!gCCPriv->NotClipped) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Rectangle2DControl, 1);
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 6);
- WRITE(gCCPriv->buf, DepthMode, 0);
- WRITE(gCCPriv->buf, AlphaBlendMode, 0);
- WRITE(gCCPriv->buf, Rectangle2DMode, (((gCCPriv->h & 0xfff)<<12) |
- (gCCPriv->w & 0xfff)));
- WRITE(gCCPriv->buf, DrawRectangle2D, (((gCCPriv->y & 0xffff)<<16) |
- (gCCPriv->x & 0xffff)));
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
- WRITE(gCCPriv->buf, AlphaBlendMode, gCCPriv->AlphaBlendMode);
-
- /* Turn off GID clipping if window is not clipped */
- if (gCCPriv->NotClipped) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Rectangle2DControl, 0);
- }
- }
-
- if (mask & GL_COLOR_BUFFER_BIT) {
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ColorDDAMode, gCCPriv->ColorDDAMode);
- } else {
- /* Turn on writes the FB */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, FBWriteMode, FBWriteModeEnable);
- }
-
-#ifdef DO_VALIDATE
- PROCESS_DMA_BUFFER_TOP_HALF(gCCPriv);
-
- DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
- driScrnPriv->drawLockID);
- VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gCC,gCCPriv);
-
- PROCESS_DMA_BUFFER_BOTTOM_HALF(gCCPriv);
-#endif
-
-#if 0
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-#endif
-}
-
-void _gamma_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
-{
- DEBUG_GLCMDS(("ClearAccum: %f %f %f %f\n", red, green, blue, alpha));
-}
-
-void _gamma_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-{
- DEBUG_GLCMDS(("ClearColor: %f %f %f %f\n",
- (float)red, (float)green, (float)blue, (float)alpha));
-
- gCCPriv->ClearColor[0] = red;
- gCCPriv->ClearColor[1] = green;
- gCCPriv->ClearColor[2] = blue;
- gCCPriv->ClearColor[3] = alpha;
-}
-
-void _gamma_ClearDepth(GLclampd depth)
-{
- DEBUG_GLCMDS(("ClearDepth: %f\n", (float)depth));
-
- gCCPriv->ClearDepth = depth;
-}
-
-void _gamma_ClearIndex(GLfloat c)
-{
- DEBUG_GLCMDS(("ClearIndex: %f\n", c));
-}
-
-void _gamma_ClearStencil(GLint s)
-{
- DEBUG_GLCMDS(("ClearStencil: %d\n", (int)s));
-}
-
-void _gamma_ClipPlane(GLenum plane, const GLdouble *equation)
-{
- DEBUG_GLCMDS(("ClipPlane: %04x %f %f %f %f\n", (int)plane,
- equation[0], equation[1], equation[2], equation[3]));
-}
-
-void _gamma_Color3b(GLbyte red, GLbyte green, GLbyte blue)
-{
- DEBUG_GLCMDS(("Color3b: %d %d %d\n", red, green, blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3bv(const GLbyte *v)
-{
- DEBUG_GLCMDS(("Color3bv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color3d(GLdouble red, GLdouble green, GLdouble blue)
-{
- DEBUG_GLCMDS(("Color3d: %f %f %f\n", red, green, blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Color3dv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color3f(GLfloat red, GLfloat green, GLfloat blue)
-{
- DEBUG_GLCMDS(("Color3f: %f %f %f\n", red, green, blue));
-
- gCCPriv->Current.Color[0] = red;
- gCCPriv->Current.Color[1] = green;
- gCCPriv->Current.Color[2] = blue;
- gCCPriv->Current.Color[3] = 1.0f;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, Cb, blue);
- WRITEF(gCCPriv->buf, Cg, green);
- WRITEF(gCCPriv->buf, Cr3, red);
-}
-
-void _gamma_Color3fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Color3fv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Color3f(v[0],v[1],v[2]);
-}
-
-void _gamma_Color3i(GLint red, GLint green, GLint blue)
-{
- DEBUG_GLCMDS(("Color3i: %d %d %d\n", (int)red, (int)green, (int)blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3iv(const GLint *v)
-{
- DEBUG_GLCMDS(("Color3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color3s(GLshort red, GLshort green, GLshort blue)
-{
- DEBUG_GLCMDS(("Color3s: %d %d %d\n", red, green, blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3sv(const GLshort *v)
-{
- DEBUG_GLCMDS(("Color3sv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color3ub(GLubyte red, GLubyte green, GLubyte blue)
-{
- GLuint c;
-
- DEBUG_GLCMDS(("Color3ub: %d %d %d\n", red, green, blue));
-
- c = (blue << 16) | (green << 8) | red;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, PackedColor3, c);
-}
-
-void _gamma_Color3ubv(const GLubyte *v)
-{
- GLuint c;
-
- DEBUG_GLCMDS(("Color3ubv: %d %d %d\n", v[0], v[1], v[2]));
-
- c = (v[2] << 16) | (v[1] << 8) | v[0];
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, PackedColor3, c);
-}
-
-void _gamma_Color3ui(GLuint red, GLuint green, GLuint blue)
-{
- DEBUG_GLCMDS(("Color3ui: %d %d %d\n",
- (unsigned int)red, (unsigned int)green, (unsigned int)blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3uiv(const GLuint *v)
-{
- DEBUG_GLCMDS(("Color3uiv: %d %d %d\n",
- (unsigned int)v[0], (unsigned int)v[1], (unsigned int)v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color3us(GLushort red, GLushort green, GLushort blue)
-{
- DEBUG_GLCMDS(("Color3us: %d %d %d\n", red, green, blue));
-
- _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue);
-}
-
-void _gamma_Color3usv(const GLushort *v)
-{
- DEBUG_GLCMDS(("Color3usv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Color3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Color4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)
-{
- GLfloat r,g,b,a;
-
- DEBUG_GLCMDS(("Color4b: %d %d %d %d\n", red, green, blue, alpha));
-
- r = BYTE_TO_FLOAT(red);
- g = BYTE_TO_FLOAT(green);
- b = BYTE_TO_FLOAT(blue);
- a = BYTE_TO_FLOAT(alpha);
-
- _gamma_Color4f(r,g,b,a);
-}
-
-void _gamma_Color4bv(const GLbyte *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("Color4bv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- p[0] = BYTE_TO_FLOAT(v[0]);
- p[1] = BYTE_TO_FLOAT(v[1]);
- p[2] = BYTE_TO_FLOAT(v[2]);
- p[3] = BYTE_TO_FLOAT(v[3]);
-
- _gamma_Color4fv(p);
-}
-
-void _gamma_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
-{
- DEBUG_GLCMDS(("Color4d: %f %f %f %f\n", red, green, blue, alpha));
-
- _gamma_Color4f((GLfloat)red,(GLfloat)green,(GLfloat)blue,(GLfloat)alpha);
-}
-
-void _gamma_Color4dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Color4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- _gamma_Color4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]);
-}
-
-void _gamma_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
-{
- DEBUG_GLCMDS(("Color4f: %f %f %f %f\n", red, green, blue, alpha));
-
- gCCPriv->Current.Color[0] = red;
- gCCPriv->Current.Color[1] = green;
- gCCPriv->Current.Color[2] = blue;
- gCCPriv->Current.Color[3] = alpha;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, Ca, alpha);
- WRITEF(gCCPriv->buf, Cb, blue);
- WRITEF(gCCPriv->buf, Cg, green);
- WRITEF(gCCPriv->buf, Cr4, red);
-}
-
-void _gamma_Color4fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Color4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- gCCPriv->Current.Color[0] = v[0];
- gCCPriv->Current.Color[1] = v[1];
- gCCPriv->Current.Color[2] = v[2];
- gCCPriv->Current.Color[3] = v[3];
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, Ca, v[3]);
- WRITEF(gCCPriv->buf, Cb, v[2]);
- WRITEF(gCCPriv->buf, Cg, v[1]);
- WRITEF(gCCPriv->buf, Cr4, v[0]);
-}
-
-void _gamma_Color4i(GLint red, GLint green, GLint blue, GLint alpha)
-{
- GLfloat r,g,b,a;
-
- DEBUG_GLCMDS(("Color4i: %d %d %d %d\n", (int)red, (int)green, (int)blue,
- (int)alpha));
-
- r = INT_TO_FLOAT(red);
- g = INT_TO_FLOAT(green);
- b = INT_TO_FLOAT(blue);
- a = INT_TO_FLOAT(alpha);
-
- _gamma_Color4f(r,g,b,a);
-}
-
-void _gamma_Color4iv(const GLint *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("Color4iv: %d %d %d %d\n", (int)v[0], (int)v[1], (int)v[2],
- (int)v[3]));
-
- p[0] = INT_TO_FLOAT(v[0]);
- p[1] = INT_TO_FLOAT(v[1]);
- p[2] = INT_TO_FLOAT(v[2]);
- p[3] = INT_TO_FLOAT(v[3]);
-
- _gamma_Color4fv(p);
-}
-
-void _gamma_Color4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)
-{
- GLfloat r,g,b,a;
-
- DEBUG_GLCMDS(("Color4s: %d %d %d %d\n", red, green, blue, alpha));
-
- r = SHORT_TO_FLOAT(red);
- g = SHORT_TO_FLOAT(green);
- b = SHORT_TO_FLOAT(blue);
- a = SHORT_TO_FLOAT(alpha);
-
- _gamma_Color4f(r,g,b,a);
-}
-
-void _gamma_Color4sv(const GLshort *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("Color4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- p[0] = SHORT_TO_FLOAT(v[0]);
- p[1] = SHORT_TO_FLOAT(v[1]);
- p[2] = SHORT_TO_FLOAT(v[2]);
- p[3] = SHORT_TO_FLOAT(v[3]);
-
- _gamma_Color4fv(p);
-}
-
-void _gamma_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
-{
- GLuint c;
-
- DEBUG_GLCMDS(("Color4ub: %d %d %d %d\n", red, green, blue, alpha));
-
- c = (alpha << 24) | (blue << 16) | (green << 8) | red;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, PackedColor4, c);
-}
-
-void _gamma_Color4ubv(const GLubyte *v)
-{
- GLuint c;
-
- DEBUG_GLCMDS(("Color4ubv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- c = (v[3] << 24) | (v[2] << 16) | (v[1] << 8) | v[0];
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, PackedColor4, c);
-}
-
-void _gamma_Color4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
-{
- GLfloat r,g,b,a;
-
- DEBUG_GLCMDS(("Color4ui: %d %d %d %d\n",
- (unsigned int)red, (unsigned int)green,
- (unsigned int)blue, (unsigned int)alpha));
-
- r = UINT_TO_FLOAT(red);
- g = UINT_TO_FLOAT(green);
- b = UINT_TO_FLOAT(blue);
- a = UINT_TO_FLOAT(alpha);
-
- _gamma_Color4f(r,g,b,a);
-}
-
-void _gamma_Color4uiv(const GLuint *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("Color4uiv: %d %d %d %d\n",
- (unsigned int)v[0], (unsigned int)v[1],
- (unsigned int)v[2], (unsigned int)v[3]));
-
- p[0] = UINT_TO_FLOAT(v[0]);
- p[1] = UINT_TO_FLOAT(v[1]);
- p[2] = UINT_TO_FLOAT(v[2]);
- p[3] = UINT_TO_FLOAT(v[3]);
-
- _gamma_Color4fv(p);
-}
-
-void _gamma_Color4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)
-{
- GLfloat r,g,b,a;
-
- DEBUG_GLCMDS(("Color4us: %d %d %d %d\n", red, green, blue, alpha));
-
- r = USHORT_TO_FLOAT(red);
- g = USHORT_TO_FLOAT(green);
- b = USHORT_TO_FLOAT(blue);
- a = USHORT_TO_FLOAT(alpha);
-
- _gamma_Color4f(r,g,b,a);
-}
-
-void _gamma_Color4usv(const GLushort *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("Color4usv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- p[0] = USHORT_TO_FLOAT(v[0]);
- p[1] = USHORT_TO_FLOAT(v[1]);
- p[2] = USHORT_TO_FLOAT(v[2]);
- p[3] = USHORT_TO_FLOAT(v[3]);
-
- _gamma_Color4fv(p);
-}
-
-void _gamma_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
-{
- DEBUG_GLCMDS(("ColorMask: %d %d %d %d\n", red, green, blue, alpha));
-}
-
-void _gamma_ColorMaterial(GLenum face, GLenum mode)
-{
- DEBUG_GLCMDS(("ColorMaterial: %04x %04x\n", (int)face, (int)mode));
-
- gCCPriv->ColorMaterialMode &= ~ColorMaterialModeMask;
-
- switch (face) {
- case GL_FRONT:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeFront;
- break;
- case GL_BACK:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeBack;
- break;
- case GL_FRONT_AND_BACK:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeFrontAndBack;
- break;
- }
-
- switch (mode) {
- case GL_AMBIENT:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeAmbient;
- break;
- case GL_EMISSION:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeEmission;
- break;
- case GL_DIFFUSE:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeDiffuse;
- break;
- case GL_SPECULAR:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeSpecular;
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeAmbAndDiff;
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode);
-}
-
-void _gamma_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("ColorPointer: %d %04x %d\n",
- (int)size, (int)type, (int)stride));
-
- if (size<3 || size>4) {
- gamma_error( GL_INVALID_VALUE, "glColorPointer(size)" );
- return;
- }
- if (stride<0) {
- gamma_error( GL_INVALID_VALUE, "glColorPointer(stride)" );
- return;
- }
- switch (type) {
- case GL_BYTE:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLbyte);
- break;
- case GL_UNSIGNED_BYTE:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLubyte);
- break;
- case GL_SHORT:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLshort);
- break;
- case GL_UNSIGNED_SHORT:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLushort);
- break;
- case GL_INT:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLint);
- break;
- case GL_UNSIGNED_INT:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLuint);
- break;
- case GL_FLOAT:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLfloat);
- break;
- case GL_DOUBLE:
- gCCPriv->Array.ColorStrideB = stride ? stride : size*sizeof(GLdouble);
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glColorPointer(type)" );
- return;
- }
- gCCPriv->Array.ColorSize = size;
- gCCPriv->Array.ColorType = type;
- gCCPriv->Array.ColorStride = stride;
- gCCPriv->Array.ColorPtr = (void *) pointer;
-}
-
-void _gamma_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
-{
- DEBUG_GLCMDS(("CopyPixels: %d %d %d %d %04x\n", (int)x, (int)y,
- (int)width, (int)height, (int)type));
-}
-
-void _gamma_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
-{
- DEBUG_GLCMDS(("CopyTexImage1D: %04x %d %04x %d %d %d %d\n",
- (int)target, (int)level, (int)internalformat,
- (int)x, (int)y, (int)width, (int)border));
-}
-
-void _gamma_CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
-{
- DEBUG_GLCMDS(("CopyTexImage2D: %04x %d %04x %d %d %d %d %d\n",
- (int)target, (int)level, (int)internalformat,
- (int)x, (int)y, (int)width, (int)height, (int)border));
-}
-
-void _gamma_CopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
-{
- DEBUG_GLCMDS(("CopyTexSubImage1D: %04x %d %d %d %d %d\n",
- (int)target, (int)level,
- (int)xoffset, (int)x, (int)y, (int)width));
-}
-
-void _gamma_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
-{
- DEBUG_GLCMDS(("CopyTexSubImage2D: %04x %d %d %d %d %d %d %d\n",
- (int)target, (int)level, (int)xoffset, (int)yoffset,
- (int)x, (int)y, (int)width, (int)height));
-}
-
-void _gamma_CullFace(GLenum mode)
-{
- DEBUG_GLCMDS(("CullFace: %04x\n", (int)mode));
-
- gCCPriv->GeometryMode &= ~GM_PolyCullMask;
-
- switch (mode) {
- case GL_FRONT:
- gCCPriv->GeometryMode |= GM_PolyCullFront;
- break;
- case GL_BACK:
- gCCPriv->GeometryMode |= GM_PolyCullBack;
- break;
- case GL_FRONT_AND_BACK:
- gCCPriv->GeometryMode |= GM_PolyCullBoth;
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
-}
-
-#if 0 /* Now in dlist.c */
-void _gamma_DeleteLists(GLuint list, GLsizei range)
-{
- DEBUG_GLCMDS(("DeleteLists: %d %d\n", (unsigned int)list, (int)range));
-}
-#endif
-
-void _gamma_DeleteTextures(GLsizei n, const GLuint *textures)
-{
- int i;
-
- DEBUG_GLCMDS(("DeleteTextures: %d\n", (int)n));
-#ifdef DEBUG_VERBOSE_EXTRA
- {
- int t;
- for (t = 0; t < n; t++)
- printf("\t%d\n", (unsigned int)textures[t]);
- }
-#endif
-
- for (i = 0; i < n; i++) {
- gammaTexObj *t = gammaTOFind(textures[i]);
- if (driTMMDeleteImages(gCCPriv->tmm, MIPMAP_LEVELS, t->image) < 0) {
- DEBUG_ERROR(("DeleteTextures: unable\n"));
- /* NOT_DONE: Handle error */
- }
- gammaTODelete(textures[i]);
- }
-
- gCCPriv->curTexObj = gammaTOFind(0);
- gCCPriv->curTexObj1D = gCCPriv->curTexObj;
- gCCPriv->curTexObj2D = gCCPriv->curTexObj;
-}
-
-void _gamma_DepthFunc(GLenum func)
-{
- DEBUG_GLCMDS(("DepthFunc: %04x\n", (int)func));
-
- gCCPriv->DepthMode &= ~DM_CompareMask;
-
- switch (func) {
- case GL_NEVER:
- gCCPriv->DepthMode |= DM_Never;
- break;
- case GL_LESS:
- gCCPriv->DepthMode |= DM_Less;
- break;
- case GL_EQUAL:
- gCCPriv->DepthMode |= DM_Equal;
- break;
- case GL_LEQUAL:
- gCCPriv->DepthMode |= DM_LessEqual;
- break;
- case GL_GREATER:
- gCCPriv->DepthMode |= DM_Greater;
- break;
- case GL_NOTEQUAL:
- gCCPriv->DepthMode |= DM_NotEqual;
- break;
- case GL_GEQUAL:
- gCCPriv->DepthMode |= DM_GreaterEqual;
- break;
- case GL_ALWAYS:
- gCCPriv->DepthMode |= DM_Always;
- break;
- default:
- /* ERROR!! */
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
-}
-
-void _gamma_DepthMask(GLboolean flag)
-{
- DEBUG_GLCMDS(("DepthMask: %d\n", flag));
-
- if (flag) {
- gCCPriv->DepthMode |= DM_WriteMask;
- } else {
- gCCPriv->DepthMode &= ~DM_WriteMask;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
-}
-
-void _gamma_DepthRange(GLclampd zNear, GLclampd zFar)
-{
- GLfloat sz, oz;
-
- DEBUG_GLCMDS(("DepthRange: %f %f\n", (float)zNear, (float)zFar));
-
- gCCPriv->zNear = zNear;
- gCCPriv->zFar = zFar;
-
- oz = (zFar+zNear)/2.0;
- sz = (zFar-zNear)/2.0;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITEF(gCCPriv->buf, ViewPortScaleZ, sz);
- WRITEF(gCCPriv->buf, ViewPortOffsetZ, oz);
-}
-
-void _gamma_Disable(GLenum cap)
-{
- DEBUG_GLCMDS(("Disable %04x\n", (int)cap));
-
- switch (cap) {
- case GL_CULL_FACE:
- gCCPriv->GeometryMode &= ~GM_PolyCullEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
- break;
- case GL_DEPTH_TEST:
- if (gCCPriv->Flags & GAMMA_DEPTH_BUFFER) {
- gCCPriv->EnabledFlags &= ~GAMMA_DEPTH_BUFFER;
- gCCPriv->DepthMode &= ~DepthModeEnable;
- gCCPriv->LBReadMode &= ~LBReadDstEnable;
- gCCPriv->DeltaMode &= ~DM_DepthEnable;
- gCCPriv->Window &= ~W_DepthFCP;
-
- /* Turn depth mode off */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
- WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode);
- WRITE(gCCPriv->buf, LBReadModeAnd, ~LBReadDstEnable);
- WRITE(gCCPriv->buf, WindowAnd, ~W_DepthFCP);
- }
- break;
- case GL_ALPHA_TEST:
- /* Do I need to verify that alpha is enabled? */
- gCCPriv->AlphaTestMode &= ~AlphaTestModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, AlphaTestMode, gCCPriv->AlphaTestMode);
- WRITE(gCCPriv->buf, RouterMode, R_Order_DepthTexture);
- break;
- case GL_BLEND:
- /* Do I need to verify that alpha is enabled? */
- gCCPriv->AlphaBlendMode &= ~AlphaBlendModeEnable;
- gCCPriv->AB_FBReadMode = 0;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, AlphaBlendMode, gCCPriv->AlphaBlendMode);
- WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode |
- gCCPriv->AB_FBReadMode));
- break;
- case GL_COLOR_MATERIAL:
- gCCPriv->ColorMaterialMode &= ~ColorMaterialModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode);
- break;
- case GL_FOG:
- gCCPriv->Begin &= ~B_FogEnable;
- gCCPriv->GeometryMode &= ~GM_FogEnable;
- gCCPriv->DeltaMode &= ~DM_FogEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
- WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode);
- WRITE(gCCPriv->buf, FogMode, FogModeDisable);
- break;
- case GL_LIGHTING:
- gCCPriv->LightingMode &= ~LightingModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode);
- break;
- case GL_LIGHT0:
- gCCPriv->Light0Mode &= ~LNM_On;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode);
- break;
- case GL_LIGHT1:
- gCCPriv->Light1Mode &= ~LNM_On;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode);
- break;
- case GL_LOGIC_OP:
- gCCPriv->LogicalOpMode &= ~LogicalOpModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LogicalOpMode, gCCPriv->LogicalOpMode);
- break;
- case GL_NORMALIZE:
- gCCPriv->NormalizeMode &= ~NormalizeModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, NormalizeMode, gCCPriv->NormalizeMode);
- WRITE(gCCPriv->buf, TransformModeOr, 0xc);
- break;
- case GL_SCISSOR_TEST:
- gCCPriv->ScissorMode &= ~UserScissorEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ScissorMode, gCCPriv->ScissorMode);
- break;
- case GL_TEXTURE_2D:
- gCCPriv->Texture2DEnabled = GL_FALSE;
- gCCPriv->Begin &= ~B_TextureEnable;
- gCCPriv->GeometryMode &= ~GM_TextureEnable;
- gCCPriv->DeltaMode &= ~DM_TextureEnable;
- gCCPriv->curTexObj->TextureAddressMode &= ~TextureAddressModeEnable;
- gCCPriv->curTexObj->TextureReadMode &= ~TextureReadModeEnable;
- gCCPriv->curTexObj->TextureColorMode &= ~TextureColorModeEnable;
- gCCPriv->curTexObj->TextureFilterMode &= ~TextureFilterModeEnable;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 6);
- WRITE(gCCPriv->buf, GeometryModeAnd, ~GM_TextureEnable);
- WRITE(gCCPriv->buf, DeltaModeAnd, ~DM_TextureEnable);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj->TextureAddressMode);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj->TextureReadMode);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj->TextureColorMode);
- WRITE(gCCPriv->buf, TextureFilterMode,
- gCCPriv->curTexObj->TextureFilterMode);
- break;
- default:
- break;
- }
-}
-
-void _gamma_DisableClientState(GLenum array)
-{
- DEBUG_GLCMDS(("DisableClientState: %04x\n", (int)array));
-
- switch (array) {
- case GL_VERTEX_ARRAY:
- gCCPriv->Array.VertexEnabled = GL_FALSE;
- break;
- case GL_NORMAL_ARRAY:
- gCCPriv->Array.NormalEnabled = GL_FALSE;
- break;
- case GL_COLOR_ARRAY:
- gCCPriv->Array.ColorEnabled = GL_FALSE;
- break;
- case GL_INDEX_ARRAY:
- gCCPriv->Array.IndexEnabled = GL_FALSE;
- break;
- case GL_TEXTURE_COORD_ARRAY:
- gCCPriv->Array.TexCoordEnabled = GL_FALSE;
- break;
- case GL_EDGE_FLAG_ARRAY:
- gCCPriv->Array.EdgeFlagEnabled = GL_FALSE;
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glEnable/DisableClientState" );
- }
-}
-
-void _gamma_DrawArrays(GLenum mode, GLint first, GLsizei count)
-{
- DEBUG_GLCMDS(("DrawArrays: %04x %d %d\n", (int)mode, (int)first,
- (int)count));
-}
-
-void _gamma_DrawBuffer(GLenum mode)
-{
- DEBUG_GLCMDS(("DrawBuffer: %04x\n", (int)mode));
-}
-
-void _gamma_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
-{
- DEBUG_GLCMDS(("DrawElements: %04x %d %04x\n", (int)mode, (int)count,
- (int)type));
-}
-
-void _gamma_DrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image)
-{
- DEBUG_GLCMDS(("DrawPixels: %d %d %04x %04x\n", (int)width, (int)height,
- (int)format, (int)type));
-}
-
-void _gamma_EdgeFlag(GLboolean flag)
-{
- DEBUG_GLCMDS(("EdgeFlag: %d\n", flag));
-}
-
-void _gamma_EdgeFlagPointer(GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("EdgeFlagPointer: %d\n", (int)stride));
-}
-
-void _gamma_EdgeFlagv(const GLboolean *flag)
-{
- DEBUG_GLCMDS(("EdgeFlagv: \n"));
-}
-
-void _gamma_Enable(GLenum cap)
-{
- DEBUG_GLCMDS(("Enable %04x\n", (int)cap));
-
- switch (cap) {
- case GL_CULL_FACE:
- gCCPriv->GeometryMode |= GM_PolyCullEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
- break;
- case GL_DEPTH_TEST:
- if (gCCPriv->Flags & GAMMA_DEPTH_BUFFER) {
- gCCPriv->EnabledFlags |= GAMMA_DEPTH_BUFFER;
-#ifndef TURN_OFF_DEPTH
- gCCPriv->DepthMode |= DepthModeEnable;
- gCCPriv->LBReadMode |= LBReadDstEnable;
- gCCPriv->DeltaMode |= DM_DepthEnable;
-#ifndef TURN_OFF_FCP
- gCCPriv->Window |= W_DepthFCP;
-#endif
-
- /* Turn depth mode on */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITE(gCCPriv->buf, DepthMode, gCCPriv->DepthMode);
- WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode);
- WRITE(gCCPriv->buf, LBReadModeOr, LBReadDstEnable);
-#ifndef TURN_OFF_FCP
- WRITE(gCCPriv->buf, WindowOr, (W_DepthFCP |
- (gCCPriv->FrameCount << 9)));
-#else
- WRITE(gCCPriv->buf, WindowOr, (gCCPriv->FrameCount << 9));
-#endif
-#endif
- }
- break;
- case GL_ALPHA_TEST:
- gCCPriv->AlphaTestMode |= AlphaTestModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, AlphaTestMode, gCCPriv->AlphaTestMode);
- WRITE(gCCPriv->buf, RouterMode, R_Order_TextureDepth);
- break;
- case GL_BLEND:
-#ifndef TURN_OFF_BLEND
- gCCPriv->AlphaBlendMode |= AlphaBlendModeEnable;
- gCCPriv->AB_FBReadMode = gCCPriv->AB_FBReadMode_Save;
-#endif
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, AlphaBlendMode, gCCPriv->AlphaBlendMode);
- WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode |
- gCCPriv->AB_FBReadMode));
- break;
- case GL_COLOR_MATERIAL:
- gCCPriv->ColorMaterialMode |= ColorMaterialModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode);
- break;
- case GL_FOG:
- gCCPriv->Begin |= B_FogEnable;
- gCCPriv->GeometryMode |= GM_FogEnable;
- gCCPriv->DeltaMode |= DM_FogEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
- WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode);
- WRITE(gCCPriv->buf, FogMode, FogModeEnable);
- break;
- case GL_LIGHTING:
- gCCPriv->LightingMode |= LightingModeEnable | 16<<6;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode);
- break;
- case GL_LIGHT0:
- gCCPriv->Light0Mode |= LNM_On;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode);
- break;
- case GL_LIGHT1:
- gCCPriv->Light1Mode |= LNM_On;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode);
- break;
- case GL_LOGIC_OP:
- gCCPriv->LogicalOpMode |= LogicalOpModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LogicalOpMode, gCCPriv->LogicalOpMode);
- break;
- case GL_NORMALIZE:
- gCCPriv->NormalizeMode |= NormalizeModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, NormalizeMode, gCCPriv->NormalizeMode);
- WRITE(gCCPriv->buf, TransformModeAnd, 0xffffff3f);
- break;
- case GL_SCISSOR_TEST:
- gCCPriv->ScissorMode |= UserScissorEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, ScissorMode, gCCPriv->ScissorMode);
- break;
- case GL_TEXTURE_2D:
- gCCPriv->Texture2DEnabled = GL_TRUE;
-#ifndef TURN_OFF_TEXTURES
- gCCPriv->Begin |= B_TextureEnable;
-#endif
- gCCPriv->GeometryMode |= GM_TextureEnable;
- gCCPriv->DeltaMode |= DM_TextureEnable;
- gCCPriv->curTexObj->TextureAddressMode |= TextureAddressModeEnable;
- gCCPriv->curTexObj->TextureReadMode |= TextureReadModeEnable;
- gCCPriv->curTexObj->TextureColorMode |= TextureColorModeEnable;
- gCCPriv->curTexObj->TextureFilterMode |= TextureFilterModeEnable;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 6);
- WRITE(gCCPriv->buf, GeometryModeOr, GM_TextureEnable);
- WRITE(gCCPriv->buf, DeltaModeOr, DM_TextureEnable);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj->TextureAddressMode);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj->TextureReadMode);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj->TextureColorMode);
- WRITE(gCCPriv->buf, TextureFilterMode,
- gCCPriv->curTexObj->TextureFilterMode);
- break;
- default:
- break;
- }
-}
-
-void _gamma_EnableClientState(GLenum array)
-{
- DEBUG_GLCMDS(("EnableClientState: %04x\n", (int)array));
-
- switch (array) {
- case GL_VERTEX_ARRAY:
- gCCPriv->Array.VertexEnabled = GL_TRUE;
- break;
- case GL_NORMAL_ARRAY:
- gCCPriv->Array.NormalEnabled = GL_TRUE;
- break;
- case GL_COLOR_ARRAY:
- gCCPriv->Array.ColorEnabled = GL_TRUE;
- break;
- case GL_INDEX_ARRAY:
- gCCPriv->Array.IndexEnabled = GL_TRUE;
- break;
- case GL_TEXTURE_COORD_ARRAY:
- gCCPriv->Array.TexCoordEnabled = GL_TRUE;
- break;
- case GL_EDGE_FLAG_ARRAY:
- gCCPriv->Array.EdgeFlagEnabled = GL_TRUE;
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glEnable/DisableClientState" );
- }
-}
-
-void _gamma_End(void)
-{
- DEBUG_GLCMDS(("End\n"));
-
- if ((gCCPriv->Begin & B_PrimType_Mask) == B_PrimType_Null) {
- /* ERROR!!! */
- return;
- }
-
- /* No longer inside of Begin/End */
- gCCPriv->Begin &= ~B_PrimType_Mask;
- gCCPriv->Begin |= B_PrimType_Null;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, End, 0);
-#if 0
- /* To force creation of smaller buffers */
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-#endif
-}
-
-#if 0 /* Now in dlist.c */
-void _gamma_EndList(void)
-{
- DEBUG_GLCMDS(("EndList\n"));
-}
-#endif
-
-void _gamma_EvalCoord1d(GLdouble u)
-{
- DEBUG_GLCMDS(("EvalCoord1d: %f\n", u));
-}
-
-void _gamma_EvalCoord1dv(const GLdouble *u)
-{
- DEBUG_GLCMDS(("EvalCoord1dv: %f\n", *u));
-}
-
-void _gamma_EvalCoord1f(GLfloat u)
-{
- DEBUG_GLCMDS(("EvalCoord1f: %f\n", u));
-}
-
-void _gamma_EvalCoord1fv(const GLfloat *u)
-{
- DEBUG_GLCMDS(("EvalCoord1fv: %f\n", *u));
-}
-
-void _gamma_EvalCoord2d(GLdouble u, GLdouble v)
-{
- DEBUG_GLCMDS(("EvalCoord2d: %f %f\n", u, v));
-}
-
-void _gamma_EvalCoord2dv(const GLdouble *u)
-{
- DEBUG_GLCMDS(("EvalCoord2dv: %f %f\n", u[0], u[1]));
-}
-
-void _gamma_EvalCoord2f(GLfloat u, GLfloat v)
-{
- DEBUG_GLCMDS(("EvalCoord2f: %f %f\n", u, v));
-}
-
-void _gamma_EvalCoord2fv(const GLfloat *u)
-{
- DEBUG_GLCMDS(("EvalCoord1fv: %f %f\n", u[0], u[1]));
-}
-
-void _gamma_EvalMesh1(GLenum mode, GLint i1, GLint i2)
-{
- DEBUG_GLCMDS(("EvalMesh1: %d %d %d\n", mode, i1, i2));
-}
-
-void _gamma_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
-{
-}
-
-void _gamma_EvalPoint1(GLint i)
-{
-}
-
-void _gamma_EvalPoint2(GLint i, GLint j)
-{
-}
-
-void _gamma_FeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)
-{
- DEBUG_GLCMDS(("FeedbackBuffer: %d %04x\n", (int)size, (int)type));
-}
-
-void _gamma_Finish(void)
-{
- DEBUG_GLCMDS(("Finish\n"));
-
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-}
-
-void _gamma_Flush(void)
-{
- DEBUG_GLCMDS(("Flush\n"));
-
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-}
-
-void _gamma_Fogf(GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("Fogf: %04x %f\n", (int)pname, param));
-
- switch (pname) {
- case GL_FOG_DENSITY:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, FogDensity, param);
- break;
- }
-}
-
-void _gamma_Fogfv(GLenum pname, const GLfloat *params)
-{
- int color;
-
- DEBUG_GLCMDS(("Fogfv: %04x %f\n", (int)pname, *params));
-
- switch (pname) {
- case GL_FOG_COLOR:
- color = (FLOAT_TO_UBYTE(params[3])<<24) |
- (FLOAT_TO_UBYTE(params[2])<<16) |
- (FLOAT_TO_UBYTE(params[1])<<8) |
- (FLOAT_TO_UBYTE(params[0]));
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, FogColor, color);
- break;
- }
-}
-
-void _gamma_Fogi(GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("Fogi: %04x %d\n", (int)pname, (int)param));
-
- gCCPriv->GeometryMode &= ~GM_FogMask;
-
- switch (pname) {
- case GL_FOG_MODE:
- switch (param) {
- case GL_EXP:
- gCCPriv->GeometryMode |= GM_FogExp;
- break;
- case GL_EXP2:
- gCCPriv->GeometryMode |= GM_FogExpSquared;
- break;
- case GL_LINEAR:
- gCCPriv->GeometryMode |= GM_FogLinear;
- break;
- }
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
-}
-
-void _gamma_Fogiv(GLenum pname, const GLint *params)
-{
- DEBUG_GLCMDS(("Fogiv: %04x %d\n", (int)pname, (int)*params));
-}
-
-void _gamma_FrontFace(GLenum mode)
-{
- DEBUG_GLCMDS(("FrontFace: %04x\n", (int)mode));
-
- gCCPriv->GeometryMode &= ~GM_FFMask;
-
- if (mode == GL_CCW)
- gCCPriv->GeometryMode |= GM_FrontFaceCCW;
- else
- gCCPriv->GeometryMode |= GM_FrontFaceCW;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
-}
-
-void _gamma_Frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
-{
-#define FRUSTUM_X() ((GLfloat)((2.0*zNear)/(right-left)))
-#define FRUSTUM_Y() ((GLfloat)((2.0*zNear)/(top-bottom)))
-
-#define FRUSTUM_A() ((GLfloat)( (right+left)/(right-left)))
-#define FRUSTUM_B() ((GLfloat)( (top+bottom)/(top-bottom)))
-#define FRUSTUM_C() ((GLfloat)( -((zFar+zNear)/(zFar-zNear))))
-#define FRUSTUM_D() ((GLfloat)(-((2.0*zFar*zNear)/(zFar-zNear))))
-
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("Frustum: %f %f %f %f %f %f\n",
- left, right, bottom, top, zNear, zFar));
-
- for (i = 0; i < 16; i++) m[i] = 0.0;
-
- m[0] = FRUSTUM_X();
- m[5] = FRUSTUM_Y();
- m[8] = FRUSTUM_A();
- m[9] = FRUSTUM_B();
- m[10] = FRUSTUM_C();
- m[11] = -1.0;
- m[14] = FRUSTUM_D();
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-#if 0 /* Now in dlist.c */
-GLuint _gamma_GenLists(GLsizei range)
-{
- DEBUG_GLCMDS(("GenLists: %d\n", (int)range));
-
- return GL_TRUE;
-}
-#endif
-
-void _gamma_GenTextures(GLsizei n, GLuint *textures)
-{
- DEBUG_GLCMDS(("GenTextures: %d\n", (int)n));
-}
-
-void _gamma_GetBooleanv(GLenum val, GLboolean *b)
-{
- int loop;
-
- DEBUG_GLCMDS(("GetBooleanv: %04x\n", (int)val));
-
- switch (val) {
- case GL_CURRENT_COLOR:
- b[0] = FLOAT_TO_BOOL(gCCPriv->Current.Color[0]);
- b[1] = FLOAT_TO_BOOL(gCCPriv->Current.Color[1]);
- b[2] = FLOAT_TO_BOOL(gCCPriv->Current.Color[2]);
- b[3] = FLOAT_TO_BOOL(gCCPriv->Current.Color[3]);
- break;
- case GL_CURRENT_NORMAL:
- b[0] = FLOAT_TO_BOOL(gCCPriv->Current.Normal[0]);
- b[1] = FLOAT_TO_BOOL(gCCPriv->Current.Normal[1]);
- b[2] = FLOAT_TO_BOOL(gCCPriv->Current.Normal[2]);
- break;
- case GL_MAX_TEXTURE_SIZE:
- *b = FLOAT_TO_BOOL(GAMMA_MAX_TEXTURE_SIZE);
- break;
- case GL_MODELVIEW_MATRIX:
- for (loop = 0; loop < 16; loop++)
- b[loop] = FLOAT_TO_BOOL(gCCPriv->ModelView[loop]);
- break;
- case GL_CURRENT_TEXTURE_COORDS:
- b[0] = FLOAT_TO_BOOL(gCCPriv->Current.TexCoord[0]);
- b[1] = FLOAT_TO_BOOL(gCCPriv->Current.TexCoord[1]);
- b[2] = FLOAT_TO_BOOL(gCCPriv->Current.TexCoord[2]);
- b[3] = FLOAT_TO_BOOL(gCCPriv->Current.TexCoord[3]);
- break;
- }
-}
-
-void _gamma_GetClipPlane(GLenum plane, GLdouble *equation)
-{
- DEBUG_GLCMDS(("GetClipPlane: %04x %f %f %f %f\n", (int)plane,
- equation[0], equation[1], equation[2], equation[3]));
-}
-
-void _gamma_GetDoublev(GLenum val, GLdouble *d)
-{
- int loop;
-
- DEBUG_GLCMDS(("GetDoublev: %04x\n", (int)val));
-
- switch (val) {
- case GL_CURRENT_COLOR:
- d[0] = (GLdouble)gCCPriv->Current.Color[0];
- d[1] = (GLdouble)gCCPriv->Current.Color[1];
- d[2] = (GLdouble)gCCPriv->Current.Color[2];
- d[3] = (GLdouble)gCCPriv->Current.Color[3];
- break;
- case GL_CURRENT_NORMAL:
- d[0] = (GLdouble)gCCPriv->Current.Normal[0];
- d[1] = (GLdouble)gCCPriv->Current.Normal[1];
- d[2] = (GLdouble)gCCPriv->Current.Normal[2];
- break;
- case GL_MAX_TEXTURE_SIZE:
- *d = (GLdouble)INT_TO_FLOAT(GAMMA_MAX_TEXTURE_SIZE);
- break;
- case GL_MODELVIEW_MATRIX:
- for (loop = 0; loop < 16; loop++)
- d[loop] = (GLdouble)gCCPriv->ModelView[loop];
- break;
- case GL_CURRENT_TEXTURE_COORDS:
- d[0] = (GLdouble)gCCPriv->Current.TexCoord[0];
- d[1] = (GLdouble)gCCPriv->Current.TexCoord[1];
- d[2] = (GLdouble)gCCPriv->Current.TexCoord[2];
- d[3] = (GLdouble)gCCPriv->Current.TexCoord[3];
- break;
- }
-}
-
-GLenum _gamma_GetError(void)
-{
- DEBUG_GLCMDS(("GetError\n"));
-
- return gCCPriv->ErrorValue;
-}
-
-void _gamma_GetFloatv(GLenum val, GLfloat *f)
-{
- int loop;
-
- DEBUG_GLCMDS(("GetFloatv: %04x\n", (int)val));
-
- switch (val) {
- case GL_CURRENT_COLOR:
- f[0] = gCCPriv->Current.Color[0];
- f[1] = gCCPriv->Current.Color[1];
- f[2] = gCCPriv->Current.Color[2];
- f[3] = gCCPriv->Current.Color[3];
- break;
- case GL_CURRENT_NORMAL:
- f[0] = gCCPriv->Current.Normal[0];
- f[1] = gCCPriv->Current.Normal[1];
- f[2] = gCCPriv->Current.Normal[2];
- break;
- case GL_MAX_TEXTURE_SIZE:
- *f = INT_TO_FLOAT(GAMMA_MAX_TEXTURE_SIZE);
- break;
- case GL_MODELVIEW_MATRIX:
- for (loop = 0; loop < 16; loop++)
- f[loop] = gCCPriv->ModelView[loop];
- break;
- case GL_CURRENT_TEXTURE_COORDS:
- f[0] = gCCPriv->Current.TexCoord[0];
- f[1] = gCCPriv->Current.TexCoord[1];
- f[2] = gCCPriv->Current.TexCoord[2];
- f[3] = gCCPriv->Current.TexCoord[3];
- break;
- default:
- break;
- }
-}
-
-void _gamma_GetIntegerv(GLenum val, GLint *i)
-{
- int loop;
-
- DEBUG_GLCMDS(("GetIntegerv: %04x\n", (int)val));
-
- switch (val) {
- case GL_CURRENT_COLOR:
- i[0] = FLOAT_TO_INT(gCCPriv->Current.Color[0]);
- i[1] = FLOAT_TO_INT(gCCPriv->Current.Color[1]);
- i[2] = FLOAT_TO_INT(gCCPriv->Current.Color[2]);
- i[3] = FLOAT_TO_INT(gCCPriv->Current.Color[3]);
- break;
- case GL_CURRENT_NORMAL:
- i[0] = FLOAT_TO_INT(gCCPriv->Current.Normal[0]);
- i[1] = FLOAT_TO_INT(gCCPriv->Current.Normal[1]);
- i[2] = FLOAT_TO_INT(gCCPriv->Current.Normal[2]);
- break;
- case GL_MAX_TEXTURE_SIZE:
- *i = GAMMA_MAX_TEXTURE_SIZE;
- break;
- case GL_MODELVIEW_MATRIX:
- for (loop = 0; loop < 16; loop++)
- i[loop] = FLOAT_TO_INT(gCCPriv->ModelView[loop]);
- break;
- case GL_CURRENT_TEXTURE_COORDS:
- i[0] = FLOAT_TO_INT(gCCPriv->Current.TexCoord[0]);
- i[1] = FLOAT_TO_INT(gCCPriv->Current.TexCoord[1]);
- i[2] = FLOAT_TO_INT(gCCPriv->Current.TexCoord[2]);
- i[3] = FLOAT_TO_INT(gCCPriv->Current.TexCoord[3]);
- break;
- }
-}
-
-void _gamma_GetLightfv(GLenum light, GLenum pname, GLfloat *params)
-{
- DEBUG_GLCMDS(("GetLightfv: %04x %04x %f\n",
- (int)light, (int)pname, *params));
-}
-
-void _gamma_GetLightiv(GLenum light, GLenum pname, GLint *params)
-{
- DEBUG_GLCMDS(("GetLightiv: %04x %04x %d\n",
- (int)light, (int)pname, *params));
-}
-
-void _gamma_GetMapdv(GLenum target, GLenum query, GLdouble *v)
-{
-}
-
-void _gamma_GetMapfv(GLenum target, GLenum query, GLfloat *v)
-{
-}
-
-void _gamma_GetMapiv(GLenum target, GLenum query, GLint *v)
-{
-}
-
-void _gamma_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
-{
-}
-
-void _gamma_GetMaterialiv(GLenum face, GLenum pname, GLint *params)
-{
-}
-
-void _gamma_GetPixelMapfv(GLenum map, GLfloat *values)
-{
-}
-
-void _gamma_GetPixelMapuiv(GLenum map, GLuint *values)
-{
-}
-
-void _gamma_GetPixelMapusv(GLenum map, GLushort *values)
-{
-}
-
-void _gamma_GetPointerv(GLenum pname, void **params)
-{
- DEBUG_GLCMDS(("GetPointerv: %04x\n", (int)pname));
-}
-
-void _gamma_GetPolygonStipple(GLubyte *mask)
-{
-}
-
-const GLubyte *_gamma_GetString(GLenum name)
-{
- static unsigned char vendor[] = "Precision Insight, Inc.";
- static unsigned char renderer[] = "DRI Glint-Gamma 20000605";
- static unsigned char version[] = "1.1";
- static unsigned char ext[] = "";
-
- switch (name) {
- case GL_VENDOR:
- return vendor;
- case GL_RENDERER:
- return renderer;
- case GL_VERSION:
- return version;
- case GL_EXTENSIONS:
- return ext;
- }
-
- return NULL;
-}
-
-void _gamma_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params)
-{
-}
-
-void _gamma_GetTexEnviv(GLenum target, GLenum pname, GLint *params)
-{
-}
-
-void _gamma_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params)
-{
-}
-
-void _gamma_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
-{
-}
-
-void _gamma_GetTexGeniv(GLenum coord, GLenum pname, GLint *params)
-{
-}
-
-void _gamma_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *texels)
-{
-}
-
-void _gamma_GetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params)
-{
-}
-
-void _gamma_GetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
-{
-}
-
-void _gamma_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
-{
-}
-
-void _gamma_GetTexParameteriv(GLenum target, GLenum pname, GLint *params)
-{
-}
-
-void _gamma_Hint(GLenum target, GLenum mode)
-{
- DEBUG_GLCMDS(("Hint: %04x %04x\n", (int)target, (int)mode));
-}
-
-void _gamma_IndexMask(GLuint mask)
-{
- DEBUG_GLCMDS(("Hint: %d\n", (unsigned int)mask));
-}
-
-void _gamma_IndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("IndexPointer: %04x %d\n", (int)type, (int)stride));
-}
-
-void _gamma_Indexd(GLdouble c)
-{
- DEBUG_GLCMDS(("Indexd: %f\n", c));
-}
-
-void _gamma_Indexdv(const GLdouble *c)
-{
- DEBUG_GLCMDS(("Indexdv: %f\n", *c));
-}
-
-void _gamma_Indexf(GLfloat c)
-{
- DEBUG_GLCMDS(("Indexf: %f\n", c));
-}
-
-void _gamma_Indexfv(const GLfloat *c)
-{
- DEBUG_GLCMDS(("Indexdv: %f\n", *c));
-}
-
-void _gamma_Indexi(GLint c)
-{
- DEBUG_GLCMDS(("Indexi: %d\n", (int)c));
-}
-
-void _gamma_Indexiv(const GLint *c)
-{
- DEBUG_GLCMDS(("Indexiv: %d\n", (int)*c));
-}
-
-void _gamma_Indexs(GLshort c)
-{
- DEBUG_GLCMDS(("Indexs: %d\n", c));
-}
-
-void _gamma_Indexsv(const GLshort *c)
-{
- DEBUG_GLCMDS(("Indexsv: %d\n", *c));
-}
-
-void _gamma_Indexub(GLubyte c)
-{
- DEBUG_GLCMDS(("Indexub: %d\n", c));
-}
-
-void _gamma_Indexubv(const GLubyte *c)
-{
- DEBUG_GLCMDS(("Indexubv: %d\n", *c));
-}
-
-void _gamma_InitNames(void)
-{
- DEBUG_GLCMDS(("InitNames\n"));
-}
-
-void _gamma_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("InterleavedArrays: %04x %d\n", (int)format, (int)stride));
-}
-
-GLboolean _gamma_IsEnabled(GLenum cap)
-{
- DEBUG_GLCMDS(("IsEnabled: %04x\n", (int)cap));
-
- switch (cap) {
- case GL_LIGHTING:
- return ((gCCPriv->LightingMode & LightingModeEnable)?GL_TRUE:GL_FALSE);
- break;
- }
-
- return GL_TRUE;
-}
-
-#if 0 /* Now in dlist.c */
-GLboolean _gamma_IsList(GLuint list)
-{
- DEBUG_GLCMDS(("IsList: %04x\n", (unsigned int)list));
-
- return GL_TRUE;
-}
-#endif
-
-GLboolean _gamma_IsTexture(GLuint texture)
-{
- DEBUG_GLCMDS(("IsTexture: %04x\n", (unsigned int)texture));
-
- return GL_TRUE;
-}
-
-void _gamma_LightModelf(GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("LightModelf: %04x %f\n",
- (int)pname, param));
-}
-
-void _gamma_LightModelfv(GLenum pname, const GLfloat *params)
-{
- DEBUG_GLCMDS(("LightModelfv: %04x %f\n",
- (int)pname, *params));
-
- switch (pname) {
- case GL_LIGHT_MODEL_AMBIENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, SceneAmbientColorBlue, params[2]);
- WRITEF(gCCPriv->buf, SceneAmbientColorGreen, params[1]);
- WRITEF(gCCPriv->buf, SceneAmbientColorRed, params[0]);
- break;
- case GL_LIGHT_MODEL_LOCAL_VIEWER:
- if (params[0] != 0.0)
- gCCPriv->LightingMode |= LightingModeLocalViewer;
- else
- gCCPriv->LightingMode &= ~LightingModeLocalViewer;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode);
- break;
- case GL_LIGHT_MODEL_TWO_SIDE:
- if (params[0] == 1.0f) {
- gCCPriv->LightingMode |= LightingModeTwoSides;
- gCCPriv->MaterialMode |= MaterialModeTwoSides;
- } else {
- gCCPriv->LightingMode &= ~LightingModeTwoSides;
- gCCPriv->MaterialMode &= ~MaterialModeTwoSides;
- }
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode);
- WRITE(gCCPriv->buf, MaterialMode, gCCPriv->MaterialMode);
- break;
- }
-}
-
-void _gamma_LightModeli(GLenum pname, GLint param)
-{
-}
-
-void _gamma_LightModeliv(GLenum pname, const GLint *params)
-{
-}
-
-void _gamma_Lightf(GLenum light, GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("Lightf: %04x %04x %f\n",
- (int)light, (int)pname, param));
-}
-
-void _gamma_Lightfv(GLenum light, GLenum pname, const GLfloat *params)
-{
- GLfloat l,x,y,z,w;
- DEBUG_GLCMDS(("Lightfv: %04x %04x %f\n",
- (int)light, (int)pname, *params));
-
- switch(light) {
- case GL_LIGHT0:
- switch (pname) {
- case GL_AMBIENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light0AmbientIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light0AmbientIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light0AmbientIntensityRed, params[0]);
- break;
- case GL_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light0DiffuseIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light0DiffuseIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light0DiffuseIntensityRed, params[0]);
- break;
- case GL_SPECULAR:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light0SpecularIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light0SpecularIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light0SpecularIntensityRed, params[0]);
- break;
- case GL_POSITION:
- /* Normalize <x,y,z> */
- x = params[0]; y = params[1]; z = params[2]; w = params[3];
- l = sqrt(x*x + y*y + z*z + w*w);
- w /= l;
- x /= l;
- y /= l;
- z /= l;
- if (params[3] != 0.0) {
- gCCPriv->Light0Mode |= Light0ModeAttenuation;
- gCCPriv->Light0Mode |= Light0ModeLocal;
- } else {
- gCCPriv->Light0Mode &= ~Light0ModeAttenuation;
- gCCPriv->Light0Mode &= ~Light0ModeLocal;
- }
- CHECK_DMA_BUFFER(gCC, gCCPriv, 5);
- WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode);
- WRITEF(gCCPriv->buf, Light0PositionW, w);
- WRITEF(gCCPriv->buf, Light0PositionZ, z);
- WRITEF(gCCPriv->buf, Light0PositionY, y);
- WRITEF(gCCPriv->buf, Light0PositionX, x);
- break;
- case GL_SPOT_DIRECTION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* WRITEF(gCCPriv->buf, Light0SpotlightDirectionW, params[3]); */
- WRITEF(gCCPriv->buf, Light0SpotlightDirectionZ, params[2]);
- WRITEF(gCCPriv->buf, Light0SpotlightDirectionY, params[1]);
- WRITEF(gCCPriv->buf, Light0SpotlightDirectionX, params[0]);
- break;
- case GL_SPOT_EXPONENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light0SpotlightExponent, params[0]);
- break;
- case GL_SPOT_CUTOFF:
- if (params[0] != 180.0)
- gCCPriv->Light0Mode |= Light0ModeSpotLight;
- else
- gCCPriv->Light0Mode &= ~Light0ModeSpotLight;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode);
- WRITEF(gCCPriv->buf, Light0CosSpotlightCutoffAngle, cos(params[0]*DEG2RAD));
- break;
- case GL_CONSTANT_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light0ConstantAttenuation, params[0]);
- break;
- case GL_LINEAR_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light0LinearAttenuation, params[0]);
- break;
- case GL_QUADRATIC_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light0QuadraticAttenuation, params[0]);
- break;
- }
- break;
- case GL_LIGHT1:
- switch (pname) {
- case GL_AMBIENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light1AmbientIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light1AmbientIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light1AmbientIntensityRed, params[0]);
- break;
- case GL_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light1DiffuseIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light1DiffuseIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light1DiffuseIntensityRed, params[0]);
- break;
- case GL_SPECULAR:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* We don't do alpha */
- WRITEF(gCCPriv->buf, Light1SpecularIntensityBlue, params[2]);
- WRITEF(gCCPriv->buf, Light1SpecularIntensityGreen, params[1]);
- WRITEF(gCCPriv->buf, Light1SpecularIntensityRed, params[0]);
- break;
- case GL_POSITION:
- /* Normalize <x,y,z> */
- x = params[0]; y = params[1]; z = params[2];
- l = sqrt(x*x + y*y + z*z);
- x /= l;
- y /= l;
- z /= l;
- if (params[3] != 0.0) {
- gCCPriv->Light1Mode |= Light1ModeAttenuation;
- gCCPriv->Light1Mode |= Light1ModeLocal;
- } else {
- gCCPriv->Light0Mode &= ~Light0ModeAttenuation;
- gCCPriv->Light0Mode &= ~Light0ModeLocal;
- }
- CHECK_DMA_BUFFER(gCC, gCCPriv, 5);
- WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode);
- WRITEF(gCCPriv->buf, Light1PositionW, params[3]);
- WRITEF(gCCPriv->buf, Light1PositionZ, z);
- WRITEF(gCCPriv->buf, Light1PositionY, y);
- WRITEF(gCCPriv->buf, Light1PositionX, x);
- break;
- case GL_SPOT_DIRECTION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- /* WRITEF(gCCPriv->buf, Light1SpotlightDirectionW, params[3]); */
- WRITEF(gCCPriv->buf, Light1SpotlightDirectionZ, params[2]);
- WRITEF(gCCPriv->buf, Light1SpotlightDirectionY, params[1]);
- WRITEF(gCCPriv->buf, Light1SpotlightDirectionX, params[0]);
- break;
- case GL_SPOT_EXPONENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light1SpotlightExponent, params[0]);
- break;
- case GL_SPOT_CUTOFF:
- if (params[0] != 180.0)
- gCCPriv->Light1Mode |= Light1ModeSpotLight;
- else
- gCCPriv->Light1Mode &= ~Light1ModeSpotLight;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode);
- WRITEF(gCCPriv->buf, Light1CosSpotlightCutoffAngle, cos(params[0]*DEG2RAD));
- break;
- case GL_CONSTANT_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light1ConstantAttenuation, params[0]);
- break;
- case GL_LINEAR_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light1LinearAttenuation, params[0]);
- break;
- case GL_QUADRATIC_ATTENUATION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, Light1QuadraticAttenuation, params[0]);
- break;
- }
- }
-}
-
-void _gamma_Lighti(GLenum light, GLenum pname, GLint param)
-{
-}
-
-void _gamma_Lightiv(GLenum light, GLenum pname, const GLint *params)
-{
-}
-
-void _gamma_LineStipple(GLint factor, GLushort pattern)
-{
- DEBUG_GLCMDS(("LineStipple: %d %d\n", (int)factor, pattern));
-}
-
-void _gamma_LineWidth(GLfloat width)
-{
- DEBUG_GLCMDS(("LineWidth: %f\n", width));
-}
-
-#if 0 /* Now in dlist.c */
-void _gamma_ListBase(GLuint base)
-{
- DEBUG_GLCMDS(("ListBase: %d\n", (unsigned int)base));
-}
-#endif
-
-void _gamma_LoadIdentity(void)
-{
- DEBUG_GLCMDS(("LoadIdentity: %04x\n", gCCPriv->MatrixMode));
-
- gammaSetMatrix(IdentityMatrix);
- gammaLoadHWMatrix();
-}
-
-void _gamma_LoadMatrixd(const GLdouble *m)
-{
- GLfloat f[16];
- int i;
-
- DEBUG_GLCMDS(("LoadMatrixd: %04x\n", gCCPriv->MatrixMode));
-
- for (i = 0; i < 16; i++) f[i] = m[i];
- gammaSetMatrix(f);
- gammaLoadHWMatrix();
-}
-
-void _gamma_LoadMatrixf(const GLfloat *m)
-{
- DEBUG_GLCMDS(("LoadMatrixf: %04x\n", gCCPriv->MatrixMode));
-
- gammaSetMatrix((GLfloat *)m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_LoadName(GLuint name)
-{
- DEBUG_GLCMDS(("LoadName: %d\n", (unsigned int)name));
-}
-
-void _gamma_LogicOp(GLenum opcode)
-{
- DEBUG_GLCMDS(("LogicOp: %04x\n", (int)opcode));
-
- gCCPriv->LogicalOpMode &= ~LogicalOpModeMask;
-
- gCCPriv->LogicalOpMode |= (opcode & 0x0f) << 1;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, LogicalOpMode, gCCPriv->LogicalOpMode);
-}
-
-void _gamma_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *pnts)
-{
- DEBUG_GLCMDS(("Map1d: %04x %f %f %d %d\n", (int)target, u1, u2,
- (int)stride, (int)order));
-}
-
-void _gamma_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *pnts)
-{
- DEBUG_GLCMDS(("Map1f: %04x %f %f %d %d\n", (int)target, u1, u2,
- (int)stride, (int)order));
-}
-
-void _gamma_Map2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord, GLdouble v1, GLdouble v2, GLint vstr, GLint vord, const GLdouble *pnts)
-{
- DEBUG_GLCMDS(("Map2d: %04x %f %f %d %d %f %f %d %d\n",
- (int)target,
- u1, u2, (int)ustr, (int)uord,
- v1, v2, (int)vstr, (int)vord));
-}
-
-void _gamma_Map2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord, const GLfloat *pnts)
-{
- DEBUG_GLCMDS(("Map2f: %04x %f %f %d %d %f %f %d %d\n",
- (int)target,
- u1, u2, (int)ustr, (int)uord,
- v1, v2, (int)vstr, (int)vord));
-}
-
-void _gamma_MapGrid1d(GLint un, GLdouble u1, GLdouble u2)
-{
- DEBUG_GLCMDS(("MapGrid1d: %d %f %f\n", (int)un, u1, u2));
-}
-
-void _gamma_MapGrid1f(GLint un, GLfloat u1, GLfloat u2)
-{
- DEBUG_GLCMDS(("MapGrid1f: %d %f %f\n", (int)un, u1, u2));
-}
-
-void _gamma_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
-{
- DEBUG_GLCMDS(("MapGrid2d: %d %f %f %d %f %f\n",
- (int)un, u1, u2,
- (int)vn, v1, v2));
-}
-
-void _gamma_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
-{
- DEBUG_GLCMDS(("MapGrid2f: %d %f %f %d %f %f\n",
- (int)un, u1, u2,
- (int)vn, v1, v2));
-}
-
-void _gamma_Materialf(GLenum face, GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("Materialf: %04x %04x %f\n", (int)face, (int)pname, param));
-
- _gamma_Materialfv(face, pname, &param);
-}
-
-void _gamma_Materialfv(GLenum face, GLenum pname, const GLfloat *params)
-{
- DEBUG_GLCMDS(("Materialfv: %04x %04x %f\n",
- (int)face, (int)pname, *params));
-
- gCCPriv->MaterialMode |= MaterialModeEnable;
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, MaterialMode, gCCPriv->MaterialMode);
-
- if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) {
- switch (pname) {
- case GL_AMBIENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, FrontAmbientColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontAmbientColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontAmbientColorRed, params[0]);
- break;
- case GL_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, FrontAlpha, params[3]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorRed, params[0]);
- break;
- case GL_SPECULAR:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, FrontSpecularColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontSpecularColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontSpecularColorRed, params[0]);
- break;
- case GL_EMISSION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, FrontEmissiveColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontEmissiveColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontEmissiveColorRed, params[0]);
- break;
- case GL_SHININESS:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, FrontSpecularExponent, params[0]);
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 7);
- WRITEF(gCCPriv->buf, FrontAmbientColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontAmbientColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontAmbientColorRed, params[0]);
- WRITEF(gCCPriv->buf, FrontAlpha, params[3]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorBlue, params[2]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorGreen, params[1]);
- WRITEF(gCCPriv->buf, FrontDiffuseColorRed, params[0]);
- break;
- case GL_COLOR_INDEXES:
- /* NOT_DONE */
- break;
- }
- }
-
- if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) {
- switch (pname) {
- case GL_AMBIENT:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, BackAmbientColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackAmbientColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackAmbientColorRed, params[0]);
- break;
- case GL_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, BackAlpha, params[3]);
- WRITEF(gCCPriv->buf, BackDiffuseColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackDiffuseColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackDiffuseColorRed, params[0]);
- break;
- case GL_SPECULAR:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, BackSpecularColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackSpecularColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackSpecularColorRed, params[0]);
- break;
- case GL_EMISSION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, BackEmissiveColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackEmissiveColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackEmissiveColorRed, params[0]);
- break;
- case GL_SHININESS:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITEF(gCCPriv->buf, BackSpecularExponent, params[0]);
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 7);
- WRITEF(gCCPriv->buf, BackAmbientColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackAmbientColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackAmbientColorRed, params[0]);
- WRITEF(gCCPriv->buf, BackAlpha, params[3]);
- WRITEF(gCCPriv->buf, BackDiffuseColorBlue, params[2]);
- WRITEF(gCCPriv->buf, BackDiffuseColorGreen, params[1]);
- WRITEF(gCCPriv->buf, BackDiffuseColorRed, params[0]);
- break;
- case GL_COLOR_INDEXES:
- /* NOT_DONE */
- break;
- }
- }
-}
-
-void _gamma_Materiali(GLenum face, GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("Materiali: %04x %04x %d\n",
- (int)face, (int)pname, (int)param));
-}
-
-void _gamma_Materialiv(GLenum face, GLenum pname, const GLint *params)
-{
- DEBUG_GLCMDS(("Materialiv: %04x %04x %d\n",
- (int)face, (int)pname, (int)*params));
-}
-
-void _gamma_MatrixMode(GLenum mode)
-{
- DEBUG_GLCMDS(("MatrixMode: %04x\n", (int)mode));
-
- switch (mode) {
- case GL_TEXTURE:
- /* Enable the Texture transform */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, TransformModeOr, XM_XformTexture);
- case GL_MODELVIEW:
- case GL_PROJECTION:
- gCCPriv->MatrixMode = mode;
- break;
- default:
- /* ERROR!!! */
- break;
- }
-}
-
-void _gamma_MultMatrixd(const GLdouble *m)
-{
- GLfloat f[16];
- int i;
-
- DEBUG_GLCMDS(("MatrixMultd\n"));
-
- for (i = 0; i < 16; i++) f[i] = m[i];
- gammaMultMatrix(f);
- gammaLoadHWMatrix();
-}
-
-void _gamma_MultMatrixf(const GLfloat *m)
-{
- DEBUG_GLCMDS(("MatrixMultf\n"));
-
- gammaMultMatrix((GLfloat *)m);
- gammaLoadHWMatrix();
-}
-
-#if 0 /* Now in dlist.c */
-void _gamma_NewList(GLuint list, GLenum mode)
-{
- DEBUG_GLCMDS(("NewList: %d %04x\n", (unsigned int)list, (int)mode));
-}
-#endif
-
-void _gamma_Normal3b(GLbyte nx, GLbyte ny, GLbyte nz)
-{
- DEBUG_GLCMDS(("Normal3b: %d %d %d\n", nx, ny, nz));
-
- _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
-}
-
-void _gamma_Normal3bv(const GLbyte *v)
-{
- DEBUG_GLCMDS(("Normal3bv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Normal3d(GLdouble nx, GLdouble ny, GLdouble nz)
-{
- DEBUG_GLCMDS(("Normal3d: %f %f %f\n", nx, ny, nz));
-
- _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
-}
-
-void _gamma_Normal3dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Normal3dv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Normal3f(GLfloat nx, GLfloat ny, GLfloat nz)
-{
- DEBUG_GLCMDS(("Normal3f: %f %f %f\n", nx, ny, nz));
-
- gCCPriv->Current.Normal[0] = nx;
- gCCPriv->Current.Normal[1] = ny;
- gCCPriv->Current.Normal[2] = nz;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, Nz, nz);
- WRITEF(gCCPriv->buf, Ny, ny);
- WRITEF(gCCPriv->buf, Nx, nx);
-}
-
-void _gamma_Normal3fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Normal3fv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Normal3i(GLint nx, GLint ny, GLint nz)
-{
- DEBUG_GLCMDS(("Normal3i: %d %d %d\n", (int)nx, (int)ny, (int)nz));
-
- _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
-}
-
-void _gamma_Normal3iv(const GLint *v)
-{
- DEBUG_GLCMDS(("Normal3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
-
- _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Normal3s(GLshort nx, GLshort ny, GLshort nz)
-{
- DEBUG_GLCMDS(("Normal3s: %d %d %d\n", nx, ny, nz));
-
- _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz);
-}
-
-void _gamma_Normal3sv(const GLshort *v)
-{
- DEBUG_GLCMDS(("Normal3sv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("NormalPointer: %04x %d\n", (int)type, (int)stride));
-
- if (stride<0) {
- gamma_error( GL_INVALID_VALUE, "glNormalPointer(stride)" );
- return;
- }
- switch (type) {
- case GL_BYTE:
- gCCPriv->Array.NormalStrideB = stride ? stride : 3*sizeof(GLbyte);
- break;
- case GL_SHORT:
- gCCPriv->Array.NormalStrideB = stride ? stride : 3*sizeof(GLshort);
- break;
- case GL_INT:
- gCCPriv->Array.NormalStrideB = stride ? stride : 3*sizeof(GLint);
- break;
- case GL_FLOAT:
- gCCPriv->Array.NormalStrideB = stride ? stride : 3*sizeof(GLfloat);
- break;
- case GL_DOUBLE:
- gCCPriv->Array.NormalStrideB = stride ? stride : 3*sizeof(GLdouble);
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glNormalPointer(type)" );
- return;
- }
- gCCPriv->Array.NormalType = type;
- gCCPriv->Array.NormalStride = stride;
- gCCPriv->Array.NormalPtr = (void *) pointer;
-}
-
-void _gamma_Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
-{
-#define ORTHO_X() ((GLfloat)( 2.0/(right-left)))
-#define ORTHO_Y() ((GLfloat)( 2.0/(top-bottom)))
-#define ORTHO_Z() ((GLfloat)(-2.0/(zFar-zNear)))
-
-#define ORTHO_TX() ((GLfloat)(-((right+left)/(right-left))))
-#define ORTHO_TY() ((GLfloat)(-((top+bottom)/(top-bottom))))
-#define ORTHO_TZ() ((GLfloat)(-((zFar+zNear)/(zFar-zNear))))
-
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("Ortho: %f %f %f %f %f %f\n",
- left, right, bottom, top, zNear, zFar));
-
- for (i = 0; i < 16; i++) m[i] = 0.0;
-
- m[0] = ORTHO_X();
- m[5] = ORTHO_Y();
- m[10] = ORTHO_Z();
- m[12] = ORTHO_TX();
- m[13] = ORTHO_TY();
- m[14] = ORTHO_TZ();
- m[15] = 1.0;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_PassThrough(GLfloat token)
-{
- DEBUG_GLCMDS(("PassThrough: %f\n", token));
-}
-
-void _gamma_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values)
-{
- DEBUG_GLCMDS(("PixelMapfv: %04x %d\n", (int)map, (int)mapsize));
-}
-
-void _gamma_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values)
-{
- DEBUG_GLCMDS(("PixelMapiv: %04x %d\n", (int)map, (int)mapsize));
-}
-
-void _gamma_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
-{
- DEBUG_GLCMDS(("PixelMapusv: %04x %d\n", (int)map, (int)mapsize));
-}
-
-void _gamma_PixelStoref(GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("PixelStoref: %04x %f\n", (int)pname, param));
-}
-
-void _gamma_PixelStorei(GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("PixelStorei: %04x %d\n", (int)pname, (int)param));
-}
-
-void _gamma_PixelTransferf(GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("PixelTransferf: %04x %f\n", (int)pname, param));
-}
-
-void _gamma_PixelTransferi(GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("PixelTransferi: %04x %d\n", (int)pname, (int)param));
-}
-
-void _gamma_PixelZoom(GLfloat xfactor, GLfloat yfactor)
-{
- DEBUG_GLCMDS(("PixelZoom: %f %f\n", xfactor, yfactor));
-}
-
-void _gamma_PointSize(GLfloat size)
-{
- unsigned char s = size;
-
- DEBUG_GLCMDS(("PointSize: %f\n", size));
-
- /* NOT_DONE: Needs to handle AAPoints also */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, PointSize, s);
-}
-
-void _gamma_PolygonMode(GLenum face, GLenum mode)
-{
- DEBUG_GLCMDS(("PolygonMode: %04x %04x\n", (int)face, (int)mode));
-
- gCCPriv->GeometryMode &= ~GM_FB_PolyMask;
-
- switch (mode) {
- case GL_FILL:
- switch (face) {
- case GL_FRONT:
- gCCPriv->GeometryMode |= GM_FrontPolyFill;
- break;
- case GL_BACK:
- gCCPriv->GeometryMode |= GM_BackPolyFill;
- break;
- case GL_FRONT_AND_BACK:
- gCCPriv->GeometryMode |= GM_FrontPolyFill;
- gCCPriv->GeometryMode |= GM_BackPolyFill;
- break;
- }
- break;
- case GL_LINE:
- switch (face) {
- case GL_FRONT:
- gCCPriv->GeometryMode |= GM_FrontPolyLine;
- break;
- case GL_BACK:
- gCCPriv->GeometryMode |= GM_BackPolyLine;
- break;
- case GL_FRONT_AND_BACK:
- gCCPriv->GeometryMode |= GM_FrontPolyLine;
- gCCPriv->GeometryMode |= GM_BackPolyLine;
- break;
- }
- break;
- case GL_POINT:
- switch (face) {
- case GL_FRONT:
- gCCPriv->GeometryMode |= GM_FrontPolyPoint;
- break;
- case GL_BACK:
- gCCPriv->GeometryMode |= GM_BackPolyPoint;
- break;
- case GL_FRONT_AND_BACK:
- gCCPriv->GeometryMode |= GM_FrontPolyPoint;
- gCCPriv->GeometryMode |= GM_BackPolyPoint;
- break;
- }
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
-}
-
-void _gamma_PolygonOffset(GLfloat factor, GLfloat units)
-{
- DEBUG_GLCMDS(("PolygonOffset: %f %f\n", factor, units));
-}
-
-void _gamma_PolygonStipple(const GLubyte *mask)
-{
- DEBUG_GLCMDS(("PolygonStipple: \n"));
-}
-
-void _gamma_PopAttrib(void)
-{
- DEBUG_GLCMDS(("PopAttrib\n"));
-}
-
-void _gamma_PopClientAttrib(void)
-{
- DEBUG_GLCMDS(("PopClientAttrib\n"));
-}
-
-void _gamma_PopMatrix(void)
-{
- DEBUG_GLCMDS(("PopMatrix: %04x\n", gCCPriv->MatrixMode));
-
- switch (gCCPriv->MatrixMode) {
- case GL_TEXTURE:
- if (gCCPriv->TextureCount == 0) {
- /* ERROR!!! */
- } else {
- gCCPriv->TextureCount--;
- memcpy(gCCPriv->Texture,
- &gCCPriv->TextureStack[gCCPriv->TextureCount*16],
- 16*sizeof(*gCCPriv->Texture));
- gammaLoadHWMatrix();
- }
- break;
- case GL_MODELVIEW:
- if (gCCPriv->ModelViewCount == 0) {
- /* ERROR!!! */
- } else {
- gCCPriv->ModelViewCount--;
- memcpy(gCCPriv->ModelView,
- &gCCPriv->ModelViewStack[gCCPriv->ModelViewCount*16],
- 16*sizeof(*gCCPriv->ModelView));
- gammaLoadHWMatrix();
- }
- break;
- case GL_PROJECTION:
- if (gCCPriv->ProjCount == 0) {
- /* ERROR!!! */
- } else {
- gCCPriv->ProjCount--;
- memcpy(gCCPriv->Proj,
- &gCCPriv->ProjStack[gCCPriv->ProjCount*16],
- 16*sizeof(*gCCPriv->Proj));
- gammaLoadHWMatrix();
- }
- break;
- default:
- /* ERROR!!! */
- break;
- }
-}
-
-void _gamma_PopName(void)
-{
- DEBUG_GLCMDS(("PopName\n"));
-}
-
-void _gamma_PrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities)
-{
- DEBUG_GLCMDS(("PrioritizeTextures: %d\n", (int)n));
-}
-
-void _gamma_PushAttrib(GLbitfield mask)
-{
- DEBUG_GLCMDS(("PushAttrib: %04x\n", (int)mask));
-}
-
-void _gamma_PushClientAttrib(GLuint mask)
-{
- DEBUG_GLCMDS(("PushClientAttrib: %04x\n", (unsigned int)mask));
-}
-
-void _gamma_PushMatrix(void)
-{
- DEBUG_GLCMDS(("PushMatrix: %04x\n", gCCPriv->MatrixMode));
-
- switch (gCCPriv->MatrixMode) {
- case GL_TEXTURE:
- if (gCCPriv->TextureCount >= MAX_TEXTURE_STACK-1) {
- /* ERROR!!! */
- } else {
- memcpy(&gCCPriv->TextureStack[gCCPriv->TextureCount*16],
- gCCPriv->Texture,
- 16*sizeof(*gCCPriv->Texture));
- gCCPriv->TextureCount++;
- }
- break;
- case GL_MODELVIEW:
- if (gCCPriv->ModelViewCount >= MAX_MODELVIEW_STACK-1) {
- /* ERROR!!! */
- } else {
- memcpy(&gCCPriv->ModelViewStack[gCCPriv->ModelViewCount*16],
- gCCPriv->ModelView,
- 16*sizeof(*gCCPriv->ModelView));
- gCCPriv->ModelViewCount++;
- }
- break;
- case GL_PROJECTION:
- if (gCCPriv->ProjCount >= MAX_PROJECTION_STACK-1) {
- /* ERROR!!! */
- } else {
- memcpy(&gCCPriv->ProjStack[gCCPriv->ProjCount*16],
- gCCPriv->Proj,
- 16*sizeof(*gCCPriv->Proj));
- gCCPriv->ProjCount++;
- }
- break;
- default:
- /* ERROR!!! */
- break;
- }
-}
-
-void _gamma_PushName(GLuint name)
-{
- DEBUG_GLCMDS(("PushName: %d\n", (int)name));
-}
-
-void _gamma_RasterPos2d(GLdouble x, GLdouble y)
-{
- DEBUG_GLCMDS(("RasterPos2d: %f %f\n", x, y));
-
- _gamma_RasterPos2f((GLfloat)x,(GLfloat)y);
-}
-
-void _gamma_RasterPos2dv(const GLdouble *v)
-{
- _gamma_RasterPos2f((GLfloat)v[0],(GLfloat)v[1]);
-}
-
-void _gamma_RasterPos2f(GLfloat x, GLfloat y)
-{
- DEBUG_GLCMDS(("RasterPos2f: %f %f\n", x, y));
-
- gCCPriv->Current.RasterPos[0] = x;
- gCCPriv->Current.RasterPos[1] = y;
- gCCPriv->Current.RasterPos[2] = 0.0f;
- gCCPriv->Current.RasterPos[3] = 1.0f;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITEF(gCCPriv->buf, RPy, y);
- WRITEF(gCCPriv->buf, RPx2, x);
-}
-
-void _gamma_RasterPos2fv(const GLfloat *v)
-{
- _gamma_RasterPos2f(v[0],v[1]);
-}
-
-void _gamma_RasterPos2i(GLint x, GLint y)
-{
- _gamma_RasterPos2f((GLfloat)x,(GLfloat)y);
-}
-
-void _gamma_RasterPos2iv(const GLint *v)
-{
-}
-
-void _gamma_RasterPos2s(GLshort x, GLshort y)
-{
-}
-
-void _gamma_RasterPos2sv(const GLshort *v)
-{
-}
-
-void _gamma_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
-{
-}
-
-void _gamma_RasterPos3dv(const GLdouble *v)
-{
-}
-
-void _gamma_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
-{
-}
-
-void _gamma_RasterPos3fv(const GLfloat *v)
-{
-}
-
-void _gamma_RasterPos3i(GLint x, GLint y, GLint z)
-{
-}
-
-void _gamma_RasterPos3iv(const GLint *v)
-{
-}
-
-void _gamma_RasterPos3s(GLshort x, GLshort y, GLshort z)
-{
-}
-
-void _gamma_RasterPos3sv(const GLshort *v)
-{
-}
-
-void _gamma_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
-}
-
-void _gamma_RasterPos4dv(const GLdouble *v)
-{
-}
-
-void _gamma_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
-}
-
-void _gamma_RasterPos4fv(const GLfloat *v)
-{
-}
-
-void _gamma_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
-{
-}
-
-void _gamma_RasterPos4iv(const GLint *v)
-{
-}
-
-void _gamma_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
-{
-}
-
-void _gamma_RasterPos4sv(const GLshort *v)
-{
-}
-
-void _gamma_ReadBuffer(GLenum mode)
-{
- DEBUG_GLCMDS(("ReadBuffer: %04x\n", (int)mode));
-}
-
-void _gamma_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
-{
- DEBUG_GLCMDS(("ReadPixels: %d %d %d %d %04x %04x\n", (int)x, (int)y,
- (int)width, (int)height, (int)format, (int)type));
-}
-
-void _gamma_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
-{
- DEBUG_GLCMDS(("Rectd: %f %f %f %f\n", x1, y1, x2, y2));
-}
-
-void _gamma_Rectdv(const GLdouble *v1, const GLdouble *v2)
-{
- DEBUG_GLCMDS(("Rectdv: %f %f %f %f\n", v1[0], v1[1], v2[0], v2[1]));
-}
-
-void _gamma_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
-{
- DEBUG_GLCMDS(("Rectf: %f %f %f %f\n", x1, y1, x2, y2));
-
- /* This should be done with Gamma's Rectangle engine - later */
-
- _gamma_Begin(GL_POLYGON);
- _gamma_Vertex2f(x1,y1);
- _gamma_Vertex2f(x2,y1);
- _gamma_Vertex2f(x2,y2);
- _gamma_Vertex2f(x1,y2);
- _gamma_End();
-}
-
-void _gamma_Rectfv(const GLfloat *v1, const GLfloat *v2)
-{
- DEBUG_GLCMDS(("Rectfv: %f %f %f %f\n", v1[0], v1[1], v2[0], v2[1]));
-}
-
-void _gamma_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
-{
- DEBUG_GLCMDS(("Recti: %d %d %d %d\n", (int)x1, (int)y1, (int)x2, (int)y2));
-}
-
-void _gamma_Rectiv(const GLint *v1, const GLint *v2)
-{
- DEBUG_GLCMDS(("Rectiv: %d %d %d %d\n",
- (int)v1[0], (int)v1[1], (int)v2[0], (int)v2[1]));
-}
-
-void _gamma_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
-{
- DEBUG_GLCMDS(("Rects: %d %d %d %d\n", x1, y1, x2, y2));
-}
-
-void _gamma_Rectsv(const GLshort *v1, const GLshort *v2)
-{
- DEBUG_GLCMDS(("Rectsv: %d %d %d %d\n", v1[0], v1[1], v2[0], v2[1]));
-}
-
-GLint _gamma_RenderMode(GLenum mode)
-{
- DEBUG_GLCMDS(("RenderMode: %04x\n", (int)mode));
-
- return GL_TRUE;
-}
-
-void _gamma_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
-{
- GLfloat m[16];
- GLfloat l, c, s;
-
- DEBUG_GLCMDS(("Rotated: %f %f %f %f\n", angle, x, y, z));
-
- /* Normalize <x,y,z> */
- l = sqrt(x*x + y*y + z*z);
- x /= l;
- y /= l;
- z /= l;
-
- c = cos(angle * M_PI/180.0);
- s = sin(angle * M_PI/180.0);
-
- m[0] = x * x * (1 - c) + c;
- m[1] = y * x * (1 - c) + z * s;
- m[2] = x * z * (1 - c) - y * s;
- m[3] = 0.0;
- m[4] = x * y * (1 - c) - z * s;
- m[5] = y * y * (1 - c) + c;
- m[6] = y * z * (1 - c) + x * s;
- m[7] = 0.0;
- m[8] = x * z * (1 - c) + y * s;
- m[9] = y * z * (1 - c) - x * s;
- m[10] = z * z * (1 - c) + c;
- m[11] = 0.0;
- m[12] = 0.0;
- m[13] = 0.0;
- m[14] = 0.0;
- m[15] = 1.0;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat m[16];
- GLfloat l, c, s;
-
- DEBUG_GLCMDS(("Rotatef: %f %f %f %f\n", angle, x, y, z));
-
- /* Normalize <x,y,z> */
- l = sqrt(x*x + y*y + z*z);
- x /= l;
- y /= l;
- z /= l;
-
- c = cos((double)angle * M_PI/180.0);
- s = sin((double)angle * M_PI/180.0);
-
- m[0] = x * x * (1 - c) + c;
- m[1] = y * x * (1 - c) + z * s;
- m[2] = x * z * (1 - c) - y * s;
- m[3] = 0.0;
- m[4] = x * y * (1 - c) - z * s;
- m[5] = y * y * (1 - c) + c;
- m[6] = y * z * (1 - c) + x * s;
- m[7] = 0.0;
- m[8] = x * z * (1 - c) + y * s;
- m[9] = y * z * (1 - c) - x * s;
- m[10] = z * z * (1 - c) + c;
- m[11] = 0.0;
- m[12] = 0.0;
- m[13] = 0.0;
- m[14] = 0.0;
- m[15] = 1.0;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Scaled(GLdouble x, GLdouble y, GLdouble z)
-{
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("scaled: %f %f %f\n", x, y, z));
-
- for (i = 0; i < 16; i++) m[i] = 0.0;
-
- m[0] = x;
- m[5] = y;
- m[10] = z;
- m[15] = 1.0;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Scalef(GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("scalef: %f %f %f\n", x, y, z));
-
- for (i = 0; i < 16; i++) m[i] = 0.0;
-
- m[0] = x;
- m[5] = y;
- m[10] = z;
- m[15] = 1.0;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Scissor(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- GLint x1, y1, x2, y2;
-
- DEBUG_GLCMDS(("Scissor: %d %d %d %d\n",
- (int)x, (int)y, (int)width, (int)height));
-
- x1 = gCC->driDrawablePriv->x + x;
- y1 = gCC->driScreenPriv->fbHeight -
- (gCC->driDrawablePriv->y +
- gCC->driDrawablePriv->h) + y;
- x2 = x1 + width;
- y2 = y1 + height;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, ScissorMinXY, (y1&0xffff)<<16 | (x1&0xffff));
- WRITE(gCCPriv->buf, ScissorMaxXY, (y2&0xffff)<<16 | (x2&0xffff));
-}
-
-void _gamma_SelectBuffer(GLsizei numnames, GLuint *buffer)
-{
- DEBUG_GLCMDS(("SelectBuffer: %d\n", (int)numnames));
-}
-
-void _gamma_ShadeModel(GLenum mode)
-{
- DEBUG_GLCMDS(("ShadeModel: %04x\n", (int)mode));
-
- gCCPriv->GeometryMode &= ~GM_ShadingMask;
- gCCPriv->ColorDDAMode &= ~ColorDDAShadingMask;
-
- switch (mode) {
- case GL_FLAT:
- gCCPriv->ColorDDAMode |= ColorDDAFlat;
- gCCPriv->GeometryMode |= GM_FlatShading;
- break;
- case GL_SMOOTH:
- gCCPriv->ColorDDAMode |= ColorDDAGouraud;
- gCCPriv->GeometryMode |= GM_GouraudShading;
- break;
- default:
- /* ERROR!!! */
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode);
- WRITE(gCCPriv->buf, ColorDDAMode, gCCPriv->ColorDDAMode);
-}
-
-void _gamma_StencilFunc(GLenum func, GLint ref, GLuint mask)
-{
- DEBUG_GLCMDS(("StencilFunc: %04x %d %d\n",
- (int)func, (int)ref, (unsigned int)mask));
-}
-
-void _gamma_StencilMask(GLuint mask)
-{
- DEBUG_GLCMDS(("StencilMask: %d\n", (unsigned int)mask));
-}
-
-void _gamma_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
-{
- DEBUG_GLCMDS(("StencilOp: %04x %04x %04x\n",
- (int)fail, (int)zfail, (int)zpass));
-}
-
-void _gamma_TexCoord1d(GLdouble s)
-{
- DEBUG_GLCMDS(("TexCoord1d: %f\n", s));
-
- _gamma_TexCoord1f((GLfloat)s);
-}
-
-void _gamma_TexCoord1dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("TexCoord1dv: %f\n", *v));
-
- _gamma_TexCoord1fv((GLfloat*)v);
-}
-
-void _gamma_TexCoord1f(GLfloat s)
-{
- DEBUG_GLCMDS(("TexCoord1f: %f\n", s));
-
- gCCPriv->Current.TexCoord[0] = s;
- gCCPriv->Current.TexCoord[1] = 0.0f;
- gCCPriv->Current.TexCoord[2] = 0.0f;
- gCCPriv->Current.TexCoord[3] = 1.0f;
-
- WRITEF(gCCPriv->buf, Ts1, s);
-}
-
-void _gamma_TexCoord1fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("TexCoord1fv: %f\n", *v));
-
- gCCPriv->Current.TexCoord[0] = v[0];
- gCCPriv->Current.TexCoord[1] = 0.0f;
- gCCPriv->Current.TexCoord[2] = 0.0f;
- gCCPriv->Current.TexCoord[3] = 1.0f;
-
- WRITEF(gCCPriv->buf, Ts1, v[0]);
-}
-
-void _gamma_TexCoord1i(GLint s)
-{
- GLfloat x;
-
- DEBUG_GLCMDS(("TexCoord1i: %d\n", (int)s));
-
- x = INT_TO_FLOAT(s);
-
- _gamma_TexCoord1f(x);
-}
-
-void _gamma_TexCoord1iv(const GLint *v)
-{
- GLfloat p[1];
-
- DEBUG_GLCMDS(("TexCoord1iv: %d\n", (int)*v));
-
- p[0] = INT_TO_FLOAT(v[0]);
-
- _gamma_TexCoord1fv(p);
-}
-
-void _gamma_TexCoord1s(GLshort s)
-{
- GLfloat x;
-
- DEBUG_GLCMDS(("TexCoord1s: %d\n", s));
-
- x = SHORT_TO_FLOAT(s);
-
- _gamma_TexCoord1f(x);
-}
-
-void _gamma_TexCoord1sv(const GLshort *v)
-{
- GLfloat p[1];
-
- DEBUG_GLCMDS(("TexCoord1sv: %d\n", *v));
-
- p[0] = SHORT_TO_FLOAT(v[0]);
-
- _gamma_TexCoord1fv(p);
-}
-
-void _gamma_TexCoord2d(GLdouble s, GLdouble t)
-{
- DEBUG_GLCMDS(("TexCoord2d: %f %f\n", s, t));
-
- _gamma_TexCoord2f((GLfloat)s,(GLfloat)t);
-}
-
-void _gamma_TexCoord2dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("TexCoord2dv: %f %f\n", v[0], v[1]));
-
- _gamma_TexCoord2fv((GLfloat*)v);
-}
-
-void _gamma_TexCoord2f(GLfloat s, GLfloat t)
-{
- DEBUG_GLCMDS(("TexCoord2f: %f %f\n", s, t));
-
- gCCPriv->Current.TexCoord[0] = s;
- gCCPriv->Current.TexCoord[1] = t;
- gCCPriv->Current.TexCoord[2] = 0.0f;
- gCCPriv->Current.TexCoord[3] = 1.0f;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITEF(gCCPriv->buf, Tt2, t);
- WRITEF(gCCPriv->buf, Ts2, s);
-}
-
-void _gamma_TexCoord2fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("TexCoord2fv: %f %f\n", v[0], v[1]));
-
- gCCPriv->Current.TexCoord[0] = v[0];
- gCCPriv->Current.TexCoord[1] = v[1];
- gCCPriv->Current.TexCoord[2] = 0.0f;
- gCCPriv->Current.TexCoord[3] = 1.0f;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITEF(gCCPriv->buf, Tt2, v[1]);
- WRITEF(gCCPriv->buf, Ts2, v[0]);
-}
-
-void _gamma_TexCoord2i(GLint s, GLint t)
-{
- GLfloat x,y;
-
- DEBUG_GLCMDS(("TexCoord2i: %d %d\n", (int)s, (int)t));
-
- x = INT_TO_FLOAT(s);
- y = INT_TO_FLOAT(t);
-
- _gamma_TexCoord2f(x,y);
-}
-
-void _gamma_TexCoord2iv(const GLint *v)
-{
- GLfloat p[2];
-
- DEBUG_GLCMDS(("TexCoord2iv: %d %d\n", (int)v[0], (int)v[1]));
-
- p[0] = INT_TO_FLOAT(v[0]);
- p[1] = INT_TO_FLOAT(v[1]);
-
- _gamma_TexCoord2fv(p);
-}
-
-void _gamma_TexCoord2s(GLshort s, GLshort t)
-{
- GLfloat x,y;
-
- DEBUG_GLCMDS(("TexCoord2s: %d %d\n", s, t));
-
- x = SHORT_TO_FLOAT(s);
- y = SHORT_TO_FLOAT(t);
-
- _gamma_TexCoord2f(x,y);
-}
-
-void _gamma_TexCoord2sv(const GLshort *v)
-{
- GLfloat p[2];
-
- DEBUG_GLCMDS(("TexCoord2sv: %d %d\n", v[0], v[1]));
-
- p[0] = SHORT_TO_FLOAT(v[0]);
- p[1] = SHORT_TO_FLOAT(v[1]);
-
- _gamma_TexCoord2fv(p);
-}
-
-void _gamma_TexCoord3d(GLdouble s, GLdouble t, GLdouble r)
-{
- DEBUG_GLCMDS(("TexCoord3d: %f %f %f\n", s, t, r));
-
- _gamma_TexCoord3f((GLfloat)s,(GLfloat)t,(GLfloat)r);
-}
-
-void _gamma_TexCoord3dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("TexCoord3dv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_TexCoord3fv((GLfloat*)v);
-}
-
-void _gamma_TexCoord3f(GLfloat s, GLfloat t, GLfloat r)
-{
- DEBUG_GLCMDS(("TexCoord3f: %f %f %f\n", s, t, r));
-
- _gamma_TexCoord4f(s,t,r,1.0f);
-}
-
-void _gamma_TexCoord3fv(const GLfloat *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("TexCoord3fv: %f %f %f\n", v[0], v[1], v[2]));
-
- p[0] = v[0];
- p[1] = v[1];
- p[2] = v[2];
- p[3] = 1.0f;
-
- _gamma_TexCoord4fv(p);
-}
-
-void _gamma_TexCoord3i(GLint s, GLint t, GLint r)
-{
- GLfloat x,y,z;
-
- DEBUG_GLCMDS(("TexCoord3i: %d %d %d\n", (int)s, (int)t, (int)r));
-
- x = INT_TO_FLOAT(s);
- y = INT_TO_FLOAT(t);
- z = INT_TO_FLOAT(r);
-
- _gamma_TexCoord4f(x,y,z,1.0f);
-}
-
-void _gamma_TexCoord3iv(const GLint *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("TexCoord3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
-
- p[0] = INT_TO_FLOAT(v[0]);
- p[1] = INT_TO_FLOAT(v[1]);
- p[2] = INT_TO_FLOAT(v[2]);
- p[3] = 1.0f;
-
- _gamma_TexCoord4fv(p);
-}
-
-void _gamma_TexCoord3s(GLshort s, GLshort t, GLshort r)
-{
- GLfloat x,y,z;
-
- DEBUG_GLCMDS(("TexCoord3s: %d %d %d\n", s, t, r));
-
- x = SHORT_TO_FLOAT(s);
- y = SHORT_TO_FLOAT(t);
- z = SHORT_TO_FLOAT(r);
-
- _gamma_TexCoord4f(x,y,z,1.0f);
-}
-
-void _gamma_TexCoord3sv(const GLshort *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("TexCoord3sv: %d %d %d\n", v[0], v[1], v[2]));
-
- p[0] = SHORT_TO_FLOAT(v[0]);
- p[1] = SHORT_TO_FLOAT(v[1]);
- p[2] = SHORT_TO_FLOAT(v[2]);
- p[3] = 1.0f;
-
- _gamma_TexCoord4fv(p);
-}
-
-void _gamma_TexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)
-{
- DEBUG_GLCMDS(("TexCoord4d: %f %f %f %f\n", s, t, r, q));
-
- _gamma_TexCoord4f((GLfloat)s,(GLfloat)t,(GLfloat)r,(GLfloat)q);
-}
-
-void _gamma_TexCoord4dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("TexCoord4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- _gamma_TexCoord4fv((GLfloat*)v);
-}
-
-void _gamma_TexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
-{
- DEBUG_GLCMDS(("TexCoord4f: %f %f %f %f\n", s, t, r, q));
-
- gCCPriv->Current.TexCoord[0] = s;
- gCCPriv->Current.TexCoord[1] = t;
- gCCPriv->Current.TexCoord[2] = t;
- gCCPriv->Current.TexCoord[3] = q;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, Tq4, q);
- WRITEF(gCCPriv->buf, Tr4, r);
- WRITEF(gCCPriv->buf, Tt4, t);
- WRITEF(gCCPriv->buf, Ts4, s);
-}
-
-void _gamma_TexCoord4fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("TexCoord4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- gCCPriv->Current.TexCoord[0] = v[0];
- gCCPriv->Current.TexCoord[1] = v[1];
- gCCPriv->Current.TexCoord[2] = v[2];
- gCCPriv->Current.TexCoord[3] = v[3];
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, Tq4, v[3]);
- WRITEF(gCCPriv->buf, Tr4, v[2]);
- WRITEF(gCCPriv->buf, Tt4, v[1]);
- WRITEF(gCCPriv->buf, Ts4, v[0]);
-}
-
-void _gamma_TexCoord4i(GLint s, GLint t, GLint r, GLint q)
-{
- GLfloat x,y,z,a;
-
- DEBUG_GLCMDS(("TexCoord4i: %d %d %d %d\n", (int)s, (int)t, (int)r, (int)q));
-
- x = INT_TO_FLOAT(s);
- y = INT_TO_FLOAT(t);
- z = INT_TO_FLOAT(r);
- a = INT_TO_FLOAT(q);
-
- _gamma_TexCoord4f(x,y,z,a);
-}
-
-void _gamma_TexCoord4iv(const GLint *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("TexCoord4iv: %d %d %d %d\n",
- (int)v[0], (int)v[1], (int)v[2], (int)v[3]));
-
- p[0] = INT_TO_FLOAT(v[0]);
- p[1] = INT_TO_FLOAT(v[1]);
- p[2] = INT_TO_FLOAT(v[2]);
- p[3] = INT_TO_FLOAT(v[3]);
-
- _gamma_TexCoord4fv(p);
-}
-
-void _gamma_TexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)
-{
- GLfloat x,y,z,a;
-
- DEBUG_GLCMDS(("TexCoord4s: %d %d %d %d\n", s, t, r, q));
-
- x = SHORT_TO_FLOAT(s);
- y = SHORT_TO_FLOAT(t);
- z = SHORT_TO_FLOAT(r);
- a = SHORT_TO_FLOAT(q);
-
- _gamma_TexCoord4f(s,t,r,q);
-}
-
-void _gamma_TexCoord4sv(const GLshort *v)
-{
- GLfloat p[4];
-
- DEBUG_GLCMDS(("TexCoord4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- p[0] = SHORT_TO_FLOAT(v[0]);
- p[1] = SHORT_TO_FLOAT(v[1]);
- p[2] = SHORT_TO_FLOAT(v[2]);
- p[3] = SHORT_TO_FLOAT(v[3]);
-
- _gamma_TexCoord4fv(p);
-}
-
-void _gamma_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("TexCoordPointer: %d %04x %d\n",
- (int)size, (int)type, (int)stride));
-
- if (size<1 || size>4) {
- gamma_error( GL_INVALID_VALUE, "glTexCoordPointer(size)" );
- return;
- }
- if (stride<0) {
- gamma_error( GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
- return;
- }
- switch (type) {
- case GL_SHORT:
- gCCPriv->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLshort);
- break;
- case GL_INT:
- gCCPriv->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLint);
- break;
- case GL_FLOAT:
- gCCPriv->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLfloat);
- break;
- case GL_DOUBLE:
- gCCPriv->Array.TexCoordStrideB = stride ? stride : size*sizeof(GLdouble);
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glTexCoordPointer(type)" );
- return;
- }
- gCCPriv->Array.TexCoordSize = size;
- gCCPriv->Array.TexCoordType = type;
- gCCPriv->Array.TexCoordStride = stride;
- gCCPriv->Array.TexCoordPtr = (void *) pointer;
-}
-
-void _gamma_TexEnvf(GLenum target, GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("TexEnvf: %04x %04x %f\n", (int)target, (int)pname, param));
-
- if (target != GL_TEXTURE_ENV || pname != GL_TEXTURE_ENV_MODE) {
- /* ERROR !! */
- }
-
- gCCPriv->curTexObj->TextureColorMode &= ~TCM_ApplicationMask;
-
- switch ((int)param) {
- case GL_MODULATE:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Modulate;
- break;
- case GL_DECAL:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Decal;
- break;
- case GL_BLEND:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Blend;
- break;
- case GL_REPLACE:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Replace;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj->TextureColorMode);
-}
-
-void _gamma_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
-{
- DEBUG_GLCMDS(("TexEnvfv: %04x %04x %f\n",
- (int)target, (int)pname, *params));
-
- if (target != GL_TEXTURE_ENV) {
- /* ERROR !! */
- }
-
- switch (pname) {
- case GL_TEXTURE_ENV_MODE:
- gCCPriv->curTexObj->TextureColorMode &= ~TCM_ApplicationMask;
- switch ((int)params[0]) {
- case GL_MODULATE:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Modulate;
- break;
- case GL_DECAL:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Decal;
- break;
- case GL_BLEND:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Blend;
- break;
- case GL_REPLACE:
- gCCPriv->curTexObj->TextureColorMode |= TCM_Replace;
- break;
- }
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj->TextureColorMode);
-}
-
-void _gamma_TexEnvi(GLenum target, GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("TexEnvi: %04x %04x %d\n",
- (int)target, (int)pname, (int)param));
-}
-
-void _gamma_TexEnviv(GLenum target, GLenum pname, const GLint *params)
-{
- DEBUG_GLCMDS(("TexEnviv: %04x %04x %d\n",
- (int)target, (int)pname, (int)*params));
-}
-
-void _gamma_TexGend(GLenum coord, GLenum pname, GLdouble param)
-{
- DEBUG_GLCMDS(("TexGend: %04x %04x %f\n", (int)coord, (int)pname, param));
-}
-
-void _gamma_TexGendv(GLenum coord, GLenum pname, const GLdouble *params)
-{
- DEBUG_GLCMDS(("TexGendv: %04x %04x %f\n", (int)coord, (int)pname, *params));
-}
-
-void _gamma_TexGenf(GLenum coord, GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("TexGenf: %04x %04x %f\n", (int)coord, (int)pname, param));
-}
-
-void _gamma_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params)
-{
- DEBUG_GLCMDS(("TexGenfv: %04x %04x %f\n", (int)coord, (int)pname, *params));
-}
-
-void _gamma_TexGeni(GLenum coord, GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("TexGeni: %04x %04x %d\n",
- (int)coord, (int)pname, (int)param));
-}
-
-void _gamma_TexGeniv(GLenum coord, GLenum pname, const GLint *params)
-{
- DEBUG_GLCMDS(("TexGeniv: %04x %04x %d\n",
- (int)coord, (int)pname, (int)*params));
-}
-
-void _gamma_TexImage1D(GLenum target, GLint level, GLint components, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *image)
-{
- DEBUG_GLCMDS(("TexImage1D: %04x %d %d %d %d %04x %04x\n",
- (int)target, (int)level, (int)components,
- (int)width, (int)border, (int)format, (int)type));
-}
-
-void _gamma_TexImage2D(GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *image)
-{
- unsigned long addrs[MIPMAP_LEVELS];
- int l2w, l2h, l2d;
- gammaTexObj *t;
- int i;
-
- DEBUG_GLCMDS(("TexImage2D: %04x %d %d %d %d %d %04x %04x\n",
- (int)target, (int)level, (int)components,
- (int)width, (int)height, (int)border,
- (int)format, (int)type));
-
- if (target == GL_TEXTURE_1D) {
- /* NOT_DONE */
- DEBUG_ERROR(("TexImage2D: 1D requested - ERROR\n"));
- } else if (target == GL_TEXTURE_2D) {
- /* NOT_DONE: The follow are not currently supported... */
- if (border != 0 /* || format != GL_RGBA */ || type != GL_UNSIGNED_BYTE ||
- (components != 3 && components != 4)) {
- DEBUG_ERROR(("TexImage2D: 2D op not supported - ERROR\n"));
- return;
- }
-
- if (width > 2048 || height > 2048) return; /* ERROR !! */
- if (level < 0 || level > 11) return; /* ERROR !! */
-
- /* Calculate the log2width, log2height and log2depth */
- CALC_LOG2(l2w, width);
- CALC_LOG2(l2h, height);
- l2d = 5;
-
- t = gCCPriv->curTexObj2D;
-
- /* Set the texture params for level 0 only */
- if (level == 0) {
- t->TextureAddressMode &= ~(TAM_WidthMask |
- TAM_HeightMask);
- t->TextureAddressMode |= (l2w << 9);
- t->TextureAddressMode |= (l2h << 13);
-
- /* NOT_DONE: Support patch mode */
- t->TextureReadMode &= ~(TRM_WidthMask |
- TRM_HeightMask |
- TRM_DepthMask |
- TRM_Border |
- TRM_Patch);
- t->TextureReadMode |= (l2w << 1);
- t->TextureReadMode |= (l2h << 5);
- t->TextureReadMode |= (l2d << 9);
-
- t->TextureColorMode &= ~(TCM_BaseFormatMask);
-
- switch (components) {
- case 3:
- t->TextureColorMode |= TCM_BaseFormat_RGB;
- break;
- case 4:
- t->TextureColorMode |= TCM_BaseFormat_RGBA;
- break;
- }
-
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- t->TextureFormat = (TF_LittleEndian |
-#else
- t->TextureFormat = (TF_BigEndian |
-#endif
- TF_ColorOrder_BGR |
- TF_Compnents_4 |
- TF_OutputFmt_Texel);
- }
-
- /* Remove the old image */
- if (t->image[level])
- driTMMDeleteImage(gCCPriv->tmm, t->image[level]);
-
- /* Insert the new image */
- t->image[level] = driTMMInsertImage(gCCPriv->tmm,
- width, height, 1<<l2d,
- image, NULL);
-
- if (!t->image[level]) {
- /* NOT_DONE: Handle error */
- DEBUG_ERROR(("TexImage2D: unable1\n"));
- }
-
- /* Make the new image resident (and all of the other mipmaps) */
- if (driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS,
- t->image, addrs) < 0) {
- /* NOT_DONE: Handle error */
- DEBUG_ERROR(("TexImage2D: unable2\n"));
- }
-
- for (i = 0; i < MIPMAP_LEVELS; i++)
- t->TextureBaseAddr[i] = addrs[i] << 5;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureColorMode,
- gCCPriv->curTexObj2D->TextureColorMode);
- WRITE(gCCPriv->buf, TextureFormat,
- gCCPriv->curTexObj2D->TextureFormat);
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- switch (level) {
- case 0:
- WRITE(gCCPriv->buf, TxBaseAddr0,
- gCCPriv->curTexObj2D->TextureBaseAddr[0]);
- break;
- case 1:
- WRITE(gCCPriv->buf, TxBaseAddr1,
- gCCPriv->curTexObj2D->TextureBaseAddr[1]);
- break;
- case 2:
- WRITE(gCCPriv->buf, TxBaseAddr2,
- gCCPriv->curTexObj2D->TextureBaseAddr[2]);
- break;
- case 3:
- WRITE(gCCPriv->buf, TxBaseAddr3,
- gCCPriv->curTexObj2D->TextureBaseAddr[3]);
- break;
- case 4:
- WRITE(gCCPriv->buf, TxBaseAddr4,
- gCCPriv->curTexObj2D->TextureBaseAddr[4]);
- break;
- case 5:
- WRITE(gCCPriv->buf, TxBaseAddr5,
- gCCPriv->curTexObj2D->TextureBaseAddr[5]);
- break;
- case 6:
- WRITE(gCCPriv->buf, TxBaseAddr6,
- gCCPriv->curTexObj2D->TextureBaseAddr[6]);
- break;
- case 7:
- WRITE(gCCPriv->buf, TxBaseAddr7,
- gCCPriv->curTexObj2D->TextureBaseAddr[7]);
- break;
- case 8:
- WRITE(gCCPriv->buf, TxBaseAddr8,
- gCCPriv->curTexObj2D->TextureBaseAddr[8]);
- break;
- case 9:
- WRITE(gCCPriv->buf, TxBaseAddr9,
- gCCPriv->curTexObj2D->TextureBaseAddr[9]);
- break;
- case 10:
- WRITE(gCCPriv->buf, TxBaseAddr10,
- gCCPriv->curTexObj2D->TextureBaseAddr[10]);
- break;
- case 11:
- WRITE(gCCPriv->buf, TxBaseAddr11,
- gCCPriv->curTexObj2D->TextureBaseAddr[11]);
- break;
- }
- } else {
- /* ERROR !! */
- }
-}
-
-void _gamma_TexParameterf(GLenum target, GLenum pname, GLfloat param)
-{
- DEBUG_GLCMDS(("TexParameterf: %04x %04x %f\n",
- (int)target, (int)pname, param));
-
- if (target == GL_TEXTURE_1D) {
- /* NOT_DONE */
- } else if (target == GL_TEXTURE_2D) {
- switch (pname) {
- case GL_TEXTURE_MAG_FILTER:
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Mag_Mask;
- switch ((int)param) {
- case GL_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Mag_Nearest;
- break;
- case GL_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Mag_Linear;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- break;
- case GL_TEXTURE_MIN_FILTER:
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Min_Mask;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_LODEnable;
- switch ((int)param) {
- case GL_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_Nearest;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable;
- break;
- case GL_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_Linear;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_NearestMMNearest;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_NearestMMLinear;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_LinearMMNearest;
- break;
- case GL_LINEAR_MIPMAP_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_LinearMMLinear;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- case GL_TEXTURE_WRAP_S:
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_SWrap_Mask;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_UWrap_Mask;
- switch ((int)param) {
- case GL_CLAMP:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Clamp;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Clamp;
- break;
- case GL_REPEAT:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Repeat;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Repeat;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- case GL_TEXTURE_WRAP_T:
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_TWrap_Mask;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_VWrap_Mask;
- switch ((int)param) {
- case GL_CLAMP:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Clamp;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Clamp;
- break;
- case GL_REPEAT:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Repeat;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Repeat;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- default:
- break;
- }
- } else {
- /* ERROR !! */
- }
-}
-
-void _gamma_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
-{
- DEBUG_GLCMDS(("TexParameterfv: %04x %04x %f\n",
- (int)target, (int)pname, *params));
-
- if (target == GL_TEXTURE_1D) {
- /* NOT_DONE */
- } else if (target == GL_TEXTURE_2D) {
- switch (pname) {
- case GL_TEXTURE_MAG_FILTER:
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Mag_Mask;
- switch ((int)params[0]) {
- case GL_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Mag_Nearest;
- break;
- case GL_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Mag_Linear;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- break;
- case GL_TEXTURE_MIN_FILTER:
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Min_Mask;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_LODEnable;
- switch ((int)params[0]) {
- case GL_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_Nearest;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable;
- break;
- case GL_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_Linear;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable;
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_NearestMMNearest;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_NearestMMLinear;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_LinearMMNearest;
- break;
- case GL_LINEAR_MIPMAP_LINEAR:
- gCCPriv->curTexObj2D->TextureReadMode |=
- TRM_Min_LinearMMLinear;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- case GL_TEXTURE_WRAP_S:
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_SWrap_Mask;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_UWrap_Mask;
- switch ((int)params[0]) {
- case GL_CLAMP:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Clamp;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Clamp;
- break;
- case GL_REPEAT:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Repeat;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Repeat;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- case GL_TEXTURE_WRAP_T:
- gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_TWrap_Mask;
- gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_VWrap_Mask;
- switch ((int)params[0]) {
- case GL_CLAMP:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Clamp;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Clamp;
- break;
- case GL_REPEAT:
- gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Repeat;
- gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Repeat;
- break;
- default:
- break;
- }
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, TextureReadMode,
- gCCPriv->curTexObj2D->TextureReadMode);
- WRITE(gCCPriv->buf, TextureAddressMode,
- gCCPriv->curTexObj2D->TextureAddressMode);
- break;
- default:
- break;
- }
- } else {
- /* ERROR !! */
- }
-}
-
-void _gamma_TexParameteri(GLenum target, GLenum pname, GLint param)
-{
- DEBUG_GLCMDS(("TexParameteri: %04x %04x %d\n",
- (int)target, (int)pname, (int)param));
-}
-
-void _gamma_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
-{
- DEBUG_GLCMDS(("TexParameteriv: %04x %04x %d\n",
- (int)target, (int)pname, (int)*params));
-}
-
-void _gamma_TexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *image)
-{
- DEBUG_GLCMDS(("TexSubImage1D: %04x %d %d %d %04x %04x\n",
- (int)target, (int)level,
- (int)xoffset, (int)width, (int)format, (int)type));
-}
-
-void _gamma_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image)
-{
- DEBUG_GLCMDS(("TexSubImage2D: %04x %d %d %d %d %d %04x %04x\n",
- (int)target, (int)level,
- (int)xoffset, (int)yoffset, (int)width, (int)height,
- (int)format, (int)type));
-
- if (target == GL_TEXTURE_1D) {
- /* NOT_DONE */
- } else if (target == GL_TEXTURE_2D) {
- /* NOT_DONE: The follow are not currently supported... */
- if (format != GL_RGBA || type != GL_UNSIGNED_BYTE) {
- return;
- }
-
- if (width > 2048 || height > 2048) return; /* ERROR !! */
- if (level < 0 || level > 11) return; /* ERROR !! */
-
- /*
- ** NOT_DONE: This should convert the image into the internal
- ** format for the image that it is replacing.
- */
-
- if (driTMMSubImage(gCCPriv->tmm, gCCPriv->curTexObj2D->image[level],
- xoffset, yoffset, width, height, image) < 0) {
- /* NOT_DONE: Handle error */
- }
- } else {
- /* ERROR !! */
- }
-}
-
-void _gamma_Translated(GLdouble x, GLdouble y, GLdouble z)
-{
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("Translated: %f %f %f\n", x, y, z));
-
- for (i = 0; i < 16; i++)
- if (i % 5 == 0)
- m[i] = 1.0;
- else
- m[i] = 0.0;
-
- m[12] = x;
- m[13] = y;
- m[14] = z;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Translatef(GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat m[16];
- int i;
-
- DEBUG_GLCMDS(("Translatef: %f %f %f\n", x, y, z));
-
- for (i = 0; i < 16; i++)
- if (i % 5 == 0)
- m[i] = 1.0;
- else
- m[i] = 0.0;
-
- m[12] = x;
- m[13] = y;
- m[14] = z;
-
- gammaMultMatrix(m);
- gammaLoadHWMatrix();
-}
-
-void _gamma_Vertex2d(GLdouble x, GLdouble y)
-{
- DEBUG_GLCMDS(("Vertex2d: %f %f\n", x, y));
-
- _gamma_Vertex2f((GLfloat)x,(GLfloat)y);
-}
-
-void _gamma_Vertex2dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Vertex2dv: %f %f\n", v[0], v[1]));
-
- _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]);
-}
-
-void _gamma_Vertex2f(GLfloat x, GLfloat y)
-{
- DEBUG_GLCMDS(("Vertex2f: %f %f\n", x, y));
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITEF(gCCPriv->buf, Vy, y);
- WRITEF(gCCPriv->buf, Vx2, x);
-}
-
-void _gamma_Vertex2fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Vertex2fv: %f %f\n", v[0], v[1]));
-
- _gamma_Vertex2f(v[0],v[1]);
-}
-
-void _gamma_Vertex2i(GLint x, GLint y)
-{
- DEBUG_GLCMDS(("Vertex2i: %d %d\n", (int)x, (int)y));
-
- _gamma_Vertex2f((GLfloat)x,(GLfloat)y);
-}
-
-void _gamma_Vertex2iv(const GLint *v)
-{
- DEBUG_GLCMDS(("Vertex2iv: %d %d\n", (int)v[0], (int)v[1]));
-
- _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]);
-}
-
-void _gamma_Vertex2s(GLshort x, GLshort y)
-{
- DEBUG_GLCMDS(("Vertex2s: %d %d\n", x, y));
-
- _gamma_Vertex2f((GLfloat)x,(GLfloat)y);
-}
-
-void _gamma_Vertex2sv(const GLshort *v)
-{
- DEBUG_GLCMDS(("Vertex2sv: %d %d\n", v[0], v[1]));
-
- _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]);
-}
-
-void _gamma_Vertex3d(GLdouble x, GLdouble y, GLdouble z)
-{
- DEBUG_GLCMDS(("Vertex3d: %f %f %f\n", x, y, z));
-
- _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z);
-}
-
-void _gamma_Vertex3dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Vertex2fv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Vertex3f(GLfloat x, GLfloat y, GLfloat z)
-{
- DEBUG_GLCMDS(("Vertex3f: %f %f %f\n", x, y, z));
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITEF(gCCPriv->buf, Vz, z);
- WRITEF(gCCPriv->buf, Vy, y);
- WRITEF(gCCPriv->buf, Vx3, x);
-}
-
-void _gamma_Vertex3fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Vertex3fv: %f %f %f\n", v[0], v[1], v[2]));
-
- _gamma_Vertex3f(v[0],v[1],v[2]);
-}
-
-void _gamma_Vertex3i(GLint x, GLint y, GLint z)
-{
- DEBUG_GLCMDS(("Vertex3i: %d %d %d\n", (int)x, (int)y, (int)z));
-
- _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z);
-}
-
-void _gamma_Vertex3iv(const GLint *v)
-{
- DEBUG_GLCMDS(("Vertex3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2]));
-
- _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Vertex3s(GLshort x, GLshort y, GLshort z)
-{
- DEBUG_GLCMDS(("Vertex3s: %d %d %d\n", x, y, z));
-
- _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z);
-}
-
-void _gamma_Vertex3sv(const GLshort *v)
-{
- DEBUG_GLCMDS(("Vertex3sv: %d %d %d\n", v[0], v[1], v[2]));
-
- _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]);
-}
-
-void _gamma_Vertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
-{
- DEBUG_GLCMDS(("Vertex4d: %f %f %f %f\n", x, y, z, w));
-
- _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w);
-}
-
-void _gamma_Vertex4dv(const GLdouble *v)
-{
- DEBUG_GLCMDS(("Vertex4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]);
-}
-
-void _gamma_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- DEBUG_GLCMDS(("Vertex4f: %f %f %f %f\n", x, y, z, w));
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, Vw, w);
- WRITEF(gCCPriv->buf, Vz, z);
- WRITEF(gCCPriv->buf, Vy, y);
- WRITEF(gCCPriv->buf, Vx4, x);
-}
-
-void _gamma_Vertex4fv(const GLfloat *v)
-{
- DEBUG_GLCMDS(("Vertex4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3]));
-
- _gamma_Vertex4f(v[0],v[1],v[2],v[3]);
-}
-
-void _gamma_Vertex4i(GLint x, GLint y, GLint z, GLint w)
-{
- DEBUG_GLCMDS(("Vertex4i: %d %d %d %d\n", (int)x, (int)y, (int)z, (int)w));
-
- _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w);
-}
-
-void _gamma_Vertex4iv(const GLint *v)
-{
- DEBUG_GLCMDS(("Vertex4iv: %d %d %d %d\n",
- (int)v[0], (int)v[1], (int)v[2], (int)v[3]));
-
- _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]);
-}
-
-void _gamma_Vertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
-{
- DEBUG_GLCMDS(("Vertex4s: %d %d %d %d\n", x, y, z, w));
-
- _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w);
-}
-
-void _gamma_Vertex4sv(const GLshort *v)
-{
- DEBUG_GLCMDS(("Vertex4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3]));
-
- _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]);
-}
-
-void _gamma_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
-{
- DEBUG_GLCMDS(("VertexPointer: %d %04x %d\n",
- (int)size, (int)type, (int)stride));
-
- if (size<2 || size>4) {
- gamma_error( GL_INVALID_VALUE, "glVertexPointer(size)" );
- return;
- }
- if (stride<0) {
- gamma_error( GL_INVALID_VALUE, "glVertexPointer(stride)" );
- return;
- }
- switch (type) {
- case GL_SHORT:
- gCCPriv->Array.VertexStrideB = stride ? stride : size*sizeof(GLshort);
- break;
- case GL_INT:
- gCCPriv->Array.VertexStrideB = stride ? stride : size*sizeof(GLint);
- break;
- case GL_FLOAT:
- gCCPriv->Array.VertexStrideB = stride ? stride : size*sizeof(GLfloat);
- break;
- case GL_DOUBLE:
- gCCPriv->Array.VertexStrideB = stride ? stride : size*sizeof(GLdouble);
- break;
- default:
- gamma_error( GL_INVALID_ENUM, "glVertexPointer(type)" );
- return;
- }
- gCCPriv->Array.VertexSize = size;
- gCCPriv->Array.VertexType = type;
- gCCPriv->Array.VertexStride = stride;
- gCCPriv->Array.VertexPtr = (void *) pointer;
-}
-
-void _gamma_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
-{
- GLfloat sx, sy, ox, oy;
-
- DEBUG_GLCMDS(("Viewport: %d %d %d %d\n",
- (int)x, (int)y, (int)width, (int)height));
-
- gCCPriv->x = gCC->driDrawablePriv->x + x;
- gCCPriv->y = gCC->driScreenPriv->fbHeight -
- (gCC->driDrawablePriv->y +
- gCC->driDrawablePriv->h) + y;
- gCCPriv->w = width;
- gCCPriv->h = height;
-
- x = gCCPriv->x;
- y = gCCPriv->y;
-
- sx = width/2.0f;
- sy = height/2.0f;
- ox = x + sx;
- oy = y + sy;
-
- CHECK_DMA_BUFFER(gCC, gCCPriv, 4);
- WRITEF(gCCPriv->buf, ViewPortOffsetX, ox);
- WRITEF(gCCPriv->buf, ViewPortOffsetY, oy);
- WRITEF(gCCPriv->buf, ViewPortScaleX, sx);
- WRITEF(gCCPriv->buf, ViewPortScaleY, sy);
-#if 1 /* Err - this shouldn't be needed, but something isn't flushing */
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-#endif
-}
-
-
-static GLint
-generic_noop(void)
-{
- DEBUG_GLCMDS(("OOPS GENERIC NOOP CALLED\n"));
-
- return 0;
-}
-
-
-static void
-init_no_op_table(struct _glapi_table *table)
-{
- /* Check to be sure the dispatcher's table is at least as big as Mesa's. */
- const GLuint size = sizeof(struct _glapi_table) / sizeof(void *);
- assert(_glapi_get_dispatch_table_size() >= size);
-
- {
- const GLuint n = _glapi_get_dispatch_table_size();
- GLuint i;
- void **dispatch = (void **) table;
- for (i = 0; i < n; i++) {
- dispatch[i] = (void *) generic_noop;
- }
- }
-}
-
-
-void
-_gamma_init_exec(struct _glapi_table *dispatch)
-{
- init_no_op_table(dispatch);
-
- /* 1.0 */
- dispatch->Accum = _gamma_Accum;
- dispatch->AlphaFunc = _gamma_AlphaFunc;
- dispatch->Begin = _gamma_Begin;
- dispatch->Bitmap = _gamma_Bitmap;
- dispatch->BlendFunc = _gamma_BlendFunc;
- dispatch->CallList = _gamma_CallList;
- dispatch->CallLists = _gamma_CallLists;
- dispatch->Clear = _gamma_Clear;
- dispatch->ClearAccum = _gamma_ClearAccum;
- dispatch->ClearColor = _gamma_ClearColor;
- dispatch->ClearDepth = _gamma_ClearDepth;
- dispatch->ClearIndex = _gamma_ClearIndex;
- dispatch->ClearStencil = _gamma_ClearStencil;
- dispatch->ClipPlane = _gamma_ClipPlane;
- dispatch->Color3b = _gamma_Color3b;
- dispatch->Color3bv = _gamma_Color3bv;
- dispatch->Color3d = _gamma_Color3d;
- dispatch->Color3dv = _gamma_Color3dv;
- dispatch->Color3f = _gamma_Color3f;
- dispatch->Color3fv = _gamma_Color3fv;
- dispatch->Color3i = _gamma_Color3i;
- dispatch->Color3iv = _gamma_Color3iv;
- dispatch->Color3s = _gamma_Color3s;
- dispatch->Color3sv = _gamma_Color3sv;
- dispatch->Color3ub = _gamma_Color3ub;
- dispatch->Color3ubv = _gamma_Color3ubv;
- dispatch->Color3ui = _gamma_Color3ui;
- dispatch->Color3uiv = _gamma_Color3uiv;
- dispatch->Color3us = _gamma_Color3us;
- dispatch->Color3usv = _gamma_Color3usv;
- dispatch->Color4b = _gamma_Color4b;
- dispatch->Color4bv = _gamma_Color4bv;
- dispatch->Color4d = _gamma_Color4d;
- dispatch->Color4dv = _gamma_Color4dv;
- dispatch->Color4f = _gamma_Color4f;
- dispatch->Color4fv = _gamma_Color4fv;
- dispatch->Color4i = _gamma_Color4i;
- dispatch->Color4iv = _gamma_Color4iv;
- dispatch->Color4s = _gamma_Color4s;
- dispatch->Color4sv = _gamma_Color4sv;
- dispatch->Color4ub = _gamma_Color4ub;
- dispatch->Color4ubv = _gamma_Color4ubv;
- dispatch->Color4ui = _gamma_Color4ui;
- dispatch->Color4uiv = _gamma_Color4uiv;
- dispatch->Color4us = _gamma_Color4us;
- dispatch->Color4usv = _gamma_Color4usv;
- dispatch->ColorMask = _gamma_ColorMask;
- dispatch->ColorMaterial = _gamma_ColorMaterial;
- dispatch->CopyPixels = _gamma_CopyPixels;
- dispatch->CullFace = _gamma_CullFace;
- dispatch->DeleteLists = _gamma_DeleteLists;
- dispatch->DepthFunc = _gamma_DepthFunc;
- dispatch->DepthMask = _gamma_DepthMask;
- dispatch->DepthRange = _gamma_DepthRange;
- dispatch->Disable = _gamma_Disable;
- dispatch->DrawBuffer = _gamma_DrawBuffer;
- dispatch->DrawPixels = _gamma_DrawPixels;
- dispatch->EdgeFlag = _gamma_EdgeFlag;
- dispatch->EdgeFlagv = _gamma_EdgeFlagv;
- dispatch->Enable = _gamma_Enable;
- dispatch->End = _gamma_End;
- dispatch->EndList = _gamma_EndList;
- dispatch->EvalCoord1d = _gamma_EvalCoord1d;
- dispatch->EvalCoord1dv = _gamma_EvalCoord1dv;
- dispatch->EvalCoord1f = _gamma_EvalCoord1f;
- dispatch->EvalCoord1fv = _gamma_EvalCoord1fv;
- dispatch->EvalCoord2d = _gamma_EvalCoord2d;
- dispatch->EvalCoord2dv = _gamma_EvalCoord2dv;
- dispatch->EvalCoord2f = _gamma_EvalCoord2f;
- dispatch->EvalCoord2fv = _gamma_EvalCoord2fv;
- dispatch->EvalMesh1 = _gamma_EvalMesh1;
- dispatch->EvalMesh2 = _gamma_EvalMesh2;
- dispatch->EvalPoint1 = _gamma_EvalPoint1;
- dispatch->EvalPoint2 = _gamma_EvalPoint2;
- dispatch->FeedbackBuffer = _gamma_FeedbackBuffer;
- dispatch->Finish = _gamma_Finish;
- dispatch->Flush = _gamma_Flush;
- dispatch->Fogf = _gamma_Fogf;
- dispatch->Fogfv = _gamma_Fogfv;
- dispatch->Fogi = _gamma_Fogi;
- dispatch->Fogiv = _gamma_Fogiv;
- dispatch->FrontFace = _gamma_FrontFace;
- dispatch->Frustum = _gamma_Frustum;
- dispatch->GenLists = _gamma_GenLists;
- dispatch->GetBooleanv = _gamma_GetBooleanv;
- dispatch->GetClipPlane = _gamma_GetClipPlane;
- dispatch->GetDoublev = _gamma_GetDoublev;
- dispatch->GetError = _gamma_GetError;
- dispatch->GetFloatv = _gamma_GetFloatv;
- dispatch->GetIntegerv = _gamma_GetIntegerv;
- dispatch->GetLightfv = _gamma_GetLightfv;
- dispatch->GetLightiv = _gamma_GetLightiv;
- dispatch->GetMapdv = _gamma_GetMapdv;
- dispatch->GetMapfv = _gamma_GetMapfv;
- dispatch->GetMapiv = _gamma_GetMapiv;
- dispatch->GetMaterialfv = _gamma_GetMaterialfv;
- dispatch->GetMaterialiv = _gamma_GetMaterialiv;
- dispatch->GetPixelMapfv = _gamma_GetPixelMapfv;
- dispatch->GetPixelMapuiv = _gamma_GetPixelMapuiv;
- dispatch->GetPixelMapusv = _gamma_GetPixelMapusv;
- dispatch->GetPolygonStipple = _gamma_GetPolygonStipple;
- dispatch->GetString = _gamma_GetString;
- dispatch->GetTexEnvfv = _gamma_GetTexEnvfv;
- dispatch->GetTexEnviv = _gamma_GetTexEnviv;
- dispatch->GetTexGendv = _gamma_GetTexGendv;
- dispatch->GetTexGenfv = _gamma_GetTexGenfv;
- dispatch->GetTexGeniv = _gamma_GetTexGeniv;
- dispatch->GetTexImage = _gamma_GetTexImage;
- dispatch->GetTexLevelParameterfv = _gamma_GetTexLevelParameterfv;
- dispatch->GetTexLevelParameteriv = _gamma_GetTexLevelParameteriv;
- dispatch->GetTexParameterfv = _gamma_GetTexParameterfv;
- dispatch->GetTexParameteriv = _gamma_GetTexParameteriv;
- dispatch->Hint = _gamma_Hint;
- dispatch->IndexMask = _gamma_IndexMask;
- dispatch->Indexd = _gamma_Indexd;
- dispatch->Indexdv = _gamma_Indexdv;
- dispatch->Indexf = _gamma_Indexf;
- dispatch->Indexfv = _gamma_Indexfv;
- dispatch->Indexi = _gamma_Indexi;
- dispatch->Indexiv = _gamma_Indexiv;
- dispatch->Indexs = _gamma_Indexs;
- dispatch->Indexsv = _gamma_Indexsv;
- dispatch->InitNames = _gamma_InitNames;
- dispatch->IsEnabled = _gamma_IsEnabled;
- dispatch->IsList = _gamma_IsList;
- dispatch->LightModelf = _gamma_LightModelf;
- dispatch->LightModelfv = _gamma_LightModelfv;
- dispatch->LightModeli = _gamma_LightModeli;
- dispatch->LightModeliv = _gamma_LightModeliv;
- dispatch->Lightf = _gamma_Lightf;
- dispatch->Lightfv = _gamma_Lightfv;
- dispatch->Lighti = _gamma_Lighti;
- dispatch->Lightiv = _gamma_Lightiv;
- dispatch->LineStipple = _gamma_LineStipple;
- dispatch->LineWidth = _gamma_LineWidth;
- dispatch->ListBase = _gamma_ListBase;
- dispatch->LoadIdentity = _gamma_LoadIdentity;
- dispatch->LoadMatrixd = _gamma_LoadMatrixd;
- dispatch->LoadMatrixf = _gamma_LoadMatrixf;
- dispatch->LoadName = _gamma_LoadName;
- dispatch->LogicOp = _gamma_LogicOp;
- dispatch->Map1d = _gamma_Map1d;
- dispatch->Map1f = _gamma_Map1f;
- dispatch->Map2d = _gamma_Map2d;
- dispatch->Map2f = _gamma_Map2f;
- dispatch->MapGrid1d = _gamma_MapGrid1d;
- dispatch->MapGrid1f = _gamma_MapGrid1f;
- dispatch->MapGrid2d = _gamma_MapGrid2d;
- dispatch->MapGrid2f = _gamma_MapGrid2f;
- dispatch->Materialf = _gamma_Materialf;
- dispatch->Materialfv = _gamma_Materialfv;
- dispatch->Materiali = _gamma_Materiali;
- dispatch->Materialiv = _gamma_Materialiv;
- dispatch->MatrixMode = _gamma_MatrixMode;
- dispatch->MultMatrixd = _gamma_MultMatrixd;
- dispatch->MultMatrixf = _gamma_MultMatrixf;
- dispatch->NewList = _gamma_NewList;
- dispatch->Normal3b = _gamma_Normal3b;
- dispatch->Normal3bv = _gamma_Normal3bv;
- dispatch->Normal3d = _gamma_Normal3d;
- dispatch->Normal3dv = _gamma_Normal3dv;
- dispatch->Normal3f = _gamma_Normal3f;
- dispatch->Normal3fv = _gamma_Normal3fv;
- dispatch->Normal3i = _gamma_Normal3i;
- dispatch->Normal3iv = _gamma_Normal3iv;
- dispatch->Normal3s = _gamma_Normal3s;
- dispatch->Normal3sv = _gamma_Normal3sv;
- dispatch->Ortho = _gamma_Ortho;
- dispatch->PassThrough = _gamma_PassThrough;
- dispatch->PixelMapfv = _gamma_PixelMapfv;
- dispatch->PixelMapuiv = _gamma_PixelMapuiv;
- dispatch->PixelMapusv = _gamma_PixelMapusv;
- dispatch->PixelStoref = _gamma_PixelStoref;
- dispatch->PixelStorei = _gamma_PixelStorei;
- dispatch->PixelTransferf = _gamma_PixelTransferf;
- dispatch->PixelTransferi = _gamma_PixelTransferi;
- dispatch->PixelZoom = _gamma_PixelZoom;
- dispatch->PointSize = _gamma_PointSize;
- dispatch->PolygonMode = _gamma_PolygonMode;
- dispatch->PolygonOffset = _gamma_PolygonOffset;
- dispatch->PolygonStipple = _gamma_PolygonStipple;
- dispatch->PopAttrib = _gamma_PopAttrib;
- dispatch->PopMatrix = _gamma_PopMatrix;
- dispatch->PopName = _gamma_PopName;
- dispatch->PushAttrib = _gamma_PushAttrib;
- dispatch->PushMatrix = _gamma_PushMatrix;
- dispatch->PushName = _gamma_PushName;
- dispatch->RasterPos2d = _gamma_RasterPos2d;
- dispatch->RasterPos2dv = _gamma_RasterPos2dv;
- dispatch->RasterPos2f = _gamma_RasterPos2f;
- dispatch->RasterPos2fv = _gamma_RasterPos2fv;
- dispatch->RasterPos2i = _gamma_RasterPos2i;
- dispatch->RasterPos2iv = _gamma_RasterPos2iv;
- dispatch->RasterPos2s = _gamma_RasterPos2s;
- dispatch->RasterPos2sv = _gamma_RasterPos2sv;
- dispatch->RasterPos3d = _gamma_RasterPos3d;
- dispatch->RasterPos3dv = _gamma_RasterPos3dv;
- dispatch->RasterPos3f = _gamma_RasterPos3f;
- dispatch->RasterPos3fv = _gamma_RasterPos3fv;
- dispatch->RasterPos3i = _gamma_RasterPos3i;
- dispatch->RasterPos3iv = _gamma_RasterPos3iv;
- dispatch->RasterPos3s = _gamma_RasterPos3s;
- dispatch->RasterPos3sv = _gamma_RasterPos3sv;
- dispatch->RasterPos4d = _gamma_RasterPos4d;
- dispatch->RasterPos4dv = _gamma_RasterPos4dv;
- dispatch->RasterPos4f = _gamma_RasterPos4f;
- dispatch->RasterPos4fv = _gamma_RasterPos4fv;
- dispatch->RasterPos4i = _gamma_RasterPos4i;
- dispatch->RasterPos4iv = _gamma_RasterPos4iv;
- dispatch->RasterPos4s = _gamma_RasterPos4s;
- dispatch->RasterPos4sv = _gamma_RasterPos4sv;
- dispatch->ReadBuffer = _gamma_ReadBuffer;
- dispatch->ReadPixels = _gamma_ReadPixels;
- dispatch->Rectd = _gamma_Rectd;
- dispatch->Rectdv = _gamma_Rectdv;
- dispatch->Rectf = _gamma_Rectf;
- dispatch->Rectfv = _gamma_Rectfv;
- dispatch->Recti = _gamma_Recti;
- dispatch->Rectiv = _gamma_Rectiv;
- dispatch->Rects = _gamma_Rects;
- dispatch->Rectsv = _gamma_Rectsv;
- dispatch->RenderMode = _gamma_RenderMode;
- dispatch->Rotated = _gamma_Rotated;
- dispatch->Rotatef = _gamma_Rotatef;
- dispatch->Scaled = _gamma_Scaled;
- dispatch->Scalef = _gamma_Scalef;
- dispatch->Scissor = _gamma_Scissor;
- dispatch->SelectBuffer = _gamma_SelectBuffer;
- dispatch->ShadeModel = _gamma_ShadeModel;
- dispatch->StencilFunc = _gamma_StencilFunc;
- dispatch->StencilMask = _gamma_StencilMask;
- dispatch->StencilOp = _gamma_StencilOp;
- dispatch->TexCoord1d = _gamma_TexCoord1d;
- dispatch->TexCoord1dv = _gamma_TexCoord1dv;
- dispatch->TexCoord1f = _gamma_TexCoord1f;
- dispatch->TexCoord1fv = _gamma_TexCoord1fv;
- dispatch->TexCoord1i = _gamma_TexCoord1i;
- dispatch->TexCoord1iv = _gamma_TexCoord1iv;
- dispatch->TexCoord1s = _gamma_TexCoord1s;
- dispatch->TexCoord1sv = _gamma_TexCoord1sv;
- dispatch->TexCoord2d = _gamma_TexCoord2d;
- dispatch->TexCoord2dv = _gamma_TexCoord2dv;
- dispatch->TexCoord2f = _gamma_TexCoord2f;
- dispatch->TexCoord2fv = _gamma_TexCoord2fv;
- dispatch->TexCoord2i = _gamma_TexCoord2i;
- dispatch->TexCoord2iv = _gamma_TexCoord2iv;
- dispatch->TexCoord2s = _gamma_TexCoord2s;
- dispatch->TexCoord2sv = _gamma_TexCoord2sv;
- dispatch->TexCoord3d = _gamma_TexCoord3d;
- dispatch->TexCoord3dv = _gamma_TexCoord3dv;
- dispatch->TexCoord3f = _gamma_TexCoord3f;
- dispatch->TexCoord3fv = _gamma_TexCoord3fv;
- dispatch->TexCoord3i = _gamma_TexCoord3i;
- dispatch->TexCoord3iv = _gamma_TexCoord3iv;
- dispatch->TexCoord3s = _gamma_TexCoord3s;
- dispatch->TexCoord3sv = _gamma_TexCoord3sv;
- dispatch->TexCoord4d = _gamma_TexCoord4d;
- dispatch->TexCoord4dv = _gamma_TexCoord4dv;
- dispatch->TexCoord4f = _gamma_TexCoord4f;
- dispatch->TexCoord4fv = _gamma_TexCoord4fv;
- dispatch->TexCoord4i = _gamma_TexCoord4i;
- dispatch->TexCoord4iv = _gamma_TexCoord4iv;
- dispatch->TexCoord4s = _gamma_TexCoord4s;
- dispatch->TexCoord4sv = _gamma_TexCoord4sv;
- dispatch->TexEnvf = _gamma_TexEnvf;
- dispatch->TexEnvfv = _gamma_TexEnvfv;
- dispatch->TexEnvi = _gamma_TexEnvi;
- dispatch->TexEnviv = _gamma_TexEnviv;
- dispatch->TexGend = _gamma_TexGend;
- dispatch->TexGendv = _gamma_TexGendv;
- dispatch->TexGenf = _gamma_TexGenf;
- dispatch->TexGenfv = _gamma_TexGenfv;
- dispatch->TexGeni = _gamma_TexGeni;
- dispatch->TexGeniv = _gamma_TexGeniv;
- dispatch->TexImage1D = _gamma_TexImage1D;
- dispatch->TexImage2D = _gamma_TexImage2D;
- dispatch->TexParameterf = _gamma_TexParameterf;
- dispatch->TexParameterfv = _gamma_TexParameterfv;
- dispatch->TexParameteri = _gamma_TexParameteri;
- dispatch->TexParameteriv = _gamma_TexParameteriv;
- dispatch->Translated = _gamma_Translated;
- dispatch->Translatef = _gamma_Translatef;
- dispatch->Vertex2d = _gamma_Vertex2d;
- dispatch->Vertex2dv = _gamma_Vertex2dv;
- dispatch->Vertex2f = _gamma_Vertex2f;
- dispatch->Vertex2fv = _gamma_Vertex2fv;
- dispatch->Vertex2i = _gamma_Vertex2i;
- dispatch->Vertex2iv = _gamma_Vertex2iv;
- dispatch->Vertex2s = _gamma_Vertex2s;
- dispatch->Vertex2sv = _gamma_Vertex2sv;
- dispatch->Vertex3d = _gamma_Vertex3d;
- dispatch->Vertex3dv = _gamma_Vertex3dv;
- dispatch->Vertex3f = _gamma_Vertex3f;
- dispatch->Vertex3fv = _gamma_Vertex3fv;
- dispatch->Vertex3i = _gamma_Vertex3i;
- dispatch->Vertex3iv = _gamma_Vertex3iv;
- dispatch->Vertex3s = _gamma_Vertex3s;
- dispatch->Vertex3sv = _gamma_Vertex3sv;
- dispatch->Vertex4d = _gamma_Vertex4d;
- dispatch->Vertex4dv = _gamma_Vertex4dv;
- dispatch->Vertex4f = _gamma_Vertex4f;
- dispatch->Vertex4fv = _gamma_Vertex4fv;
- dispatch->Vertex4i = _gamma_Vertex4i;
- dispatch->Vertex4iv = _gamma_Vertex4iv;
- dispatch->Vertex4s = _gamma_Vertex4s;
- dispatch->Vertex4sv = _gamma_Vertex4sv;
- dispatch->Viewport = _gamma_Viewport;
-
- /* 1.1 */
- dispatch->AreTexturesResident = _gamma_AreTexturesResident;
- dispatch->ArrayElement = gl_save_ArrayElement; /*_gamma_ArrayElement;*/
- dispatch->BindTexture = _gamma_BindTexture;
- dispatch->ColorPointer = _gamma_ColorPointer;
- dispatch->CopyTexImage1D = _gamma_CopyTexImage1D;
- dispatch->CopyTexImage2D = _gamma_CopyTexImage2D;
- dispatch->CopyTexSubImage1D = _gamma_CopyTexSubImage1D;
- dispatch->CopyTexSubImage2D = _gamma_CopyTexSubImage2D;
- dispatch->DeleteTextures = _gamma_DeleteTextures;
- dispatch->DisableClientState = _gamma_DisableClientState;
- dispatch->DrawArrays = _gamma_DrawArrays;
- dispatch->DrawElements = _gamma_DrawElements;
- dispatch->EdgeFlagPointer = _gamma_EdgeFlagPointer;
- dispatch->EnableClientState = _gamma_EnableClientState;
- dispatch->GenTextures = _gamma_GenTextures;
- dispatch->GetPointerv = _gamma_GetPointerv;
- dispatch->IndexPointer = _gamma_IndexPointer;
- dispatch->Indexub = _gamma_Indexub;
- dispatch->Indexubv = _gamma_Indexubv;
- dispatch->InterleavedArrays = _gamma_InterleavedArrays;
- dispatch->IsTexture = _gamma_IsTexture;
- dispatch->NormalPointer = _gamma_NormalPointer;
- dispatch->PopClientAttrib = _gamma_PopClientAttrib;
- dispatch->PrioritizeTextures = _gamma_PrioritizeTextures;
- dispatch->PushClientAttrib = _gamma_PushClientAttrib;
- dispatch->TexCoordPointer = _gamma_TexCoordPointer;
- dispatch->TexSubImage1D = _gamma_TexSubImage1D;
- dispatch->TexSubImage2D = _gamma_TexSubImage2D;
- dispatch->VertexPointer = _gamma_VertexPointer;
-}
-
-void
-_gamma_init_save(struct _glapi_table *table)
-{
- init_no_op_table(table);
-
- table->Accum = gl_save_Accum;
- table->AlphaFunc = gl_save_AlphaFunc;
- table->AreTexturesResident = _gamma_AreTexturesResident; /* NOT SAVED */
- table->ArrayElement = gl_save_ArrayElement;
- table->Begin = gl_save_Begin;
- table->BindTexture = gl_save_BindTexture;
- table->Bitmap = gl_save_Bitmap;
- table->BlendFunc = gl_save_BlendFunc;
- table->CallList = gl_save_CallList;
- table->CallLists = gl_save_CallLists;
- table->Clear = gl_save_Clear;
- table->ClearAccum = gl_save_ClearAccum;
- table->ClearColor = gl_save_ClearColor;
- table->ClearDepth = gl_save_ClearDepth;
- table->ClearIndex = gl_save_ClearIndex;
- table->ClearStencil = gl_save_ClearStencil;
- table->ClipPlane = gl_save_ClipPlane;
- table->Color3f = gl_save_Color3f;
- table->Color3fv = gl_save_Color3fv;
- table->Color4f = gl_save_Color4f;
- table->Color4fv = gl_save_Color4fv;
- table->Color4ub = gl_save_Color4ub;
- table->Color4ubv = gl_save_Color4ubv;
- table->ColorMask = gl_save_ColorMask;
- table->ColorMaterial = gl_save_ColorMaterial;
- table->ColorPointer = _gamma_ColorPointer; /* NOT SAVED */
- table->CopyPixels = gl_save_CopyPixels;
- table->CopyTexImage1D = gl_save_CopyTexImage1D;
- table->CopyTexImage2D = gl_save_CopyTexImage2D;
- table->CopyTexSubImage1D = gl_save_CopyTexSubImage1D;
- table->CopyTexSubImage2D = gl_save_CopyTexSubImage2D;
- table->CullFace = gl_save_CullFace;
- table->DeleteLists = _gamma_DeleteLists; /* NOT SAVED */
- table->DeleteTextures = _gamma_DeleteTextures; /* NOT SAVED */
- table->DepthFunc = gl_save_DepthFunc;
- table->DepthMask = gl_save_DepthMask;
- table->DepthRange = gl_save_DepthRange;
- table->Disable = gl_save_Disable;
- table->DisableClientState = _gamma_DisableClientState; /* NOT SAVED */
- table->DrawArrays = gl_save_DrawArrays;
- table->DrawBuffer = gl_save_DrawBuffer;
- table->DrawElements = gl_save_DrawElements;
- table->DrawPixels = gl_save_DrawPixels;
- table->EdgeFlag = gl_save_EdgeFlag;
- table->EdgeFlagPointer = _gamma_EdgeFlagPointer; /* NOT SAVED */
- table->Enable = gl_save_Enable;
- table->EnableClientState = _gamma_EnableClientState; /* NOT SAVED */
- table->End = gl_save_End;
- table->EndList = _gamma_EndList; /* NOT SAVED */
- table->EvalCoord1f = gl_save_EvalCoord1f;
- table->EvalCoord2f = gl_save_EvalCoord2f;
- table->EvalMesh1 = gl_save_EvalMesh1;
- table->EvalMesh2 = gl_save_EvalMesh2;
- table->EvalPoint1 = gl_save_EvalPoint1;
- table->EvalPoint2 = gl_save_EvalPoint2;
- table->FeedbackBuffer = _gamma_FeedbackBuffer; /* NOT SAVED */
- table->Finish = _gamma_Finish; /* NOT SAVED */
- table->Flush = _gamma_Flush; /* NOT SAVED */
- table->Fogfv = gl_save_Fogfv;
- table->FrontFace = gl_save_FrontFace;
- table->Frustum = gl_save_Frustum;
- table->GenLists = _gamma_GenLists; /* NOT SAVED */
- table->GenTextures = _gamma_GenTextures; /* NOT SAVED */
-
- /* NONE OF THESE COMMANDS ARE COMPILED INTO DISPLAY LISTS */
- table->GetBooleanv = _gamma_GetBooleanv;
- table->GetClipPlane = _gamma_GetClipPlane;
- table->GetDoublev = _gamma_GetDoublev;
- table->GetError = _gamma_GetError;
- table->GetFloatv = _gamma_GetFloatv;
- table->GetIntegerv = _gamma_GetIntegerv;
- table->GetString = _gamma_GetString;
- table->GetLightfv = _gamma_GetLightfv;
- table->GetLightiv = _gamma_GetLightiv;
- table->GetMapdv = _gamma_GetMapdv;
- table->GetMapfv = _gamma_GetMapfv;
- table->GetMapiv = _gamma_GetMapiv;
- table->GetMaterialfv = _gamma_GetMaterialfv;
- table->GetMaterialiv = _gamma_GetMaterialiv;
- table->GetPixelMapfv = _gamma_GetPixelMapfv;
- table->GetPixelMapuiv = _gamma_GetPixelMapuiv;
- table->GetPixelMapusv = _gamma_GetPixelMapusv;
- table->GetPointerv = _gamma_GetPointerv;
- table->GetPolygonStipple = _gamma_GetPolygonStipple;
- table->GetTexEnvfv = _gamma_GetTexEnvfv;
- table->GetTexEnviv = _gamma_GetTexEnviv;
- table->GetTexGendv = _gamma_GetTexGendv;
- table->GetTexGenfv = _gamma_GetTexGenfv;
- table->GetTexGeniv = _gamma_GetTexGeniv;
- table->GetTexImage = _gamma_GetTexImage;
- table->GetTexLevelParameterfv = _gamma_GetTexLevelParameterfv;
- table->GetTexLevelParameteriv = _gamma_GetTexLevelParameteriv;
- table->GetTexParameterfv = _gamma_GetTexParameterfv;
- table->GetTexParameteriv = _gamma_GetTexParameteriv;
-
- table->Hint = gl_save_Hint;
- table->IndexMask = gl_save_IndexMask;
- table->Indexf = gl_save_Indexf;
- table->Indexi = gl_save_Indexi;
- table->IndexPointer = _gamma_IndexPointer; /* NOT SAVED */
- table->InitNames = gl_save_InitNames;
- table->InterleavedArrays = _gamma_InterleavedArrays; /* NOT SAVED */
- table->IsEnabled = _gamma_IsEnabled; /* NOT SAVED */
- table->IsTexture = _gamma_IsTexture; /* NOT SAVED */
- table->IsList = _gamma_IsList; /* NOT SAVED */
- table->LightModelfv = gl_save_LightModelfv;
- table->Lightfv = gl_save_Lightfv;
- table->LineStipple = gl_save_LineStipple;
- table->LineWidth = gl_save_LineWidth;
- table->ListBase = gl_save_ListBase;
- table->LoadIdentity = gl_save_LoadIdentity;
- table->LoadMatrixf = gl_save_LoadMatrixf;
- table->LoadName = gl_save_LoadName;
- table->LogicOp = gl_save_LogicOp;
- table->Map1f = gl_save_Map1f;
- table->Map2f = gl_save_Map2f;
- table->MapGrid1f = gl_save_MapGrid1f;
- table->MapGrid2f = gl_save_MapGrid2f;
- table->Materialfv = gl_save_Materialfv;
- table->MatrixMode = gl_save_MatrixMode;
- table->MultMatrixf = gl_save_MultMatrixf;
- table->NewList = gl_save_NewList;
- table->Normal3f = gl_save_Normal3f;
- table->Normal3fv = gl_save_Normal3fv;
- table->NormalPointer = _gamma_NormalPointer; /* NOT SAVED */
- table->Ortho = gl_save_Ortho;
- table->PassThrough = gl_save_PassThrough;
- table->PixelMapfv = gl_save_PixelMapfv;
- table->PixelStorei = _gamma_PixelStorei; /* NOT SAVED */
- table->PixelTransferf = gl_save_PixelTransferf;
- table->PixelZoom = gl_save_PixelZoom;
- table->PointSize = gl_save_PointSize;
- table->PolygonMode = gl_save_PolygonMode;
- table->PolygonOffset = gl_save_PolygonOffset;
- table->PolygonStipple = gl_save_PolygonStipple;
- table->PopAttrib = gl_save_PopAttrib;
- table->PopClientAttrib = _gamma_PopClientAttrib; /* NOT SAVED */
- table->PopMatrix = gl_save_PopMatrix;
- table->PopName = gl_save_PopName;
- table->PrioritizeTextures = gl_save_PrioritizeTextures;
- table->PushAttrib = gl_save_PushAttrib;
- table->PushClientAttrib = _gamma_PushClientAttrib; /* NOT SAVED */
- table->PushMatrix = gl_save_PushMatrix;
- table->PushName = gl_save_PushName;
- table->RasterPos4f = gl_save_RasterPos4f;
- table->ReadBuffer = gl_save_ReadBuffer;
- table->ReadPixels = _gamma_ReadPixels; /* NOT SAVED */
- table->Rectf = gl_save_Rectf;
- table->RenderMode = _gamma_RenderMode; /* NOT SAVED */
- table->Rotatef = gl_save_Rotatef;
- table->Scalef = gl_save_Scalef;
- table->Scissor = gl_save_Scissor;
- table->SelectBuffer = _gamma_SelectBuffer; /* NOT SAVED */
- table->ShadeModel = gl_save_ShadeModel;
- table->StencilFunc = gl_save_StencilFunc;
- table->StencilMask = gl_save_StencilMask;
- table->StencilOp = gl_save_StencilOp;
- table->TexCoord2f = gl_save_TexCoord2f;
- table->TexCoord2fv = gl_save_TexCoord2fv;
- table->TexCoord3fv = gl_save_TexCoord3fv;
- table->TexCoord4f = gl_save_TexCoord4f;
- table->TexCoordPointer = _gamma_TexCoordPointer; /* NOT SAVED */
- table->TexEnvfv = gl_save_TexEnvfv;
- table->TexGenfv = gl_save_TexGenfv;
- table->TexImage1D = gl_save_TexImage1D;
- table->TexImage2D = gl_save_TexImage2D;
- table->TexSubImage1D = gl_save_TexSubImage1D;
- table->TexSubImage2D = gl_save_TexSubImage2D;
- table->TexParameterfv = gl_save_TexParameterfv;
- table->Translatef = gl_save_Translatef;
- table->Vertex2f = gl_save_Vertex2f;
- table->Vertex3f = gl_save_Vertex3f;
- table->Vertex4f = gl_save_Vertex4f;
- table->Vertex3fv = gl_save_Vertex3fv;
- table->VertexPointer = _gamma_VertexPointer; /* NOT SAVED */
- table->Viewport = gl_save_Viewport;
-}
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.h
deleted file mode 100644
index 212f91895..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.h
+++ /dev/null
@@ -1,384 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_gl.h,v 1.5 2001/02/07 13:26:16 alanh Exp $ */
-/**************************************************************************
-
-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 _GAMMA_GL_H_
-#define _GAMMA_GL_H_
-
-#include "GL/gl.h"
-#include "glapi.h"
-
-extern void gamma_error(GLenum error, const char *s);
-
-extern void _gamma_Accum(GLenum op, GLfloat value);
-extern void _gamma_AlphaFunc(GLenum func, GLclampf ref);
-extern GLboolean _gamma_AreTexturesResident(GLsizei n, const GLuint *textures, GLboolean *residences);
-extern void _gamma_ArrayElement(GLint i);
-extern void _gamma_Begin(GLenum mode);
-extern void _gamma_BindTexture(GLenum target, GLuint texture);
-extern void _gamma_Bitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap);
-extern void _gamma_BlendFunc(GLenum sfactor, GLenum dfactor);
-extern void _gamma_CallList(GLuint list);
-extern void _gamma_CallLists(GLsizei n, GLenum type, const GLvoid *lists);
-extern void _gamma_Clear(GLbitfield mask);
-extern void _gamma_ClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-extern void _gamma_ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-extern void _gamma_ClearDepth(GLclampd depth);
-extern void _gamma_ClearIndex(GLfloat c);
-extern void _gamma_ClearStencil(GLint s);
-extern void _gamma_ClipPlane(GLenum plane, const GLdouble *equation);
-extern void _gamma_Color3b(GLbyte red, GLbyte green, GLbyte blue);
-extern void _gamma_Color3bv(const GLbyte *v);
-extern void _gamma_Color3d(GLdouble red, GLdouble green, GLdouble blue);
-extern void _gamma_Color3dv(const GLdouble *v);
-extern void _gamma_Color3f(GLfloat red, GLfloat green, GLfloat blue);
-extern void _gamma_Color3fv(const GLfloat *v);
-extern void _gamma_Color3i(GLint red, GLint green, GLint blue);
-extern void _gamma_Color3iv(const GLint *v);
-extern void _gamma_Color3s(GLshort red, GLshort green, GLshort blue);
-extern void _gamma_Color3sv(const GLshort *v);
-extern void _gamma_Color3ub(GLubyte red, GLubyte green, GLubyte blue);
-extern void _gamma_Color3ubv(const GLubyte *v);
-extern void _gamma_Color3ui(GLuint red, GLuint green, GLuint blue);
-extern void _gamma_Color3uiv(const GLuint *v);
-extern void _gamma_Color3us(GLushort red, GLushort green, GLushort blue);
-extern void _gamma_Color3usv(const GLushort *v);
-extern void _gamma_Color4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
-extern void _gamma_Color4bv(const GLbyte *v);
-extern void _gamma_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
-extern void _gamma_Color4dv(const GLdouble *v);
-extern void _gamma_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
-extern void _gamma_Color4fv(const GLfloat *v);
-extern void _gamma_Color4i(GLint red, GLint green, GLint blue, GLint alpha);
-extern void _gamma_Color4iv(const GLint *v);
-extern void _gamma_Color4s(GLshort red, GLshort green, GLshort blue, GLshort alpha);
-extern void _gamma_Color4sv(const GLshort *v);
-extern void _gamma_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
-extern void _gamma_Color4ubv(const GLubyte *v);
-extern void _gamma_Color4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha);
-extern void _gamma_Color4uiv(const GLuint *v);
-extern void _gamma_Color4us(GLushort red, GLushort green, GLushort blue, GLushort alpha);
-extern void _gamma_Color4usv(const GLushort *v);
-extern void _gamma_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-extern void _gamma_ColorMaterial(GLenum face, GLenum mode);
-extern void _gamma_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-extern void _gamma_CopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
-extern void _gamma_CopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-extern void _gamma_CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-extern void _gamma_CopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-extern void _gamma_CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-extern void _gamma_CullFace(GLenum mode);
-extern void _gamma_DeleteLists(GLuint list, GLsizei range);
-extern void _gamma_DeleteTextures(GLsizei n, const GLuint *textures);
-extern void _gamma_DepthFunc(GLenum func);
-extern void _gamma_DepthMask(GLboolean flag);
-extern void _gamma_DepthRange(GLclampd zNear, GLclampd zFar);
-extern void _gamma_Disable(GLenum cap);
-extern void _gamma_DisableClientState(GLenum array);
-extern void _gamma_DrawArrays(GLenum mode, GLint first, GLsizei count);
-extern void _gamma_DrawBuffer(GLenum mode);
-extern void _gamma_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
-extern void _gamma_DrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-extern void _gamma_EdgeFlag(GLboolean flag);
-extern void _gamma_EdgeFlagPointer(GLsizei stride, const GLvoid *pointer);
-extern void _gamma_EdgeFlagv(const GLboolean *flag);
-extern void _gamma_Enable(GLenum cap);
-extern void _gamma_EnableClientState(GLenum array);
-extern void _gamma_End(void);
-extern void _gamma_EndList(void);
-extern void _gamma_EvalCoord1d(GLdouble u);
-extern void _gamma_EvalCoord1dv(const GLdouble *u);
-extern void _gamma_EvalCoord1f(GLfloat u);
-extern void _gamma_EvalCoord1fv(const GLfloat *u);
-extern void _gamma_EvalCoord2d(GLdouble u, GLdouble v);
-extern void _gamma_EvalCoord2dv(const GLdouble *u);
-extern void _gamma_EvalCoord2f(GLfloat u, GLfloat v);
-extern void _gamma_EvalCoord2fv(const GLfloat *u);
-extern void _gamma_EvalMesh1(GLenum mode, GLint i1, GLint i2);
-extern void _gamma_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
-extern void _gamma_EvalPoint1(GLint i);
-extern void _gamma_EvalPoint2(GLint i, GLint j);
-extern void _gamma_FeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer);
-extern void _gamma_Finish(void);
-extern void _gamma_Flush(void);
-extern void _gamma_Fogf(GLenum pname, GLfloat param);
-extern void _gamma_Fogfv(GLenum pname, const GLfloat *params);
-extern void _gamma_Fogi(GLenum pname, GLint param);
-extern void _gamma_Fogiv(GLenum pname, const GLint *params);
-extern void _gamma_FrontFace(GLenum mode);
-extern void _gamma_Frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-extern GLuint _gamma_GenLists(GLsizei range);
-extern void _gamma_GenTextures(GLsizei n, GLuint *textures);
-extern void _gamma_GetBooleanv(GLenum val, GLboolean *b);
-extern void _gamma_GetClipPlane(GLenum plane, GLdouble *equation);
-extern void _gamma_GetDoublev(GLenum val, GLdouble *d);
-extern GLenum _gamma_GetError(void);
-extern void _gamma_GetFloatv(GLenum val, GLfloat *f);
-extern void _gamma_GetIntegerv(GLenum val, GLint *i);
-extern void _gamma_GetLightfv(GLenum light, GLenum pname, GLfloat *params);
-extern void _gamma_GetLightiv(GLenum light, GLenum pname, GLint *params);
-extern void _gamma_GetMapdv(GLenum target, GLenum query, GLdouble *v);
-extern void _gamma_GetMapfv(GLenum target, GLenum query, GLfloat *v);
-extern void _gamma_GetMapiv(GLenum target, GLenum query, GLint *v);
-extern void _gamma_GetMaterialfv(GLenum face, GLenum pname, GLfloat *params);
-extern void _gamma_GetMaterialiv(GLenum face, GLenum pname, GLint *params);
-extern void _gamma_GetPixelMapfv(GLenum map, GLfloat *values);
-extern void _gamma_GetPixelMapuiv(GLenum map, GLuint *values);
-extern void _gamma_GetPixelMapusv(GLenum map, GLushort *values);
-extern void _gamma_GetPointerv(GLenum pname, void **params);
-extern void _gamma_GetPolygonStipple(GLubyte *mask);
-extern const GLubyte *_gamma_GetString(GLenum name);
-extern void _gamma_GetTexEnvfv(GLenum target, GLenum pname, GLfloat *params);
-extern void _gamma_GetTexEnviv(GLenum target, GLenum pname, GLint *params);
-extern void _gamma_GetTexGendv(GLenum coord, GLenum pname, GLdouble *params);
-extern void _gamma_GetTexGenfv(GLenum coord, GLenum pname, GLfloat *params);
-extern void _gamma_GetTexGeniv(GLenum coord, GLenum pname, GLint *params);
-extern void _gamma_GetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *texels);
-extern void _gamma_GetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat *params);
-extern void _gamma_GetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params);
-extern void _gamma_GetTexParameterfv(GLenum target, GLenum pname, GLfloat *params);
-extern void _gamma_GetTexParameteriv(GLenum target, GLenum pname, GLint *params);
-extern void _gamma_Hint(GLenum target, GLenum mode);
-extern void _gamma_IndexMask(GLuint mask);
-extern void _gamma_IndexPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
-extern void _gamma_Indexd(GLdouble c);
-extern void _gamma_Indexdv(const GLdouble *c);
-extern void _gamma_Indexf(GLfloat c);
-extern void _gamma_Indexfv(const GLfloat *c);
-extern void _gamma_Indexi(GLint c);
-extern void _gamma_Indexiv(const GLint *c);
-extern void _gamma_Indexs(GLshort c);
-extern void _gamma_Indexsv(const GLshort *c);
-extern void _gamma_Indexub(GLubyte c);
-extern void _gamma_Indexubv(const GLubyte *c);
-extern void _gamma_InitNames(void);
-extern void _gamma_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
-extern GLboolean _gamma_IsEnabled(GLenum cap);
-extern GLboolean _gamma_IsList(GLuint list);
-extern GLboolean _gamma_IsTexture(GLuint texture);
-extern void _gamma_LightModelf(GLenum pname, GLfloat param);
-extern void _gamma_LightModelfv(GLenum pname, const GLfloat *params);
-extern void _gamma_LightModeli(GLenum pname, GLint param);
-extern void _gamma_LightModeliv(GLenum pname, const GLint *params);
-extern void _gamma_Lightf(GLenum light, GLenum pname, GLfloat param);
-extern void _gamma_Lightfv(GLenum light, GLenum pname, const GLfloat *params);
-extern void _gamma_Lighti(GLenum light, GLenum pname, GLint param);
-extern void _gamma_Lightiv(GLenum light, GLenum pname, const GLint *params);
-extern void _gamma_LineStipple(GLint factor, GLushort pattern);
-extern void _gamma_LineWidth(GLfloat width);
-extern void _gamma_ListBase(GLuint base);
-extern void _gamma_LoadIdentity(void);
-extern void _gamma_LoadMatrixd(const GLdouble *m);
-extern void _gamma_LoadMatrixf(const GLfloat *m);
-extern void _gamma_LoadName(GLuint name);
-extern void _gamma_LogicOp(GLenum opcode);
-extern void _gamma_Map1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *pnts);
-extern void _gamma_Map1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *pnts);
-extern void _gamma_Map2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord, GLdouble v1, GLdouble v2, GLint vstr, GLint vord, const GLdouble *pnts);
-extern void _gamma_Map2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord, const GLfloat *pnts);
-extern void _gamma_MapGrid1d(GLint un, GLdouble u1, GLdouble u2);
-extern void _gamma_MapGrid1f(GLint un, GLfloat u1, GLfloat u2);
-extern void _gamma_MapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
-extern void _gamma_MapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
-extern void _gamma_Materialf(GLenum face, GLenum pname, GLfloat param);
-extern void _gamma_Materialfv(GLenum face, GLenum pname, const GLfloat *params);
-extern void _gamma_Materiali(GLenum face, GLenum pname, GLint param);
-extern void _gamma_Materialiv(GLenum face, GLenum pname, const GLint *params);
-extern void _gamma_MatrixMode(GLenum mode);
-extern void _gamma_MultMatrixd(const GLdouble *m);
-extern void _gamma_MultMatrixf(const GLfloat *m);
-extern void _gamma_NewList(GLuint list, GLenum mode);
-extern void _gamma_Normal3b(GLbyte nx, GLbyte ny, GLbyte nz);
-extern void _gamma_Normal3bv(const GLbyte *v);
-extern void _gamma_Normal3d(GLdouble nx, GLdouble ny, GLdouble nz);
-extern void _gamma_Normal3dv(const GLdouble *v);
-extern void _gamma_Normal3f(GLfloat nx, GLfloat ny, GLfloat nz);
-extern void _gamma_Normal3fv(const GLfloat *v);
-extern void _gamma_Normal3i(GLint nx, GLint ny, GLint nz);
-extern void _gamma_Normal3iv(const GLint *v);
-extern void _gamma_Normal3s(GLshort nx, GLshort ny, GLshort nz);
-extern void _gamma_Normal3sv(const GLshort *v);
-extern void _gamma_NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer);
-extern void _gamma_Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
-extern void _gamma_PassThrough(GLfloat token);
-extern void _gamma_PixelMapfv(GLenum map, GLint mapsize, const GLfloat *values);
-extern void _gamma_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values);
-extern void _gamma_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values);
-extern void _gamma_PixelStoref(GLenum pname, GLfloat param);
-extern void _gamma_PixelStorei(GLenum pname, GLint param);
-extern void _gamma_PixelTransferf(GLenum pname, GLfloat param);
-extern void _gamma_PixelTransferi(GLenum pname, GLint param);
-extern void _gamma_PixelZoom(GLfloat xfactor, GLfloat yfactor);
-extern void _gamma_PointSize(GLfloat size);
-extern void _gamma_PolygonMode(GLenum face, GLenum mode);
-extern void _gamma_PolygonOffset(GLfloat factor, GLfloat units);
-extern void _gamma_PolygonStipple(const GLubyte *mask);
-extern void _gamma_PopAttrib(void);
-extern void _gamma_PopClientAttrib(void);
-extern void _gamma_PopMatrix(void);
-extern void _gamma_PopName(void);
-extern void _gamma_PrioritizeTextures(GLsizei n, const GLuint *textures, const GLclampf *priorities);
-extern void _gamma_PushAttrib(GLbitfield mask);
-extern void _gamma_PushClientAttrib(GLuint mask);
-extern void _gamma_PushMatrix(void);
-extern void _gamma_PushName(GLuint name);
-extern void _gamma_RasterPos2d(GLdouble x, GLdouble y);
-extern void _gamma_RasterPos2dv(const GLdouble *v);
-extern void _gamma_RasterPos2f(GLfloat x, GLfloat y);
-extern void _gamma_RasterPos2fv(const GLfloat *v);
-extern void _gamma_RasterPos2i(GLint x, GLint y);
-extern void _gamma_RasterPos2iv(const GLint *v);
-extern void _gamma_RasterPos2s(GLshort x, GLshort y);
-extern void _gamma_RasterPos2sv(const GLshort *v);
-extern void _gamma_RasterPos3d(GLdouble x, GLdouble y, GLdouble z);
-extern void _gamma_RasterPos3dv(const GLdouble *v);
-extern void _gamma_RasterPos3f(GLfloat x, GLfloat y, GLfloat z);
-extern void _gamma_RasterPos3fv(const GLfloat *v);
-extern void _gamma_RasterPos3i(GLint x, GLint y, GLint z);
-extern void _gamma_RasterPos3iv(const GLint *v);
-extern void _gamma_RasterPos3s(GLshort x, GLshort y, GLshort z);
-extern void _gamma_RasterPos3sv(const GLshort *v);
-extern void _gamma_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-extern void _gamma_RasterPos4dv(const GLdouble *v);
-extern void _gamma_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-extern void _gamma_RasterPos4fv(const GLfloat *v);
-extern void _gamma_RasterPos4i(GLint x, GLint y, GLint z, GLint w);
-extern void _gamma_RasterPos4iv(const GLint *v);
-extern void _gamma_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w);
-extern void _gamma_RasterPos4sv(const GLshort *v);
-extern void _gamma_ReadBuffer(GLenum mode);
-extern void _gamma_ReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
-extern void _gamma_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
-extern void _gamma_Rectdv(const GLdouble *v1, const GLdouble *v2);
-extern void _gamma_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
-extern void _gamma_Rectfv(const GLfloat *v1, const GLfloat *v2);
-extern void _gamma_Recti(GLint x1, GLint y1, GLint x2, GLint y2);
-extern void _gamma_Rectiv(const GLint *v1, const GLint *v2);
-extern void _gamma_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
-extern void _gamma_Rectsv(const GLshort *v1, const GLshort *v2);
-extern GLint _gamma_RenderMode(GLenum mode);
-extern void _gamma_Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
-extern void _gamma_Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
-extern void _gamma_Scaled(GLdouble x, GLdouble y, GLdouble z);
-extern void _gamma_Scalef(GLfloat x, GLfloat y, GLfloat z);
-extern void _gamma_Scissor(GLint x, GLint y, GLsizei width, GLsizei height);
-extern void _gamma_SelectBuffer(GLsizei numnames, GLuint *buffer);
-extern void _gamma_ShadeModel(GLenum mode);
-extern void _gamma_StencilFunc(GLenum func, GLint ref, GLuint mask);
-extern void _gamma_StencilMask(GLuint mask);
-extern void _gamma_StencilOp(GLenum fail, GLenum zfail, GLenum zpass);
-extern void _gamma_TexCoord1d(GLdouble s);
-extern void _gamma_TexCoord1dv(const GLdouble *v);
-extern void _gamma_TexCoord1f(GLfloat s);
-extern void _gamma_TexCoord1fv(const GLfloat *v);
-extern void _gamma_TexCoord1i(GLint s);
-extern void _gamma_TexCoord1iv(const GLint *v);
-extern void _gamma_TexCoord1s(GLshort s);
-extern void _gamma_TexCoord1sv(const GLshort *v);
-extern void _gamma_TexCoord2d(GLdouble s, GLdouble t);
-extern void _gamma_TexCoord2dv(const GLdouble *v);
-extern void _gamma_TexCoord2f(GLfloat s, GLfloat t);
-extern void _gamma_TexCoord2fv(const GLfloat *v);
-extern void _gamma_TexCoord2i(GLint s, GLint t);
-extern void _gamma_TexCoord2iv(const GLint *v);
-extern void _gamma_TexCoord2s(GLshort s, GLshort t);
-extern void _gamma_TexCoord2sv(const GLshort *v);
-extern void _gamma_TexCoord3d(GLdouble s, GLdouble t, GLdouble r);
-extern void _gamma_TexCoord3dv(const GLdouble *v);
-extern void _gamma_TexCoord3f(GLfloat s, GLfloat t, GLfloat r);
-extern void _gamma_TexCoord3fv(const GLfloat *v);
-extern void _gamma_TexCoord3i(GLint s, GLint t, GLint r);
-extern void _gamma_TexCoord3iv(const GLint *v);
-extern void _gamma_TexCoord3s(GLshort s, GLshort t, GLshort r);
-extern void _gamma_TexCoord3sv(const GLshort *v);
-extern void _gamma_TexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-extern void _gamma_TexCoord4dv(const GLdouble *v);
-extern void _gamma_TexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-extern void _gamma_TexCoord4fv(const GLfloat *v);
-extern void _gamma_TexCoord4i(GLint s, GLint t, GLint r, GLint q);
-extern void _gamma_TexCoord4iv(const GLint *v);
-extern void _gamma_TexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q);
-extern void _gamma_TexCoord4sv(const GLshort *v);
-extern void _gamma_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-extern void _gamma_TexEnvf(GLenum target, GLenum pname, GLfloat param);
-extern void _gamma_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params);
-extern void _gamma_TexEnvi(GLenum target, GLenum pname, GLint param);
-extern void _gamma_TexEnviv(GLenum target, GLenum pname, const GLint *params);
-extern void _gamma_TexGend(GLenum coord, GLenum pname, GLdouble param);
-extern void _gamma_TexGendv(GLenum coord, GLenum pname, const GLdouble *params);
-extern void _gamma_TexGenf(GLenum coord, GLenum pname, GLfloat param);
-extern void _gamma_TexGenfv(GLenum coord, GLenum pname, const GLfloat *params);
-extern void _gamma_TexGeni(GLenum coord, GLenum pname, GLint param);
-extern void _gamma_TexGeniv(GLenum coord, GLenum pname, const GLint *params);
-extern void _gamma_TexImage1D(GLenum target, GLint level, GLint components, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *image);
-extern void _gamma_TexImage2D(GLenum target, GLint level, GLint components, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *image);
-extern void _gamma_TexParameterf(GLenum target, GLenum pname, GLfloat param);
-extern void _gamma_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params);
-extern void _gamma_TexParameteri(GLenum target, GLenum pname, GLint param);
-extern void _gamma_TexParameteriv(GLenum target, GLenum pname, const GLint *params);
-extern void _gamma_TexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-extern void _gamma_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-extern void _gamma_Translated(GLdouble x, GLdouble y, GLdouble z);
-extern void _gamma_Translatef(GLfloat x, GLfloat y, GLfloat z);
-extern void _gamma_Vertex2d(GLdouble x, GLdouble y);
-extern void _gamma_Vertex2dv(const GLdouble *v);
-extern void _gamma_Vertex2f(GLfloat x, GLfloat y);
-extern void _gamma_Vertex2fv(const GLfloat *v);
-extern void _gamma_Vertex2i(GLint x, GLint y);
-extern void _gamma_Vertex2iv(const GLint *v);
-extern void _gamma_Vertex2s(GLshort x, GLshort y);
-extern void _gamma_Vertex2sv(const GLshort *v);
-extern void _gamma_Vertex3d(GLdouble x, GLdouble y, GLdouble z);
-extern void _gamma_Vertex3dv(const GLdouble *v);
-extern void _gamma_Vertex3f(GLfloat x, GLfloat y, GLfloat z);
-extern void _gamma_Vertex3fv(const GLfloat *v);
-extern void _gamma_Vertex3i(GLint x, GLint y, GLint z);
-extern void _gamma_Vertex3iv(const GLint *v);
-extern void _gamma_Vertex3s(GLshort x, GLshort y, GLshort z);
-extern void _gamma_Vertex3sv(const GLshort *v);
-extern void _gamma_Vertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-extern void _gamma_Vertex4dv(const GLdouble *v);
-extern void _gamma_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-extern void _gamma_Vertex4fv(const GLfloat *v);
-extern void _gamma_Vertex4i(GLint x, GLint y, GLint z, GLint w);
-extern void _gamma_Vertex4iv(const GLint *v);
-extern void _gamma_Vertex4s(GLshort x, GLshort y, GLshort z, GLshort w);
-extern void _gamma_Vertex4sv(const GLshort *v);
-extern void _gamma_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-extern void _gamma_Viewport(GLint x, GLint y, GLsizei width, GLsizei height);
-
-
-extern void _gamma_init_exec(struct _glapi_table *dispatch);
-extern void _gamma_init_save(struct _glapi_table *dispatch);
-
-#endif /* _GAMMA_GL_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.c
deleted file mode 100644
index 1bb9e2361..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_init.c,v 1.2 2000/02/23 04:46:43 martin Exp $ */
-/**************************************************************************
-
-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>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-#include "xf86dri.h"
-#include "glint_dri.h"
-#include "gamma_init.h"
-
-static void performMagic(__DRIscreenPrivate *driScrnPriv)
-{
- gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private;
- GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
-
- gPriv->regionCount = 4; /* Magic number. Can we fix this? */
-
- gPriv->regions = Xmalloc(gPriv->regionCount * sizeof(gammaRegion));
-
- gPriv->regions[0].handle = gDRIPriv->hControlRegs0;
- gPriv->regions[0].size = gDRIPriv->sizeControlRegs0;
- gPriv->regions[1].handle = gDRIPriv->hControlRegs1;
- gPriv->regions[1].size = gDRIPriv->sizeControlRegs1;
- gPriv->regions[2].handle = gDRIPriv->hControlRegs2;
- gPriv->regions[2].size = gDRIPriv->sizeControlRegs2;
- gPriv->regions[3].handle = gDRIPriv->hControlRegs3;
- gPriv->regions[3].size = gDRIPriv->sizeControlRegs3;
-}
-
-GLboolean gammaMapAllRegions(__DRIscreenPrivate *driScrnPriv)
-{
- gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private;
- int i;
-
- /* First, pick apart pDevPriv & friends */
- performMagic(driScrnPriv);
-
- /* Next, map all the regions */
- for (i = 0; i < gPriv->regionCount; i++) {
- if (drmMap(driScrnPriv->fd,
- gPriv->regions[i].handle,
- gPriv->regions[i].size,
- &gPriv->regions[i].map)) {
- while (--i > 0) {
- (void)drmUnmap(gPriv->regions[i].map, gPriv->regions[i].size);
- }
- return GL_FALSE;
- }
- }
-
- /* Get the list of dma buffers */
- gPriv->bufs = drmMapBufs(driScrnPriv->fd);
- if (!gPriv->bufs) {
- while (gPriv->regionCount > 0) {
- (void)drmUnmap(gPriv->regions[gPriv->regionCount].map,
- gPriv->regions[gPriv->regionCount].size);
- gPriv->regionCount--;
- }
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-void gammaUnmapAllRegions(__DRIscreenPrivate *driScrnPriv)
-{
- gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private;
-
- /* First, unmap the dma buffers */
- drmUnmapBufs(gPriv->bufs);
-
- /* Next, unmap all the regions */
- while (gPriv->regionCount > 0) {
- (void)drmUnmap(gPriv->regions[gPriv->regionCount].map,
- gPriv->regions[gPriv->regionCount].size);
- gPriv->regionCount--;
- }
- Xfree(gPriv->regions);
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h
deleted file mode 100644
index ecf33b959..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_init.h,v 1.4 2001/02/07 13:26:16 alanh Exp $ */
-/**************************************************************************
-
-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>
- *
- */
-
-#ifndef _GAMMA_INIT_H_
-#define _GAMMA_INIT_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "gamma_region.h"
-#include "gamma_regs.h"
-#include "gamma_macros.h"
-#include "gamma_texture.h"
-
-typedef struct {
- int regionCount; /* Count of register regions */
- gammaRegion *regions; /* Vector of mapped region info */
- drmBufMapPtr bufs; /* Map of DMA buffers */
- __DRIscreenPrivate *driScrnPriv; /* Back pointer to DRI screen */
-} gammaScreenPrivate;
-
-typedef union {
- unsigned int i;
- float f;
-} dmaBufRec, *dmaBuf;
-
-/* Flags for context */
-#define GAMMA_FRONT_BUFFER 0x00000001
-#define GAMMA_BACK_BUFFER 0x00000002
-#define GAMMA_DEPTH_BUFFER 0x00000004
-#define GAMMA_STENCIL_BUFFER 0x00000008
-#define GAMMA_ACCUM_BUFFER 0x00000010
-
-#define GAMMA_MAX_TEXTURE_SIZE 2048
-
-/* These are the minimum requirements and should probably be increased */
-#define MAX_MODELVIEW_STACK 16
-#define MAX_PROJECTION_STACK 2
-#define MAX_TEXTURE_STACK 2
-
-struct gamma_current_attrib {
-/* GLubyte ByteColor[4]; old */ /* Current RGBA color */
- GLuint Index; /* Current color index */
- GLfloat Color[4]; /* Current RGBA color */
- GLfloat Normal[3]; /* Current normal vector */
- GLfloat TexCoord[4]; /* points into MultiTexCoord */
- GLfloat RasterPos[4]; /* Current raster position */
- GLfloat RasterDistance; /* Current raster distance */
- GLfloat RasterColor[4]; /* Current raster color */
- GLuint RasterIndex; /* Current raster index */
- GLfloat *RasterTexCoord; /* Current raster texcoord*/
- GLboolean RasterPosValid; /* Raster po valid flag */
- GLboolean EdgeFlag; /* Current edge flag */
-};
-
-struct gamma_array_attrib {
- GLint VertexSize;
- GLenum VertexType;
- GLsizei VertexStride; /* user-specified stride */
- GLsizei VertexStrideB; /* actual stride in bytes */
- void *VertexPtr;
- GLboolean VertexEnabled;
-
- GLenum NormalType;
- GLsizei NormalStride; /* user-specified stride */
- GLsizei NormalStrideB; /* actual stride in bytes */
- void *NormalPtr;
- GLboolean NormalEnabled;
-
- GLint ColorSize;
- GLenum ColorType;
- GLsizei ColorStride; /* user-specified stride */
- GLsizei ColorStrideB; /* actual stride in bytes */
- void *ColorPtr;
- GLboolean ColorEnabled;
-
- GLenum IndexType;
- GLsizei IndexStride; /* user-specified stride */
- GLsizei IndexStrideB; /* actual stride in bytes */
- void *IndexPtr;
- GLboolean IndexEnabled;
-
- GLsizei EdgeFlagStride; /* user-specified stride */
- GLsizei EdgeFlagStrideB; /* actual stride in bytes */
- GLboolean *EdgeFlagPtr;
- GLboolean EdgeFlagEnabled;
-
- GLint TexCoordSize;
- GLenum TexCoordType;
- GLsizei TexCoordStride; /* user-specified stride */
- GLsizei TexCoordStrideB; /* actual stride in bytes */
- void *TexCoordPtr;
- GLboolean TexCoordEnabled;
- GLint TexCoordInterleaveFactor;
-};
-
-typedef struct {
- drmContext hHWContext;
-
- dmaBuf buf; /* DMA buffer for regular cmds */
- int bufIndex;
- int bufSize;
- int bufCount;
-
- dmaBuf WCbuf; /* DMA buffer for window changed cmds */
- int WCbufIndex;
- int WCbufSize;
- int WCbufCount;
-
- gammaScreenPrivate *gammaScrnPriv;
-
- int x, y, w, h; /* Probably should be in drawable priv */
- int FrameCount; /* Probably should be in drawable priv */
- int NotClipped; /* Probably should be in drawable priv */
- int WindowChanged; /* Probably should be in drawabl... */
- int Flags;
- int EnabledFlags;
- int DepthSize;
- int Begin;
- GLenum ErrorValue;
-
- struct _glapi_table *Exec;
- struct _glapi_table *Save;
- struct _glapi_table *API;
-
- struct _mesa_HashTable *DisplayList;
-
- struct gl_list_attrib List;
- struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */
-
- struct gamma_array_attrib Array; /* From Mesa v3.0 */
- struct gamma_current_attrib Current; /* From Mesa v3.0 */
-
- /* Display lists */
- GLuint CallDepth; /* Current recursion calling depth */
- GLboolean ExecuteFlag; /* Execute GL commands? */
- GLboolean CompileFlag; /* Compile GL commands into display list? */
- Node *CurrentListPtr; /* Head of list being compiled */
- GLuint CurrentListNum; /* Number of the list being compiled */
- Node *CurrentBlock; /* Pointer to current block of nodes */
- GLuint CurrentPos; /* Index into current block of nodes */
-
- float ClearColor[4];
- float ClearDepth;
- int MatrixMode;
- int DepthMode;
- int TransformMode;
- float zNear, zFar;
- int LBReadMode;
- int FBReadMode;
- int FBWindowBase;
- int LBWindowBase;
- int ColorDDAMode;
- int GeometryMode;
- int AlphaTestMode;
- int AlphaBlendMode;
- int AB_FBReadMode;
- int AB_FBReadMode_Save;
- int DeltaMode;
- int ColorMaterialMode;
- int MaterialMode;
- int NormalizeMode;
- int LightingMode;
- int Light0Mode;
- int Light1Mode;
- int Light2Mode;
- int Light3Mode;
- int Light4Mode;
- int Light5Mode;
- int Light6Mode;
- int Light7Mode;
- int Light8Mode;
- int Light9Mode;
- int Light10Mode;
- int Light11Mode;
- int Light12Mode;
- int Light13Mode;
- int Light14Mode;
- int Light15Mode;
- int LogicalOpMode;
- int ScissorMode;
- int Window; /* GID part probably should be in draw priv */
-
- gammaTexObj *curTexObj;
- gammaTexObj *curTexObj1D;
- gammaTexObj *curTexObj2D;
- int Texture1DEnabled;
- int Texture2DEnabled;
-
- driTMMPtr tmm;
-
- float ModelView[16];
- float Proj[16];
- float ModelViewProj[16];
- float Texture[16];
-
- float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
- int ModelViewCount;
- float ProjStack[(MAX_PROJECTION_STACK-1)*16];
- int ProjCount;
- float TextureStack[(MAX_TEXTURE_STACK-1)*16];
- int TextureCount;
-} gammaContextPrivate;
-
-extern GLboolean gammaMapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern void gammaUnmapAllRegions(__DRIscreenPrivate *driScrnPriv);
-extern void gammaSetMatrix(GLfloat m[16]);
-extern void gammaMultMatrix(GLfloat m[16]);
-extern void gammaLoadHWMatrix(void);
-extern void gammaInitHW(gammaContextPrivate *gcp);
-
-extern float IdentityMatrix[16];
-extern __DRIcontextPrivate *nullCC;
-extern __DRIcontextPrivate *gCC;
-extern gammaContextPrivate *gCCPriv;
-
-#endif
-
-#endif /* _GAMMA_INIT_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c
index 6c87559bf..ea0edc545 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c
@@ -1,371 +1,595 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.7 2001/01/31 16:15:37 alanh Exp $ */
-/**************************************************************************
-
-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>
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Kevin E. Martin <martin@valinux.com>
*
*/
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.6 2000/11/27 10:59:37 alanh Exp $ */
-#ifdef GLX_DIRECT_RENDERING
-
-#include "gamma_init.h"
+#include "gamma_context.h"
#include "glint_dri.h"
-void gammaInitHW(gammaContextPrivate *gcp)
+void gammaInitHW( gammaContextPtr gmesa )
{
- __DRIscreenPrivate *driScrnPriv = gcp->gammaScrnPriv->driScrnPriv;
- GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
+ int i;
if (gDRIPriv->numMultiDevices == 2) {
/* Set up each MX's ScanLineOwnership for OpenGL */
- CHECK_DMA_BUFFER(nullCC, gcp, 4);
- WRITE(gcp->buf, BroadcastMask, 1);
- WRITE(gcp->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */
- WRITE(gcp->buf, BroadcastMask, 2);
- WRITE(gcp->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */
-
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, BroadcastMask, 1);
+ WRITE(gmesa->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */
+ WRITE(gmesa->buf, BroadcastMask, 2);
+ WRITE(gmesa->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */
/* Broadcast to both MX's */
- CHECK_DMA_BUFFER(nullCC, gcp, 1);
- WRITE(gcp->buf, BroadcastMask, 3);
+ WRITE(gmesa->buf, BroadcastMask, 3);
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+
+ gmesa->AlphaBlendMode = (AlphaBlendModeDisable |
+ AB_Src_One |
+ AB_Dst_Zero |
+ AB_NoAlphaBufferPresent |
+ AB_ColorFmt_8888 |
+ AB_ColorOrder_RGB |
+ AB_OpenGLType |
+ AB_AlphaDst_FBData |
+ AB_ColorConversionScale |
+ AB_AlphaConversionScale);
+
+ gmesa->DitherMode = DitherModeEnable | DM_ColorOrder_RGB;
+
+ switch (gmesa->gammaScreen->cpp) {
+ case 2:
+ gmesa->DitherMode |= DM_ColorFmt_5555;
+ gmesa->AlphaBlendMode |= AB_ColorFmt_5555;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PixelSize, 1);
+ break;
+ case 4:
+ gmesa->DitherMode |= DM_ColorFmt_8888;
+ gmesa->AlphaBlendMode |= AB_ColorFmt_8888;
+ WRITE(gmesa->buf, PixelSize, 0);
+ break;
+ }
+
+ /* FIXME for stencil, gid, etc */
+ switch (gmesa->DepthSize) {
+ case 16:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth16 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos16 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos24 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos32 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth16 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos16 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos24 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos32 );
+ break;
+ case 24:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth24 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos24 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos32 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos36 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth24 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos24 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos32 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos36 );
+ break;
+ case 32:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth32 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos32 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos40 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos44 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth32 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos32 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos40 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos44 );
+ break;
}
+ gmesa->FBHardwareWriteMask = 0xffffffff;
+ gmesa->FogMode = FogModeDisable;
+ gmesa->ClearDepth = 0xffffffff;
+ gmesa->AreaStippleMode = AreaStippleModeDisable;
+ gmesa->x = 0;
+ gmesa->y = 0;
+ gmesa->w = 0;
+ gmesa->h = 0;
+ gmesa->FrameCount = 0;
+ gmesa->MatrixMode = GL_MODELVIEW;
+ gmesa->ModelViewCount = 0;
+ gmesa->ProjCount = 0;
+ gmesa->TextureCount = 0;
+ gmesa->PointMode = PM_AntialiasQuality_4x4;
+ gmesa->LineMode = LM_AntialiasQuality_4x4;
+ gmesa->TriangleMode = TM_AntialiasQuality_4x4;
+ gmesa->AntialiasMode = AntialiasModeDisable;
+
+ for (i = 0; i < 16; i++)
+ if (i % 5 == 0)
+ gmesa->ModelView[i] =
+ gmesa->Proj[i] =
+ gmesa->ModelViewProj[i] =
+ gmesa->Texture[i] = 1.0;
+ else
+ gmesa->ModelView[i] =
+ gmesa->Proj[i] =
+ gmesa->ModelViewProj[i] =
+ gmesa->Texture[i] = 0.0;
+
+ gmesa->LBReadMode = (LBReadSrcDisable |
+ LBReadDstDisable |
+ LBDataTypeDefault |
+ LBWindowOriginBot |
+ gDRIPriv->pprod);
+ gmesa->FBReadMode = (FBReadSrcDisable |
+ FBReadDstDisable |
+ FBDataTypeDefault |
+ FBWindowOriginBot |
+ gDRIPriv->pprod);
+
+ if (gDRIPriv->numMultiDevices == 2) {
+ gmesa->LBReadMode |= LBScanLineInt2;
+ gmesa->FBReadMode |= FBScanLineInt2;
+ gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight/2 - 1);
+ gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight/2 - 1);
+ } else {
+ gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight - 1);
+ gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight - 1);
+ }
+
+ gmesa->Begin = (B_AreaStippleDisable |
+ B_LineStippleDisable |
+ B_AntiAliasDisable |
+ B_TextureDisable |
+ B_FogDisable |
+ B_SubPixelCorrectEnable |
+ B_PrimType_Null);
+
+ gmesa->ColorDDAMode = (ColorDDAEnable |
+ ColorDDAGouraud);
+
+#ifdef CULL_ALL_PRIMS
+ gmesa->GeometryMode = (GM_TextureDisable |
+ GM_FogDisable |
+ GM_FogExp |
+ GM_FrontPolyFill |
+ GM_BackPolyFill |
+ GM_FrontFaceCCW |
+ GM_PolyCullDisable |
+ GM_PolyCullBoth |
+ GM_ClipShortLinesDisable |
+ GM_ClipSmallTrisDisable |
+ GM_RenderMode |
+ GM_Feedback2D |
+ GM_CullFaceNormDisable |
+ GM_AutoFaceNormDisable |
+ GM_GouraudShading |
+ GM_UserClipNone |
+ GM_PolyOffsetPointDisable |
+ GM_PolyOffsetLineDisable |
+ GM_PolyOffsetFillDisable |
+ GM_InvertFaceNormCullDisable);
+#else
+ gmesa->GeometryMode = (GM_TextureDisable |
+ GM_FogDisable |
+ GM_FogExp |
+ GM_FrontPolyFill |
+ GM_BackPolyFill |
+ GM_FrontFaceCCW |
+ GM_PolyCullDisable |
+ GM_PolyCullBack |
+ GM_ClipShortLinesDisable |
+ GM_ClipSmallTrisDisable |
+ GM_RenderMode |
+ GM_Feedback2D |
+ GM_CullFaceNormDisable |
+ GM_AutoFaceNormDisable |
+ GM_GouraudShading |
+ GM_UserClipNone |
+ GM_PolyOffsetPointDisable |
+ GM_PolyOffsetLineDisable |
+ GM_PolyOffsetFillDisable |
+ GM_InvertFaceNormCullDisable);
+#endif
+
+ gmesa->AlphaTestMode = (AlphaTestModeDisable |
+ AT_Always);
+
+ gmesa->AB_FBReadMode_Save = gmesa->AB_FBReadMode = 0;
+
+ gmesa->Window = (WindowEnable | /* For GID testing */
+ W_PassIfEqual |
+ (0 << 5)); /* GID part is set from draw priv (below) */
+
+ gmesa->NotClipped = GL_FALSE;
+ gmesa->WindowChanged = GL_TRUE;
+
+ gmesa->Texture1DEnabled = GL_FALSE;
+ gmesa->Texture2DEnabled = GL_FALSE;
+
+ gmesa->DepthMode |= (DepthModeDisable |
+ DM_WriteMask |
+ DM_Less);
+
+ gmesa->DeltaMode |= (DM_SubPixlCorrectionEnable |
+ DM_SmoothShadingEnable |
+ DM_Target500TXMX);
+
+ gmesa->LightingMode = LightingModeDisable | LightingModeSpecularEnable;
+ gmesa->Light0Mode = LNM_Off;
+ gmesa->Light1Mode = LNM_Off;
+ gmesa->Light2Mode = LNM_Off;
+ gmesa->Light3Mode = LNM_Off;
+ gmesa->Light4Mode = LNM_Off;
+ gmesa->Light5Mode = LNM_Off;
+ gmesa->Light6Mode = LNM_Off;
+ gmesa->Light7Mode = LNM_Off;
+ gmesa->Light8Mode = LNM_Off;
+ gmesa->Light9Mode = LNM_Off;
+ gmesa->Light10Mode = LNM_Off;
+ gmesa->Light11Mode = LNM_Off;
+ gmesa->Light12Mode = LNM_Off;
+ gmesa->Light13Mode = LNM_Off;
+ gmesa->Light14Mode = LNM_Off;
+ gmesa->Light15Mode = LNM_Off;
+
+ gmesa->LogicalOpMode = LogicalOpModeDisable;
+
+ gmesa->MaterialMode = MaterialModeDisable;
+
+ gmesa->ScissorMode = UserScissorDisable | ScreenScissorDisable;
+
+ gmesa->TransformMode = XM_UseModelViewProjMatrix |
+ XM_TexGenModeS_None |
+ XM_TexGenModeT_None |
+ XM_TexGenModeR_None |
+ XM_TexGenModeQ_None;
+
/* Set MXs to known state */
- CHECK_DMA_BUFFER(nullCC, gcp, 27);
- WRITE(gcp->buf, RasterizerMode, 0);
- WRITE(gcp->buf, AreaStippleMode, 0);
- WRITE(gcp->buf, LineStippleMode, 0);
- WRITE(gcp->buf, ScissorMode, 0);
- WRITE(gcp->buf, RouterMode, 0);
- WRITE(gcp->buf, TextureAddressMode, 0);
- WRITE(gcp->buf, TextureReadMode, 0);
- WRITE(gcp->buf, TextureFilterMode, 0);
- WRITE(gcp->buf, ColorDDAMode, 0);
- WRITE(gcp->buf, TextureColorMode, 0);
- WRITE(gcp->buf, FogMode, 0);
- WRITE(gcp->buf, AntialiasMode, 0);
- WRITE(gcp->buf, AlphaTestMode, 0);
- WRITE(gcp->buf, LBReadMode, 0);
- WRITE(gcp->buf, GLINTWindow, 0);
- WRITE(gcp->buf, StencilMode, 0);
- WRITE(gcp->buf, DepthMode, 0);
- WRITE(gcp->buf, LBWriteMode, 0);
- WRITE(gcp->buf, FBReadMode, 0);
- WRITE(gcp->buf, PatternRamMode, 0);
- WRITE(gcp->buf, AlphaBlendMode, 0);
- WRITE(gcp->buf, ChromaTestMode, 0);
- WRITE(gcp->buf, DitherMode, 0);
- WRITE(gcp->buf, LogicalOpMode, 0);
- WRITE(gcp->buf, FBWriteMode, 0);
- WRITE(gcp->buf, StatisticMode, 0);
- WRITE(gcp->buf, PixelSize, 0);
+ CHECK_DMA_BUFFER(gmesa, 24);
+ WRITE(gmesa->buf, RasterizerMode, 0);
+ WRITE(gmesa->buf, AreaStippleMode, 0);
+ WRITE(gmesa->buf, LineStippleMode, 0);
+ WRITE(gmesa->buf, ScissorMode, 0);
+ WRITE(gmesa->buf, RouterMode, 0);
+ WRITE(gmesa->buf, TextureAddressMode, 0);
+ WRITE(gmesa->buf, TextureReadMode, 0);
+ WRITE(gmesa->buf, TextureFilterMode, 0);
+ WRITE(gmesa->buf, ColorDDAMode, 0);
+ WRITE(gmesa->buf, TextureColorMode, 0);
+ WRITE(gmesa->buf, FogMode, 0);
+ WRITE(gmesa->buf, AntialiasMode, 0);
+ WRITE(gmesa->buf, LBReadMode, 0);
+ WRITE(gmesa->buf, GLINTWindow, 0);
+ WRITE(gmesa->buf, StencilMode, 0);
+ WRITE(gmesa->buf, DepthMode, 0);
+ WRITE(gmesa->buf, LBWriteMode, 0);
+ WRITE(gmesa->buf, FBReadMode, 0);
+ WRITE(gmesa->buf, PatternRamMode, 0);
+ WRITE(gmesa->buf, ChromaTestMode, 0);
+ WRITE(gmesa->buf, DitherMode, 0);
+ WRITE(gmesa->buf, LogicalOpMode, 0);
+ WRITE(gmesa->buf, FBWriteMode, 0);
+ WRITE(gmesa->buf, StatisticMode, 0);
/* Set Gamma to known state */
- CHECK_DMA_BUFFER(nullCC, gcp, 10);
- WRITE(gcp->buf, TriangleMode, 0);
- WRITE(gcp->buf, GeometryMode, 0);
- WRITE(gcp->buf, NormalizeMode, 0);
- WRITE(gcp->buf, LightingMode, 0);
- WRITE(gcp->buf, ColorMaterialMode, 0);
- WRITE(gcp->buf, MaterialMode, 0);
- WRITE(gcp->buf, PointMode, 0);
- WRITE(gcp->buf, LineMode, 0);
- WRITE(gcp->buf, TransformMode, 0);
- WRITE(gcp->buf, DeltaMode, 0);
-
-#ifdef FORCE_DEPTH32
- CHECK_DMA_BUFFER(nullCC, gcp, 2);
- WRITE(gcp->buf, LBWriteFormat, 0x00000d4a);
- WRITE(gcp->buf, LBReadFormat, 0x00000d4a);
-#endif
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
+ WRITE(gmesa->buf, GeometryMode, 0);
+ WRITE(gmesa->buf, NormalizeMode, 0);
+ WRITE(gmesa->buf, ColorMaterialMode, 0);
+ WRITE(gmesa->buf, MaterialMode, 0);
+ WRITE(gmesa->buf, PointMode, gmesa->PointMode);
+ WRITE(gmesa->buf, LineMode, gmesa->LineMode);
+ WRITE(gmesa->buf, TransformMode, 0);
+ WRITE(gmesa->buf, DeltaMode, 0);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LBWriteFormat, gmesa->LBWriteFormat);
+ WRITE(gmesa->buf, LBReadFormat, gmesa->LBReadFormat);
/* Framebuffer initialization */
- CHECK_DMA_BUFFER(nullCC, gcp, 10);
- WRITE(gcp->buf, FBSourceData, 0);
- WRITE(gcp->buf, FBReadMode, gcp->FBReadMode);
- if (gcp->EnabledFlags & GAMMA_BACK_BUFFER)
- WRITE(gcp->buf, FBPixelOffset,
- (driScrnPriv->fbHeight/2)*driScrnPriv->fbWidth);
- else
- WRITE(gcp->buf, FBPixelOffset, 0);
- WRITE(gcp->buf, FBSourceOffset, 0);
- WRITE(gcp->buf, FBHardwareWriteMask, 0xffffffff);
- WRITE(gcp->buf, FBSoftwareWriteMask, 0xffffffff);
- WRITE(gcp->buf, FBWriteMode, FBWriteModeEnable);
- WRITE(gcp->buf, FBWindowBase, gcp->FBWindowBase);
- WRITE(gcp->buf, ScreenSize, ((driScrnPriv->fbHeight << 16) |
- (driScrnPriv->fbWidth)));
- WRITE(gcp->buf, WindowOrigin, 0x00000000);
+ CHECK_DMA_BUFFER(gmesa, 10);
+ WRITE(gmesa->buf, FBSourceData, 0);
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
+ if (gDRIPriv->numMultiDevices == 2) {
+ WRITE(gmesa->buf, FBPixelOffset,
+ (gmesa->driScreen->fbHeight/2)*gmesa->driScreen->fbWidth);
+ } else {
+ WRITE(gmesa->buf, FBPixelOffset,
+ gmesa->driScreen->fbHeight*gmesa->driScreen->fbWidth);
+ }
+ } else
+ WRITE(gmesa->buf, FBPixelOffset, 0);
+ WRITE(gmesa->buf, FBSourceOffset, 0);
+ WRITE(gmesa->buf, FBHardwareWriteMask, 0xffffffff);
+ WRITE(gmesa->buf, FBSoftwareWriteMask, 0xffffffff);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, FBWindowBase, gmesa->FBWindowBase);
+ WRITE(gmesa->buf, ScreenSize, ((gmesa->driScreen->fbHeight << 16) |
+ (gmesa->driScreen->fbWidth)));
+ WRITE(gmesa->buf, WindowOrigin, 0x00000000);
/* Localbuffer initialization */
- CHECK_DMA_BUFFER(nullCC, gcp, 5);
- WRITE(gcp->buf, LBReadMode, gcp->LBReadMode);
- WRITE(gcp->buf, LBSourceOffset, 0);
- WRITE(gcp->buf, LBWriteMode, LBWriteModeEnable);
- WRITE(gcp->buf, LBWindowOffset, 0);
- WRITE(gcp->buf, LBWindowBase, gcp->LBWindowBase);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 1);
- WRITE(gcp->buf, Rectangle2DControl, 1);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 11);
- WRITE(gcp->buf, DepthMode, gcp->DepthMode);
- WRITE(gcp->buf, ColorDDAMode, gcp->ColorDDAMode);
- WRITE(gcp->buf, FBBlockColor, 0x00000000);
- WRITE(gcp->buf, ConstantColor, 0x00000000);
- WRITE(gcp->buf, AlphaTestMode, gcp->AlphaTestMode);
- WRITE(gcp->buf, AlphaBlendMode, gcp->AlphaBlendMode);
- WRITE(gcp->buf, DitherMode, DitherModeEnable | DM_ColorOrder_RGB);
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, LBSourceOffset, 0);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ WRITE(gmesa->buf, LBWindowOffset, 0);
+ WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+
+ CHECK_DMA_BUFFER(gmesa, 11);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ WRITE(gmesa->buf, FBBlockColor, 0x00000000);
+ WRITE(gmesa->buf, ConstantColor, 0x00000000);
+ WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
if (gDRIPriv->numMultiDevices == 2)
- WRITE(gcp->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf);
+ WRITE(gmesa->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf);
else
- WRITE(gcp->buf, RasterizerMode, RM_BiasCoordNearHalf);
- WRITE(gcp->buf, GLINTWindow, gcp->Window);
- WRITE(gcp->buf, FastClearDepth, 0xffffffff);
- WRITE(gcp->buf, GLINTDepth, 0xffffffff);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 1);
- WRITE(gcp->buf, TextureColorMode, gcp->curTexObj->TextureColorMode);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 1);
- WRITE(gcp->buf, EdgeFlag, EdgeFlagEnable);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 16);
- WRITEF(gcp->buf, ModelViewMatrix0, 1.0);
- WRITEF(gcp->buf, ModelViewMatrix1, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix2, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix3, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix4, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix5, 1.0);
- WRITEF(gcp->buf, ModelViewMatrix6, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix7, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix8, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix9, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix10, 1.0);
- WRITEF(gcp->buf, ModelViewMatrix11, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix12, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix13, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix14, 0.0);
- WRITEF(gcp->buf, ModelViewMatrix15, 1.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 16);
- WRITEF(gcp->buf, ModelViewProjectionMatrix0, 1.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix1, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix2, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix3, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix4, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix5, 1.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix6, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix7, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix8, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix9, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix10, 1.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix11, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix12, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix13, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix14, 0.0);
- WRITEF(gcp->buf, ModelViewProjectionMatrix15, 1.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 16);
- WRITEF(gcp->buf, TextureMatrix0, 1.0);
- WRITEF(gcp->buf, TextureMatrix1, 0.0);
- WRITEF(gcp->buf, TextureMatrix2, 0.0);
- WRITEF(gcp->buf, TextureMatrix3, 0.0);
- WRITEF(gcp->buf, TextureMatrix4, 0.0);
- WRITEF(gcp->buf, TextureMatrix5, 1.0);
- WRITEF(gcp->buf, TextureMatrix6, 0.0);
- WRITEF(gcp->buf, TextureMatrix7, 0.0);
- WRITEF(gcp->buf, TextureMatrix8, 0.0);
- WRITEF(gcp->buf, TextureMatrix9, 0.0);
- WRITEF(gcp->buf, TextureMatrix10, 1.0);
- WRITEF(gcp->buf, TextureMatrix11, 0.0);
- WRITEF(gcp->buf, TextureMatrix12, 0.0);
- WRITEF(gcp->buf, TextureMatrix13, 0.0);
- WRITEF(gcp->buf, TextureMatrix14, 0.0);
- WRITEF(gcp->buf, TextureMatrix15, 1.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 16);
- WRITEF(gcp->buf, TexGen0, 0.0);
- WRITEF(gcp->buf, TexGen1, 0.0);
- WRITEF(gcp->buf, TexGen2, 0.0);
- WRITEF(gcp->buf, TexGen3, 0.0);
- WRITEF(gcp->buf, TexGen4, 0.0);
- WRITEF(gcp->buf, TexGen5, 0.0);
- WRITEF(gcp->buf, TexGen6, 0.0);
- WRITEF(gcp->buf, TexGen7, 0.0);
- WRITEF(gcp->buf, TexGen8, 0.0);
- WRITEF(gcp->buf, TexGen9, 0.0);
- WRITEF(gcp->buf, TexGen10, 0.0);
- WRITEF(gcp->buf, TexGen11, 0.0);
- WRITEF(gcp->buf, TexGen12, 0.0);
- WRITEF(gcp->buf, TexGen13, 0.0);
- WRITEF(gcp->buf, TexGen14, 0.0);
- WRITEF(gcp->buf, TexGen15, 0.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 9);
- WRITEF(gcp->buf, NormalMatrix0, 1.0);
- WRITEF(gcp->buf, NormalMatrix1, 0.0);
- WRITEF(gcp->buf, NormalMatrix2, 0.0);
- WRITEF(gcp->buf, NormalMatrix3, 0.0);
- WRITEF(gcp->buf, NormalMatrix4, 1.0);
- WRITEF(gcp->buf, NormalMatrix5, 0.0);
- WRITEF(gcp->buf, NormalMatrix6, 0.0);
- WRITEF(gcp->buf, NormalMatrix7, 0.0);
- WRITEF(gcp->buf, NormalMatrix8, 1.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 3);
- WRITEF(gcp->buf, FogDensity, 0.0);
- WRITEF(gcp->buf, FogEnd, 0.0);
- WRITEF(gcp->buf, FogScale, 0.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 2);
- WRITEF(gcp->buf, LineClipLengthThreshold, 0.0);
- WRITEF(gcp->buf, TriangleClipAreaThreshold, 0.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 5);
- WRITE(gcp->buf, GeometryMode, gcp->GeometryMode);
- WRITE(gcp->buf, NormalizeMode, NormalizeModeDisable);
- WRITE(gcp->buf, LightingMode, gcp->LightingMode);
- WRITE(gcp->buf, ColorMaterialMode, ColorMaterialModeDisable);
- WRITE(gcp->buf, MaterialMode, MaterialModeDisable);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 2);
- WRITE(gcp->buf, FrontSpecularExponent, 0); /* fixed point */
- WRITE(gcp->buf, BackSpecularExponent, 0); /* fixed point */
-
- CHECK_DMA_BUFFER(nullCC, gcp, 29);
- WRITEF(gcp->buf, FrontAmbientColorRed, 0.2);
- WRITEF(gcp->buf, FrontAmbientColorGreen, 0.2);
- WRITEF(gcp->buf, FrontAmbientColorBlue, 0.2);
- WRITEF(gcp->buf, BackAmbientColorRed, 0.2);
- WRITEF(gcp->buf, BackAmbientColorGreen, 0.2);
- WRITEF(gcp->buf, BackAmbientColorBlue, 0.2);
- WRITEF(gcp->buf, FrontDiffuseColorRed, 0.8);
- WRITEF(gcp->buf, FrontDiffuseColorGreen, 0.8);
- WRITEF(gcp->buf, FrontDiffuseColorBlue, 0.8);
- WRITEF(gcp->buf, BackDiffuseColorRed, 0.8);
- WRITEF(gcp->buf, BackDiffuseColorGreen, 0.8);
- WRITEF(gcp->buf, BackDiffuseColorBlue, 0.8);
- WRITEF(gcp->buf, FrontSpecularColorRed, 0.0);
- WRITEF(gcp->buf, FrontSpecularColorGreen, 0.0);
- WRITEF(gcp->buf, FrontSpecularColorBlue, 0.0);
- WRITEF(gcp->buf, BackSpecularColorRed, 0.0);
- WRITEF(gcp->buf, BackSpecularColorGreen, 0.0);
- WRITEF(gcp->buf, BackSpecularColorBlue, 0.0);
- WRITEF(gcp->buf, FrontEmissiveColorRed, 0.0);
- WRITEF(gcp->buf, FrontEmissiveColorGreen, 0.0);
- WRITEF(gcp->buf, FrontEmissiveColorBlue, 0.0);
- WRITEF(gcp->buf, BackEmissiveColorRed, 0.0);
- WRITEF(gcp->buf, BackEmissiveColorGreen, 0.0);
- WRITEF(gcp->buf, BackEmissiveColorBlue, 0.0);
- WRITEF(gcp->buf, SceneAmbientColorRed, 0.2);
- WRITEF(gcp->buf, SceneAmbientColorGreen, 0.2);
- WRITEF(gcp->buf, SceneAmbientColorBlue, 0.2);
- WRITEF(gcp->buf, FrontAlpha, 1.0);
- WRITEF(gcp->buf, BackAlpha, 1.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 8);
- WRITE(gcp->buf, PointMode, (PM_AntialiasDisable |
- PM_AntialiasQuality_4x4));
- WRITE(gcp->buf, PointSize, 1);
- WRITE(gcp->buf, LineMode, (LM_StippleDisable |
- LM_MirrorDisable |
- LM_AntialiasDisable |
- LM_AntialiasQuality_4x4));
- WRITE(gcp->buf, LineWidth, 1);
- WRITE(gcp->buf, LineWidthOffset, 0);
- WRITE(gcp->buf, TriangleMode, (TM_AntialiasDisable |
- TM_AntialiasQuality_4x4 |
- TM_UseTriPacketInterface));
- WRITE(gcp->buf, TransformMode, (XM_UseModelViewProjMatrix |
- XM_TexGenModeS_None |
- XM_TexGenModeT_None |
- XM_TexGenModeR_None |
- XM_TexGenModeQ_None));
- WRITE(gcp->buf, DeltaMode, gcp->DeltaMode);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 16);
- WRITE(gcp->buf, Light0Mode, LNM_Off);
- WRITE(gcp->buf, Light1Mode, LNM_Off);
- WRITE(gcp->buf, Light2Mode, LNM_Off);
- WRITE(gcp->buf, Light3Mode, LNM_Off);
- WRITE(gcp->buf, Light4Mode, LNM_Off);
- WRITE(gcp->buf, Light5Mode, LNM_Off);
- WRITE(gcp->buf, Light6Mode, LNM_Off);
- WRITE(gcp->buf, Light7Mode, LNM_Off);
- WRITE(gcp->buf, Light8Mode, LNM_Off);
- WRITE(gcp->buf, Light9Mode, LNM_Off);
- WRITE(gcp->buf, Light10Mode, LNM_Off);
- WRITE(gcp->buf, Light11Mode, LNM_Off);
- WRITE(gcp->buf, Light12Mode, LNM_Off);
- WRITE(gcp->buf, Light13Mode, LNM_Off);
- WRITE(gcp->buf, Light14Mode, LNM_Off);
- WRITE(gcp->buf, Light15Mode, LNM_Off);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 22);
- WRITEF(gcp->buf, Light0AmbientIntensityBlue, 0.0);
- WRITEF(gcp->buf, Light0AmbientIntensityGreen, 0.0);
- WRITEF(gcp->buf, Light0AmbientIntensityRed, 0.0);
- WRITEF(gcp->buf, Light0DiffuseIntensityBlue, 1.0);
- WRITEF(gcp->buf, Light0DiffuseIntensityGreen, 1.0);
- WRITEF(gcp->buf, Light0DiffuseIntensityRed, 1.0);
- WRITEF(gcp->buf, Light0SpecularIntensityBlue, 1.0);
- WRITEF(gcp->buf, Light0SpecularIntensityGreen, 1.0);
- WRITEF(gcp->buf, Light0SpecularIntensityRed, 1.0);
- WRITEF(gcp->buf, Light0SpotlightDirectionZ, 0.0);
- WRITEF(gcp->buf, Light0SpotlightDirectionY, 0.0);
- WRITEF(gcp->buf, Light0SpotlightDirectionX, -1.0);
- WRITEF(gcp->buf, Light0SpotlightExponent, 0.0);
- WRITEF(gcp->buf, Light0PositionZ, 0.0);
- WRITEF(gcp->buf, Light0PositionY, 0.0);
- WRITEF(gcp->buf, Light0PositionX, 1.0);
- WRITEF(gcp->buf, Light0PositionW, 0.0);
- WRITEF(gcp->buf, Light0CosSpotlightCutoffAngle, -1.0);
- WRITEF(gcp->buf, Light0ConstantAttenuation, 1.0);
- WRITEF(gcp->buf, Light0LinearAttenuation, 0.0);
- WRITEF(gcp->buf, Light0QuadraticAttenuation,0.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 6);
- WRITEF(gcp->buf, ViewPortScaleX, (gcp->w)/2.0);
- WRITEF(gcp->buf, ViewPortScaleY, (gcp->h)/2.0);
- WRITEF(gcp->buf, ViewPortScaleZ, (gcp->zFar-gcp->zNear)/2.0);
- WRITEF(gcp->buf, ViewPortOffsetX, gcp->x);
- WRITEF(gcp->buf, ViewPortOffsetY, gcp->y);
- WRITEF(gcp->buf, ViewPortOffsetZ, (gcp->zFar+gcp->zNear)/2.0);
-
- CHECK_DMA_BUFFER(nullCC, gcp, 3);
- WRITEF(gcp->buf, Nz, 1.0);
- WRITEF(gcp->buf, Ny, 0.0);
- WRITEF(gcp->buf, Nx, 0.0);
+ WRITE(gmesa->buf, RasterizerMode, RM_BiasCoordNearHalf);
+ WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
+ WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
+ WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, EdgeFlag, EdgeFlagEnable);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewMatrix0, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix1, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix2, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix3, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix4, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix5, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix6, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix7, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix8, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix9, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix10, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix11, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix12, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix13, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix14, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix0, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix1, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix2, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix3, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix4, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix5, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix6, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix7, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix8, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix9, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix10, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix11, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix12, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix13, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix14, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, TextureMatrix0, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix1, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix2, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix3, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix4, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix5, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix6, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix7, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix8, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix9, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix10, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix11, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix12, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix13, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix14, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, TexGen0, 0.0);
+ WRITEF(gmesa->buf, TexGen1, 0.0);
+ WRITEF(gmesa->buf, TexGen2, 0.0);
+ WRITEF(gmesa->buf, TexGen3, 0.0);
+ WRITEF(gmesa->buf, TexGen4, 0.0);
+ WRITEF(gmesa->buf, TexGen5, 0.0);
+ WRITEF(gmesa->buf, TexGen6, 0.0);
+ WRITEF(gmesa->buf, TexGen7, 0.0);
+ WRITEF(gmesa->buf, TexGen8, 0.0);
+ WRITEF(gmesa->buf, TexGen9, 0.0);
+ WRITEF(gmesa->buf, TexGen10, 0.0);
+ WRITEF(gmesa->buf, TexGen11, 0.0);
+ WRITEF(gmesa->buf, TexGen12, 0.0);
+ WRITEF(gmesa->buf, TexGen13, 0.0);
+ WRITEF(gmesa->buf, TexGen14, 0.0);
+ WRITEF(gmesa->buf, TexGen15, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITEF(gmesa->buf, NormalMatrix0, 1.0);
+ WRITEF(gmesa->buf, NormalMatrix1, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix2, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix3, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix4, 1.0);
+ WRITEF(gmesa->buf, NormalMatrix5, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix6, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix7, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix8, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITEF(gmesa->buf, FogDensity, 0.0);
+ WRITEF(gmesa->buf, FogEnd, 0.0);
+ WRITEF(gmesa->buf, FogScale, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, LineClipLengthThreshold, 0.0);
+ WRITEF(gmesa->buf, TriangleClipAreaThreshold, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ WRITE(gmesa->buf, NormalizeMode, NormalizeModeDisable);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, ColorMaterialMode, ColorMaterialModeDisable);
+ WRITE(gmesa->buf, MaterialMode, MaterialModeDisable);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FrontSpecularExponent, 0); /* fixed point */
+ WRITE(gmesa->buf, BackSpecularExponent, 0); /* fixed point */
+
+ CHECK_DMA_BUFFER(gmesa, 29);
+ WRITEF(gmesa->buf, FrontAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, FrontAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, FrontAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, FrontDiffuseColorRed, 0.8);
+ WRITEF(gmesa->buf, FrontDiffuseColorGreen, 0.8);
+ WRITEF(gmesa->buf, FrontDiffuseColorBlue, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorRed, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorGreen, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorBlue, 0.8);
+ WRITEF(gmesa->buf, FrontSpecularColorRed, 0.0);
+ WRITEF(gmesa->buf, FrontSpecularColorGreen, 0.0);
+ WRITEF(gmesa->buf, FrontSpecularColorBlue, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorRed, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorGreen, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorBlue, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorRed, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorGreen, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorBlue, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorRed, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorGreen, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorBlue, 0.0);
+ WRITEF(gmesa->buf, SceneAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, SceneAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, SceneAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, FrontAlpha, 1.0);
+ WRITEF(gmesa->buf, BackAlpha, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 7);
+ WRITE(gmesa->buf, PointSize, 1);
+ WRITEF(gmesa->buf, AApointSize, 1.0);
+ WRITE(gmesa->buf, LineWidth, 1);
+ WRITEF(gmesa->buf, AAlineWidth, 1.0);
+ WRITE(gmesa->buf, LineWidthOffset, 0);
+ WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITE(gmesa->buf, Light0Mode, LNM_Off);
+ WRITE(gmesa->buf, Light1Mode, LNM_Off);
+ WRITE(gmesa->buf, Light2Mode, LNM_Off);
+ WRITE(gmesa->buf, Light3Mode, LNM_Off);
+ WRITE(gmesa->buf, Light4Mode, LNM_Off);
+ WRITE(gmesa->buf, Light5Mode, LNM_Off);
+ WRITE(gmesa->buf, Light6Mode, LNM_Off);
+ WRITE(gmesa->buf, Light7Mode, LNM_Off);
+ WRITE(gmesa->buf, Light8Mode, LNM_Off);
+ WRITE(gmesa->buf, Light9Mode, LNM_Off);
+ WRITE(gmesa->buf, Light10Mode, LNM_Off);
+ WRITE(gmesa->buf, Light11Mode, LNM_Off);
+ WRITE(gmesa->buf, Light12Mode, LNM_Off);
+ WRITE(gmesa->buf, Light13Mode, LNM_Off);
+ WRITE(gmesa->buf, Light14Mode, LNM_Off);
+ WRITE(gmesa->buf, Light15Mode, LNM_Off);
+
+ CHECK_DMA_BUFFER(gmesa, 22);
+ WRITEF(gmesa->buf, Light0AmbientIntensityBlue, 0.0);
+ WRITEF(gmesa->buf, Light0AmbientIntensityGreen, 0.0);
+ WRITEF(gmesa->buf, Light0AmbientIntensityRed, 0.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, 1.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, 1.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityRed, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityBlue, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityGreen, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityRed, 1.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionZ, 0.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionY, 0.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionX, -1.0);
+ WRITEF(gmesa->buf, Light0SpotlightExponent, 0.0);
+ WRITEF(gmesa->buf, Light0PositionZ, 0.0);
+ WRITEF(gmesa->buf, Light0PositionY, 0.0);
+ WRITEF(gmesa->buf, Light0PositionX, 1.0);
+ WRITEF(gmesa->buf, Light0PositionW, 0.0);
+ WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, -1.0);
+ WRITEF(gmesa->buf, Light0ConstantAttenuation, 1.0);
+ WRITEF(gmesa->buf, Light0LinearAttenuation, 0.0);
+ WRITEF(gmesa->buf, Light0QuadraticAttenuation,0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, XBias, 0.0);
+ WRITEF(gmesa->buf, YBias, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, ViewPortScaleX, gmesa->driScreen->fbWidth/4);
+ WRITEF(gmesa->buf, ViewPortScaleY, gmesa->driScreen->fbHeight/4);
+ WRITEF(gmesa->buf, ViewPortScaleZ, 1.0f);
+ WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->x);
+ WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->y);
+ WRITEF(gmesa->buf, ViewPortOffsetZ, 0.0f);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITEF(gmesa->buf, Nz, 1.0);
+ WRITEF(gmesa->buf, Ny, 0.0);
+ WRITEF(gmesa->buf, Nx, 0.0);
/* Send the initialization commands to the HW */
- FLUSH_DMA_BUFFER(nullCC, gcp);
+ FLUSH_DMA_BUFFER(gmesa);
}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c
new file mode 100644
index 000000000..23693347f
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c
@@ -0,0 +1,57 @@
+
+#include "gamma_context.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+
+/* Update the hardware state. This is called if another context has
+ * grabbed the hardware lock, which includes the X server. This
+ * function also updates the driver's window state after the X server
+ * moves, resizes or restacks a window -- the change will be reflected
+ * in the drawable position and clip rects. Since the X server grabs
+ * the hardware lock when it changes the window state, this routine will
+ * automatically be called after such a change.
+ */
+void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = gmesa->driScreen;
+
+ drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
+
+ /* The window might have moved, so we might need to get new clip
+ * rects.
+ *
+ * NOTE: This releases and regrabs the hw lock to allow the X server
+ * to respond to the DRI protocol request for new drawable info.
+ * Since the hardware state depends on having the latest drawable
+ * clip rects, all state checking must be done _after_ this call.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( gmesa->display, sPriv, dPriv );
+
+ if ( gmesa->lastStamp != dPriv->lastStamp ) {
+ gmesa->lastStamp = dPriv->lastStamp;
+ gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
+ }
+
+ gmesa->numClipRects = dPriv->numClipRects;
+ gmesa->pClipRects = dPriv->pClipRects;
+
+#if 0
+ gmesa->dirty = ~0;
+
+ if ( sarea->ctxOwner != gmesa->hHWContext ) {
+ sarea->ctxOwner = gmesa->hHWContext;
+ gmesa->dirty = GAMMA_UPLOAD_ALL;
+ }
+
+ for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
+ if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
+ gammaAgeTextures( gmesa, i );
+ }
+ }
+#endif
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.h
new file mode 100644
index 000000000..8b66e19aa
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_lock.h
@@ -0,0 +1,88 @@
+#ifndef __GAMMA_LOCK_H__
+#define __GAMMA_LOCK_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#if DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+
+#define DEBUG_LOCK() \
+ do { \
+ prevLockFile = (__FILE__); \
+ prevLockLine = (__LINE__); \
+ } while (0)
+
+#define DEBUG_RESET() \
+ do { \
+ prevLockFile = 0; \
+ prevLockLine = 0; \
+ } while (0)
+
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if ( prevLockFile ) { \
+ fprintf( stderr, \
+ "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
+ prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
+ exit( 1 ); \
+ } \
+ } while (0)
+
+#else
+
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+
+#endif
+
+/*
+ * !!! We may want to separate locks from locks with validation. This
+ * could be used to improve performance for those things commands that
+ * do not do any drawing !!!
+ */
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( gmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \
+ (DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \
+ if ( __ret ) \
+ gammaGetLock( gmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware.
+ */
+#define UNLOCK_HARDWARE( gmesa ) \
+ do { \
+ DRM_UNLOCK( gmesa->driFd, \
+ gmesa->driHwLock, \
+ gmesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif
+
+#define GAMMAHW_LOCK( gmesa ) \
+ DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
+ gmesa->driScreen->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+
+#define GAMMAHW_UNLOCK( gmesa ) \
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
+ gmesa->driScreen->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+#endif /* __GAMMA_LOCK_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
index 124722170..b0b7184c5 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h,v 1.4 2000/06/17 00:02:56 martin Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h,v 1.3 2000/02/23 04:46:44 martin Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -55,6 +55,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define TURN_OFF_TEXTURES_NOT
#define DO_VALIDATE
+#define GAMMA_DMA_BUFFER_SIZE 4096
+
#if 0
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_PRIORITY
#define GAMMA_DMA_SEND_FLAGS DRM_DMA_BLOCK
@@ -63,10 +65,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define GAMMA_DMA_SEND_FLAGS 0
#endif
+#if 0
#define GAMMA_DMA_GET_FLAGS \
(DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
-
-#define GAMMA_DMA_BUFFER_SIZE 4096
+#else
+#define GAMMA_DMA_GET_FLAGS DRM_DMA_WAIT
+#endif
#if defined(DEBUG_DRMDMA) || defined(DEBUG_COMMANDS) || defined(DEBUG_VERBOSE)
#include <stdio.h>
@@ -100,6 +104,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DEBUG_ERROR(s)
#endif
+#define WRITEV(buf,val1,val2,val3,val4) \
+do { \
+ buf++->i = 0x9C008300; \
+ buf++->f = val1; \
+ buf++->f = val2; \
+ buf++->f = val3; \
+ buf++->f = val4; \
+} while (0)
+
#define WRITE(buf,reg,val) \
do { \
buf++->i = Glint##reg##Tag; \
@@ -114,22 +127,29 @@ do { \
DEBUG_WRITE(("WRITEF(buf, %s, %f);\n", #reg, (float)val)); \
} while (0)
-#define CHECK_DMA_BUFFER(gcc,gcp,n) \
+#define CHECK_WC_DMA_BUFFER(gcp,n) \
+do { \
+ (gcp)->WCbufCount += (n<<1); \
+} while (0)
+
+#define CHECK_DMA_BUFFER(gcp,n) \
do { \
if ((gcp)->bufCount+(n<<1) >= (gcp)->bufSize) \
- PROCESS_DMA_BUFFER(gcc,gcp); \
+ PROCESS_DMA_BUFFER(gcp); \
(gcp)->bufCount += (n<<1); \
} while (0)
-#define CHECK_WC_DMA_BUFFER(gcp,n) \
+#define CHECK_DMA_BUFFER2(gcp,n) \
do { \
- (gcp)->WCbufCount += (n<<1); \
+ if ((gcp)->bufCount+n >= (gcp)->bufSize) \
+ PROCESS_DMA_BUFFER(gcp); \
+ (gcp)->bufCount += n; \
} while (0)
-#define FLUSH_DMA_BUFFER(gcc,gcp) \
+#define FLUSH_DMA_BUFFER(gcp) \
do { \
- if (gcp->bufCount) \
- PROCESS_DMA_BUFFER(gcc,gcp); \
+ if (gcp->bufCount) \
+ PROCESS_DMA_BUFFER(gcp); \
} while (0)
#ifdef DONT_SEND_DMA
@@ -205,64 +225,45 @@ do { \
#define PROCESS_DMA_BUFFER_TOP_HALF(gcp) \
do { \
- SEND_DMA((gcp)->gammaScrnPriv->driScrnPriv->fd, \
+ SEND_DMA((gcp)->driFd, \
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufCount); \
} while (0)
#define PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp) \
do { \
- GET_DMA((gcp)->gammaScrnPriv->driScrnPriv->fd, \
+ GET_DMA((gcp)->driFd, \
(gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufSize); \
\
(gcp)->buf = \
- (dmaBuf)(gcp)->gammaScrnPriv->bufs->list[(gcp)->bufIndex].address; \
+ (dmaBuf)(gcp)->gammaScreen->bufs->list[(gcp)->bufIndex].address; \
} while (0)
-#define PROCESS_DMA_BUFFER(gcc,gcp) \
+#define PROCESS_DMA_BUFFER(gcp) \
do { \
- if (gcc) VALIDATE_DRAWABLE_INFO(gcc, gcp); \
+ VALIDATE_DRAWABLE_INFO(gcp); \
PROCESS_DMA_BUFFER_TOP_HALF(gcp); \
PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp); \
} while (0)
#ifdef DO_VALIDATE
-#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcc,gcp) \
+#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
do { \
- __DRIcontextPrivate *pcp = gcc; \
- __DRIscreenPrivate *psp = pcp->driScreenPriv; \
- __DRIdrawablePrivate *pdp = pcp->driDrawablePriv; \
+ __DRIscreenPrivate *psp = gcp->driScreen; \
+ __DRIdrawablePrivate *pdp = gcp->driDrawable; \
\
if (*(pdp->pStamp) != pdp->lastStamp) { \
int old_index = pdp->index; \
while (*(pdp->pStamp) != pdp->lastStamp) { \
- DRI_MESA_VALIDATE_DRAWABLE_INFO(pcp->display, psp->myNum, pdp);\
+ DRI_VALIDATE_DRAWABLE_INFO_ONCE(gcp->display, psp->myNum, pdp);\
} \
- \
if (pdp->index != old_index) { \
gcp->Window &= ~W_GIDMask; \
gcp->Window |= (pdp->index << 5); \
CHECK_WC_DMA_BUFFER(gcp, 1); \
- WRITEF(gcp->WCbuf, GLINTWindow, gcp->Window); \
- } \
- \
- if (pdp->x != gcp->x || \
- pdp->y != gcp->y) { \
- GLfloat sx, sy, ox, oy; \
- \
- gcp->x = pdp->x; \
- gcp->y = psp->fbHeight - (pdp->y+pdp->h); \
- \
- sx = gcp->w/2.0f; \
- sy = gcp->h/2.0f; \
- ox = gcp->x + sx; \
- oy = gcp->y + sy; \
- \
- CHECK_WC_DMA_BUFFER(gcp, 4); \
- WRITEF(gcp->WCbuf, ViewPortOffsetX, ox); \
- WRITEF(gcp->WCbuf, ViewPortOffsetY, oy); \
- WRITEF(gcp->WCbuf, ViewPortScaleX, sx); \
- WRITEF(gcp->WCbuf, ViewPortScaleY, sy); \
+ WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\
} \
+ \
+ gammaUpdateViewportOffset( gcp->glCtx); \
\
if (pdp->numClipRects == 1 && \
pdp->pClipRects->x1 == pdp->x && \
@@ -270,17 +271,17 @@ do { \
pdp->pClipRects->y1 == pdp->y && \
pdp->pClipRects->y2 == (pdp->y+pdp->h)) { \
CHECK_WC_DMA_BUFFER(gcp, 1); \
- WRITEF(gcp->WCbuf, Rectangle2DControl, 0); \
+ WRITE(gcp->WCbuf, Rectangle2DControl, 0); \
gcp->NotClipped = GL_TRUE; \
} else { \
CHECK_WC_DMA_BUFFER(gcp, 1); \
- WRITEF(gcp->WCbuf, Rectangle2DControl, 1); \
+ WRITE(gcp->WCbuf, Rectangle2DControl, 1); \
gcp->NotClipped = GL_FALSE; \
} \
gcp->WindowChanged = GL_TRUE; \
\
if (gcp->WCbufCount) { \
- SEND_DMA((gcp)->gammaScrnPriv->driScrnPriv->fd, \
+ SEND_DMA((gcp)->gammaScreen->driScreen->fd, \
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
&(gcp)->WCbufCount); \
(gcp)->WCbufIndex = -1; \
@@ -288,31 +289,31 @@ do { \
} \
} while (0)
-#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcc,gcp) \
+#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp) \
do { \
if ((gcp)->WCbufIndex < 0) { \
- GET_DMA((gcp)->gammaScrnPriv->driScrnPriv->fd, \
+ GET_DMA((gcp)->gammaScreen->driScreen->fd, \
(gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
&(gcp)->WCbufSize); \
\
(gcp)->WCbuf = \
- (dmaBuf)(gcp)->gammaScrnPriv->bufs-> \
+ (dmaBuf)(gcp)->gammaScreen->bufs-> \
list[(gcp)->WCbufIndex].address; \
} \
} while (0)
-#define VALIDATE_DRAWABLE_INFO(gcc,gcp) \
+#define VALIDATE_DRAWABLE_INFO(gcp) \
do { \
- __DRIcontextPrivate *pcp = gcc; \
- __DRIscreenPrivate *psp = pcp->driScreenPriv; \
- \
+ __DRIscreenPrivate *psp = gcp->driScreen; \
+if (gcp->driDrawable) { \
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
- VALIDATE_DRAWABLE_INFO_NO_LOCK(gcc,gcp); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp); \
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
- VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcc,gcp); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp); \
+} \
} while (0)
#else
-#define VALIDATE_DRAWABLE_INFO(gcc,gcp)
+#define VALIDATE_DRAWABLE_INFO(gcp)
#endif
#define CALC_LOG2(l2,s) \
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c
deleted file mode 100644
index 8d340ad09..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c
+++ /dev/null
@@ -1,229 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c,v 1.3 2000/06/17 00:02:56 martin Exp $ */
-/**************************************************************************
-
-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>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "gamma_init.h"
-
-float IdentityMatrix[16] =
-{
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
-};
-
-static void doMultMatrix(GLfloat *p, GLfloat *a, GLfloat *b)
-{
-/* Column-major order multiply */
-#define MATRIX_MULT(__p, __a, __b) \
-do { \
- GLint __row; \
- for (__row = 0; __row < 4; __row++) { \
- GLfloat __t[4]; \
- __t[0] = __a[__row]; \
- __t[1] = __a[__row+4]; \
- __t[2] = __a[__row+8]; \
- __t[3] = __a[__row+12]; \
- __p[__row] = (__t[0] * __b[0] + \
- __t[1] * __b[1] + \
- __t[2] * __b[2] + \
- __t[3] * __b[3]); \
- __p[__row+4] = (__t[0] * __b[4] + \
- __t[1] * __b[5] + \
- __t[2] * __b[6] + \
- __t[3] * __b[7]); \
- __p[__row+8] = (__t[0] * __b[8] + \
- __t[1] * __b[9] + \
- __t[2] * __b[10] + \
- __t[3] * __b[11]); \
- __p[__row+12] = (__t[0] * __b[12] + \
- __t[1] * __b[13] + \
- __t[2] * __b[14] + \
- __t[3] * __b[15]); \
- } \
-} while(0)
-
- if (p == a || p == b) {
- GLfloat t[16];
- int i;
-
- MATRIX_MULT(t,a,b);
- for (i = 0; i < 16; i++) p[i] = t[i];
- } else {
- MATRIX_MULT(p,a,b);
- }
-
-}
-
-void gammaSetMatrix(GLfloat m[16])
-{
- int i;
-
- switch (gCCPriv->MatrixMode) {
- case GL_MODELVIEW:
- for (i = 0; i < 16; i++) gCCPriv->ModelView[i] = m[i];
- doMultMatrix(gCCPriv->ModelViewProj,
- gCCPriv->Proj, gCCPriv->ModelView);
- break;
-
- case GL_PROJECTION:
- for (i = 0; i < 16; i++) gCCPriv->Proj[i] = m[i];
- doMultMatrix(gCCPriv->ModelViewProj, gCCPriv->Proj,
- gCCPriv->ModelView);
- break;
-
- case GL_TEXTURE:
- for (i = 0; i < 16; i++) gCCPriv->Texture[i] = m[i];
- break;
-
- default:
- /* ERROR!!! -- how did this happen? */
- return;
- }
-
-}
-
-void gammaMultMatrix(GLfloat *m)
-{
- switch (gCCPriv->MatrixMode) {
- case GL_MODELVIEW:
- doMultMatrix(gCCPriv->ModelView, gCCPriv->ModelView, m);
- doMultMatrix(gCCPriv->ModelViewProj,
- gCCPriv->Proj, gCCPriv->ModelView);
- break;
-
- case GL_PROJECTION:
- doMultMatrix(gCCPriv->Proj, gCCPriv->Proj, m);
- doMultMatrix(gCCPriv->ModelViewProj,
- gCCPriv->Proj, gCCPriv->ModelView);
- break;
-
- case GL_TEXTURE:
- doMultMatrix(gCCPriv->Texture, gCCPriv->Texture, m);
- break;
-
- default:
- /* ERROR!!! -- how did this happen? */
- break;
- }
-}
-
-void gammaLoadHWMatrix(void)
-{
- switch (gCCPriv->MatrixMode) {
- case GL_MODELVIEW:
-#if 0
- /* The ModelView matrix is not currently used */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 16);
- WRITEF(gCCPriv->buf, ModelViewMatrix0, gCCPriv->ModelView[0]);
- WRITEF(gCCPriv->buf, ModelViewMatrix1, gCCPriv->ModelView[1]);
- WRITEF(gCCPriv->buf, ModelViewMatrix2, gCCPriv->ModelView[2]);
- WRITEF(gCCPriv->buf, ModelViewMatrix3, gCCPriv->ModelView[3]);
- WRITEF(gCCPriv->buf, ModelViewMatrix4, gCCPriv->ModelView[4]);
- WRITEF(gCCPriv->buf, ModelViewMatrix5, gCCPriv->ModelView[5]);
- WRITEF(gCCPriv->buf, ModelViewMatrix6, gCCPriv->ModelView[6]);
- WRITEF(gCCPriv->buf, ModelViewMatrix7, gCCPriv->ModelView[7]);
- WRITEF(gCCPriv->buf, ModelViewMatrix8, gCCPriv->ModelView[8]);
- WRITEF(gCCPriv->buf, ModelViewMatrix9, gCCPriv->ModelView[9]);
- WRITEF(gCCPriv->buf, ModelViewMatrix10, gCCPriv->ModelView[10]);
- WRITEF(gCCPriv->buf, ModelViewMatrix11, gCCPriv->ModelView[11]);
- WRITEF(gCCPriv->buf, ModelViewMatrix12, gCCPriv->ModelView[12]);
- WRITEF(gCCPriv->buf, ModelViewMatrix13, gCCPriv->ModelView[13]);
- WRITEF(gCCPriv->buf, ModelViewMatrix14, gCCPriv->ModelView[14]);
- WRITEF(gCCPriv->buf, ModelViewMatrix15, gCCPriv->ModelView[15]);
-#endif
- case GL_PROJECTION:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 16);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix0, gCCPriv->ModelViewProj[0]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix1, gCCPriv->ModelViewProj[1]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix2, gCCPriv->ModelViewProj[2]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix3, gCCPriv->ModelViewProj[3]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix4, gCCPriv->ModelViewProj[4]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix5, gCCPriv->ModelViewProj[5]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix6, gCCPriv->ModelViewProj[6]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix7, gCCPriv->ModelViewProj[7]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix8, gCCPriv->ModelViewProj[8]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix9, gCCPriv->ModelViewProj[9]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix10, gCCPriv->ModelViewProj[10]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix11, gCCPriv->ModelViewProj[11]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix12, gCCPriv->ModelViewProj[12]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix13, gCCPriv->ModelViewProj[13]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix14, gCCPriv->ModelViewProj[14]);
- WRITEF(gCCPriv->buf,
- ModelViewProjectionMatrix15, gCCPriv->ModelViewProj[15]);
- break;
-
- case GL_TEXTURE:
- CHECK_DMA_BUFFER(gCC, gCCPriv, 16);
- WRITEF(gCCPriv->buf, TextureMatrix0, gCCPriv->Texture[0]);
- WRITEF(gCCPriv->buf, TextureMatrix1, gCCPriv->Texture[1]);
- WRITEF(gCCPriv->buf, TextureMatrix2, gCCPriv->Texture[2]);
- WRITEF(gCCPriv->buf, TextureMatrix3, gCCPriv->Texture[3]);
- WRITEF(gCCPriv->buf, TextureMatrix4, gCCPriv->Texture[4]);
- WRITEF(gCCPriv->buf, TextureMatrix5, gCCPriv->Texture[5]);
- WRITEF(gCCPriv->buf, TextureMatrix6, gCCPriv->Texture[6]);
- WRITEF(gCCPriv->buf, TextureMatrix7, gCCPriv->Texture[7]);
- WRITEF(gCCPriv->buf, TextureMatrix8, gCCPriv->Texture[8]);
- WRITEF(gCCPriv->buf, TextureMatrix9, gCCPriv->Texture[9]);
- WRITEF(gCCPriv->buf, TextureMatrix10, gCCPriv->Texture[10]);
- WRITEF(gCCPriv->buf, TextureMatrix11, gCCPriv->Texture[11]);
- WRITEF(gCCPriv->buf, TextureMatrix12, gCCPriv->Texture[12]);
- WRITEF(gCCPriv->buf, TextureMatrix13, gCCPriv->Texture[13]);
- WRITEF(gCCPriv->buf, TextureMatrix14, gCCPriv->Texture[14]);
- WRITEF(gCCPriv->buf, TextureMatrix15, gCCPriv->Texture[15]);
- break;
-
- default:
- /* ERROR!!! -- how did this happen? */
- break;
- }
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_region.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_region.h
deleted file mode 100644
index f7a7826ce..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_region.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_region.h,v 1.2 2000/02/23 04:46:45 martin Exp $ */
-/**************************************************************************
-
-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:
- * Rik Faith <faith@precisioninsight.com>
- * Kevin E. Martin <kevin@precisioninsight.com>
- *
- */
-
-#ifndef _GAMMA_REGION_H_
-#define _GAMMA_REGION_H_
-
-typedef struct _gammaRegion {
- drmHandle handle;
- drmSize size;
- drmAddress map;
-} gammaRegion, *gammaRegionPtr;
-
-#endif /* _GAMMA_REGION_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h
index 613385909..81a1f67fb 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h
@@ -139,6 +139,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define AB_AlphaConversionScale 0x00000000
#define AB_AlphaConversionShift 0x00020000
+/* AntialiasMode */
+#define AntialiasModeDisable 0x00000000
+#define AntialiasModeEnable 0x00000001
+
+/* AreaStippleMode */
+#define AreaStippleModeDisable 0x00000000
+#define AreaStippleModeEnable 0x00000001
+#define ASM_X32 0x00000008
+#define ASM_Y32 0x00000040
+
/* DepthMode */
#define DepthModeDisable 0x00000000
#define DepthModeEnable 0x00000001
@@ -174,6 +184,42 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LBW_UploadDepth 0x00000002
#define LBW_UploadStencil 0x00000004
+/* LBRead/Write Format */
+#define LBRF_DepthWidth15 0x03 /* only permedia */
+#define LBRF_DepthWidth16 0x00
+#define LBRF_DepthWidth24 0x01
+#define LBRF_DepthWidth32 0x02
+#define LBRF_StencilWidth0 (0 << 2)
+#define LBRF_StencilWidth4 (1 << 2)
+#define LBRF_StencilWidth8 (2 << 2)
+#define LBRF_StencilPos16 (0 << 4)
+#define LBRF_StencilPos20 (1 << 4)
+#define LBRF_StencilPos24 (2 << 4)
+#define LBRF_StencilPos28 (3 << 4)
+#define LBRF_StencilPos32 (4 << 4)
+#define LBRF_FrameCount0 (0 << 7)
+#define LBRF_FrameCount4 (1 << 7)
+#define LBRF_FrameCount8 (2 << 7)
+#define LBRF_FrameCountPos16 (0 << 9)
+#define LBRF_FrameCountPos20 (1 << 9)
+#define LBRF_FrameCountPos24 (2 << 9)
+#define LBRF_FrameCountPos28 (3 << 9)
+#define LBRF_FrameCountPos32 (4 << 9)
+#define LBRF_FrameCountPos36 (5 << 9)
+#define LBRF_FrameCountPos40 (6 << 9)
+#define LBRF_GIDWidth0 (0 << 12)
+#define LBRF_GIDWidth4 (1 << 12)
+#define LBRF_GIDPos16 (0 << 13)
+#define LBRF_GIDPos20 (1 << 13)
+#define LBRF_GIDPos24 (2 << 13)
+#define LBRF_GIDPos28 (3 << 13)
+#define LBRF_GIDPos32 (4 << 13)
+#define LBRF_GIDPos36 (5 << 13)
+#define LBRF_GIDPos40 (6 << 13)
+#define LBRF_GIDPos44 (7 << 13)
+#define LBRF_GIDPos48 (8 << 13)
+#define LBRF_Compact32 (1 << 17)
+
/* StencilMode */
#define StencilDisable 0x00000000
#define StencilEnable 0x00000001
@@ -382,7 +428,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define TF_LUTOffsetMask 0x0003fc00
#define TF_OneCompFmt_Lum 0x00000000
#define TF_OneCompFmt_Alpha 0x00040000
-#define TF_OneCompFmt_Intesity 0x00080000
+#define TF_OneCompFmt_Intensity 0x00080000
#define TF_OneCompFmt_Mask 0x000c0000
/**************** MX FLAGS ****************/
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_render.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_render.c
new file mode 100644
index 000000000..3bf35db0e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_render.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * 3DLabs Gamma driver.
+ *
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mem.h"
+#include "mtypes.h"
+#include "mmath.h"
+
+#include "tnl/t_context.h"
+
+#include "gamma_context.h"
+#include "gamma_tris.h"
+#include "gamma_vb.h"
+
+
+/* !! Should template this eventually !! */
+
+static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ GLubyte (*col)[4];
+ GLuint col_stride;
+ int i;
+ GLuint tc0_stride = 0;
+ GLfloat (*tc0)[4] = 0;
+ GLuint tc0_size = 0;
+
+ if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
+ gamma_import_float_colors( ctx );
+
+ col = VB->ColorPtr[0]->Ptr;
+ col_stride = VB->ColorPtr[0]->StrideB;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ tc0_stride = VB->TexCoordPtr[0]->stride;
+ tc0 = VB->TexCoordPtr[0]->data;
+ tc0_size = VB->TexCoordPtr[0]->size;
+ coord = VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ } else {
+ coord = VB->ProjectedClipPtr->data;
+ coord_stride = VB->ProjectedClipPtr->stride;
+ }
+
+ if (VB->importable_data) {
+ if (start) {
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ STRIDE_4UB(col, start * col_stride);
+ if (ctx->Texture.Unit[0]._ReallyEnabled)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ }
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITEF(gmesa->buf, Tq4, tc0[0][3]);
+ WRITEF(gmesa->buf, Tr4, tc0[0][2]);
+ WRITEF(gmesa->buf, Tt4, tc0[0][0]);
+ WRITEF(gmesa->buf, Ts4, tc0[0][1]);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
+ WRITEF(gmesa->buf, Vw, coord[0][3]);
+ WRITEF(gmesa->buf, Vz, coord[0][2]);
+ WRITEF(gmesa->buf, Vy, coord[0][1]);
+ WRITEF(gmesa->buf, Vx4, coord[0][0]);
+ STRIDE_4UB(col, col_stride);
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ }
+ } else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 7);
+ WRITEF(gmesa->buf, Tt2, tc0[0][0]);
+ WRITEF(gmesa->buf, Ts2, tc0[0][1]);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
+ WRITEF(gmesa->buf, Vw, coord[0][3]);
+ WRITEF(gmesa->buf, Vz, coord[0][2]);
+ WRITEF(gmesa->buf, Vy, coord[0][1]);
+ WRITEF(gmesa->buf, Vx4, coord[0][0]);
+ STRIDE_4UB(col, col_stride);
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ }
+ } else {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[0]);
+ WRITEF(gmesa->buf, Vz, coord[0][2]);
+ WRITEF(gmesa->buf, Vy, coord[0][1]);
+ WRITEF(gmesa->buf, Vx3, coord[0][0]);
+ STRIDE_4UB(col, col_stride);
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ }
+ }
+ } else {
+ if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITEF(gmesa->buf, Tq4, tc0[i][3]);
+ WRITEF(gmesa->buf, Tr4, tc0[i][2]);
+ WRITEF(gmesa->buf, Tt4, tc0[i][0]);
+ WRITEF(gmesa->buf, Ts4, tc0[i][1]);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
+ WRITEF(gmesa->buf, Vw, coord[i][3]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx4, coord[i][0]);
+ }
+ } else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 7);
+ WRITEF(gmesa->buf, Tt2, tc0[i][0]);
+ WRITEF(gmesa->buf, Ts2, tc0[i][1]);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
+ WRITEF(gmesa->buf, Vw, coord[i][3]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx4, coord[i][0]);
+ }
+ } else {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITE(gmesa->buf, PackedColor4, *(CARD32*)col[i]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx3, coord[i][0]);
+ }
+ }
+ }
+}
+
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 1
+#define HAVE_QUAD_STRIPS 1
+#define HAVE_POLYGONS 1
+
+#define HAVE_ELTS 0
+
+static void VERT_FALLBACK( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+ tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
+ tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, count, flags );
+ GAMMA_CONTEXT(ctx)->SetupNewInputs = VERT_CLIP;
+}
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ B_PrimType_Points,
+ B_PrimType_Lines,
+ B_PrimType_LineLoop,
+ B_PrimType_LineStrip,
+ B_PrimType_Triangles,
+ B_PrimType_TriangleStrip,
+ B_PrimType_TriangleFan,
+ B_PrimType_Quads,
+ B_PrimType_QuadStrip,
+ B_PrimType_Polygon
+};
+
+static __inline void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim )
+{
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, gmesa->Begin | hw_prim[prim]);
+}
+
+static __inline void gammaEndPrimitive( gammaContextPtr gmesa )
+{
+ GLcontext *ctx = gmesa->glCtx;
+
+ if ( ctx->Line.SmoothFlag ||
+ ctx->Polygon.SmoothFlag ||
+ ctx->Point.SmoothFlag ) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+#define LOCAL_VARS gammaContextPtr gmesa = GAMMA_CONTEXT(ctx)
+#define INIT( prim ) gammaStartPrimitive( gmesa, prim )
+#define FINISH gammaEndPrimitive( gmesa )
+#define NEW_PRIMITIVE() /* GAMMA_STATECHANGE( gmesa, 0 ) */
+#define NEW_BUFFER() /* GAMMA_FIREVERTICES( gmesa ) */
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (gmesa->bufSize - gmesa->bufCount) / 2
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ GAMMA_DMA_BUFFER_SIZE / 2
+#define EMIT_VERTS( ctx, j, nr ) gamma_emit(ctx, j, (j)+(nr))
+
+#define TAG(x) gamma_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean gamma_run_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i, length, flags = 0;
+ render_func *tab;
+
+ /* GH: THIS IS A HACK!!! */
+ if (VB->ClipOrMask || gmesa->RenderIndex != 0)
+ return GL_TRUE; /* don't handle clipping here */
+
+ /* We don't do elts */
+ if (VB->Elts)
+ return GL_TRUE;
+
+ tab = TAG(render_tab_verts);
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length)
+ {
+ flags = VB->Primitive[i];
+ length = VB->PrimitiveLength[i];
+ if (length)
+ tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+static void gamma_check_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ GLuint inputs = VERT_CLIP|VERT_RGBA;
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ inputs |= VERT_SPEC_RGB;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled)
+ inputs |= VERT_TEX(0);
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled)
+ inputs |= VERT_TEX(1);
+
+ if (ctx->Fog.Enabled)
+ inputs |= VERT_FOG_COORD;
+ }
+
+ stage->inputs = inputs;
+}
+
+
+static void dtr( struct gl_pipeline_stage *stage )
+{
+ (void)stage;
+}
+
+
+const struct gl_pipeline_stage _gamma_render_stage =
+{
+ "gamma render",
+ (_DD_NEW_SEPARATE_SPECULAR |
+ _NEW_TEXTURE|
+ _NEW_FOG|
+ _NEW_RENDERMODE), /* re-check (new inputs) */
+ 0, /* re-run (always runs) */
+ GL_TRUE, /* active */
+ 0, 0, /* inputs (set in check_render), outputs */
+ 0, 0, /* changed_inputs, private */
+ dtr, /* destructor */
+ gamma_check_render, /* check - initially set to alloc data */
+ gamma_run_render /* run */
+};
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c
new file mode 100644
index 000000000..f826a5038
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "glint_dri.h"
+
+#include "mem.h"
+
+gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ gammaScreenPtr gammaScreen;
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
+ int i;
+
+#if 0
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
+ if ( major != 3 || minor != 1 || patch < 0 ) {
+ __driUtilMessage( "r128 DRI driver expected DRI version 3.1.x but got version %d.%d.%d", major, minor, patch );
+ return GL_FALSE;
+ }
+ }
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( sPriv->ddxMajor != 4 ||
+ sPriv->ddxMinor != 0 ||
+ sPriv->ddxPatch < 0 ) {
+ __driUtilMessage( "r128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( sPriv->drmMajor != 2 ||
+ sPriv->drmMinor != 1 ||
+ sPriv->drmPatch < 0 ) {
+ __driUtilMessage( "r128 DRI driver expected DRM driver version 2.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
+ return GL_FALSE;
+ }
+#endif
+
+ /* Allocate the private area */
+ gammaScreen = (gammaScreenPtr) CALLOC( sizeof(*gammaScreen) );
+ if ( !gammaScreen ) return NULL;
+
+ gammaScreen->regionCount = 4; /* Magic number. Can we fix this? */
+
+ gammaScreen->regions = Xmalloc(gammaScreen->regionCount *
+ sizeof(gammaRegion));
+
+ gammaScreen->regions[0].handle = gDRIPriv->registers0.handle;
+ gammaScreen->regions[0].size = gDRIPriv->registers0.size;
+ gammaScreen->regions[1].handle = gDRIPriv->registers1.handle;
+ gammaScreen->regions[1].size = gDRIPriv->registers1.size;
+ gammaScreen->regions[2].handle = gDRIPriv->registers2.handle;
+ gammaScreen->regions[2].size = gDRIPriv->registers2.size;
+ gammaScreen->regions[3].handle = gDRIPriv->registers3.handle;
+ gammaScreen->regions[3].size = gDRIPriv->registers3.size;
+
+ /* Next, map all the regions */
+ for (i = 0; i < gammaScreen->regionCount; i++) {
+ if (drmMap(sPriv->fd,
+ gammaScreen->regions[i].handle,
+ gammaScreen->regions[i].size,
+ &gammaScreen->regions[i].map)) {
+ while (--i > 0) {
+ (void)drmUnmap(gammaScreen->regions[i].map,
+ gammaScreen->regions[i].size);
+ }
+ return GL_FALSE;
+ }
+ }
+
+ /* Get the list of dma buffers */
+ gammaScreen->bufs = drmMapBufs(sPriv->fd);
+
+ if (!gammaScreen->bufs) {
+ while (gammaScreen->regionCount > 0) {
+ (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
+ gammaScreen->regions[gammaScreen->regionCount].size);
+ gammaScreen->regionCount--;
+ }
+ return GL_FALSE;
+ }
+
+ gammaScreen->textureSize = gDRIPriv->textureSize;
+ gammaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+ gammaScreen->cpp = gDRIPriv->cpp;
+ gammaScreen->frontOffset = gDRIPriv->frontOffset;
+ gammaScreen->frontPitch = gDRIPriv->frontPitch;
+ gammaScreen->backOffset = gDRIPriv->backOffset;
+ gammaScreen->backPitch = gDRIPriv->backPitch;
+ gammaScreen->backX = gDRIPriv->backX;
+ gammaScreen->backY = gDRIPriv->backY;
+ gammaScreen->depthOffset = gDRIPriv->depthOffset;
+ gammaScreen->depthPitch = gDRIPriv->depthPitch;
+
+ gammaScreen->driScreen = sPriv;
+
+ return gammaScreen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+void gammaDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private;
+
+ /* First, unmap the dma buffers */
+ drmUnmapBufs( gammaScreen->bufs );
+
+ /* Next, unmap all the regions */
+ while (gammaScreen->regionCount > 0) {
+ (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
+ gammaScreen->regions[gammaScreen->regionCount].size);
+ gammaScreen->regionCount--;
+ }
+ FREE(gammaScreen->regions);
+ FREE(gammaScreen);
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.h
new file mode 100644
index 000000000..6f3cf1e5b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_screen.h
@@ -0,0 +1,30 @@
+typedef struct _gammaRegion {
+ drmHandle handle;
+ drmSize size;
+ drmAddress map;
+} gammaRegion, *gammaRegionPtr;
+
+typedef struct {
+
+ int regionCount; /* Count of register regions */
+ gammaRegion *regions; /* Vector of mapped region info */
+
+ drmBufMapPtr bufs; /* Map of DMA buffers */
+
+ __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
+
+ int cpp;
+ int frontPitch;
+ int frontOffset;
+
+ int backPitch;
+ int backOffset;
+ int backX;
+ int backY;
+
+ int depthOffset;
+ int depthPitch;
+
+ int textureSize;
+ int logTextureGranularity;
+} gammaScreenRec, *gammaScreenPtr;
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_span.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_span.c
new file mode 100644
index 000000000..bad4b0608
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_span.c
@@ -0,0 +1,339 @@
+#include "gamma_context.h"
+#include "gamma_lock.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ gammaScreenPtr gammascrn = gmesa->gammaScreen; \
+ __DRIscreenPrivate *sPriv = gmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
+ GLuint pitch = sPriv->fbWidth * gammascrn->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ gmesa->drawOffset + \
+ (dPriv->x * gammascrn->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(sPriv->pFB + \
+ gmesa->readOffset + \
+ (dPriv->x * gammascrn->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+/* FIXME! Depth/Stencil read/writes don't work ! */
+#define LOCAL_DEPTH_VARS \
+ gammaScreenPtr gammascrn = gmesa->gammaScreen; \
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
+ __DRIscreenPrivate *sPriv = gmesa->driScreen; \
+ GLuint pitch = gammascrn->depthPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ gammascrn->depthOffset + \
+ dPriv->x * gammascrn->cpp + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+
+#define CLIPPIXEL( _x, _y ) \
+ ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+
+
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
+ if ( _y < miny || _y >= maxy ) { \
+ _n1 = 0, _x1 = x; \
+ } else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
+ }
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK() \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ FLUSH_DMA_BUFFER(gmesa); \
+ gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); \
+ GAMMAHW_LOCK( gmesa );
+
+#define HW_CLIPLOOP() \
+ do { \
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
+ int _nc = dPriv->numClipRects; \
+ \
+ while ( _nc-- ) { \
+ int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \
+ int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \
+ int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \
+ int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+#define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa )
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
+ (((int)g & 0xfc) << 3) | \
+ (((int)b & 0xf8) >> 3))
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = (p >> 8) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p << 3) & 0xf8; \
+ rgba[3] = 0xff; \
+ if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
+ if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
+ if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \
+ } while (0)
+
+#define TAG(x) gamma##x##_RGB565
+#include "spantmp.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16) | \
+ (a << 24) )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch); \
+ rgba[0] = (p >> 16) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 0) & 0xff; \
+ rgba[3] = (p >> 24) & 0xff; \
+} while (0)
+
+#define TAG(x) gamma##x##_ARGB8888
+#include "spantmp.h"
+
+
+/* 16 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + _x*2 + _y*pitch);
+
+#define TAG(x) gamma##x##_16
+#include "depthtmp.h"
+
+
+
+
+/* 32 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch);
+
+#define TAG(x) gamma##x##_32
+#include "depthtmp.h"
+
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xff; \
+ tmp |= (d) & 0xffffff00; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff;
+
+
+#define TAG(x) gamma##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xffffff00; \
+ tmp |= d & 0xff; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
+
+#define TAG(x) gamma##x##_24_8
+#include "stenciltmp.h"
+
+#if 0
+static void gammaReadRGBASpan8888( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gammaScreenPtr gammascrn = gmesa->gammaScreen;
+ CARD32 dwords1, dwords2, i = 0;
+ char *src = (char *)rgba[0];
+ GLuint read = n * gammascrn->cpp; /* Number of bytes we are expecting */
+ CARD32 data;
+
+ FLUSH_DMA_BUFFER(gmesa);
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode & ~(LBReadSrcEnable | LBReadDstEnable));
+ WRITE(gmesa->buf, ColorDDAMode, ColorDDAEnable);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode & ~FBReadSrcEnable) | FBReadDstEnable | FBDataTypeColor);
+ WRITE(gmesa->buf, FilterMode, 0x200); /* Pass FBColorData */
+ WRITE(gmesa->buf, FBWriteMode, FBW_UploadColorData | FBWriteModeDisable);
+ WRITE(gmesa->buf, StartXSub, (x+n)<<16);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, GLINTCount, 1);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, Render, PrimitiveTrapezoid);
+ FLUSH_DMA_BUFFER(gmesa);
+
+moredata:
+
+ dwords1 = *(volatile CARD32*)(void *)(((CARD8*)gammascrn->regions[0].map) + (GlintOutFIFOWords));
+ dwords2 = *(volatile CARD32*)(void *)(((CARD8*)gammascrn->regions[2].map) + (GlintOutFIFOWords));
+
+ if (dwords1) {
+ memcpy(src, (char*)gammascrn->regions[1].map + 0x1000, dwords1 << 2);
+ src += dwords1 << 2;
+ read -= dwords1 << 2;
+ }
+ if (dwords2) {
+ memcpy(src, (char*)gammascrn->regions[3].map + 0x1000, dwords2 << 2);
+ src += dwords2 << 2;
+ read -= dwords2 << 2;
+ }
+
+ if (read)
+ goto moredata;
+
+done:
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, FilterMode, 0x400);
+}
+#endif
+
+static void gammaSetReadBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ gmesa->readOffset = 0;
+ break;
+ case GL_BACK_LEFT:
+ gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ break;
+ }
+}
+
+
+void gammaDDInitSpanFuncs( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetReadBuffer = gammaSetReadBuffer;
+
+ switch ( gmesa->gammaScreen->cpp ) {
+ case 2:
+ swdd->WriteRGBASpan = gammaWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = gammaWriteRGBSpan_RGB565;
+ swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_RGB565;
+ swdd->WriteRGBAPixels = gammaWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = gammaReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = gammaReadRGBAPixels_RGB565;
+ break;
+
+ case 4:
+ swdd->WriteRGBASpan = gammaWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = gammaWriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = gammaWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_ARGB8888;
+#if 1
+ swdd->ReadRGBASpan = gammaReadRGBASpan_ARGB8888;
+#else
+ swdd->ReadRGBASpan = gammaReadRGBASpan8888;
+#endif
+ swdd->ReadRGBAPixels = gammaReadRGBAPixels_ARGB8888;
+ break;
+
+ default:
+ break;
+ }
+
+ switch ( gmesa->glCtx->Visual.depthBits ) {
+ case 16:
+ swdd->ReadDepthSpan = gammaReadDepthSpan_16;
+ swdd->WriteDepthSpan = gammaWriteDepthSpan_16;
+ swdd->ReadDepthPixels = gammaReadDepthPixels_16;
+ swdd->WriteDepthPixels = gammaWriteDepthPixels_16;
+ break;
+
+ case 24:
+ swdd->ReadDepthSpan = gammaReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = gammaWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = gammaReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = gammaWriteDepthPixels_24_8;
+
+#if 0
+ swdd->ReadStencilSpan = gammaReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = gammaWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = gammaReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = gammaWriteStencilPixels_24_8;
+#endif
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c
new file mode 100644
index 000000000..5f69853fd
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_state.c
@@ -0,0 +1,1731 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * 3DLabs Gamma driver
+ */
+
+#include <X11/Xlibint.h>
+#include "gamma_context.h"
+#include "gamma_macros.h"
+#include "macros.h"
+#include "glint_dri.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+
+#define ENABLELIGHTING 0
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void gammaUpdateAlphaMode( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 a = gmesa->AlphaTestMode;
+ CARD32 b = gmesa->AlphaBlendMode;
+ CARD32 f = gmesa->AB_FBReadMode_Save = 0;
+
+ a &= ~(AT_CompareMask | AT_RefValueMask);
+ b &= ~(AB_SrcBlendMask | AB_DstBlendMask);
+
+ a |= ctx->Color.AlphaRef << 4;
+
+ switch ( ctx->Color.AlphaFunc ) {
+ case GL_NEVER:
+ a |= AT_Never;
+ break;
+ case GL_LESS:
+ a |= AT_Less;
+ break;
+ case GL_EQUAL:
+ a |= AT_Equal;
+ break;
+ case GL_LEQUAL:
+ a |= AT_LessEqual;
+ break;
+ case GL_GEQUAL:
+ a |= AT_GreaterEqual;
+ break;
+ case GL_GREATER:
+ a |= AT_Greater;
+ break;
+ case GL_NOTEQUAL:
+ a |= AT_NotEqual;
+ break;
+ case GL_ALWAYS:
+ a |= AT_Always;
+ break;
+ }
+
+ if ( ctx->Color.AlphaEnabled ) {
+ f |= FBReadDstEnable;
+ a |= AlphaTestModeEnable;
+ } else {
+ a &= ~AlphaTestModeEnable;
+ }
+
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ b |= AB_Src_Zero;
+ break;
+ case GL_ONE:
+ b |= AB_Src_One;
+ break;
+ case GL_DST_COLOR:
+ b |= AB_Src_DstColor;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ b |= AB_Src_OneMinusDstColor;
+ break;
+ case GL_SRC_ALPHA:
+ b |= AB_Src_SrcAlpha;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= AB_Src_OneMinusSrcAlpha;
+ break;
+ case GL_DST_ALPHA:
+ b |= AB_Src_DstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= AB_Src_OneMinusDstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ b |= AB_Src_SrcAlphaSaturate;
+ break;
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ b |= AB_Dst_Zero;
+ break;
+ case GL_ONE:
+ b |= AB_Dst_One;
+ break;
+ case GL_SRC_COLOR:
+ b |= AB_Dst_SrcColor;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ b |= AB_Dst_OneMinusSrcColor;
+ break;
+ case GL_SRC_ALPHA:
+ b |= AB_Dst_SrcAlpha;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= AB_Dst_OneMinusSrcAlpha;
+ break;
+ case GL_DST_ALPHA:
+ b |= AB_Dst_DstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= AB_Dst_OneMinusDstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ }
+
+ if ( ctx->Color.BlendEnabled ) {
+ f |= FBReadDstEnable;
+ b |= AlphaBlendModeEnable;
+ } else {
+ b &= ~AlphaBlendModeEnable;
+ }
+
+ if ( gmesa->AlphaTestMode != a ) {
+ gmesa->AlphaTestMode = a;
+ gmesa->dirty |= GAMMA_UPLOAD_ALPHA;
+ }
+ if ( gmesa->AlphaBlendMode != b) {
+ gmesa->AlphaBlendMode = b;
+ gmesa->dirty |= GAMMA_UPLOAD_BLEND;
+ }
+ gmesa->AB_FBReadMode_Save = f;
+}
+
+static void gammaDDAlphaFunc( GLcontext *ctx, GLenum func, GLchan ref )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+static void gammaDDBlendEquation( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+static void gammaDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+static void gammaDDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static void gammaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
+ GLuint temp = 0;
+
+ FLUSH_BATCH( gmesa );
+
+ /* Update and emit any new state. We need to do this here to catch
+ * changes to the masks.
+ * FIXME: Just update the masks?
+ */
+ if ( gmesa->new_state )
+ gammaDDUpdateHWState( ctx );
+
+#ifdef DO_VALIDATE
+ /* Flush any partially filled buffers */
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+#endif
+
+ if (mask & DD_DEPTH_BIT) {
+ /* Turn off writes the FB */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeDisable);
+
+ mask &= ~DD_DEPTH_BIT;
+
+ /*
+ * Turn Rectangle2DControl off when the window is not clipped
+ * (i.e., the GID tests are not necessary). This dramatically
+ * increases the performance of the depth clears.
+ */
+ if (!gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+ }
+
+ temp = (gmesa->LBReadMode & LBPartialProdMask) | LBWindowOriginBot;
+ if (gDRIPriv->numMultiDevices == 2) temp |= LBScanLineInt2;
+
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, LBReadMode, temp);
+ WRITE(gmesa->buf, DeltaMode, DM_DepthEnable);
+ WRITE(gmesa->buf, DepthMode, (DepthModeEnable |
+ DM_Always |
+ DM_SourceDepthRegister |
+ DM_WriteMask));
+ WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
+
+ /* Increment the frame count */
+ gmesa->FrameCount++;
+#ifdef FAST_CLEAR_4
+ gmesa->FrameCount &= 0x0f;
+#else
+ gmesa->FrameCount &= 0xff;
+#endif
+
+ /* Force FCP to be written */
+ WRITE(gmesa->buf, GLINTWindow, (WindowEnable |
+ W_PassIfEqual |
+ (gmesa->Window & W_GIDMask) |
+ W_DepthFCP |
+ W_LBUpdateFromRegisters |
+ W_OverrideWriteFiltering |
+ (gmesa->FrameCount << 9)));
+
+ /* Clear part of the depth and FCP buffers */
+ {
+ int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h;
+ int x = gmesa->driDrawable->x;
+ int w = gmesa->driDrawable->w;
+ int h = gmesa->driDrawable->h;
+#ifndef TURN_OFF_FCP
+ float hsub = h;
+
+ if (gmesa->WindowChanged) {
+ gmesa->WindowChanged = GL_FALSE;
+ } else {
+#ifdef FAST_CLEAR_4
+ hsub /= 16;
+#else
+ hsub /= 256;
+#endif
+
+ /* Handle the case where the height < # of FCPs */
+ if (hsub < 1.0) {
+ if (gmesa->FrameCount > h)
+ gmesa->FrameCount = 0;
+ h = 1;
+ y += gmesa->FrameCount;
+ } else {
+ h = (gmesa->FrameCount+1)*hsub;
+ h -= (int)(gmesa->FrameCount*hsub);
+ y += gmesa->FrameCount*hsub;
+ }
+ }
+#endif
+ if (h && w) {
+#if 0
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, Rectangle2DMode, ((h & 0xfff)<<12) |
+ (w & 0xfff) );
+ WRITE(gmesa->buf, DrawRectangle2D, ((y & 0xffff)<<16) |
+ (x & 0xffff) );
+#else
+ CHECK_DMA_BUFFER(gmesa, 8);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, StartXSub, (x+w)<<16);
+ WRITE(gmesa->buf, GLINTCount, h);
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, Render, 0x00000040); /* NOT_DONE */
+#endif
+ }
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
+ WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+
+ /* Turn on Depth FCP */
+ if (gmesa->Window & W_DepthFCP) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, WindowOr, (gmesa->FrameCount << 9));
+ }
+
+ /* Turn off GID clipping if window is not clipped */
+ if (gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 0);
+ }
+ }
+
+ if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
+ int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h;
+ int x = gmesa->driDrawable->x;
+ int w = gmesa->driDrawable->w;
+ int h = gmesa->driDrawable->h;
+
+ mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
+
+ if (x < 0) { w -= -x; x = 0; }
+
+ /* Turn on GID clipping if window is clipped */
+ if (!gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 18);
+ WRITE(gmesa->buf, FBBlockColor, gmesa->ClearColor);
+ WRITE(gmesa->buf, ColorDDAMode, ColorDDADisable);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, DepthMode, 0);
+ WRITE(gmesa->buf, DeltaMode, 0);
+ WRITE(gmesa->buf, AlphaBlendMode, 0);
+#if 1
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, StartXSub, (x+w)<<16);
+ WRITE(gmesa->buf, GLINTCount, h);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, Render, 0x00000048); /* NOT_DONE */
+#else
+ WRITE(gmesa->buf, Rectangle2DMode, (((h & 0xfff)<<12) |
+ (w & 0xfff)));
+ WRITE(gmesa->buf, DrawRectangle2D, (((y & 0xffff)<<16) |
+ (x & 0xffff)));
+#endif
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+
+ /* Turn off GID clipping if window is clipped */
+ if (gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 0);
+ }
+ }
+
+#ifdef DO_VALIDATE
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
+
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+#endif
+
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void gammaUpdateZMode( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 z = gmesa->DepthMode;
+ CARD32 delta = gmesa->DeltaMode;
+ CARD32 window = gmesa->Window;
+ CARD32 lbread = gmesa->LBReadMode;
+
+ z &= ~DM_CompareMask;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ z |= DM_Never;
+ break;
+ case GL_ALWAYS:
+ z |= DM_Always;
+ break;
+ case GL_LESS:
+ z |= DM_Less;
+ break;
+ case GL_LEQUAL:
+ z |= DM_LessEqual;
+ break;
+ case GL_EQUAL:
+ z |= DM_Equal;
+ break;
+ case GL_GEQUAL:
+ z |= DM_GreaterEqual;
+ break;
+ case GL_GREATER:
+ z |= DM_Greater;
+ break;
+ case GL_NOTEQUAL:
+ z |= DM_NotEqual;
+ break;
+ }
+
+ if ( ctx->Depth.Test ) {
+ z |= DepthModeEnable;
+ delta |= DM_DepthEnable;
+ window |= W_DepthFCP;
+ lbread |= LBReadDstEnable;
+ } else {
+ z &= ~DepthModeEnable;
+ delta &= ~DM_DepthEnable;
+ window &= ~W_DepthFCP;
+ lbread &= ~LBReadDstEnable;
+ }
+
+ if ( ctx->Depth.Mask ) {
+ z |= DM_WriteMask;
+ } else {
+ z &= ~DM_WriteMask;
+ }
+
+#if 0
+ if ( gmesa->DepthMode != z ){
+#endif
+ gmesa->DepthMode = z;
+ gmesa->DeltaMode = delta;
+ gmesa->Window = window;
+ gmesa->LBReadMode = lbread;
+ gmesa->dirty |= GAMMA_UPLOAD_DEPTH;
+#if 0
+ }
+#endif
+}
+
+static void gammaDDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+}
+
+static void gammaDDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+}
+
+static void gammaDDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( gmesa->DepthSize ) {
+ case 16:
+ gmesa->ClearDepth = d * 0x0000ffff;
+ break;
+ case 24:
+ gmesa->ClearDepth = d * 0x00ffffff;
+ break;
+ case 32:
+ gmesa->ClearDepth = d * 0xffffffff;
+ break;
+ }
+}
+
+static void gammaDDFinish( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_DMA_BUFFER(gmesa);
+}
+
+static void gammaDDFlush( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_DMA_BUFFER(gmesa);
+}
+
+/* =============================================================
+ * Fog
+ */
+
+static void gammaUpdateFogAttrib( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 f = gmesa->FogMode;
+ CARD32 g = gmesa->GeometryMode;
+ CARD32 d = gmesa->DeltaMode;
+
+ if (ctx->Fog.Enabled) {
+ f |= FogModeEnable;
+ g |= GM_FogEnable;
+ d |= DM_FogEnable;
+ } else {
+ f &= ~FogModeEnable;
+ g &= ~GM_FogEnable;
+ d &= ~DM_FogEnable;
+ }
+
+ g &= ~GM_FogMask;
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ g |= GM_FogLinear;
+ break;
+ case GL_EXP:
+ g |= GM_FogExp;
+ break;
+ case GL_EXP2:
+ g |= GM_FogExpSquared;
+ break;
+ }
+
+ if ( gmesa->FogMode != f ) {
+ gmesa->FogMode = f;
+ gmesa->dirty |= GAMMA_UPLOAD_FOG;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+
+ if ( gmesa->DeltaMode != d ) {
+ gmesa->DeltaMode = d;
+ gmesa->dirty |= GAMMA_UPLOAD_DEPTH;
+ }
+}
+
+static void gammaDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_FOG;
+}
+
+/* =============================================================
+ * Lines
+ */
+static void gammaDDLineWidth( GLcontext *ctx, GLfloat width )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, LineWidth, (GLuint)width);
+ WRITEF(gmesa->buf, AAlineWidth, width);
+ WRITE(gmesa->buf, LineWidthOffset, (GLuint)(width-1)/2);
+}
+
+static void gammaDDLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ gmesa->LineMode &= ~(LM_StippleMask | LM_RepeatFactorMask);
+ gmesa->LineMode |= ((GLuint)(factor - 1) << 1) | ((GLuint)pattern << 10);
+
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+}
+
+
+
+/* =============================================================
+ * Points
+ */
+static void gammaDDPointSize( GLcontext *ctx, GLfloat size )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, PointSize, (GLuint)size);
+ WRITEF(gmesa->buf, AApointSize, size);
+}
+
+/* =============================================================
+ * Polygon
+ */
+
+static void gammaUpdatePolygon( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 g = gmesa->GeometryMode;
+
+ g &= ~(GM_PolyOffsetFillEnable | GM_PolyOffsetPointEnable |
+ GM_PolyOffsetLineEnable);
+
+ if (ctx->Polygon.OffsetFill) g |= GM_PolyOffsetFillEnable;
+ if (ctx->Polygon.OffsetPoint) g |= GM_PolyOffsetPointEnable;
+ if (ctx->Polygon.OffsetLine) g |= GM_PolyOffsetLineEnable;
+
+ g &= ~GM_FB_PolyMask;
+
+ switch (ctx->Polygon.FrontMode) {
+ case GL_FILL:
+ g |= GM_FrontPolyFill;
+ break;
+ case GL_LINE:
+ g |= GM_FrontPolyLine;
+ break;
+ case GL_POINT:
+ g |= GM_FrontPolyPoint;
+ break;
+ }
+
+ switch (ctx->Polygon.BackMode) {
+ case GL_FILL:
+ g |= GM_BackPolyFill;
+ break;
+ case GL_LINE:
+ g |= GM_BackPolyLine;
+ break;
+ case GL_POINT:
+ g |= GM_BackPolyPoint;
+ break;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_POLYGON;
+}
+
+static void gammaDDPolygonMode( GLcontext *ctx, GLenum face, GLenum mode)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_POLYGON;
+}
+
+static void gammaUpdateStipple( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ if (ctx->Polygon.StippleFlag) {
+ gmesa->AreaStippleMode |= AreaStippleModeEnable/* | ASM_X32 | ASM_Y32*/;
+ } else {
+ gmesa->AreaStippleMode &= ~AreaStippleModeEnable;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_STIPPLE;
+}
+
+static void gammaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_STIPPLE;
+}
+
+/* =============================================================
+ * Clipping
+ */
+
+static void gammaUpdateClipping( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLint x1, y1, x2, y2;
+
+ if ( gmesa->driDrawable ) {
+ x1 = gmesa->driDrawable->x + ctx->Scissor.X;
+ y1 = gmesa->driScreen->fbHeight -
+ (gmesa->driDrawable->y +
+ gmesa->driDrawable->h) + ctx->Scissor.Y;
+ x2 = x1 + ctx->Scissor.Width;
+ y2 = y1 + ctx->Scissor.Height;
+
+ gmesa->ScissorMinXY = x1 | (y1 << 16);
+ gmesa->ScissorMaxXY = x2 | (y2 << 16);
+ if (ctx->Scissor.Enabled)
+ gmesa->ScissorMode |= UserScissorEnable;
+ else
+ gmesa->ScissorMode &= ~UserScissorEnable;
+
+ gmesa->dirty |= GAMMA_UPLOAD_CLIP;
+ }
+}
+
+static void gammaDDScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+}
+
+/* =============================================================
+ * Culling
+ */
+
+static void gammaUpdateCull( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 g = gmesa->GeometryMode;
+
+ g &= ~(GM_PolyCullMask | GM_FFMask);
+
+ if (ctx->Polygon.FrontFace == GL_CCW) {
+ g |= GM_FrontFaceCCW;
+ } else {
+ g |= GM_FrontFaceCW;
+ }
+
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_FRONT:
+ g |= GM_PolyCullFront;
+ break;
+ case GL_BACK:
+ g |= GM_PolyCullBack;
+ break;
+ case GL_FRONT_AND_BACK:
+ g |= GM_PolyCullBoth;
+ break;
+ }
+
+ if ( ctx->Polygon.CullFlag ) {
+ g |= GM_PolyCullEnable;
+ } else {
+ g &= ~GM_PolyCullEnable;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+}
+
+static void gammaDDCullFace( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+}
+
+static void gammaDDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+}
+
+/* =============================================================
+ * Masks
+ */
+
+static void gammaUpdateMasks( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+
+ GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16;
+
+ if ( gmesa->FBHardwareWriteMask != mask ) {
+ gmesa->FBHardwareWriteMask = mask;
+ gmesa->dirty |= GAMMA_UPLOAD_MASKS;
+ }
+}
+
+static void gammaDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_MASKS;
+}
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+static void gammaDDLightfv(GLcontext *ctx, GLenum light, GLenum pname,
+ const GLfloat *params, GLint nParams)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLfloat l,x,y,z,w;
+
+ switch(light) {
+ case GL_LIGHT0:
+ switch (pname) {
+ case GL_AMBIENT:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0AmbientIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0AmbientIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0AmbientIntensityRed, params[0]);
+ break;
+ case GL_DIFFUSE:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityRed, params[0]);
+ break;
+ case GL_SPECULAR:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0SpecularIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0SpecularIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0SpecularIntensityRed, params[0]);
+ break;
+ case GL_POSITION:
+ /* Normalize <x,y,z> */
+ x = params[0]; y = params[1]; z = params[2]; w = params[3];
+ l = sqrt(x*x + y*y + z*z + w*w);
+ w /= l;
+ x /= l;
+ y /= l;
+ z /= l;
+ if (params[3] != 0.0) {
+ gmesa->Light0Mode |= Light0ModeAttenuation;
+ gmesa->Light0Mode |= Light0ModeLocal;
+ } else {
+ gmesa->Light0Mode &= ~Light0ModeAttenuation;
+ gmesa->Light0Mode &= ~Light0ModeLocal;
+ }
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode);
+ WRITEF(gmesa->buf, Light0PositionW, w);
+ WRITEF(gmesa->buf, Light0PositionZ, z);
+ WRITEF(gmesa->buf, Light0PositionY, y);
+ WRITEF(gmesa->buf, Light0PositionX, x);
+ break;
+ case GL_SPOT_DIRECTION:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* WRITEF(gmesa->buf, Light0SpotlightDirectionW, params[3]); */
+ WRITEF(gmesa->buf, Light0SpotlightDirectionZ, params[2]);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionY, params[1]);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionX, params[0]);
+ break;
+ case GL_SPOT_EXPONENT:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0SpotlightExponent, params[0]);
+ break;
+ case GL_SPOT_CUTOFF:
+ if (params[0] != 180.0)
+ gmesa->Light0Mode |= Light0ModeSpotLight;
+ else
+ gmesa->Light0Mode &= ~Light0ModeSpotLight;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode);
+ WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, cos(params[0]*DEG2RAD));
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0ConstantAttenuation, params[0]);
+ break;
+ case GL_LINEAR_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0LinearAttenuation, params[0]);
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0QuadraticAttenuation, params[0]);
+ break;
+ }
+ break;
+ }
+}
+
+static void gammaDDLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *params )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, SceneAmbientColorBlue, params[2]);
+ WRITEF(gmesa->buf, SceneAmbientColorGreen, params[1]);
+ WRITEF(gmesa->buf, SceneAmbientColorRed, params[0]);
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ if (params[0] != 0.0)
+ gmesa->LightingMode |= LightingModeLocalViewer;
+ else
+ gmesa->LightingMode &= ~LightingModeLocalViewer;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ if (params[0] == 1.0f) {
+ gmesa->LightingMode |= LightingModeTwoSides;
+ gmesa->MaterialMode |= MaterialModeTwoSides;
+ } else {
+ gmesa->LightingMode &= ~LightingModeTwoSides;
+ gmesa->MaterialMode &= ~MaterialModeTwoSides;
+ }
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode);
+ break;
+ }
+}
+
+static void gammaDDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ CARD32 g = gmesa->GeometryMode;
+ CARD32 c = gmesa->ColorDDAMode;
+
+ g &= ~GM_ShadingMask;
+ c &= ~ColorDDAShadingMask;
+
+ switch ( mode ) {
+ case GL_FLAT:
+ g |= GM_FlatShading;
+ c |= ColorDDAFlat;
+ break;
+ case GL_SMOOTH:
+ g |= GM_GouraudShading;
+ c |= ColorDDAGouraud;
+ break;
+ default:
+ return;
+ }
+
+ if ( gmesa->ColorDDAMode != c ) {
+ FLUSH_BATCH( gmesa );
+ gmesa->ColorDDAMode = c;
+
+ gmesa->dirty |= GAMMA_UPLOAD_SHADE;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ FLUSH_BATCH( gmesa );
+ gmesa->GeometryMode = g;
+
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+}
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void gammaDDClearColor( GLcontext *ctx, const GLchan color[4])
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ gmesa->ClearColor = gammaPackColor( gmesa->gammaScreen->cpp,
+ color[0], color[1], color[2], color[3] );
+
+ if (gmesa->gammaScreen->cpp == 2) gmesa->ClearColor |= gmesa->ClearColor<<16;
+}
+
+
+static void gammaDDLogicalOpcode( GLcontext *ctx, GLenum opcode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ if ( ctx->Color.ColorLogicOpEnabled ) {
+ gmesa->LogicalOpMode = opcode << 1 | LogicalOpModeEnable;
+ } else {
+ gmesa->LogicalOpMode = LogicalOpModeDisable;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_LOGICOP;
+}
+
+static GLboolean gammaDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ gmesa->drawOffset = 0;
+ break;
+ case GL_BACK_LEFT:
+ gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ break;
+ }
+
+ return GL_TRUE;
+}
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+void gammaUpdateWindow( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat sy = v[MAT_SY];
+ GLfloat ty = v[MAT_TY] + yoffset;
+ GLfloat sz = v[MAT_SZ] * gmesa->depth_scale;
+ GLfloat tz = v[MAT_TZ] * gmesa->depth_scale;
+
+ gmesa->dirty |= GAMMA_UPLOAD_VIEWPORT;
+
+ gmesa->ViewportScaleX = sx;
+ gmesa->ViewportScaleY = sy;
+ gmesa->ViewportScaleZ = sz;
+ gmesa->ViewportOffsetX = tx;
+ gmesa->ViewportOffsetY = ty;
+ gmesa->ViewportOffsetZ = tz;
+}
+
+
+
+static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ gammaUpdateWindow( ctx );
+}
+
+static void gammaDDDepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ gammaUpdateWindow( ctx );
+}
+
+void gammaUpdateViewportOffset( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat ty = v[MAT_TY] + yoffset;
+
+ if ( gmesa->ViewportOffsetX != tx ||
+ gmesa->ViewportOffsetY != ty )
+ {
+ gmesa->ViewportOffsetX = tx;
+ gmesa->ViewportOffsetY = ty;
+
+ gmesa->new_state |= GAMMA_NEW_WINDOW;
+ }
+
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+}
+
+/*
+ * Matrix
+ */
+
+static void gammaLoadHWMatrix(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ gmesa->TransformMode &= ~XM_XformTexture;
+
+ switch (ctx->Transform.MatrixMode) {
+ case GL_MODELVIEW:
+ gmesa->TransformMode |= XM_UseModelViewMatrix;
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewMatrix0, ctx->ModelView.m[0]);
+ WRITEF(gmesa->buf, ModelViewMatrix1, ctx->ModelView.m[1]);
+ WRITEF(gmesa->buf, ModelViewMatrix2, ctx->ModelView.m[2]);
+ WRITEF(gmesa->buf, ModelViewMatrix3, ctx->ModelView.m[3]);
+ WRITEF(gmesa->buf, ModelViewMatrix4, ctx->ModelView.m[4]);
+ WRITEF(gmesa->buf, ModelViewMatrix5, ctx->ModelView.m[5]);
+ WRITEF(gmesa->buf, ModelViewMatrix6, ctx->ModelView.m[6]);
+ WRITEF(gmesa->buf, ModelViewMatrix7, ctx->ModelView.m[7]);
+ WRITEF(gmesa->buf, ModelViewMatrix8, ctx->ModelView.m[8]);
+ WRITEF(gmesa->buf, ModelViewMatrix9, ctx->ModelView.m[9]);
+ WRITEF(gmesa->buf, ModelViewMatrix10, ctx->ModelView.m[10]);
+ WRITEF(gmesa->buf, ModelViewMatrix11, ctx->ModelView.m[11]);
+ WRITEF(gmesa->buf, ModelViewMatrix12, ctx->ModelView.m[12]);
+ WRITEF(gmesa->buf, ModelViewMatrix13, ctx->ModelView.m[13]);
+ WRITEF(gmesa->buf, ModelViewMatrix14, ctx->ModelView.m[14]);
+ WRITEF(gmesa->buf, ModelViewMatrix15, ctx->ModelView.m[15]);
+ break;
+ case GL_PROJECTION:
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix0,
+ ctx->ProjectionMatrix.m[0]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix1,
+ ctx->ProjectionMatrix.m[1]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix2,
+ ctx->ProjectionMatrix.m[2]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix3,
+ ctx->ProjectionMatrix.m[3]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix4,
+ ctx->ProjectionMatrix.m[4]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix5,
+ ctx->ProjectionMatrix.m[5]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix6,
+ ctx->ProjectionMatrix.m[6]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix7,
+ ctx->ProjectionMatrix.m[7]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix8,
+ ctx->ProjectionMatrix.m[8]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix9,
+ ctx->ProjectionMatrix.m[9]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix10,
+ ctx->ProjectionMatrix.m[10]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix11,
+ ctx->ProjectionMatrix.m[11]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix12,
+ ctx->ProjectionMatrix.m[12]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix13,
+ ctx->ProjectionMatrix.m[13]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix14,
+ ctx->ProjectionMatrix.m[14]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix15,
+ ctx->ProjectionMatrix.m[15]);
+ break;
+ case GL_TEXTURE:
+ CHECK_DMA_BUFFER(gmesa, 16);
+ gmesa->TransformMode |= XM_XformTexture;
+ WRITEF(gmesa->buf, TextureMatrix0, ctx->TextureMatrix[0].m[0]);
+ WRITEF(gmesa->buf, TextureMatrix1, ctx->TextureMatrix[0].m[1]);
+ WRITEF(gmesa->buf, TextureMatrix2, ctx->TextureMatrix[0].m[2]);
+ WRITEF(gmesa->buf, TextureMatrix3, ctx->TextureMatrix[0].m[3]);
+ WRITEF(gmesa->buf, TextureMatrix4, ctx->TextureMatrix[0].m[4]);
+ WRITEF(gmesa->buf, TextureMatrix5, ctx->TextureMatrix[0].m[5]);
+ WRITEF(gmesa->buf, TextureMatrix6, ctx->TextureMatrix[0].m[6]);
+ WRITEF(gmesa->buf, TextureMatrix7, ctx->TextureMatrix[0].m[7]);
+ WRITEF(gmesa->buf, TextureMatrix8, ctx->TextureMatrix[0].m[8]);
+ WRITEF(gmesa->buf, TextureMatrix9, ctx->TextureMatrix[0].m[9]);
+ WRITEF(gmesa->buf, TextureMatrix10, ctx->TextureMatrix[0].m[10]);
+ WRITEF(gmesa->buf, TextureMatrix11, ctx->TextureMatrix[0].m[11]);
+ WRITEF(gmesa->buf, TextureMatrix12, ctx->TextureMatrix[0].m[12]);
+ WRITEF(gmesa->buf, TextureMatrix13, ctx->TextureMatrix[0].m[13]);
+ WRITEF(gmesa->buf, TextureMatrix14, ctx->TextureMatrix[0].m[14]);
+ WRITEF(gmesa->buf, TextureMatrix15, ctx->TextureMatrix[0].m[15]);
+ break;
+
+ default:
+ /* ERROR!!! -- how did this happen? */
+ break;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_TRANSFORM;
+}
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void gammaDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ case GL_BLEND:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+ break;
+
+ case GL_CULL_FACE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+ break;
+
+ case GL_DEPTH_TEST:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+ break;
+
+ case GL_DITHER:
+ do {
+ CARD32 d = gmesa->DitherMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ d |= DM_DitherEnable;
+ } else {
+ d &= ~DM_DitherEnable;
+ }
+
+ if ( gmesa->DitherMode != d ) {
+ gmesa->DitherMode = d;
+ gmesa->dirty |= GAMMA_UPLOAD_DITHER;
+ }
+ } while (0);
+ break;
+
+#if 0
+ case GL_FOG:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_FOG;
+ break;
+#endif
+
+ case GL_INDEX_LOGIC_OP:
+ case GL_COLOR_LOGIC_OP:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_LOGICOP;
+ break;
+
+#if ENABLELIGHTING
+ case GL_LIGHTING:
+ do {
+ CARD32 l = gmesa->LightingMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ l |= LightingModeEnable;
+ } else {
+ l &= ~LightingModeEnable;
+ }
+
+ if ( gmesa->LightingMode != l ) {
+ gmesa->LightingMode = l;
+ gmesa->dirty |= GAMMA_UPLOAD_LIGHT;
+ }
+ } while (0);
+ break;
+
+ case GL_COLOR_MATERIAL:
+ do {
+ CARD32 m = gmesa->MaterialMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ m |= MaterialModeEnable;
+ } else {
+ m &= ~MaterialModeEnable;
+ }
+
+ if ( gmesa->MaterialMode != m ) {
+ gmesa->MaterialMode = m;
+ gmesa->dirty |= GAMMA_UPLOAD_LIGHT;
+ }
+ } while (0);
+ break;
+#endif
+
+ case GL_LINE_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->LineMode |= LM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->LineMode &= ~LM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+ break;
+
+ case GL_POINT_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->PointMode |= PM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->PointMode &= ~PM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_POINTMODE;
+ break;
+
+ case GL_POLYGON_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->TriangleMode |= TM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->TriangleMode &= ~TM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_TRIMODE;
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+ break;
+
+ case GL_POLYGON_OFFSET_FILL:
+ case GL_POLYGON_OFFSET_POINT:
+ case GL_POLYGON_OFFSET_LINE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_POLYGON;
+ break;
+
+ case GL_LINE_STIPPLE:
+ FLUSH_BATCH( gmesa );
+ if ( state )
+ gmesa->LineMode |= LM_StippleEnable;
+ else
+ gmesa->LineMode &= ~LM_StippleEnable;
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_STIPPLE;
+ break;
+
+ default:
+ return;
+ }
+}
+
+/* =============================================================
+ * State initialization, management
+ */
+
+
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void gammaEmitHwState( gammaContextPtr gmesa )
+{
+ if (!gmesa->driDrawable) return;
+
+ if (!gmesa->dirty) return;
+
+#ifdef DO_VALIDATE
+ /* Flush any partially filled buffers */
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+#endif
+
+ if (gmesa->dirty & GAMMA_UPLOAD_VIEWPORT) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_VIEWPORT;
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->ViewportOffsetX);
+ WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->ViewportOffsetY);
+ WRITEF(gmesa->buf, ViewPortOffsetZ, gmesa->ViewportOffsetZ);
+ WRITEF(gmesa->buf, ViewPortScaleX, gmesa->ViewportScaleX);
+ WRITEF(gmesa->buf, ViewPortScaleY, gmesa->ViewportScaleY);
+ WRITEF(gmesa->buf, ViewPortScaleZ, gmesa->ViewportScaleZ);
+ }
+ if ( (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) ||
+ (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) ||
+ (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) ) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_POINTMODE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PointMode, gmesa->PointMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LINEMODE;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LineMode, gmesa->LineMode);
+ WRITE(gmesa->buf, LineStippleMode, gmesa->LineMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_TRIMODE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_FOG) {
+ GLchan c[3], col;
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( c, gmesa->glCtx->Fog.Color );
+ col = gammaPackColor(4, c[0], c[1], c[2], 0);
+ gmesa->dirty &= ~GAMMA_UPLOAD_FOG;
+ CHECK_DMA_BUFFER(gmesa, 5);
+#if 0
+ WRITE(gmesa->buf, FogMode, gmesa->FogMode);
+ WRITE(gmesa->buf, FogColor, col);
+ WRITEF(gmesa->buf, FStart, gmesa->glCtx->Fog.Start);
+#endif
+ WRITEF(gmesa->buf, FogEnd, gmesa->glCtx->Fog.End);
+ WRITEF(gmesa->buf, FogDensity, gmesa->glCtx->Fog.Density);
+ WRITEF(gmesa->buf, FogScale,
+ 1.0f/(gmesa->glCtx->Fog.End - gmesa->glCtx->Fog.Start));
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_DITHER) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_DITHER;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LOGICOP) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LOGICOP;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_CLIP) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_CLIP;
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, ScissorMinXY, gmesa->ScissorMinXY);
+ WRITE(gmesa->buf, ScissorMaxXY, gmesa->ScissorMaxXY);
+ WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_MASKS) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_MASKS;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FBHardwareWriteMask, gmesa->FBHardwareWriteMask);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_ALPHA) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_ALPHA;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_BLEND) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_BLEND;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ }
+ CHECK_DMA_BUFFER(gmesa, 1);
+ if (gmesa->glCtx->Color.BlendEnabled || gmesa->glCtx->Color.AlphaEnabled) {
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode | gmesa->AB_FBReadMode_Save);
+ } else {
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LIGHT) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LIGHT;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_SHADE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_SHADE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_POLYGON) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_POLYGON;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, PolygonOffsetBias, gmesa->glCtx->Polygon.OffsetUnits);
+ WRITEF(gmesa->buf, PolygonOffsetFactor, gmesa->glCtx->Polygon.OffsetFactor);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_STIPPLE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_STIPPLE;
+ CHECK_DMA_BUFFER(gmesa, 33);
+ WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);
+ WRITE(gmesa->buf, AreaStipplePattern0, gmesa->glCtx->PolygonStipple[0]);
+ WRITE(gmesa->buf, AreaStipplePattern1, gmesa->glCtx->PolygonStipple[1]);
+ WRITE(gmesa->buf, AreaStipplePattern2, gmesa->glCtx->PolygonStipple[2]);
+ WRITE(gmesa->buf, AreaStipplePattern3, gmesa->glCtx->PolygonStipple[3]);
+ WRITE(gmesa->buf, AreaStipplePattern4, gmesa->glCtx->PolygonStipple[4]);
+ WRITE(gmesa->buf, AreaStipplePattern5, gmesa->glCtx->PolygonStipple[5]);
+ WRITE(gmesa->buf, AreaStipplePattern6, gmesa->glCtx->PolygonStipple[6]);
+ WRITE(gmesa->buf, AreaStipplePattern7, gmesa->glCtx->PolygonStipple[7]);
+ WRITE(gmesa->buf, AreaStipplePattern8, gmesa->glCtx->PolygonStipple[8]);
+ WRITE(gmesa->buf, AreaStipplePattern9, gmesa->glCtx->PolygonStipple[9]);
+ WRITE(gmesa->buf, AreaStipplePattern10, gmesa->glCtx->PolygonStipple[10]);
+ WRITE(gmesa->buf, AreaStipplePattern11, gmesa->glCtx->PolygonStipple[11]);
+ WRITE(gmesa->buf, AreaStipplePattern12, gmesa->glCtx->PolygonStipple[12]);
+ WRITE(gmesa->buf, AreaStipplePattern13, gmesa->glCtx->PolygonStipple[13]);
+ WRITE(gmesa->buf, AreaStipplePattern14, gmesa->glCtx->PolygonStipple[14]);
+ WRITE(gmesa->buf, AreaStipplePattern15, gmesa->glCtx->PolygonStipple[15]);
+ WRITE(gmesa->buf, AreaStipplePattern16, gmesa->glCtx->PolygonStipple[16]);
+ WRITE(gmesa->buf, AreaStipplePattern17, gmesa->glCtx->PolygonStipple[17]);
+ WRITE(gmesa->buf, AreaStipplePattern18, gmesa->glCtx->PolygonStipple[18]);
+ WRITE(gmesa->buf, AreaStipplePattern19, gmesa->glCtx->PolygonStipple[19]);
+ WRITE(gmesa->buf, AreaStipplePattern20, gmesa->glCtx->PolygonStipple[20]);
+ WRITE(gmesa->buf, AreaStipplePattern21, gmesa->glCtx->PolygonStipple[21]);
+ WRITE(gmesa->buf, AreaStipplePattern22, gmesa->glCtx->PolygonStipple[22]);
+ WRITE(gmesa->buf, AreaStipplePattern23, gmesa->glCtx->PolygonStipple[23]);
+ WRITE(gmesa->buf, AreaStipplePattern24, gmesa->glCtx->PolygonStipple[24]);
+ WRITE(gmesa->buf, AreaStipplePattern25, gmesa->glCtx->PolygonStipple[25]);
+ WRITE(gmesa->buf, AreaStipplePattern26, gmesa->glCtx->PolygonStipple[26]);
+ WRITE(gmesa->buf, AreaStipplePattern27, gmesa->glCtx->PolygonStipple[27]);
+ WRITE(gmesa->buf, AreaStipplePattern28, gmesa->glCtx->PolygonStipple[28]);
+ WRITE(gmesa->buf, AreaStipplePattern29, gmesa->glCtx->PolygonStipple[29]);
+ WRITE(gmesa->buf, AreaStipplePattern30, gmesa->glCtx->PolygonStipple[30]);
+ WRITE(gmesa->buf, AreaStipplePattern31, gmesa->glCtx->PolygonStipple[31]);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_DEPTH) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_DEPTH;
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, GLINTWindow,gmesa->Window | (gmesa->FrameCount << 9));
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_GEOMETRY) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_GEOMETRY;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TRANSFORM) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_TRANSFORM;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TEX0) {
+ gammaTextureObjectPtr curTex = gmesa->CurrentTexObj[0];
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
+ if (curTex) {
+ CHECK_DMA_BUFFER(gmesa, 21);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode | GM_TextureEnable);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode | DM_TextureEnable);
+ WRITE(gmesa->buf, TextureAddressMode, curTex->TextureAddressMode);
+ WRITE(gmesa->buf, TextureReadMode, curTex->TextureReadMode);
+ WRITE(gmesa->buf, TextureColorMode, curTex->TextureColorMode);
+ WRITE(gmesa->buf, TextureFilterMode, curTex->TextureFilterMode);
+ WRITE(gmesa->buf, TextureFormat, curTex->TextureFormat);
+ WRITE(gmesa->buf, GLINTBorderColor, curTex->TextureBorderColor);
+ WRITE(gmesa->buf, TxBaseAddr0, curTex->TextureBaseAddr[0]);
+ WRITE(gmesa->buf, TxBaseAddr1, curTex->TextureBaseAddr[1]);
+ WRITE(gmesa->buf, TxBaseAddr2, curTex->TextureBaseAddr[2]);
+ WRITE(gmesa->buf, TxBaseAddr3, curTex->TextureBaseAddr[3]);
+ WRITE(gmesa->buf, TxBaseAddr4, curTex->TextureBaseAddr[4]);
+ WRITE(gmesa->buf, TxBaseAddr5, curTex->TextureBaseAddr[5]);
+ WRITE(gmesa->buf, TxBaseAddr6, curTex->TextureBaseAddr[6]);
+ WRITE(gmesa->buf, TxBaseAddr7, curTex->TextureBaseAddr[7]);
+ WRITE(gmesa->buf, TxBaseAddr8, curTex->TextureBaseAddr[8]);
+ WRITE(gmesa->buf, TxBaseAddr9, curTex->TextureBaseAddr[9]);
+ WRITE(gmesa->buf, TxBaseAddr10, curTex->TextureBaseAddr[10]);
+ WRITE(gmesa->buf, TxBaseAddr11, curTex->TextureBaseAddr[11]);
+ WRITE(gmesa->buf, TxBaseAddr12, curTex->TextureBaseAddr[12]);
+ WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
+ } else {
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, TextureAddressMode, TextureAddressModeDisable);
+ WRITE(gmesa->buf, TextureReadMode, TextureReadModeDisable);
+ WRITE(gmesa->buf, TextureFilterMode, TextureFilterModeDisable);
+ WRITE(gmesa->buf, TextureColorMode, TextureColorModeDisable);
+ }
+ }
+#ifdef DO_VALIDATE
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
+
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+#endif
+}
+
+void gammaDDUpdateHWState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ int new_state = gmesa->new_state;
+
+ if ( new_state )
+ {
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state = 0;
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & GAMMA_NEW_ALPHA )
+ gammaUpdateAlphaMode( ctx );
+
+ if ( new_state & GAMMA_NEW_DEPTH )
+ gammaUpdateZMode( ctx );
+
+ if ( new_state & GAMMA_NEW_FOG )
+ gammaUpdateFogAttrib( ctx );
+
+ if ( new_state & GAMMA_NEW_CLIP )
+ gammaUpdateClipping( ctx );
+
+ if ( new_state & GAMMA_NEW_POLYGON )
+ gammaUpdatePolygon( ctx );
+
+ if ( new_state & GAMMA_NEW_CULL )
+ gammaUpdateCull( ctx );
+
+ if ( new_state & GAMMA_NEW_MASKS )
+ gammaUpdateMasks( ctx );
+
+ if ( new_state & GAMMA_NEW_WINDOW )
+ gammaUpdateWindow( ctx );
+
+ if ( new_state & GAMMA_NEW_STIPPLE )
+ gammaUpdateStipple( ctx );
+ }
+
+ /* HACK ! */
+
+ gammaEmitHwState( gmesa );
+}
+
+
+void gammaDDUpdateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ GAMMA_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+/* Initialize the context's hardware state.
+ */
+void gammaDDInitState( gammaContextPtr gmesa )
+{
+ gmesa->new_state = 0;
+}
+
+/* Initialize the driver's state functions.
+ */
+void gammaDDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = gammaDDUpdateState;
+
+ ctx->Driver.Clear = gammaDDClear;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = gammaDDClearColor;
+ ctx->Driver.SetDrawBuffer = gammaDDSetDrawBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = gammaDDColorMask;
+
+ ctx->Driver.AlphaFunc = gammaDDAlphaFunc;
+ ctx->Driver.BlendEquation = gammaDDBlendEquation;
+ ctx->Driver.BlendFunc = gammaDDBlendFunc;
+ ctx->Driver.BlendFuncSeparate = gammaDDBlendFuncSeparate;
+ ctx->Driver.ClearDepth = gammaDDClearDepth;
+ ctx->Driver.CullFace = gammaDDCullFace;
+ ctx->Driver.FrontFace = gammaDDFrontFace;
+ ctx->Driver.DepthFunc = gammaDDDepthFunc;
+ ctx->Driver.DepthMask = gammaDDDepthMask;
+ ctx->Driver.DepthRange = gammaDDDepthRange;
+ ctx->Driver.Enable = gammaDDEnable;
+ ctx->Driver.Finish = gammaDDFinish;
+ ctx->Driver.Flush = gammaDDFlush;
+#if 0
+ ctx->Driver.Fogfv = gammaDDFogfv;
+#endif
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.LineWidth = gammaDDLineWidth;
+ ctx->Driver.LineStipple = gammaDDLineStipple;
+#if ENABLELIGHTING
+ ctx->Driver.Lightfv = gammaDDLightfv;
+ ctx->Driver.LightModelfv = gammaDDLightModelfv;
+#endif
+ ctx->Driver.LogicOpcode = gammaDDLogicalOpcode;
+ ctx->Driver.PointSize = gammaDDPointSize;
+ ctx->Driver.PolygonMode = gammaDDPolygonMode;
+ ctx->Driver.PolygonStipple = gammaDDPolygonStipple;
+ ctx->Driver.Scissor = gammaDDScissor;
+ ctx->Driver.ShadeModel = gammaDDShadeModel;
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ ctx->Driver.Viewport = gammaDDViewport;
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c
new file mode 100644
index 000000000..73434ba0a
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c
@@ -0,0 +1,417 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "mem.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+#include "gamma_context.h"
+#include "mmath.h"
+
+
+/*
+ * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
+ */
+static GLuint gammaComputeLodBias(GLfloat bias)
+{
+ return bias;
+}
+
+
+static void gammaSetTexWrapping(gammaTextureObjectPtr t,
+ GLenum wraps, GLenum wrapt)
+{
+ CARD32 t1 = t->TextureAddressMode;
+ CARD32 t2 = t->TextureReadMode;
+
+ t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask);
+ t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask);
+
+ if (wraps != GL_CLAMP) {
+ t1 |= TAM_SWrap_Repeat;
+ t2 |= TRM_UWrap_Repeat;
+ }
+
+ if (wrapt != GL_CLAMP) {
+ t1 |= TAM_TWrap_Repeat;
+ t2 |= TRM_VWrap_Repeat;
+ }
+
+ t->TextureAddressMode = t1;
+ t->TextureReadMode = t2;
+}
+
+
+static void gammaSetTexFilter(gammaContextPtr gmesa,
+ gammaTextureObjectPtr t,
+ GLenum minf, GLenum magf,
+ GLfloat bias)
+{
+ CARD32 t1 = t->TextureAddressMode;
+ CARD32 t2 = t->TextureReadMode;
+
+ t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask);
+
+ switch (minf) {
+ case GL_NEAREST:
+ t1 &= ~TAM_LODEnable;
+ t2 &= ~TRM_MipMapEnable;
+ t2 |= TRM_Min_Nearest;
+ break;
+ case GL_LINEAR:
+ t1 &= ~TAM_LODEnable;
+ t2 &= ~TRM_MipMapEnable;
+ t2 |= TRM_Min_Linear;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t2 |= TRM_Min_NearestMMNearest;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t2 |= TRM_Min_LinearMMNearest;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t2 |= TRM_Min_NearestMMLinear;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t2 |= TRM_Min_LinearMMLinear;
+ break;
+ default:
+ break;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ t2 |= TRM_Mag_Nearest;
+ break;
+ case GL_LINEAR:
+ t2 |= TRM_Mag_Linear;
+ break;
+ default:
+ break;
+ }
+
+ t->TextureAddressMode = t1;
+ t->TextureReadMode = t2;
+}
+
+
+static void gammaSetTexBorderColor(gammaContextPtr gmesa,
+ gammaTextureObjectPtr t,
+ GLubyte color[4])
+{
+ t->TextureBorderColor = PACK_COLOR_8888(color[0], color[1], color[2], color[3]);
+}
+
+
+static void gammaTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ if (!t)
+ return;
+
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting gmesa->new_state means that
+ * gammaUpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ }
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Radeon. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ gammaSwapOutTexObj( gmesa, t );
+ break;
+
+ default:
+ return;
+ }
+
+ if (t == gmesa->CurrentTexObj[0])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0;
+
+#if 0
+ if (t == gmesa->CurrentTexObj[1]) {
+ gmesa->dirty |= GAMMA_UPLOAD_TEX1;
+ }
+#endif
+}
+
+
+static void gammaTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLfloat *fc = texUnit->EnvColor;
+ GLuint r, g, b, a, col;
+ CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
+ CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
+
+ col = ((a << 24) |
+ (r << 16) |
+ (g << 8) |
+ (b << 0));
+
+ break;
+ }
+ case GL_TEXTURE_ENV_MODE:
+ gmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
+
+ case GL_TEXTURE_LOD_BIAS_EXT:
+ {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void gammaTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, pack, texObj, texImage );
+}
+
+static void gammaTexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, pack, texObj,
+ texImage);
+}
+
+static void gammaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+}
+
+static void gammaTexSubImage2D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+}
+
+
+static void gammaBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+
+ if (!t) {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ t = CALLOC_STRUCT(gamma_texture_object_t);
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->globj = tObj;
+
+ t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
+ TAM_DY_Enable | TAM_LODEnable;
+ t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
+ TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
+ t->TextureColorMode = TextureColorModeEnable;
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+ if (target == GL_TEXTURE_2D) {
+ t->TextureAddressMode |= TAM_TexMapType_2D;
+ t->TextureReadMode |= TRM_TexMapType_2D;
+ } else
+ if (target == GL_TEXTURE_1D) {
+ t->TextureAddressMode |= TAM_TexMapType_1D;
+ t->TextureReadMode |= TRM_TexMapType_1D;
+ }
+
+ t->TextureColorMode = TextureColorModeEnable;
+
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ t->TextureFormat = (TF_LittleEndian |
+#else
+ t->TextureFormat = (TF_BigEndian |
+#endif
+ TF_ColorOrder_RGB |
+ TF_OutputFmt_Texel);
+
+ t->dirty_images = ~0;
+
+ tObj->DriverData = t;
+ make_empty_list( t );
+
+ gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ gammaSetTexBorderColor( gmesa, t, tObj->BorderColor );
+ }
+}
+
+
+static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+
+ if (t) {
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+#if 0
+ if (gmesa)
+ GAMMA_FIREVERTICES( gmesa );
+#endif
+ gammaDestroyTexObj( gmesa, t );
+ tObj->DriverData = 0;
+ }
+}
+
+static GLboolean gammaIsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+ return t && t->MemBlock;
+}
+
+static void gammaInitTextureObjects( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct gl_texture_object *texObj;
+ GLuint tmp = ctx->Texture.CurrentUnit;
+
+ ctx->Texture.CurrentUnit = 0;
+
+ texObj = ctx->Texture.Unit[0].Current1D;
+ gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[0].Current2D;
+ gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
+
+#if 0
+ ctx->Texture.CurrentUnit = 1;
+
+ texObj = ctx->Texture.Unit[1].Current1D;
+ gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[1].Current2D;
+ gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
+#endif
+
+ ctx->Texture.CurrentUnit = tmp;
+}
+
+
+void gammaDDInitTextureFuncs( GLcontext *ctx )
+{
+ ctx->Driver.TexEnv = gammaTexEnv;
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = gammaTexImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = gammaTexSubImage2D;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.BindTexture = gammaBindTexture;
+ ctx->Driver.DeleteTexture = gammaDeleteTexture;
+ ctx->Driver.TexParameter = gammaTexParameter;
+ ctx->Driver.UpdateTexturePalette = 0;
+ ctx->Driver.IsTextureResident = gammaIsTextureResident;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
+ gammaInitTextureObjects( ctx );
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c
new file mode 100644
index 000000000..c6e1496e2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c
@@ -0,0 +1,528 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "gamma_context.h"
+#include "gamma_lock.h"
+
+void gammaDestroyTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
+{
+ if (!t) return;
+
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (gmesa && t->age > gmesa->dirtyAge)
+ gmesa->dirtyAge = t->age;
+ }
+
+ if (t->globj)
+ t->globj->DriverData = 0;
+
+ if (gmesa) {
+ if (gmesa->CurrentTexObj[0] == t) {
+ gmesa->CurrentTexObj[0] = 0;
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
+ }
+
+#if 0
+ if (gmesa->CurrentTexObj[1] == t) {
+ gmesa->CurrentTexObj[1] = 0;
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX1;
+ }
+#endif
+ }
+
+ remove_from_list(t);
+ free(t);
+}
+
+
+void gammaSwapOutTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (t->age > gmesa->dirtyAge)
+ gmesa->dirtyAge = t->age;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail(&(gmesa->SwappedOut), t);
+}
+
+
+
+/* Upload an image from mesa's internal copy.
+ */
+static void gammaUploadTexLevel( gammaContextPtr gmesa, gammaTextureObjectPtr t, int level )
+{
+ const struct gl_texture_image *image = t->image[level].image;
+ int i,j;
+ int l2d;
+ int offset = 0;
+ int words, depthLog2;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ l2d = 5; /* 32bits per texel == 1<<5 */
+
+ if (level == 0) {
+ t->TextureAddressMode &= ~(TAM_WidthMask | TAM_HeightMask);
+ t->TextureAddressMode |= (image->WidthLog2 << 9) |
+ (image->HeightLog2 << 13);
+ t->TextureReadMode &= ~(TRM_WidthMask | TRM_HeightMask |
+ TRM_DepthMask | TRM_Border |
+ TRM_Patch);
+ t->TextureReadMode |= (image->WidthLog2 << 1) |
+ (image->HeightLog2 << 5) |
+ (l2d << 9);
+ t->TextureFormat &= ~(TF_CompnentsMask | TF_OneCompFmt_Mask);
+ }
+
+ t->TextureBaseAddr[level] = (t->image[level].offset + t->BufAddr) << 5;
+
+ CALC_LOG2(depthLog2, 1<<l2d);
+ words = (image->Width * image->Height) >> (5-depthLog2);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, LBWindowBase, t->TextureBaseAddr[level] >> 5);
+ WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
+ WRITE(gmesa->buf, WaitForCompletion, 0);
+ FLUSH_DMA_BUFFER(gmesa);
+
+ switch (t->image[level].internalFormat) {
+ case GL_RGB:
+ case 3:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_3;
+
+#if 0 /* This is the texture download code we SHOULD be using */
+ /* In the routines below, but this causes an DMA overrun - WHY ? */
+ while (offset < words) {
+ int count = gmesa->bufSize;
+ int i;
+ count -= 3;
+ if (count > words-offset) count = words-offset;
+
+ gmesa->buf->i = GlintTextureDownloadOffsetTag;
+ gmesa->buf++;
+ gmesa->buf->i = offset;
+ gmesa->buf++;
+ gmesa->buf->i = (GlintTextureDataTag | ((count-1) << 16));
+ gmesa->buf++;
+
+ for (i = 0; i < count; i++) {
+ gmesa->buf->i = PACK_COLOR_565(src[0],src[1],src[2]);
+ gmesa->buf++;
+ src += 3;
+ }
+
+ gmesa->bufCount = count+3; /* texture data + 3 values */
+ offset += count;
+
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+#else
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_565(src[0],src[1],src[2]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 3;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+#endif
+ }
+ break;
+
+ case GL_RGBA:
+ case 4:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_4;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 4;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_LUMINANCE:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Lum;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_888(src[0],src[0],src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src ++;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_INTENSITY:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Intensity;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src ++;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_2;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 2;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Alpha;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(255,255,255,src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 1;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ /* TODO: Translate color indices *now*:
+ */
+ case GL_COLOR_INDEX:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = src[0];
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Not supported texture format %s\n",
+ _mesa_lookup_enum_by_nr(image->Format));
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, WaitForCompletion, 0);
+ WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
+}
+
+void gammaPrintLocalLRU( gammaContextPtr gmesa )
+{
+ gammaTextureObjectPtr t;
+ int sz = 1 << (gmesa->gammaScreen->logTextureGranularity);
+
+ foreach( t, &gmesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture at %x sz %x\n",
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void gammaPrintGlobalLRU( gammaContextPtr gmesa )
+{
+ int i, j;
+ drm_gamma_tex_region_t *list = gmesa->sarea->texList;
+
+ for (i = 0, j = GAMMA_NR_TEX_REGIONS ; i < GAMMA_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == GAMMA_NR_TEX_REGIONS) break;
+ }
+
+ if (j != GAMMA_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void gammaResetGlobalLRU( gammaContextPtr gmesa )
+{
+ drm_gamma_tex_region_t *list = gmesa->sarea->texList;
+ int sz = 1 << gmesa->gammaScreen->logTextureGranularity;
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (GAMMA_NR_TEX_REGIONS) is the sentinal. Keeping it
+ * at the end of the array allows it to be addressed rationally
+ * when looking up objects at a particular location in texture
+ * memory.
+ */
+ for (i = 0 ; (i+1) * sz <= gmesa->gammaScreen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = GAMMA_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = GAMMA_NR_TEX_REGIONS;
+ list[GAMMA_NR_TEX_REGIONS].prev = i;
+ list[GAMMA_NR_TEX_REGIONS].next = 0;
+ gmesa->sarea->texAge = 0;
+}
+
+
+void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t )
+{
+ int i;
+ int logsz = gmesa->gammaScreen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ drm_gamma_tex_region_t *list = gmesa->sarea->texList;
+
+ gmesa->texAge = ++gmesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(gmesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = gmesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = GAMMA_NR_TEX_REGIONS;
+ list[i].next = list[GAMMA_NR_TEX_REGIONS].next;
+ list[(unsigned)list[GAMMA_NR_TEX_REGIONS].next].prev = i;
+ list[GAMMA_NR_TEX_REGIONS].next = i;
+ }
+}
+
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void gammaTexturesGone( gammaContextPtr gmesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ gammaTextureObjectPtr t, tmp;
+
+ foreach_s ( t, tmp, &gmesa->TexObjList ) {
+
+ if (t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it off. Need to hold onto the currently bound
+ * objects, however.
+ */
+ gammaSwapOutTexObj( gmesa, t );
+ }
+
+ if (in_use) {
+ t = (gammaTextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( gmesa->texHeap, size, 0, offset);
+ insert_at_head( &gmesa->TexObjList, t );
+ }
+
+ /* Reload any lost textures referenced by current vertex buffer.
+ */
+#if 0
+ if (gmesa->vertex_buffer) {
+ int i, j;
+
+ fprintf(stderr, "\n\nreload tex\n");
+
+ for (i = 0 ; i < gmesa->statenr ; i++) {
+ for (j = 0 ; j < 2 ; j++) {
+ gammaTextureObjectPtr t = gmesa->state_tex[j][i];
+ if (t) {
+ if (t->MemBlock == 0)
+ gammaUploadTexImages( gmesa, t );
+ }
+ }
+ }
+
+ /* Hard to do this with the lock held:
+ */
+/* GAMMA_FIREVERTICES( gmesa ); */
+ }
+#endif
+}
+
+
+
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+
+ /* /fprintf(stderr, "%s\n", __FUNCTION__); */
+#if 0
+ LOCK_HARDWARE( gmesa );
+#endif
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+ while (1)
+ {
+ t->MemBlock = mmAllocMem( gmesa->texHeap, t->totalSize, 12, 0 );
+ if (t->MemBlock)
+ break;
+
+ if (gmesa->TexObjList.prev == gmesa->CurrentTexObj[0] ||
+ gmesa->TexObjList.prev == gmesa->CurrentTexObj[1]) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ gammaPrintLocalLRU( gmesa );
+ return;
+ }
+
+ if (gmesa->TexObjList.prev == &(gmesa->TexObjList)) {
+ fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ mmDumpMemInfo( gmesa->texHeap );
+ return;
+ }
+
+ gammaSwapOutTexObj( gmesa, gmesa->TexObjList.prev );
+ }
+
+ ofs = t->MemBlock->ofs;
+ t->BufAddr = gmesa->LBWindowBase + ofs;
+
+ if (t == gmesa->CurrentTexObj[0])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0;
+
+#if 0
+ if (t == gmesa->CurrentTexObj[1])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX1;
+#endif
+
+ gammaUpdateTexLRU( gmesa, t );
+ }
+
+#if 0
+ if (gmesa->dirtyAge >= GET_DISPATCH_AGE(gmesa))
+ gammaWaitAgeLocked( gmesa, gmesa->dirtyAge );
+#endif
+
+ numLevels = t->lastLevel - t->firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->dirty_images & (1<<i))
+ gammaUploadTexLevel( gmesa, t, i );
+
+ t->dirty_images = 0;
+
+#if 0
+ UNLOCK_HARDWARE( gmesa );
+#endif
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c
new file mode 100644
index 000000000..3d747596b
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c
@@ -0,0 +1,214 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "gamma_context.h"
+
+static void gammaSetTexImages( gammaContextPtr gmesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint height, width, pitch, i, textureFormat, log_pitch;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+ GLint log2Width, log2Height;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ t->texelBytes = 2;
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
+ firstLevel = lastLevel = tObj->BaseLevel;
+ }
+ else {
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ log2Width = tObj->Image[firstLevel]->WidthLog2;
+ log2Height = tObj->Image[firstLevel]->HeightLog2;
+
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ width = tObj->Image[firstLevel]->Width * t->texelBytes;
+ for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
+ log_pitch++;
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[i].image = tObj->Image[firstLevel + i];
+ t->image[i].offset = height * pitch;
+ t->image[i].internalFormat = baseImage->Format;
+ height += t->image[i].image->Height;
+ t->TextureBaseAddr[i] = (t->image[i].offset + t->BufAddr) << 5;
+
+ }
+
+ t->Pitch = pitch;
+ t->totalSize = height*pitch;
+ t->max_level = i-1;
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* | GAMMA_UPLOAD_TEX1*/;
+
+ gammaUploadTexImages( gmesa, t );
+}
+
+static void gammaUpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLuint format = tObj->Image[tObj->BaseLevel]->Format;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+ GLuint tc;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ tc = t->TextureColorMode & ~(TCM_BaseFormatMask | TCM_ApplicationMask);
+
+ switch (format) {
+ case GL_RGB:
+ tc |= TCM_BaseFormat_RGB;
+ break;
+ case GL_LUMINANCE:
+ tc |= TCM_BaseFormat_Lum;
+ break;
+ case GL_ALPHA:
+ tc |= TCM_BaseFormat_Alpha;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ tc |= TCM_BaseFormat_LumAlpha;
+ break;
+ case GL_INTENSITY:
+ tc |= TCM_BaseFormat_Intensity;
+ break;
+ case GL_RGBA:
+ tc |= TCM_BaseFormat_RGBA;
+ break;
+ case GL_COLOR_INDEX:
+ break;
+ }
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ tc |= TCM_Replace;
+ break;
+ case GL_MODULATE:
+ tc |= TCM_Modulate;
+ break;
+ case GL_ADD:
+ /* do nothing ???*/
+ break;
+ case GL_DECAL:
+ tc |= TCM_Decal;
+ break;
+ case GL_BLEND:
+ tc |= TCM_Blend;
+ break;
+ default:
+ fprintf(stderr, "unknown tex env mode");
+ return;
+ }
+
+ t->TextureColorMode = tc;
+}
+
+
+
+
+static void gammaUpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (texUnit->_ReallyEnabled == TEXTURE0_2D)
+ {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->dirty_images) {
+ gammaSetTexImages( gmesa, tObj );
+ if (!t->MemBlock) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ }
+
+#if 0
+ if (tObj->Image[tObj->BaseLevel]->Border > 0) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+#endif
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (gmesa->CurrentTexObj[unit] != t) {
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* << unit */;
+ gmesa->CurrentTexObj[unit] = t;
+ gammaUpdateTexLRU( gmesa, t ); /* done too often */
+ }
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ */
+ if (tObj->Image[tObj->BaseLevel]->Format != gmesa->TexEnvImageFmt[unit]) {
+ gmesa->TexEnvImageFmt[unit] = tObj->Image[tObj->BaseLevel]->Format;
+ gammaUpdateTexEnv( ctx, unit );
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else /*if (gmesa->CurrentTexObj[unit])*/ {
+ gmesa->CurrentTexObj[unit] = 0;
+ gmesa->TexEnvImageFmt[unit] = 0;
+ gmesa->dirty &= ~(GAMMA_UPLOAD_TEX0<<unit);
+ }
+}
+
+
+void gammaUpdateTextureState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_FALSE );
+ gammaUpdateTexUnit( ctx, 0 );
+#if 0
+ gammaUpdateTexUnit( ctx, 1 );
+#endif
+}
+
+
+
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c
deleted file mode 100644
index 2e056e1d9..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c,v 1.4 2001/08/27 17:40:57 dawes Exp $ */
-/**************************************************************************
-
-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>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xarch.h>
-#include <X11/Xlibint.h>
-#include "gamma_init.h"
-#include <string.h>
-
-extern void gammaTOInit(gammaTexObj *t);
-void *texHash = NULL; /* Hash table to hold texture objects */
-
-void gammaTOInit(gammaTexObj *t)
-{
- int i;
-
- t->TextureAddressMode = (TextureAddressModeDisable |
- TAM_SWrap_Repeat |
- TAM_TWrap_Repeat |
- TAM_Operation_3D |
- TAM_LODEnable |
- TAM_DY_Enable |
- TAM_TexMapType_2D);
-
- t->TextureReadMode = (TextureReadModeDisable |
- TRM_Mag_Linear |
- TRM_Min_NearestMMLinear |
- TRM_UWrap_Repeat |
- TRM_VWrap_Repeat |
- TRM_TexMapType_2D |
- TRM_MipMapEnable |
- TRM_PrimaryCacheEnable |
- TRM_FBSourceAddr_None |
- TRM_BorderClamp);
-
- t->TextureColorMode = (TextureColorModeDisable |
- TCM_Modulate |
- TCM_OpenGLType |
- TCM_KdDDA_Disable |
- TCM_KsDDA_Disable |
- TCM_BaseFormat_RGBA |
- TCM_LoadMode_None);
-
- t->TextureFilterMode = (TextureFilterModeDisable);
-
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
- t->TextureFormat = (TF_LittleEndian |
-#else
- t->TextureFormat = (TF_BigEndian |
-#endif
- TF_16Bit_565 |
- TF_ColorOrder_RGB |
- TF_Compnents_4 |
- TF_OutputFmt_Texel);
-
- for (i = 0; i < MIPMAP_LEVELS; i++) {
- t->image[i] = NULL;
- t->TextureBaseAddr[i] = 0;
- }
-}
-
-gammaTexObj *gammaTOFind(GLuint ID)
-{
- gammaTexObj *texObj;
- int retcode;
-
- /* Create the hash table */
- if (!texHash) texHash = drmHashCreate();
-
- retcode = drmHashLookup(texHash, ID, (void **)&texObj);
- if (retcode > 0) { /* Not Found */
- texObj = Xmalloc(sizeof(gammaTexObj));
- gammaTOInit(texObj);
- drmHashInsert(texHash, ID, texObj);
- } else if (retcode < 0) {
- /* NOT_DONE: Error!!! */
- }
-
- return texObj;
-}
-
-void gammaTODelete(GLuint ID)
-{
- int retcode;
- gammaTexObj *texObj;
-
- /* Create the hash table */
- if (!texHash) texHash = drmHashCreate();
-
- retcode = drmHashLookup(texHash, ID, (void **)&texObj);
- if (!retcode) { /* Found */
- drmHashDelete(texHash, ID);
- Xfree(texObj);
- } else if (retcode < 0) {
- /* NOT_DONE: Error!!! */
- }
-}
-
-int gammaTOLoad(void *private, unsigned long address,
- int width, int height, int texel_width,
- const unsigned char *image)
-{
- unsigned int *wdata = (unsigned int *)image;
- int offset = 0;
- int words, depthLog2;
-
- CALC_LOG2(depthLog2, texel_width);
- words = (width*height) << (depthLog2-5);
-
- /* NOT_DONE: Use patch mode, if possible */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITE(gCCPriv->buf, LBWindowBase, address);
- WRITE(gCCPriv->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
- WRITE(gCCPriv->buf, WaitForCompletion, 0);
-
- /* Send the old DMA buffer to the HW, and get a clean DMA buffer */
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- while (offset < words) {
- int count = gCCPriv->bufSize; /* Buf size in words */
- count -= 3; /* 3 is for TDO(Tag+Data) & TD(Tag) */
- if (count > words-offset) count = words-offset;
-
- WRITE(gCCPriv->buf, TextureDownloadOffset, offset);
- gCCPriv->buf++->i = GlintTextureDataTag | ((count-1) << 16);
-
- if (wdata)
- memcpy(gCCPriv->buf, wdata, count*4);
- else
- memset(gCCPriv->buf, 0, count*4);
-
- gCCPriv->buf += count;
- gCCPriv->bufCount = count+3; /* 3 is for TDO(Tag+Data) & TD(Tag) */
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- offset += count;
- wdata += count;
- }
-
- /* Make sure the texture has been completely written */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, WaitForCompletion, 0);
- WRITE(gCCPriv->buf, LBWindowBase, gCCPriv->LBWindowBase);
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- return 0;
-}
-
-int gammaTOLoadSub(void *private, unsigned long address,
- int width, int height, int texel_width,
- int xoffset, int yoffset,
- int subimage_width, int subimage_height,
- const unsigned char *image)
-{
- unsigned int *wdata = (unsigned int *)image;
- int depthLog2;
- int h;
-
- if (!wdata)
- return 0;
-
- CALC_LOG2(depthLog2, texel_width);
-
- /* NOT_DONE: Use patch mode, if possible */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 3);
- WRITE(gCCPriv->buf, LBWindowBase, address);
- WRITE(gCCPriv->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
- WRITE(gCCPriv->buf, WaitForCompletion, 0);
-
- /* Send the old DMA buffer to the HW, and get a clean DMA buffer */
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- /* Make sure we are in bounds */
- if (xoffset < 0) xoffset = 0;
- if (yoffset < 0) yoffset = 0;
- if (subimage_width > width) subimage_width = width;
- if (subimage_height > height) subimage_height = height;
-
- /* NOT_DONE: Must handle starting in the middle of a word properly */
- for (h = yoffset; h < yoffset+subimage_height; h++) {
- int start = (h*width + xoffset) << (depthLog2-5);
- int words = subimage_width << (depthLog2-5);
- int offset = 0;
-
- while (offset < words) {
- int count = gCCPriv->bufSize; /* Buf size in words */
- count -= 3; /* 3 is for TDO(Tag+Data) & TD(Tag) */
- if (count > words-offset) count = words-offset;
-
- WRITE(gCCPriv->buf, TextureDownloadOffset, start+offset);
- gCCPriv->buf++->i = GlintTextureDataTag | ((count-1) << 16);
-
- memcpy(gCCPriv->buf, wdata, count*4);
-
- gCCPriv->buf += count;
- gCCPriv->bufCount = count+3; /* 3 is for TDO(Tag+Data) & TD(Tag) */
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- offset += count;
- wdata += count;
- }
- }
-
- /* Make sure the texture has been completely written */
- CHECK_DMA_BUFFER(gCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, WaitForCompletion, 0);
- WRITE(gCCPriv->buf, LBWindowBase, gCCPriv->LBWindowBase);
- FLUSH_DMA_BUFFER(nullCC, gCCPriv);
-
- return 0;
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.h
deleted file mode 100644
index 83f754884..000000000
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texture.h,v 1.2 2000/02/23 04:46:45 martin Exp $ */
-/**************************************************************************
-
-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>
- *
- */
-
-#ifndef _GAMMA_TEXTURE_H_
-#define _GAMMA_TEXTURE_H_
-
-#ifdef GLX_DIRECT_RENDERING
-
-#define MIPMAP_LEVELS 12
-
-typedef struct {
- GLuint ID;
- void *image[MIPMAP_LEVELS];
- int TextureAddressMode;
- int TextureReadMode;
- int TextureColorMode;
- int TextureFilterMode;
- int TextureFormat;
- unsigned long TextureBaseAddr[MIPMAP_LEVELS];
-} gammaTexObj;
-
-extern gammaTexObj *gammaTOFind(GLuint ID);
-extern void gammaTODelete(GLuint ID);
-
-extern int gammaTOLoad(void *private, unsigned long address,
- int width, int height, int texel_width,
- const unsigned char *image);
-extern int gammaTOLoadSub(void *private, unsigned long address,
- int width, int height, int texel_width,
- int xoffset, int yoffset,
- int subimage_width, int subimage_height,
- const unsigned char *image);
-
-#endif
-
-#endif /* _GAMMA_INIT_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c
new file mode 100644
index 000000000..a6e78b405
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.c
@@ -0,0 +1,654 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Keith Whitwell, <keithw@valinux.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+
+/***********************************************************************
+ * Build hardware rasterization functions *
+ ***********************************************************************/
+
+#define GAMMA_RAST_ALPHA_BIT 0x01
+#define GAMMA_RAST_TEX_BIT 0x02
+#define GAMMA_RAST_FLAT_BIT 0x04
+
+static gamma_point_func gamma_point_tab[0x8];
+static gamma_line_func gamma_line_tab[0x8];
+static gamma_tri_func gamma_tri_tab[0x8];
+static gamma_quad_func gamma_quad_tab[0x8];
+
+#define IND (0)
+#define TAG(x) x
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_TEX_BIT)
+#define TAG(x) x##_tex
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT)
+#define TAG(x) x##_alpha_tex
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_tex_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_alpha_tex_flat
+#include "gamma_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ gamma_init();
+ gamma_init_alpha();
+ gamma_init_tex();
+ gamma_init_alpha_tex();
+ gamma_init_flat();
+ gamma_init_alpha_flat();
+ gamma_init_tex_flat();
+ gamma_init_alpha_tex_flat();
+}
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+gamma_fallback_quad( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2,
+ const gammaVertex *v3 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[4];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ gamma_translate_vertex( ctx, v2, &v[2] );
+ gamma_translate_vertex( ctx, v3, &v[3] );
+ _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
+}
+
+static void
+gamma_fallback_tri( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[3];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ gamma_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+static void
+gamma_fallback_line( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[2];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+gamma_fallback_point( gammaContextPtr gmesa,
+ const gammaVertex *v0 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[1];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+/***********************************************************************
+ * Choose rasterization functions *
+ ***********************************************************************/
+
+#define _GAMMA_NEW_RASTER_STATE (_NEW_FOG | \
+ _NEW_TEXTURE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _DD_NEW_LINE_STIPPLE)
+
+#define LINE_FALLBACK (0)
+#define TRI_FALLBACK (0)
+
+void gammaChooseRasterState(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ if ( ctx->Line.SmoothFlag ||
+ ctx->Polygon.SmoothFlag ||
+ ctx->Point.SmoothFlag )
+ gmesa->Begin |= B_AntiAliasEnable;
+ else
+ gmesa->Begin &= ~B_AntiAliasEnable;
+
+ if ( ctx->Texture._ReallyEnabled ) {
+ ind |= GAMMA_RAST_TEX_BIT;
+ gmesa->Begin |= B_TextureEnable;
+ } else
+ gmesa->Begin &= ~B_TextureEnable;
+
+ if (flags & DD_LINE_STIPPLE)
+ gmesa->Begin |= B_LineStippleEnable;
+ else
+ gmesa->Begin &= ~B_LineStippleEnable;
+
+ if (flags & DD_TRI_STIPPLE)
+ gmesa->Begin |= B_AreaStippleEnable;
+ else
+ gmesa->Begin &= ~B_AreaStippleEnable;
+
+ if (ctx->Fog.Enabled)
+ gmesa->Begin |= B_FogEnable;
+ else
+ gmesa->Begin &= ~B_FogEnable;
+
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= GAMMA_RAST_ALPHA_BIT;
+
+ if ( flags & DD_FLATSHADE )
+ ind |= GAMMA_RAST_FLAT_BIT;
+
+ gmesa->draw_line = gamma_line_tab[ind];
+ gmesa->draw_tri = gamma_tri_tab[ind];
+ gmesa->draw_quad = gamma_quad_tab[ind];
+ gmesa->draw_point = gamma_point_tab[ind];
+
+ /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
+ */
+ if (flags & LINE_FALLBACK)
+ gmesa->draw_line = gamma_fallback_line;
+
+ if (flags & TRI_FALLBACK) {
+ gmesa->draw_tri = gamma_fallback_tri;
+ gmesa->draw_quad = gamma_fallback_quad;
+ }
+}
+
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ gmesa->draw_tri( gmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ gmesa->draw_quad( gmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ gmesa->draw_line( gmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ gmesa->draw_point( gmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define GAMMA_OFFSET_BIT 0x01
+#define GAMMA_TWOSIDE_BIT 0x02
+#define GAMMA_UNFILLED_BIT 0x04
+#define GAMMA_FALLBACK_BIT 0x08
+#define GAMMA_MAX_TRIFUNC 0x10
+
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[GAMMA_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & GAMMA_FALLBACK_BIT)
+#define DO_OFFSET 0 /* (IND & GAMMA_OFFSET_BIT) */
+#define DO_UNFILLED 0 /* (IND & GAMMA_UNFILLED_BIT) */
+#define DO_TWOSIDE (IND & GAMMA_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX gammaVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (gmesa->verts + (e<<gmesa->vertex_stride_shift))
+
+#define VERT_SET_RGBA( v, c ) COPY_4V( v->ub4[4], c)
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+
+#define LOCAL_VARS(n) \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ GLuint color[n]; \
+ (void) color;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ B_PrimType_Points,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles
+};
+
+static void gammaResetLineStipple( GLcontext *ctx );
+static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \
+ gammaRasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE gmesa->render_primitive
+#define TAG(x) x
+#define IND GAMMA_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+
+static void init_render_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+}
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (gammaVertex *)(gammaverts + (x << shift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ gmesa->draw_point( gmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ gmesa->draw_line( gmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) gammaRenderPrimitive( ctx, x );
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ const GLuint shift = gmesa->vertex_stride_shift; \
+ const char *gammaverts = (char *)gmesa->verts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) stipple;
+#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) gamma_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint prim = gmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET)
+
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void gammaChooseRenderState(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT;
+ }
+
+ if (gmesa->RenderIndex != index) {
+ gmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (gmesa->RenderIndex == 0)
+ tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts;
+ else
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = gammaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in gammarender.c.
+ */
+
+static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ if (gmesa->hw_primitive != hwprim)
+ gmesa->hw_primitive = hwprim;
+}
+
+static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gmesa->render_primitive = prim;
+}
+
+static void gammaRunPipeline( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ if ( gmesa->new_state )
+ gammaDDUpdateHWState( ctx );
+
+ if (gmesa->new_gl_state) {
+ if (gmesa->new_gl_state & _NEW_TEXTURE)
+ gammaUpdateTextureState( ctx );
+
+ if (!gmesa->Fallback) {
+ if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX)
+ gammaChooseVertexState( ctx );
+
+ if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE)
+ gammaChooseRasterState( ctx );
+
+ if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE)
+ gammaChooseRenderState( ctx );
+ }
+
+ gmesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void gammaRenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ gammaCheckTexSizes( ctx );
+}
+
+static void gammaRenderFinish( GLcontext *ctx )
+{
+ if (0)
+ _swrast_flush( ctx ); /* never needed */
+}
+
+static void gammaResetLineStipple( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ /* Reset the hardware stipple counter.
+ */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, UpdateLineStippleCounters, 0);
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = gmesa->Fallback;
+
+ if (mode) {
+ gmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ _swsetup_Wakeup( ctx );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ gmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ gmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = gammaRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
+ tnl->Driver.Render.Finish = gammaRenderFinish;
+ tnl->Driver.Render.BuildVertices = gammaBuildVertices;
+ tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
+ gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE|
+ _GAMMA_NEW_RASTER_STATE|
+ _GAMMA_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void gammaDDInitTriFuncs( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ init_render_tab();
+ firsttime = 0;
+ }
+
+ gmesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = gammaRunPipeline;
+ tnl->Driver.Render.Start = gammaRenderStart;
+ tnl->Driver.Render.Finish = gammaRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
+ tnl->Driver.Render.BuildVertices = gammaBuildVertices;
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.h
new file mode 100644
index 000000000..944052914
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tris.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Keith Whitwell, <keithw@valinux.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#ifndef _GAMMA_TRIS_H
+#define _GAMMA_TRIS_H
+
+extern void gammaDDTrifuncInit(void);
+extern void gammaDDChooseTriRenderState(GLcontext *);
+
+
+
+#endif /* !(_GAMMA_TRIS_H) */
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_tritmp.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_tritmp.h
new file mode 100644
index 000000000..d0dbd1d6e
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_tritmp.h
@@ -0,0 +1,495 @@
+static void TAG(gamma_point)( gammaContextPtr gmesa,
+ const gammaVertex *v0 )
+{
+ CARD32 vColor;
+ CARD32 vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Points;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_line)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1 )
+{
+ CARD32 vColor;
+ CARD32 vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Lines;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_triangle)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2 )
+{
+ CARD32 vColor;
+ CARD32 vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Triangles;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v2->v.u0);
+ WRITEF(gmesa->buf, Ts2, v2->v.v0);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_quad)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2,
+ const gammaVertex *v3 )
+{
+ CARD32 vColor;
+ CARD32 vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Quads;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v3->v.color.alpha << 24) |
+ (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v2->v.u0);
+ WRITEF(gmesa->buf, Ts2, v2->v.v0);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v3->v.color.alpha << 24) |
+ (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v3->v.u0);
+ WRITEF(gmesa->buf, Ts2, v3->v.v0);
+ WRITEF(gmesa->buf, Vw, v3->v.w);
+ WRITEF(gmesa->buf, Vz, v3->v.z);
+ WRITEF(gmesa->buf, Vy, v3->v.y);
+ WRITEF(gmesa->buf, Vx4, v3->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v3->v.w);
+ WRITEF(gmesa->buf, Vz, v3->v.z);
+ WRITEF(gmesa->buf, Vy, v3->v.y);
+ WRITEF(gmesa->buf, Vx4, v3->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_init)(void)
+{
+ gamma_point_tab[IND] = TAG(gamma_point);
+ gamma_line_tab[IND] = TAG(gamma_line);
+ gamma_tri_tab[IND] = TAG(gamma_triangle);
+ gamma_quad_tab[IND] = TAG(gamma_quad);
+}
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c
new file mode 100644
index 000000000..552b47cd3
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c
@@ -0,0 +1,317 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Keith Whitwell, <keithw@valinux.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "mem.h"
+#include "macros.h"
+#include "colormac.h"
+#include "mmath.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/tnl.h"
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+
+#define GAMMA_TEX0_BIT 0x1
+#define GAMMA_RGBA_BIT 0x2
+#define GAMMA_XYZW_BIT 0x4
+#define GAMMA_PTEX_BIT 0x8
+#define GAMMA_MAX_SETUP 0x10
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[GAMMA_MAX_SETUP];
+
+
+/* Only one vertex format, atm, so no need to give them names:
+ */
+#define TINY_VERTEX_FORMAT 0
+#define NOTEX_VERTEX_FORMAT 0
+#define TEX0_VERTEX_FORMAT 0
+#define TEX1_VERTEX_FORMAT 0
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & GAMMA_XYZW_BIT)
+#define DO_RGBA (IND & GAMMA_RGBA_BIT)
+#define DO_SPEC 0
+#define DO_FOG 0
+#define DO_TEX0 (IND & GAMMA_TEX0_BIT)
+#define DO_TEX1 0
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & GAMMA_PTEX_BIT)
+
+#define VERTEX gammaVertex
+#define GET_VIEWPORT_MAT() 0
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() 0
+#define GET_VERTEX_STORE() GAMMA_CONTEXT(ctx)->verts
+#define GET_VERTEX_STRIDE_SHIFT() GAMMA_CONTEXT(ctx)->vertex_stride_shift
+#define INVALIDATE_STORED_VERTICES()
+#define GET_UBYTE_COLOR_STORE() &GAMMA_CONTEXT(ctx)->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &GAMMA_CONTEXT(ctx)->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 1
+#define HAVE_HW_DIVIDE 1
+#define HAVE_RGBA_COLOR 0 /* we're BGRA */
+#define HAVE_TINY_VERTICES 0
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 0
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 1
+
+#define PTEX_FALLBACK() /* never needed */
+
+#define IMPORT_QUALIFIER
+#define IMPORT_FLOAT_COLORS gamma_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS gamma_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) gamma_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgt0();
+ init_wgpt0();
+ init_t0();
+ init_g();
+ init_gt0();
+}
+
+
+#if 0
+void gammaPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & GAMMA_XYZW_BIT) ? " xyzw," : "",
+ (flags & GAMMA_RGBA_BIT) ? " rgba," : "",
+ (flags & GAMMA_SPEC_BIT) ? " spec," : "",
+ (flags & GAMMA_FOG_BIT) ? " fog," : "",
+ (flags & GAMMA_TEX0_BIT) ? " tex-0," : "",
+ (flags & GAMMA_TEX1_BIT) ? " tex-1," : "");
+}
+#endif
+
+
+void gammaCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+
+#if 0
+ if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) {
+ /* Invalidate stored verts
+ */
+ gmesa->SetupNewInputs = ~0;
+ gmesa->SetupIndex |= GAMMA_PTEX_BIT;
+
+ if (/*!gmesa->Fallback && */
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv;
+ }
+ }
+#endif
+
+ if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = gmesa->SetupIndex |= (GAMMA_PTEX_BIT|GAMMA_RGBA_BIT);
+
+ /* Radeon handles projective textures nicely; just have to change
+ * up to the new vertex format.
+ */
+#if 0
+ if (setup_tab[ind].vertex_format != gmesa->vertex_format) {
+ RADEON_STATECHANGE(gmesa, 0);
+ gmesa->vertex_format = setup_tab[ind].vertex_format;
+ gmesa->vertex_size = setup_tab[ind].vertex_size;
+ gmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
+ }
+#endif
+
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv;
+ }
+ }
+}
+
+void gammaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ GLubyte *v = ((GLubyte *)gmesa->verts + (start<<gmesa->vertex_stride_shift));
+ GLuint stride = 1<<gmesa->vertex_stride_shift;
+
+ newinputs |= gmesa->SetupNewInputs;
+ gmesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_CLIP) {
+ setup_tab[gmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_RGBA)
+ ind |= GAMMA_RGBA_BIT;
+
+ if (newinputs & VERT_TEX0)
+ ind |= GAMMA_TEX0_BIT;
+
+ if (gmesa->SetupIndex & GAMMA_PTEX_BIT)
+ ind = ~0;
+
+ ind &= gmesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+void gammaChooseVertexState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = GAMMA_XYZW_BIT|GAMMA_RGBA_BIT;
+
+ if (ctx->Texture._ReallyEnabled) {
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+ ind |= GAMMA_TEX0_BIT;
+ } else
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+
+ gmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = gamma_interp_extras;
+ tnl->Driver.Render.CopyPV = gamma_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+}
+
+
+void gammaInitVB( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ gmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ gmesa->vertex_stride_shift = 6; /* FIXME - only one vertex setup */
+ }
+ }
+}
+
+
+void gammaFreeVB( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ if (gmesa->verts) {
+ ALIGN_FREE(gmesa->verts);
+ gmesa->verts = 0;
+ }
+
+ if (gmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE(gmesa->UbyteSecondaryColor.Ptr);
+ gmesa->UbyteSecondaryColor.Ptr = 0;
+ }
+
+ if (gmesa->UbyteColor.Ptr) {
+ ALIGN_FREE(gmesa->UbyteColor.Ptr);
+ gmesa->UbyteColor.Ptr = 0;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.h
new file mode 100644
index 000000000..3a67d3f63
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_vb.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Keith Whitwell, <keithw@valinux.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#ifndef GAMMAVB_INC
+#define GAMMAVB_INC
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+
+#define _GAMMA_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE)
+
+
+extern void gammaChooseVertexState( GLcontext *ctx );
+extern void gammaCheckTexSizes( GLcontext *ctx );
+extern void gammaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+
+
+extern void gamma_import_float_colors( GLcontext *ctx );
+extern void gamma_import_float_spec_colors( GLcontext *ctx );
+
+extern void gamma_translate_vertex( GLcontext *ctx,
+ const gammaVertex *src,
+ SWvertex *dst );
+
+extern void gammaInitVB( GLcontext *ctx );
+extern void gammaFreeVB( GLcontext *ctx );
+
+extern void gamma_print_vertex( GLcontext *ctx, const gammaVertex *v );
+extern void gammaPrintSetupFlags(char *msg, GLuint flags );
+
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
index 94f6c8417..cbc17f453 100644
--- a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c
@@ -1,545 +1,171 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.12 2001/03/21 16:14:20 dawes Exp $ */
-/**************************************************************************
-
-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.
-
-**************************************************************************/
-
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.11 2001/02/07 13:26:17 alanh Exp $ */
/*
- * Authors:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * 3DLabs Gamma driver
*/
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-#include "gamma_init.h"
-#include "gamma_gl.h"
-#include "glapi.h"
-#include "glint_dri.h"
-#include "gamma_dlist.h"
+#include "gamma_context.h"
+#include "gamma_vb.h"
#include "context.h"
#include "mmath.h"
-#include "hash.h"
-
+#include "matrix.h"
+#include "glint_dri.h"
-__DRIcontextPrivate *nullCC = NULL;
-__DRIcontextPrivate *gCC = NULL;
-gammaContextPrivate *gCCPriv = NULL;
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
-GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+static GLboolean
+gammaInitDriver(__DRIscreenPrivate *sPriv)
{
- gammaScreenPrivate *gsp;
-
-#if 0
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- char msg[1000];
- sprintf(msg, "gamma DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
- }
- }
-
- /* Check that the DDX driver version is compatible */
- if (sPriv->ddxMajor != 1 ||
- sPriv->ddxMinor < 0) {
- char msg[1000];
- sprintf(msg, "gamma DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
+ sPriv->private = (void *) gammaCreateScreen( sPriv );
- /* Check that the DRM driver version is compatible */
- if (sPriv->drmMajor != 1 ||
- sPriv->drmMinor < 0) {
- char msg[1000];
- sprintf(msg, "gamm DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
-#endif
-
- /* Allocate the private area */
- gsp = (gammaScreenPrivate *)Xmalloc(sizeof(gammaScreenPrivate));
- if (!gsp) {
- return GL_FALSE;
- }
- gsp->driScrnPriv = sPriv;
-
- sPriv->private = (void *)gsp;
-
- if (!gammaMapAllRegions(sPriv)) {
- Xfree(sPriv->private);
+ if (!sPriv->private) {
+ gammaDestroyScreen( sPriv );
return GL_FALSE;
}
return GL_TRUE;
}
-void XMesaResetDriver(__DRIscreenPrivate *sPriv)
-{
- gammaUnmapAllRegions(sPriv);
- Xfree(sPriv->private);
- sPriv->private = NULL;
-}
-
-GLvisual *XMesaCreateVisual(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config)
+static void
+gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount(visinfo->red_mask),
- _mesa_bitcount(visinfo->green_mask),
- _mesa_bitcount(visinfo->blue_mask),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
-
-
-GLboolean XMesaCreateContext( Display *dpy,
- GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
-{
- int i;
- gammaContextPrivate *cPriv;
- __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
- gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private;
- GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
-
- cPriv = (gammaContextPrivate *)Xmalloc(sizeof(gammaContextPrivate));
- if (!cPriv) {
- return GL_FALSE;
- }
-
- if (!cPriv->Exec) {
- GLuint size = _glapi_get_dispatch_table_size() * sizeof(GLvoid *);
- cPriv->Exec = (struct _glapi_table *) malloc(size);
- _gamma_init_exec(cPriv->Exec);
- }
-
- cPriv->API = cPriv->Exec;
-
- if (!cPriv->Save) {
- GLuint size = _glapi_get_dispatch_table_size() * sizeof(GLvoid *);
- cPriv->Save = (struct _glapi_table *) malloc(size);
- _gamma_init_save(cPriv->Save);
- }
-
- cPriv->hHWContext = driContextPriv->hHWContext;
- GET_FIRST_DMA(driScrnPriv->fd, cPriv->hHWContext,
- 1, &cPriv->bufIndex, &cPriv->bufSize,
- &cPriv->buf, &cPriv->bufCount, gPriv);
+ gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate;
-#ifdef DO_VALIDATE
- GET_FIRST_DMA(driScrnPriv->fd, cPriv->hHWContext,
- 1, &cPriv->WCbufIndex, &cPriv->WCbufSize,
- &cPriv->WCbuf, &cPriv->WCbufCount, gPriv);
-#endif
+ if (gmesa) {
+ _swsetup_DestroyContext( gmesa->glCtx );
+ _tnl_DestroyContext( gmesa->glCtx );
+ _ac_DestroyContext( gmesa->glCtx );
+ _swrast_DestroyContext( gmesa->glCtx );
- gamma_init_lists();
-
- /* Display List stuff */
- cPriv->DisplayList = _mesa_NewHashTable();
- cPriv->List.ListBase = 0;
- cPriv->CallDepth = 0;
- cPriv->ExecuteFlag = GL_TRUE;
- cPriv->CompileFlag = GL_FALSE;
- cPriv->CurrentListPtr = NULL;
- cPriv->CurrentBlock = NULL;
- cPriv->CurrentListNum = 0;
- cPriv->CurrentPos = 0;
-
- /* Vertex arrays */
- cPriv->Array.VertexSize = 4;
- cPriv->Array.VertexType = GL_FLOAT;
- cPriv->Array.VertexStride = 0;
- cPriv->Array.VertexStrideB = 0;
- cPriv->Array.VertexPtr = NULL;
- cPriv->Array.VertexEnabled = GL_FALSE;
- cPriv->Array.NormalType = GL_FLOAT;
- cPriv->Array.NormalStride = 0;
- cPriv->Array.NormalStrideB = 0;
- cPriv->Array.NormalPtr = NULL;
- cPriv->Array.NormalEnabled = GL_FALSE;
- cPriv->Array.ColorSize = 4;
- cPriv->Array.ColorType = GL_FLOAT;
- cPriv->Array.ColorStride = 0;
- cPriv->Array.ColorStrideB = 0;
- cPriv->Array.ColorPtr = NULL;
- cPriv->Array.ColorEnabled = GL_FALSE;
- cPriv->Array.IndexType = GL_FLOAT;
- cPriv->Array.IndexStride = 0;
- cPriv->Array.IndexStrideB = 0;
- cPriv->Array.IndexPtr = NULL;
- cPriv->Array.IndexEnabled = GL_FALSE;
- cPriv->Array.EdgeFlagStride = 0;
- cPriv->Array.EdgeFlagStrideB = 0;
- cPriv->Array.EdgeFlagPtr = NULL;
- cPriv->Array.EdgeFlagEnabled = GL_FALSE;
-
- cPriv->Unpack.Alignment = 4;
- cPriv->Unpack.RowLength = 0;
- cPriv->Unpack.SkipPixels = 0;
- cPriv->Unpack.SkipRows = 0;
- cPriv->Unpack.SwapBytes = GL_FALSE;
- cPriv->Unpack.LsbFirst = GL_FALSE;
-
- cPriv->ClearColor[0] = 0.0;
- cPriv->ClearColor[1] = 0.0;
- cPriv->ClearColor[2] = 0.0;
- cPriv->ClearColor[3] = 1.0;
- cPriv->ClearDepth = 1.0;
- cPriv->x = 0;
- cPriv->y = 0;
- cPriv->w = 0;
- cPriv->h = 0;
- cPriv->FrameCount = 0;
- cPriv->MatrixMode = GL_MODELVIEW;
- cPriv->ModelViewCount = 0;
- cPriv->ProjCount = 0;
- cPriv->TextureCount = 0;
-
- for (i = 0; i < 16; i++)
- if (i % 5 == 0)
- cPriv->ModelView[i] =
- cPriv->Proj[i] =
- cPriv->ModelViewProj[i] =
- cPriv->Texture[i] = 1.0;
- else
- cPriv->ModelView[i] =
- cPriv->Proj[i] =
- cPriv->ModelViewProj[i] =
- cPriv->Texture[i] = 0.0;
-
- cPriv->LBReadMode = (LBReadSrcDisable |
- LBReadDstDisable |
- LBDataTypeDefault |
- LBWindowOriginBot |
- gDRIPriv->pprod);
- cPriv->FBReadMode = (FBReadSrcDisable |
- FBReadDstDisable |
- FBDataTypeDefault |
- FBWindowOriginBot |
- gDRIPriv->pprod);
-
- if (gDRIPriv->numMultiDevices == 2) {
- cPriv->LBReadMode |= LBScanLineInt2;
- cPriv->FBReadMode |= FBScanLineInt2;
- cPriv->FBWindowBase =driScrnPriv->fbWidth*(driScrnPriv->fbHeight/2 - 1);
- cPriv->LBWindowBase =driScrnPriv->fbWidth*(driScrnPriv->fbHeight/2 - 1);
- } else {
- cPriv->FBWindowBase = driScrnPriv->fbWidth * driScrnPriv->fbHeight;
- cPriv->LBWindowBase = driScrnPriv->fbWidth * driScrnPriv->fbHeight;
- }
+ gammaFreeVB( gmesa->glCtx );
- cPriv->Begin = (B_AreaStippleDisable |
- B_LineStippleDisable |
- B_AntiAliasDisable |
- B_TextureDisable |
- B_FogDisable |
- B_SubPixelCorrectEnable |
- B_PrimType_Null);
-
- cPriv->ColorDDAMode = (ColorDDAEnable |
- ColorDDAGouraud);
-
-#ifdef CULL_ALL_PRIMS
- cPriv->GeometryMode = (GM_TextureDisable |
- GM_FogDisable |
- GM_FogExp |
- GM_FrontPolyFill |
- GM_BackPolyFill |
- GM_FrontFaceCCW |
- GM_PolyCullDisable |
- GM_PolyCullBoth |
- GM_ClipShortLinesDisable |
- GM_ClipSmallTrisDisable |
- GM_RenderMode |
- GM_Feedback2D |
- GM_CullFaceNormDisable |
- GM_AutoFaceNormDisable |
- GM_GouraudShading |
- GM_UserClipNone |
- GM_PolyOffsetPointDisable |
- GM_PolyOffsetLineDisable |
- GM_PolyOffsetFillDisable |
- GM_InvertFaceNormCullDisable);
-#else
- cPriv->GeometryMode = (GM_TextureDisable |
- GM_FogDisable |
- GM_FogExp |
- GM_FrontPolyFill |
- GM_BackPolyFill |
- GM_FrontFaceCCW |
- GM_PolyCullDisable |
- GM_PolyCullBack |
- GM_ClipShortLinesDisable |
- GM_ClipSmallTrisDisable |
- GM_RenderMode |
- GM_Feedback2D |
- GM_CullFaceNormDisable |
- GM_AutoFaceNormDisable |
- GM_GouraudShading |
- GM_UserClipNone |
- GM_PolyOffsetPointDisable |
- GM_PolyOffsetLineDisable |
- GM_PolyOffsetFillDisable |
- GM_InvertFaceNormCullDisable);
-#endif
+ /* free the Mesa context */
+ gmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(gmesa->glCtx);
- cPriv->AlphaTestMode = (AlphaTestModeDisable |
- AT_Always);
-
- cPriv->AlphaBlendMode = (AlphaBlendModeDisable |
- AB_Src_One |
- AB_Dst_Zero |
- AB_ColorFmt_8888 |
- AB_NoAlphaBufferPresent |
- AB_ColorOrder_RGB |
- AB_OpenGLType |
- AB_AlphaDst_FBData |
- AB_ColorConversionScale |
- AB_AlphaConversionScale);
-
- cPriv->AB_FBReadMode_Save = cPriv->AB_FBReadMode = 0;
-
- cPriv->Window = (WindowEnable | /* For GID testing */
- W_PassIfEqual |
- (0 << 5)); /* GID part is set from draw priv (below) */
-
- cPriv->NotClipped = GL_FALSE;
- cPriv->WindowChanged = GL_TRUE;
-
- /*
- ** NOT_DONE:
- ** 1. These values should be calculated from the registers.
- ** 2. Only one client can use texture memory at this time.
- ** 3. A two-tiered texture allocation routine is needed to properly
- ** handle texture management.
- */
- cPriv->tmm = driTMMCreate(0x00080000,
- 0x00800000 - 0x00080000,
- 4, 1,
- gammaTOLoad,
- gammaTOLoadSub);
-
- cPriv->curTexObj = gammaTOFind(0);
- cPriv->curTexObj1D = cPriv->curTexObj;
- cPriv->curTexObj2D = cPriv->curTexObj;
- cPriv->Texture1DEnabled = GL_FALSE;
- cPriv->Texture2DEnabled = GL_FALSE;
-
-#ifdef FORCE_DEPTH32
- cPriv->DepthSize = 32;
-#else
- cPriv->DepthSize = mesaVis->DepthBits;
-#endif
- cPriv->zNear = 0.0;
- cPriv->zFar = 1.0;
-
- cPriv->Flags = GAMMA_FRONT_BUFFER;
- cPriv->Flags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0);
- cPriv->Flags |= (cPriv->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);
-
- cPriv->EnabledFlags = GAMMA_FRONT_BUFFER;
- cPriv->EnabledFlags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0);
-
- cPriv->DepthMode = (DepthModeDisable |
- DM_WriteMask |
- DM_Less);
-
- cPriv->DeltaMode = (DM_SubPixlCorrectionEnable |
- DM_SmoothShadingEnable |
- DM_Target500TXMX);
-
- switch (cPriv->DepthSize) {
- case 16:
- cPriv->DeltaMode |= DM_Depth16;
- break;
- case 24:
- cPriv->DeltaMode |= DM_Depth24;
- break;
- case 32:
- cPriv->DeltaMode |= DM_Depth32;
- break;
- default:
- break;
+ Xfree(gmesa);
+ driContextPriv->driverPrivate = NULL;
}
-
- cPriv->gammaScrnPriv = gPriv;
-
- cPriv->LightingMode = LightingModeDisable | LightingModeSpecularEnable;
- cPriv->Light0Mode = LNM_Off;
- cPriv->Light1Mode = LNM_Off;
- cPriv->Light2Mode = LNM_Off;
- cPriv->Light3Mode = LNM_Off;
- cPriv->Light4Mode = LNM_Off;
- cPriv->Light5Mode = LNM_Off;
- cPriv->Light6Mode = LNM_Off;
- cPriv->Light7Mode = LNM_Off;
- cPriv->Light8Mode = LNM_Off;
- cPriv->Light9Mode = LNM_Off;
- cPriv->Light10Mode = LNM_Off;
- cPriv->Light11Mode = LNM_Off;
- cPriv->Light12Mode = LNM_Off;
- cPriv->Light13Mode = LNM_Off;
- cPriv->Light14Mode = LNM_Off;
- cPriv->Light15Mode = LNM_Off;
-
- cPriv->LogicalOpMode = LogicalOpModeDisable;
-
- cPriv->MaterialMode = MaterialModeDisable;
-
- cPriv->ScissorMode = UserScissorDisable | ScreenScissorDisable;
-
- cPriv->TransformMode = XM_UseModelViewProjMatrix;
-
- driContextPriv->driverPrivate = cPriv;
-
- /* Initialize the HW to a known state */
- gammaInitHW(cPriv);
-
- return GL_TRUE;
}
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+
+static GLboolean
+gammaCreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
{
- gammaContextPrivate *cPriv;
- cPriv = (gammaContextPrivate *) driContextPriv->driverPrivate;
- if (cPriv) {
- /* XXX free driver context data? */
- }
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0
+ );
+ return (driDrawPriv->driverPrivate != NULL);
+ }
}
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
+static void
+gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0
- );
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
}
-
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
+static void
+gammaSwapBuffers(Display *dpy, void *drawablePrivate)
{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0
- );
-#else
- return NULL; /* not implemented yet */
-#endif
-}
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ (void) dpy;
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ gammaContextPtr gmesa;
+ __DRIscreenPrivate *driScrnPriv;
+ GLcontext *ctx;
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
-{
- /*
- ** NOT_DONE: This assumes buffer is currently bound to a context.
- ** This needs to be able to swap buffers when not currently bound.
- */
- if (gCC == NULL || gCCPriv == NULL)
- return;
+ gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = gmesa->glCtx;
+ driScrnPriv = gmesa->driScreen;
- VALIDATE_DRAWABLE_INFO(gCC,gCCPriv);
+ VALIDATE_DRAWABLE_INFO(gmesa);
/* Flush any partially filled buffers */
- FLUSH_DMA_BUFFER(gCC, gCCPriv);
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
+ driScrnPriv->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
- if (gCCPriv->EnabledFlags & GAMMA_BACK_BUFFER) {
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
int src, dst, x0, y0, x1, h;
int i;
- int nRect = driDrawPriv->numClipRects;
- XF86DRIClipRectPtr pRect = driDrawPriv->pClipRects;
- __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv;
+ int nRect = dPriv->numClipRects;
+ XF86DRIClipRectPtr pRect = dPriv->pClipRects;
+ __DRIscreenPrivate *driScrnPriv = gmesa->driScreen;
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
-#ifdef DO_VALIDATE
- DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
- driScrnPriv->drawLockID);
- VALIDATE_DRAWABLE_INFO_NO_LOCK(gCC,gCCPriv);
-#endif
-
- CHECK_DMA_BUFFER(nullCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode |
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
FBReadSrcEnable));
- WRITE(gCCPriv->buf, LBWriteMode, LBWriteModeDisable);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
for (i = 0; i < nRect; i++, pRect++) {
x0 = pRect->x1;
x1 = pRect->x2;
h = pRect->y2 - pRect->y1;
+
y0 = driScrnPriv->fbHeight - (pRect->y1+h);
+ if (gDRIPriv->numMultiDevices == 2)
+ src = (y0/2)*driScrnPriv->fbWidth+x0;
+ else
+ src = y0*driScrnPriv->fbWidth+x0;
- src = (y0/2)*driScrnPriv->fbWidth+x0;
y0 += driScrnPriv->fbHeight;
- dst = (y0/2)*driScrnPriv->fbWidth+x0;
-
- CHECK_DMA_BUFFER(nullCC, gCCPriv, 9);
- WRITE(gCCPriv->buf, StartXDom, x0<<16); /* X0dest */
- WRITE(gCCPriv->buf, StartY, y0<<16); /* Y0dest */
- WRITE(gCCPriv->buf, StartXSub, x1<<16); /* X1dest */
- WRITE(gCCPriv->buf, GLINTCount, h); /* H */
- WRITE(gCCPriv->buf, dY, 1<<16); /* ydir */
- WRITE(gCCPriv->buf, dXDom, 0<<16);
- WRITE(gCCPriv->buf, dXSub, 0<<16);
- WRITE(gCCPriv->buf, FBSourceOffset, (dst-src));
- WRITE(gCCPriv->buf, Render, 0x00040048); /* NOT_DONE */
+ if (gDRIPriv->numMultiDevices == 2)
+ dst = (y0/2)*driScrnPriv->fbWidth+x0;
+ else
+ dst = y0*driScrnPriv->fbWidth+x0;
+
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITE(gmesa->buf, StartXDom, x0<<16); /* X0dest */
+ WRITE(gmesa->buf, StartY, y0<<16); /* Y0dest */
+ WRITE(gmesa->buf, StartXSub, x1<<16); /* X1dest */
+ WRITE(gmesa->buf, GLINTCount, h); /* H */
+ WRITE(gmesa->buf, dY, 1<<16); /* ydir */
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, FBSourceOffset, (dst-src));
+ WRITE(gmesa->buf, Render, 0x00040048); /* NOT_DONE */
}
/*
@@ -550,74 +176,121 @@ void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
*/
/* Restore FBReadMode */
- CHECK_DMA_BUFFER(nullCC, gCCPriv, 2);
- WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode |
- gCCPriv->AB_FBReadMode));
- WRITE(gCCPriv->buf, LBWriteMode, LBWriteModeEnable);
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
+ gmesa->AB_FBReadMode));
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ }
-#ifdef DO_VALIDATE
- PROCESS_DMA_BUFFER_TOP_HALF(gCCPriv);
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
- DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
+ DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
driScrnPriv->drawLockID);
- VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gCC,gCCPriv);
-
- PROCESS_DMA_BUFFER_BOTTOM_HALF(gCCPriv);
-#else
- FLUSH_DMA_BUFFER(gCC,gCCPriv);
-#endif
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
- }
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+ } else {
+ _mesa_problem(NULL, "gammaSwapBuffers: drawable has no context!\n");
+ }
}
-GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv)
+static GLboolean
+gammaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
{
if (driContextPriv) {
- gCC = driContextPriv;
- gCCPriv = (gammaContextPrivate *) driContextPriv->driverPrivate;
+ GET_CURRENT_CONTEXT(ctx);
+ gammaContextPtr oldGammaCtx = ctx ? GAMMA_CONTEXT(ctx) : NULL;
+ gammaContextPtr newGammaCtx = (gammaContextPtr) driContextPriv->driverPrivate;
+
+ if ( newGammaCtx != oldGammaCtx ) {
+ newGammaCtx->dirty = ~0;
+ }
+
+ if (newGammaCtx->driDrawable != driDrawPriv) {
+ newGammaCtx->driDrawable = driDrawPriv;
+ gammaUpdateWindow ( newGammaCtx->glCtx );
+ gammaUpdateViewportOffset( newGammaCtx->glCtx );
+ }
- gCCPriv->Window &= ~W_GIDMask;
- gCCPriv->Window |= (driDrawPriv->index << 5);
+#if 0
+ newGammaCtx->Window &= ~W_GIDMask;
+ newGammaCtx->Window |= (driDrawPriv->index << 5);
+ CHECK_DMA_BUFFER(newGammaCtx,1);
+ WRITE(newGammaCtx->buf, GLINTWindow, newGammaCtx->Window);
+#endif
- CHECK_DMA_BUFFER(gCC, gCCPriv, 1);
- WRITE(gCCPriv->buf, GLINTWindow, gCCPriv->Window);
+newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
- _glapi_set_dispatch(gCCPriv->API);
+ _mesa_make_current2( newGammaCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
- _gamma_Viewport(0, 0, driDrawPriv->w, driDrawPriv->h);
+ if (!newGammaCtx->glCtx->Viewport.Width) {
+ _mesa_set_viewport(newGammaCtx->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+ }
} else {
- gCC = NULL;
- gCCPriv = NULL;
+ _mesa_make_current( 0, 0 );
}
return GL_TRUE;
}
-GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv )
+static GLboolean
+gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
{
- /* XXX not 100% sure what's supposed to be done here */
return GL_TRUE;
}
-GLboolean
-XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+gammaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
-GLboolean
-XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+gammaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
+static struct __DriverAPIRec gammaAPI = {
+ gammaInitDriver,
+ gammaDestroyScreen,
+ gammaCreateContext,
+ gammaDestroyContext,
+ gammaCreateBuffer,
+ gammaDestroyBuffer,
+ gammaSwapBuffers,
+ gammaMakeCurrent,
+ gammaUnbindContext,
+ gammaOpenFullScreen,
+ gammaCloseFullScreen
+};
+
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI);
+ return (void *) psp;
+}
+
void __driRegisterExtensions(void)
{
/* No extensions */
}
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/Imakefile b/xc/lib/GL/mesa/src/drv/i810/Imakefile
index 21d6e65a4..0bc38b49d 100644
--- a/xc/lib/GL/mesa/src/drv/i810/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/i810/Imakefile
@@ -22,12 +22,14 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/i810/Imakefile,v 1.19 2001/05/10 16:56:11
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
@@ -62,7 +64,7 @@ InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
#ifdef GlxSoProf
SOPROF_LIBNAME = _i810_dri_p
-NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(ALL_OBJS))
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/Imakefile.inc b/xc/lib/GL/mesa/src/drv/i810/Imakefile.inc
index 4069af00c..c53f05c8c 100644
--- a/xc/lib/GL/mesa/src/drv/i810/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/i810/Imakefile.inc
@@ -16,85 +16,95 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
- DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \
- -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(GLXLIBSRC)/glx \
+ -I$(INCLUDESRC) \
+ -I$(INCLUDESRC)/GL \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/i810 \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
-MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESADRVSRCDIR)/common \
-I$(MESADRVSRCDIR)/i810
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
- I810SRCS = $(MESADRVI810BUILDDIR)i810_xmesa.c \
- $(MESADRVI810BUILDDIR)i810dd.c \
- $(MESADRVI810BUILDDIR)i810pipeline.c \
+ I810SRCS = $(MESADRVI810BUILDDIR)i810context.c \
+ $(MESADRVI810BUILDDIR)i810ioctl.c \
+ $(MESADRVI810BUILDDIR)i810render.c \
+ $(MESADRVI810BUILDDIR)i810screen.c \
$(MESADRVI810BUILDDIR)i810span.c \
$(MESADRVI810BUILDDIR)i810state.c \
$(MESADRVI810BUILDDIR)i810tex.c \
+ $(MESADRVI810BUILDDIR)i810texmem.c \
+ $(MESADRVI810BUILDDIR)i810texstate.c \
$(MESADRVI810BUILDDIR)i810tris.c \
- $(MESADRVI810BUILDDIR)i810vb.c \
- $(MESADRVI810BUILDDIR)i810fastpath.c \
- $(MESADRVI810BUILDDIR)i810ioctl.c
+ $(MESADRVI810BUILDDIR)i810vb.c
- I810OBJS = $(MESADRVI810BUILDDIR)i810_xmesa.o \
- $(MESADRVI810BUILDDIR)i810dd.o \
- $(MESADRVI810BUILDDIR)i810pipeline.o \
+ I810OBJS = $(MESADRVI810BUILDDIR)i810context.o \
+ $(MESADRVI810BUILDDIR)i810ioctl.o \
+ $(MESADRVI810BUILDDIR)i810render.o \
+ $(MESADRVI810BUILDDIR)i810screen.o \
$(MESADRVI810BUILDDIR)i810span.o \
$(MESADRVI810BUILDDIR)i810state.o \
$(MESADRVI810BUILDDIR)i810tex.o \
+ $(MESADRVI810BUILDDIR)i810texmem.o \
+ $(MESADRVI810BUILDDIR)i810texstate.o \
$(MESADRVI810BUILDDIR)i810tris.o \
- $(MESADRVI810BUILDDIR)i810vb.o \
- $(MESADRVI810BUILDDIR)i810fastpath.o \
- $(MESADRVI810BUILDDIR)i810ioctl.o
+ $(MESADRVI810BUILDDIR)i810vb.o
- I810UOBJS = $(MESADRVI810BUILDDIR)unshared/i810_xmesa.o \
- $(MESADRVI810BUILDDIR)unshared/i810dd.o \
- $(MESADRVI810BUILDDIR)unshared/i810pipeline.o \
+ I810UOBJS = $(MESADRVI810BUILDDIR)unshared/i810context.o \
+ $(MESADRVI810BUILDDIR)unshared/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)unshared/i810render.o \
+ $(MESADRVI810BUILDDIR)unshared/i810screen.o \
$(MESADRVI810BUILDDIR)unshared/i810span.o \
$(MESADRVI810BUILDDIR)unshared/i810state.o \
$(MESADRVI810BUILDDIR)unshared/i810tex.o \
+ $(MESADRVI810BUILDDIR)unshared/i810texmem.o \
+ $(MESADRVI810BUILDDIR)unshared/i810texstate.o \
$(MESADRVI810BUILDDIR)unshared/i810tris.o \
- $(MESADRVI810BUILDDIR)unshared/i810vb.o \
- $(MESADRVI810BUILDDIR)unshared/i810fastpath.o \
- $(MESADRVI810BUILDDIR)unshared/i810ioctl.o
+ $(MESADRVI810BUILDDIR)unshared/i810vb.o
- I810DOBJS = $(MESADRVI810BUILDDIR)debugger/i810_xmesa.o \
- $(MESADRVI810BUILDDIR)debugger/i810dd.o \
- $(MESADRVI810BUILDDIR)debugger/i810pipeline.o \
+ I810DOBJS = $(MESADRVI810BUILDDIR)debugger/i810context.o \
+ $(MESADRVI810BUILDDIR)debugger/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)debugger/i810render.o \
+ $(MESADRVI810BUILDDIR)debugger/i810screen.o \
$(MESADRVI810BUILDDIR)debugger/i810span.o \
$(MESADRVI810BUILDDIR)debugger/i810state.o \
$(MESADRVI810BUILDDIR)debugger/i810tex.o \
+ $(MESADRVI810BUILDDIR)debugger/i810texmem.o \
+ $(MESADRVI810BUILDDIR)debugger/i810texstate.o \
$(MESADRVI810BUILDDIR)debugger/i810tris.o \
- $(MESADRVI810BUILDDIR)debugger/i810vb.o \
- $(MESADRVI810BUILDDIR)debugger/i810fastpath.o \
- $(MESADRVI810BUILDDIR)debugger/i810ioctl.o
+ $(MESADRVI810BUILDDIR)debugger/i810vb.o
- I810POBJS = $(MESADRVI810BUILDDIR)profiled/i810_xmesa.o \
- $(MESADRVI810BUILDDIR)profiled/i810dd.o \
- $(MESADRVI810BUILDDIR)profiled/i810pipeline.o \
+ I810POBJS = $(MESADRVI810BUILDDIR)profiled/i810context.o \
+ $(MESADRVI810BUILDDIR)profiled/i810ioctl.o \
+ $(MESADRVI810BUILDDIR)profiled/i810render.o \
+ $(MESADRVI810BUILDDIR)profiled/i810screen.o \
$(MESADRVI810BUILDDIR)profiled/i810span.o \
$(MESADRVI810BUILDDIR)profiled/i810state.o \
$(MESADRVI810BUILDDIR)profiled/i810tex.o \
+ $(MESADRVI810BUILDDIR)profiled/i810texmem.o \
+ $(MESADRVI810BUILDDIR)profiled/i810texstate.o \
$(MESADRVI810BUILDDIR)profiled/i810tris.o \
- $(MESADRVI810BUILDDIR)profiled/i810vb.o \
- $(MESADRVI810BUILDDIR)profiled/i810fastpath.o \
- $(MESADRVI810BUILDDIR)profiled/i810ioctl.o
+ $(MESADRVI810BUILDDIR)profiled/i810vb.o
#ifdef NeedToLinkMesaSrc
-LinkSourceFile(i810_xmesa.c, $(MESADRVSRCDIR)/i810)
-LinkSourceFile(i810dd.c, $(MESADRVSRCDIR)/i810)
-LinkSourceFile(i810pipeline.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810context.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810ioctl.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810render.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810screen.c, $(MESADRVSRCDIR)/i810)
LinkSourceFile(i810span.c, $(MESADRVSRCDIR)/i810)
LinkSourceFile(i810state.c, $(MESADRVSRCDIR)/i810)
LinkSourceFile(i810tex.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810texmem.c, $(MESADRVSRCDIR)/i810)
+LinkSourceFile(i810texstate.c, $(MESADRVSRCDIR)/i810)
LinkSourceFile(i810tris.c, $(MESADRVSRCDIR)/i810)
LinkSourceFile(i810vb.c, $(MESADRVSRCDIR)/i810)
-LinkSourceFile(i810fastpath.c, $(MESADRVSRCDIR)/i810)
-LinkSourceFile(i810ioctl.c, $(MESADRVSRCDIR)/i810)
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h b/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
index bb7c80809..3c19a857c 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h
@@ -88,7 +88,7 @@
#define DR4_YORG_MASK (0x3ff<<16)
#define DR4_XORG_MASK (0x7ff<<0)
-
+
/* GFXRENDERSTATE_LINEWIDTH_CULL_SHADE_MODE, p140
*
* Format:
@@ -135,7 +135,7 @@
#define LCS_UPDATE_INTERP (LCS_UPDATE_ALPHA_INTERP| \
LCS_UPDATE_RGB_INTERP| \
LCS_UPDATE_SPEC_INTERP)
-
+
/* GFXRENDERSTATE_BOOLEAN_ENA_1, p142
*
@@ -350,7 +350,7 @@
#define MC_OP_SUBTRACT (0x14)
/* GFXRENDERSTATE_MAP_PALETTE_LOAD, p128
- *
+ *
* Format:
* 0: GFX_OP_MAP_PALETTE_LOAD
* 1: 16bpp color[0]
@@ -534,20 +534,8 @@ typedef struct {
float tu1;
float tv1;
} i810_full_vertex;
-
-/* GFX_PRIMITIVE, p106
- */
-#define GFX_OP_PRIMITIVE ((0x3<<29)|(0x1f<<24))
-#define PR_TRIANGLES (0x0<<18)
-#define PR_TRISTRIP_0 (0x1<<18)
-#define PR_TRISTRIP_1 (0x2<<18)
-#define PR_TRIFAN (0x3<<18)
-#define PR_POLYGON (0x4<<18)
-#define PR_LINES (0x5<<18)
-#define PR_LINESTRIP (0x6<<18)
-#define PR_RECTS (0x7<<18)
-#define PR_DWORD_COUNT_SHIFT 0
+
/* GFXCMDPARSER_BATCH_BUFFER, p105
*
@@ -609,7 +597,7 @@ typedef struct {
*
* Format:
* 0: GFX_OP_DESTBUFFER_VARS
- * 1: DEST_*
+ * 1: DEST_*
*/
#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
#define DV_HORG_BIAS_MASK (0xf<<20)
@@ -645,28 +633,4 @@ typedef struct {
#define I810_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
-#define I810PACKCOLOR4444(r,g,b,a) \
- ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-#define I810PACKCOLOR1555(r,g,b,a) \
- ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define I810PACKCOLOR565(r,g,b) \
- ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-
-#define I810_VFMT_T0 (GFX_OP_VERTEX_FMT | \
- VF_TEXCOORD_COUNT_1 | \
- VF_SPEC_FOG_ENABLE | \
- VF_RGBA_ENABLE | \
- VF_XYZW)
-
-#define I810_VFMT_T0T1 (GFX_OP_VERTEX_FMT | \
- VF_TEXCOORD_COUNT_2 | \
- VF_SPEC_FOG_ENABLE | \
- VF_RGBA_ENABLE | \
- VF_XYZW)
-
-
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
deleted file mode 100644
index c7cf9ac35..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c
+++ /dev/null
@@ -1,684 +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.
-
-**************************************************************************/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c,v 1.14 2001/10/02 11:44:13 alanh Exp $ */
-
-/*
- * Authors:
- * Keith Whitwell <keithw@precisioninsight.com>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-#include <stdio.h>
-
-#include "i810_init.h"
-#include "context.h"
-#include "vbxform.h"
-#include "matrix.h"
-#include "simple_list.h"
-
-#include "i810dd.h"
-#include "i810state.h"
-#include "i810tex.h"
-#include "i810span.h"
-#include "i810tris.h"
-#include "i810pipeline.h"
-#include "i810ioctl.h"
-
-#include "i810_dri.h"
-
-
-
-#ifndef I810_DEBUG
-int I810_DEBUG = (0
-/* | DEBUG_ALWAYS_SYNC */
-/* | DEBUG_VERBOSE_RING */
-/* | DEBUG_VERBOSE_OUTREG */
-/* | DEBUG_VERBOSE_MSG */
-/* | DEBUG_NO_OUTRING */
-/* | DEBUG_NO_OUTREG */
-/* | DEBUG_VERBOSE_API */
-/* | DEBUG_VERBOSE_2D */
-/* | DEBUG_VERBOSE_DRI */
-/* | DEBUG_VALIDATE_RING */
-/* | DEBUG_VERBOSE_IOCTL */
- );
-#endif
-
-
-static i810ContextPtr i810Ctx = 0;
-
-
-/* These functions are accessed externally to the driver:
- *
- * XMesaInitDriver
- * XMesaResetDriver
- * XMesaCreateVisual
- * XMesaDestroyVisual
- * XMesaCreateContext
- * XMesaDestroyContext
- * XMesaCreateWindowBuffer
- * XMesaCreatePixmapBuffer
- * XMesaDestroyBuffer
- * XMesaSwapBuffers
- * XMesaMakeCurrent
- *
- */
-
-
-static int i810_malloc_proxy_buf(drmBufMapPtr buffers)
-{
- char *buffer;
- drmBufPtr buf;
- int i;
-
- buffer = Xmalloc(I810_DMA_BUF_SZ);
- if(buffer == NULL) return -1;
- for(i = 0; i < I810_DMA_BUF_NR; i++) {
- buf = &(buffers->list[i]);
- buf->address = (drmAddress)buffer;
- }
- return 0;
-}
-
-static drmBufMapPtr i810_create_empty_buffers(void)
-{
- drmBufMapPtr retval;
-
- retval = (drmBufMapPtr)Xmalloc(sizeof(drmBufMap));
- if(retval == NULL) return NULL;
- memset(retval, 0, sizeof(drmBufMap));
- retval->list = (drmBufPtr)Xmalloc(sizeof(drmBuf) * I810_DMA_BUF_NR);
- if(retval->list == NULL) {
- Xfree(retval);
- return NULL;
- }
- memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR);
- /*
- fprintf(stderr, "retval : %p, retval->list : %p\n", retval, retval->list);
- */
- return retval;
-}
-
-GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
-{
- i810ScreenPrivate *i810Screen;
- I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
-
- /* Check the DRI version */
- {
- int major, minor, patch;
- if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
- if (major != 4 || minor < 0) {
- char msg[1000];
- sprintf(msg, "i810 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
- }
- }
-
- /* Check that the DDX driver version is compatible */
- if (sPriv->ddxMajor != 1 ||
- sPriv->ddxMinor < 0) {
- char msg[1000];
- sprintf(msg, "i810 DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
-
- /* Check that the DRM driver version is compatible */
- if (sPriv->drmMajor != 1 ||
- sPriv->drmMinor < 2) {
- char msg[1000];
- sprintf(msg, "i810 DRI driver expected DRM driver version 1.2 or greater but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
- __driMesaMessage(msg);
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- i810Screen = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate));
- if (!i810Screen)
- return GL_FALSE;
-
- i810Screen->driScrnPriv = sPriv;
- sPriv->private = (void *)i810Screen;
-
- i810Screen->deviceID=gDRIPriv->deviceID;
- i810Screen->width=gDRIPriv->width;
- i810Screen->height=gDRIPriv->height;
- i810Screen->mem=gDRIPriv->mem;
- i810Screen->cpp=gDRIPriv->cpp;
- i810Screen->fbStride=gDRIPriv->fbStride;
- i810Screen->fbOffset=gDRIPriv->fbOffset;
-
- if (gDRIPriv->bitsPerPixel == 15)
- i810Screen->fbFormat = DV_PF_555;
- else
- i810Screen->fbFormat = DV_PF_565;
-
- i810Screen->backOffset=gDRIPriv->backOffset;
- i810Screen->depthOffset=gDRIPriv->depthOffset;
- i810Screen->backPitch = gDRIPriv->auxPitch;
- i810Screen->backPitchBits = gDRIPriv->auxPitchBits;
- i810Screen->textureOffset=gDRIPriv->textureOffset;
- i810Screen->textureSize=gDRIPriv->textureSize;
- i810Screen->logTextureGranularity = gDRIPriv->logTextureGranularity;
-
- if (0)
- fprintf(stderr, "Tex heap size %x, granularity %x bytes\n",
- i810Screen->textureSize, 1<<(i810Screen->logTextureGranularity));
-
- i810Screen->bufs = i810_create_empty_buffers();
- if(i810Screen->bufs == NULL)
- {
- Xfree(i810Screen);
- return GL_FALSE;
- }
-
- /* Check if you need to create a fake buffer */
- if(i810_check_copy(sPriv->fd) == 1)
- {
- i810_malloc_proxy_buf(i810Screen->bufs);
- i810Screen->use_copy_buf = 1;
- }
- else
- {
- i810Screen->use_copy_buf = 0;
- }
-
- i810Screen->back.handle = gDRIPriv->backbuffer;
- i810Screen->back.size = gDRIPriv->backbufferSize;
-
- if (drmMap(sPriv->fd,
- i810Screen->back.handle,
- i810Screen->back.size,
- (drmAddress *)&i810Screen->back.map) != 0)
- {
- Xfree(i810Screen);
- sPriv->private = NULL;
- return GL_FALSE;
- }
-
- i810Screen->depth.handle = gDRIPriv->depthbuffer;
- i810Screen->depth.size = gDRIPriv->depthbufferSize;
-
- if (drmMap(sPriv->fd,
- i810Screen->depth.handle,
- i810Screen->depth.size,
- (drmAddress *)&i810Screen->depth.map) != 0)
- {
- Xfree(i810Screen);
- drmUnmap(i810Screen->back.map, i810Screen->back.size);
- sPriv->private = NULL;
- return GL_FALSE;
- }
-
- i810Screen->tex.handle = gDRIPriv->textures;
- i810Screen->tex.size = gDRIPriv->textureSize;
- i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
-
- if (drmMap(sPriv->fd,
- i810Screen->tex.handle,
- i810Screen->tex.size,
- (drmAddress *)&i810Screen->tex.map) != 0)
- {
- Xfree(i810Screen);
- drmUnmap(i810Screen->back.map, i810Screen->back.size);
- drmUnmap(i810Screen->depth.map, i810Screen->depth.size);
- sPriv->private = NULL;
- return GL_FALSE;
- }
-
-
- i810DDFastPathInit();
- i810DDTrifuncInit();
- i810DDSetupInit();
-
- return GL_TRUE;
-}
-
-/* Accessed by dlsym from dri_mesa_init.c
- */
-void XMesaResetDriver(__DRIscreenPrivate *sPriv)
-{
- i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
-
- /* Need to unmap all the bufs and maps here:
- */
- drmUnmap(i810Screen->back.map, i810Screen->back.size);
- drmUnmap(i810Screen->depth.map, i810Screen->depth.size);
- drmUnmap(i810Screen->tex.map, i810Screen->tex.size);
-
- Xfree(i810Screen);
- sPriv->private = NULL;
-}
-
-
-GLvisual *XMesaCreateVisual(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config)
-{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount(visinfo->red_mask),
- _mesa_bitcount(visinfo->green_mask),
- _mesa_bitcount(visinfo->blue_mask),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
-
-
-GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
-{
- GLcontext *ctx = driContextPriv->mesaContext;
- i810ContextPtr imesa;
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
- drm_i810_sarea_t *saPriv=(drm_i810_sarea_t *)(((char*)sPriv->pSAREA)+
- i810Screen->sarea_priv_offset);
-
- imesa = (i810ContextPtr)Xcalloc(sizeof(i810Context), 1);
- if (!imesa) {
- return GL_FALSE;
- }
-
-
- /* Set the maximum texture size small enough that we can guarentee
- * that both texture units can bind a maximal texture and have them
- * in memory at once.
- */
- if (i810Screen->textureSize < 2*1024*1024) {
- ctx->Const.MaxTextureLevels = 9;
- ctx->Const.MaxTextureSize = 1<<8;
- } else if (i810Screen->textureSize < 8*1024*1024) {
- ctx->Const.MaxTextureLevels = 10;
- ctx->Const.MaxTextureSize = 1<<9;
- } else {
- ctx->Const.MaxTextureLevels = 11;
- ctx->Const.MaxTextureSize = 1<<10;
- }
-
- ctx->Const.MinLineWidth = 1.0;
- ctx->Const.MinLineWidthAA = 1.0;
- ctx->Const.MaxLineWidth = 3.0;
- ctx->Const.MaxLineWidthAA = 3.0;
- ctx->Const.LineWidthGranularity = 1.0;
-
-
- /* Dri stuff
- */
- imesa->display = dpy;
- imesa->hHWContext = driContextPriv->hHWContext;
- imesa->driFd = sPriv->fd;
- imesa->driHwLock = &sPriv->pSAREA->lock;
-
- imesa->i810Screen = i810Screen;
- imesa->driScreen = sPriv;
- imesa->sarea = saPriv;
- imesa->glBuffer = NULL;
-
- imesa->texHeap = mmInit( 0, i810Screen->textureSize );
-
-
- /* Utah stuff
- */
- imesa->renderindex = -1; /* impossible value */
- imesa->new_state = ~0;
- imesa->dirty = ~0;
-
- make_empty_list(&imesa->TexObjList);
- make_empty_list(&imesa->SwappedOut);
-
- imesa->TextureMode = ctx->Texture.Unit[0].EnvMode;
- imesa->CurrentTexObj[0] = 0;
- imesa->CurrentTexObj[1] = 0;
-
- ctx->DriverCtx = (void *) imesa;
- imesa->glCtx = ctx;
-
- i810DDExtensionsInit( ctx );
-
- i810DDInitStateFuncs( ctx );
- i810DDInitTextureFuncs( ctx );
- i810DDInitSpanFuncs( ctx );
- i810DDInitDriverFuncs( ctx );
- i810DDInitIoctlFuncs( ctx );
-
- ctx->Driver.TriangleCaps = (DD_TRI_CULL|
- DD_TRI_LIGHT_TWOSIDE|
- DD_TRI_STIPPLE|
- DD_TRI_OFFSET);
-
- /* Ask mesa to clip fog coordinates for us.
- */
- ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
-
- if (ctx->VB)
- i810DDRegisterVB( ctx->VB );
-
- if (ctx->NrPipelineStages)
- ctx->NrPipelineStages =
- i810DDRegisterPipelineStages(ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages);
-
- i810DDInitState( imesa );
-
- driContextPriv->driverPrivate = (void *) imesa;
-
- return GL_TRUE;
-}
-
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
- i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
-
- if (imesa) {
- i810TextureObjectPtr next_t, t;
-
- foreach_s (t, next_t, &(imesa->TexObjList))
- i810DestroyTexObj(imesa, t);
-
- foreach_s (t, next_t, &(imesa->SwappedOut))
- i810DestroyTexObj(imesa, t);
-
- Xfree(imesa);
- }
-}
-
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
-{
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0
- );
-}
-
-
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
-{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0
- );
-#else
- return NULL; /* not implemented yet */
-#endif
-}
-
-
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
-{
- /* XXX should do swap according to the buffer, not the context! */
- i810ContextPtr imesa = i810Ctx;
-
- FLUSH_VB( imesa->glCtx, "swap buffers" );
- i810SwapBuffers(imesa);
-}
-
-
-
-void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
-{
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
-
- imesa->numClipRects = dPriv->numClipRects;
- imesa->pClipRects = dPriv->pClipRects;
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
- imesa->drawX = dPriv->x;
- imesa->drawY = dPriv->y;
-
- i810EmitDrawingRectangle( imesa );
-}
-
-
-void i810XMesaSetBackClipRects( i810ContextPtr imesa )
-{
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
- int i;
-
- if (dPriv->numBackClipRects == 0)
- {
- if (I810_DEBUG & DEBUG_VERBOSE_DRI)
- fprintf(stderr, "FRONT_CLIPRECTS, %d rects\n",
- dPriv->numClipRects);
-
- imesa->numClipRects = dPriv->numClipRects;
- imesa->pClipRects = dPriv->pClipRects;
- imesa->drawX = dPriv->x;
- imesa->drawY = dPriv->y;
- } else {
- if (I810_DEBUG & DEBUG_VERBOSE_DRI)
- fprintf(stderr, "BACK_RECTS, %d rects\n",
- dPriv->numBackClipRects);
-
- imesa->numClipRects = dPriv->numBackClipRects;
- imesa->pClipRects = dPriv->pBackClipRects;
- imesa->drawX = dPriv->backX;
- imesa->drawY = dPriv->backY;
- }
-
- i810EmitDrawingRectangle( imesa );
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
-
- if (I810_DEBUG & DEBUG_VERBOSE_DRI)
- for (i = 0 ; i < imesa->numClipRects ; i++)
- fprintf(stderr, "cliprect %d: %d,%d - %d,%d\n",
- i,
- imesa->pClipRects[i].x1,
- imesa->pClipRects[i].y1,
- imesa->pClipRects[i].x2,
- imesa->pClipRects[i].y2);
-}
-
-
-static void i810XMesaWindowMoved( i810ContextPtr imesa )
-{
- if (0)
- fprintf(stderr, "i810XMesaWindowMoved\n\n");
-
- switch (imesa->glCtx->Color.DriverDrawBuffer) {
- case GL_FRONT_LEFT:
- i810XMesaSetFrontClipRects( imesa );
- break;
- case GL_BACK_LEFT:
- i810XMesaSetBackClipRects( imesa );
- break;
- default:
- /*fprintf(stderr, "fallback buffer\n");*/
- break;
- }
-}
-
-
-GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
-{
- i810ContextPtr i810 = (i810ContextPtr) driContextPriv->driverPrivate;
- if (i810)
- i810->dirty = ~0;
-
- return GL_TRUE;
-}
-
-GLboolean
-XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- return GL_TRUE;
-}
-
-GLboolean
-XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- return GL_TRUE;
-}
-
-
-GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv)
-{
- if (driContextPriv) {
- i810Ctx = (i810ContextPtr) driContextPriv->driverPrivate;
-
- gl_make_current2(i810Ctx->glCtx, driDrawPriv->mesaBuffer,
- driReadPriv->mesaBuffer);
-
-
- i810Ctx->driDrawable = driDrawPriv;
- i810Ctx->dirty = ~0;
-
- i810XMesaWindowMoved( i810Ctx );
-
- if (!i810Ctx->glCtx->Viewport.Width)
- gl_Viewport(i810Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
- }
- else
- {
- gl_make_current(0,0);
- i810Ctx = NULL;
- }
- return GL_TRUE;
-}
-
-
-void i810GetLock( i810ContextPtr imesa, GLuint flags )
-{
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
- __DRIscreenPrivate *sPriv = imesa->driScreen;
- drm_i810_sarea_t *sarea = imesa->sarea;
- int me = imesa->hHWContext;
- int stamp = dPriv->lastStamp;
-
-
- if (0) fprintf(stderr, ".\n");
-
- /* We know there has been contention.
- */
- drmGetLock(imesa->driFd, imesa->hHWContext, flags);
-
-
- /* Note contention for throttling hint
- */
- imesa->any_contend = 1;
-
- /* 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:
- */
- XMESA_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv);
-
-
- if (0)
- fprintf(stderr, "i810GetLock, last enque: %d last dispatch: %d\n",
- sarea->last_enqueue,
- sarea->last_dispatch);
-
- /* If we lost context, need to dump all registers to hardware.
- * Note that we don't care about 2d contexts, even if they perform
- * accelerated commands, so the DRI locking in the X server is even
- * more broken than usual.
- */
- if (sarea->ctxOwner != me) {
- imesa->dirty |= (I810_UPLOAD_CTX |
- I810_UPLOAD_CLIPRECTS |
- I810_UPLOAD_BUFFERS |
- I810_UPLOAD_TEX0 |
- I810_UPLOAD_TEX1);
- sarea->ctxOwner = me;
- }
-
- /* Shared texture managment - if another client has played with
- * texture space, figure out which if any of our textures have been
- * ejected, and update our global LRU.
- */
- if (sarea->texAge != imesa->texAge) {
- int sz = 1 << (imesa->i810Screen->logTextureGranularity);
- int idx, nr = 0;
-
- /* Have to go right round from the back to ensure stuff ends up
- * LRU in our local list...
- */
- for (idx = sarea->texList[I810_NR_TEX_REGIONS].prev ;
- idx != I810_NR_TEX_REGIONS && nr < I810_NR_TEX_REGIONS ;
- idx = sarea->texList[idx].prev, nr++)
- {
- if (sarea->texList[idx].age > imesa->texAge)
- i810TexturesGone(imesa, idx * sz, sz, sarea->texList[idx].in_use);
- }
-
- if (nr == I810_NR_TEX_REGIONS) {
- i810TexturesGone(imesa, 0, imesa->i810Screen->textureSize, 0);
- i810ResetGlobalLRU( imesa );
- }
-
- if (0) fprintf(stderr, "imesa %d sarea %d\n", imesa->texAge, sarea->texAge);
- imesa->dirty |= I810_UPLOAD_TEX0IMAGE;
- imesa->dirty |= I810_UPLOAD_TEX1IMAGE;
- imesa->texAge = sarea->texAge;
- }
-
-
- if (dPriv->lastStamp != stamp)
- i810XMesaWindowMoved( imesa );
-
-
- sarea->last_quiescent = -1; /* just kill it for now */
-}
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.c b/xc/lib/GL/mesa/src/drv/i810/i810context.c
new file mode 100644
index 000000000..fc423abe2
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810context.c
@@ -0,0 +1,448 @@
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c,v 1.9 2000/12/07 20:26:06 dawes Exp $ */
+
+/*
+ * Authors:
+ * Keith Whitwell <keithw@precisioninsight.com>
+ *
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "extensions.h"
+#include "mem.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810span.h"
+#include "i810tris.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+
+#include <X11/Xlibint.h>
+#include <stdio.h>
+
+
+static const GLubyte *i810GetString( GLcontext *ctx, GLenum name )
+{
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Keith Whitwell";
+ case GL_RENDERER:
+ return (GLubyte *)"Mesa DRI I810 20010624";
+ default:
+ return 0;
+ }
+}
+
+static void i810BufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE(imesa);
+ *width = imesa->driDrawable->w;
+ *height = imesa->driDrawable->h;
+ UNLOCK_HARDWARE(imesa);
+}
+
+static void i810InitExtensions( GLcontext *ctx )
+{
+ _mesa_enable_imaging_extensions( ctx);
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
+ _mesa_enable_extension( ctx, "GL_ARB_texture_env_add" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
+ _mesa_enable_extension( ctx, "GL_EXT_stencil_wrap" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
+}
+
+extern const struct gl_pipeline_stage _i810_render_stage;
+
+static const struct gl_pipeline_stage *i810_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_i810_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+GLboolean
+i810CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ i810ContextPtr imesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+ drm_i810_sarea_t *saPriv = (drm_i810_sarea_t *)
+ (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset);
+
+ /* Allocate i810 context */
+ imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t);
+ if (!imesa) {
+ return GL_FALSE;
+ }
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ imesa->glCtx = _mesa_create_context(mesaVis, shareCtx, imesa, GL_TRUE);
+ if (!imesa->glCtx) {
+ FREE(imesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = imesa;
+
+
+ /* Set the maximum texture size small enough that we can guarentee
+ * that both texture units can bind a maximal texture and have them
+ * in memory at once.
+ */
+ ctx = imesa->glCtx;
+ if (i810Screen->textureSize < 2*1024*1024) {
+ ctx->Const.MaxTextureLevels = 9;
+ } else if (i810Screen->textureSize < 8*1024*1024) {
+ ctx->Const.MaxTextureLevels = 10;
+ } else {
+ ctx->Const.MaxTextureLevels = 11;
+ }
+ ctx->Const.MaxTextureUnits = 2;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 3.0;
+ ctx->Const.MaxLineWidthAA = 3.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 3.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Driver.GetBufferSize = i810BufferSize;
+ ctx->Driver.GetString = i810GetString;
+
+ /* Who owns who?
+ */
+ ctx->DriverCtx = (void *) imesa;
+ imesa->glCtx = ctx;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, i810_pipeline );
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+
+ /* Dri stuff
+ */
+ imesa->display = dpy;
+ imesa->hHWContext = driContextPriv->hHWContext;
+ imesa->driFd = sPriv->fd;
+ imesa->driHwLock = &sPriv->pSAREA->lock;
+
+ imesa->i810Screen = i810Screen;
+ imesa->driScreen = sPriv;
+ imesa->sarea = saPriv;
+ imesa->glBuffer = NULL;
+
+ imesa->texHeap = mmInit( 0, i810Screen->textureSize );
+ imesa->stipple_in_hw = 1;
+ imesa->RenderIndex = ~0;
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ imesa->upload_cliprects = GL_TRUE;
+
+ make_empty_list(&imesa->TexObjList);
+ make_empty_list(&imesa->SwappedOut);
+
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+
+ _math_matrix_ctr( &imesa->ViewportMatrix );
+
+ i810InitExtensions( ctx );
+ i810InitStateFuncs( ctx );
+ i810InitTextureFuncs( ctx );
+ i810InitTriFuncs( ctx );
+ i810InitSpanFuncs( ctx );
+ i810InitIoctlFuncs( ctx );
+ i810InitVB( ctx );
+ i810InitState( ctx );
+
+ return GL_TRUE;
+}
+
+void
+i810DestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+
+ assert(imesa); /* should never be null */
+ if (imesa) {
+
+ _swsetup_DestroyContext( imesa->glCtx );
+ _tnl_DestroyContext( imesa->glCtx );
+ _ac_DestroyContext( imesa->glCtx );
+ _swrast_DestroyContext( imesa->glCtx );
+
+ i810FreeVB( imesa->glCtx );
+
+ /* free the Mesa context */
+ imesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(imesa->glCtx);
+
+ Xfree(imesa);
+ }
+}
+
+
+void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+
+ i810EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+
+void i810XMesaSetBackClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ if (dPriv->numBackClipRects == 0)
+ {
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+ } else {
+ imesa->numClipRects = dPriv->numBackClipRects;
+ imesa->pClipRects = dPriv->pBackClipRects;
+ imesa->drawX = dPriv->backX;
+ imesa->drawY = dPriv->backY;
+ }
+
+ i810EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+
+static void i810XMesaWindowMoved( i810ContextPtr imesa )
+{
+ switch (imesa->glCtx->Color.DriverDrawBuffer) {
+ case GL_FRONT_LEFT:
+ i810XMesaSetFrontClipRects( imesa );
+ break;
+ case GL_BACK_LEFT:
+ i810XMesaSetBackClipRects( imesa );
+ break;
+ default:
+ break;
+ }
+
+}
+
+
+GLboolean
+i810UnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+ if (imesa) {
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ if (imesa->CurrentTexObj[0]) imesa->dirty |= I810_UPLOAD_TEX0;
+ if (imesa->CurrentTexObj[1]) imesa->dirty |= I810_UPLOAD_TEX1;
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean
+i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+
+ _mesa_make_current2(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+
+ /* Shouldn't the readbuffer be stored also?
+ */
+ imesa->driDrawable = driDrawPriv;
+
+ /* Are these necessary?
+ */
+ i810XMesaWindowMoved( imesa );
+ if (!imesa->glCtx->Viewport.Width)
+ _mesa_set_viewport(imesa->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+ }
+ else {
+ _mesa_make_current(0,0);
+ }
+
+ return GL_TRUE;
+}
+
+
+void i810GetLock( i810ContextPtr imesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ __DRIscreenPrivate *sPriv = imesa->driScreen;
+ drm_i810_sarea_t *sarea = imesa->sarea;
+ int me = imesa->hHWContext;
+
+ drmGetLock(imesa->driFd, imesa->hHWContext, flags);
+
+ /* 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:
+ */
+ DRI_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv);
+
+
+ /* If we lost context, need to dump all registers to hardware.
+ * Note that we don't care about 2d contexts, even if they perform
+ * accelerated commands, so the DRI locking in the X server is even
+ * more broken than usual.
+ */
+ if (sarea->ctxOwner != me) {
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ if (imesa->CurrentTexObj[0]) imesa->dirty |= I810_UPLOAD_TEX0;
+ if (imesa->CurrentTexObj[1]) imesa->dirty |= I810_UPLOAD_TEX1;
+ sarea->ctxOwner = me;
+ }
+
+ /* Shared texture managment - if another client has played with
+ * texture space, figure out which if any of our textures have been
+ * ejected, and update our global LRU.
+ */
+ if (sarea->texAge != imesa->texAge) {
+ int sz = 1 << (imesa->i810Screen->logTextureGranularity);
+ int idx, nr = 0;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in our local list...
+ */
+ for (idx = sarea->texList[I810_NR_TEX_REGIONS].prev ;
+ idx != I810_NR_TEX_REGIONS && nr < I810_NR_TEX_REGIONS ;
+ idx = sarea->texList[idx].prev, nr++)
+ {
+ if (sarea->texList[idx].age > imesa->texAge)
+ i810TexturesGone(imesa, idx * sz, sz, sarea->texList[idx].in_use);
+ }
+
+ if (nr == I810_NR_TEX_REGIONS) {
+ i810TexturesGone(imesa, 0, imesa->i810Screen->textureSize, 0);
+ i810ResetGlobalLRU( imesa );
+ }
+
+ imesa->texAge = sarea->texAge;
+ }
+
+ if (imesa->lastStamp != dPriv->lastStamp) {
+ i810XMesaWindowMoved( imesa );
+ imesa->lastStamp = dPriv->lastStamp;
+ }
+}
+
+
+void
+i810SwapBuffers(Display *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ (void) dpy;
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ i810ContextPtr imesa;
+ GLcontext *ctx;
+ imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = imesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_swapbuffers( ctx ); /* flush pending rendering comands */
+ if ( imesa->doPageFlip ) {
+ i810PageFlip( dPriv );
+ }
+ else {
+ i810CopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "i810SwapBuffers: drawable has no context!\n");
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810context.h b/xc/lib/GL/mesa/src/drv/i810/i810context.h
index 0ac05df68..d7704ac66 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810context.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810context.h
@@ -31,43 +31,29 @@ typedef struct i810_context_t *i810ContextPtr;
typedef struct i810_texture_object_t *i810TextureObjectPtr;
#include <X11/Xlibint.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "types.h"
-#include "i810_init.h"
+#include "mtypes.h"
#include "drm.h"
#include "mm.h"
-#include "i810log.h"
+#include "i810screen.h"
#include "i810tex.h"
-#include "i810vb.h"
-/* Reasons to fallback on all primitives. (see also
- * imesa->IndirectTriangles).
+/* Reasons to disable hardware rasterization.
*/
#define I810_FALLBACK_TEXTURE 0x1
#define I810_FALLBACK_DRAW_BUFFER 0x2
#define I810_FALLBACK_READ_BUFFER 0x4
#define I810_FALLBACK_COLORMASK 0x8
-#define I810_FALLBACK_STIPPLE 0x10
#define I810_FALLBACK_SPECULAR 0x20
#define I810_FALLBACK_LOGICOP 0x40
+#define I810_FALLBACK_RENDERMODE 0x80
+#define I810_FALLBACK_STENCIL 0x100
+#define I810_FALLBACK_BLEND_EQ 0x200
+#define I810_FALLBACK_BLEND_FUNC 0x400
-
-/* for i810ctx.new_state - manage GL->driver state changes
- */
-#define I810_NEW_TEXTURE 0x1
-
-
-typedef void (*i810_interp_func)( GLfloat t,
- GLfloat *result,
- const GLfloat *in,
- const GLfloat *out );
-
#ifndef PCI_CHIP_I810
#define PCI_CHIP_I810 0x7121
#define PCI_CHIP_I810_DC100 0x7123
@@ -81,71 +67,93 @@ typedef void (*i810_interp_func)( GLfloat t,
#define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815)
-struct i810_context_t {
- GLint refcount;
+#define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
+/* Use the templated vertex formats:
+ */
+#define TAG(x) i810##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*i810_tri_func)( i810ContextPtr, i810Vertex *, i810Vertex *,
+ i810Vertex * );
+typedef void (*i810_line_func)( i810ContextPtr, i810Vertex *, i810Vertex * );
+typedef void (*i810_point_func)( i810ContextPtr, i810Vertex * );
+
+struct i810_context_t {
+ GLint refcount;
GLcontext *glCtx;
+ /* Textures
+ */
i810TextureObjectPtr CurrentTexObj[2];
-
struct i810_texture_object_t TexObjList;
struct i810_texture_object_t SwappedOut;
+ memHeap_t *texHeap;
- int TextureMode;
+ /* Bit flag to keep track of fallbacks.
+ */
+ GLuint Fallback;
- /* Hardware state
+ /* Temporaries for translating away float colors:
*/
- GLuint Setup[I810_CTX_SETUP_SIZE];
- GLuint BufferSetup[I810_DEST_SETUP_SIZE];
- int vertsize;
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
+
+ /* State for i810vb.c and i810tris.c.
+ */
+ GLuint new_state; /* _NEW_* flags */
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLuint RenderIndex;
+ GLmatrix ViewportMatrix;
+ GLenum render_primitive;
+ GLenum reduced_primitive;
+ GLuint hw_primitive;
+ char *verts;
+
+ drmBufPtr vertex_buffer;
+ char *vertex_addr;
+ GLuint vertex_low;
+ GLuint vertex_high;
+ GLuint vertex_last_prim;
+ GLboolean upload_cliprects;
+
- /* Support for CVA and the fast paths.
+ /* Fallback rasterization functions
*/
- GLuint setupdone;
- GLuint setupindex;
- GLuint renderindex;
- GLuint using_fast_path;
- i810_interp_func interp;
+ i810_point_func draw_point;
+ i810_line_func draw_line;
+ i810_tri_func draw_tri;
- /* Shortcircuit some state changes.
+ /* Hardware state
*/
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
+ GLuint dirty; /* I810_UPLOAD_* */
+ GLuint Setup[I810_CTX_SETUP_SIZE];
+ GLuint BufferSetup[I810_DEST_SETUP_SIZE];
+ int vertex_size;
+ int vertex_stride_shift;
+ GLint lastStamp;
+ GLboolean stipple_in_hw;
- /* Manage our own state */
- GLuint new_state;
+ GLenum TexEnvImageFmt[2];
- /* Manage hardware state */
- GLuint dirty;
- memHeap_t *texHeap;
-
- /* One of the few bits of hardware state that can't be calculated
- * completely on the fly:
+ /* State which can't be computed completely on the fly:
*/
GLuint LcsCullMode;
+ GLuint LcsLineWidth;
+ GLuint LcsPointSize;
/* Funny mesa mirrors
*/
- GLushort MonoColor;
GLushort ClearColor;
/* DRI stuff
*/
- drmBufPtr vertex_dma_buffer;
- GLuint vertex_prim;
-
- GLframebuffer *glBuffer;
-
- /* Two flags to keep track of fallbacks.
- */
- GLuint IndirectTriangles;
- GLuint Fallback;
-
-
GLuint needClip;
+ GLframebuffer *glBuffer;
+ GLboolean doPageFlip;
/* These refer to the current draw (front vs. back) buffer:
*/
@@ -157,13 +165,11 @@ struct i810_context_t {
XF86DRIClipRectPtr pClipRects;
int lastSwap;
- int secondLastSwap;
int texAge;
int ctxAge;
int dirtyAge;
- int any_contend; /* throttle me harder */
- int scissor;
+ GLboolean scissor;
drm_clip_rect_t draw_rect;
drm_clip_rect_t scissor_rect;
@@ -179,27 +185,51 @@ struct i810_context_t {
};
-/* To remove all debugging, make sure I810_DEBUG is defined as a
- * preprocessor symbol, and equal to zero.
+#define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
+
+#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
+
+
+/* Lock the hardware and validate our state.
*/
-#define I810_DEBUG 0
-#ifndef I810_DEBUG
-#warning "Debugging enabled - expect reduced performance"
-extern int I810_DEBUG;
-#endif
+#define LOCK_HARDWARE( imesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
+ (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
+ if (__ret) \
+ i810GetLock( imesa, 0 ); \
+ } while (0)
+
+
+
+/* Release the kernel lock.
+ */
+#define UNLOCK_HARDWARE(imesa) \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
+
+
+/* This is the wrong way to do it, I'm sure. Otherwise the drm
+ * bitches that I've already got the heavyweight lock. At worst,
+ * this is 3 ioctls. The best solution probably only gets me down
+ * to 2 ioctls in the worst case.
+ */
+#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
+ LOCK_HARDWARE( imesa ); \
+ i810RegetLockQuiescent( imesa ); \
+} while(0)
+
+
+extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
+extern void i810EmitHwStateLocked( i810ContextPtr imesa );
+extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
+extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
+extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
+extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
-#define DEBUG_VERBOSE_2D 0x1
-#define DEBUG_VERBOSE_RING 0x8
-#define DEBUG_VERBOSE_OUTREG 0x10
-#define DEBUG_ALWAYS_SYNC 0x40
-#define DEBUG_VERBOSE_MSG 0x80
-#define DEBUG_NO_OUTRING 0x100
-#define DEBUG_NO_OUTREG 0x200
-#define DEBUG_VERBOSE_API 0x400
-#define DEBUG_VALIDATE_RING 0x800
-#define DEBUG_VERBOSE_LRU 0x1000
-#define DEBUG_VERBOSE_DRI 0x2000
-#define DEBUG_VERBOSE_IOCTL 0x4000
+#define SUBPIXEL_X -.5
+#define SUBPIXEL_Y -.5
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dd.c b/xc/lib/GL/mesa/src/drv/i810/i810dd.c
deleted file mode 100644
index 910108010..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810dd.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/i810/i810dd.c,v 1.5 2001/04/10 16:07:50 dawes Exp $ */
-
-#include "types.h"
-#include "vbrender.h"
-
-#include <stdio.h>
-
-#include "mm.h"
-#include "i810dd.h"
-#include "i810log.h"
-#include "i810state.h"
-#include "i810span.h"
-#include "i810tex.h"
-#include "i810tris.h"
-#include "i810vb.h"
-#include "i810pipeline.h"
-#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
-
-
-extern int xf86VTSema;
-
-
-/***************************************
- * Mesa's Driver Functions
- ***************************************/
-
-
-static const GLubyte *i810DDGetString( GLcontext *ctx, GLenum name )
-{
- switch (name) {
- case GL_VENDOR:
- return (GLubyte *)"Keith Whitwell, Precision Insight Inc.";
- case GL_RENDERER:
- return (GLubyte *)"Mesa DRI I810 20010321";
- default:
- return 0;
- }
-}
-
-static GLint i810GetParameteri(const GLcontext *ctx, GLint param)
-{
- switch (param) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- return 0;
- }
-}
-
-
-
-static void i810BufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
-
- /* Need to lock to make sure the driDrawable is uptodate. This
- * information is used to resize Mesa's software buffers, so it has
- * to be correct.
- */
- LOCK_HARDWARE(imesa);
- *width = imesa->driDrawable->w;
- *height = imesa->driDrawable->h;
- UNLOCK_HARDWARE(imesa);
-}
-
-
-
-
-void i810DDExtensionsInit( GLcontext *ctx )
-{
- /* paletted_textures currently doesn't work.
- */
- gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
- gl_extensions_disable( ctx, "GL_EXT_paletted_texture" );
-
- /* we don't support point parameters in hardware yet */
- gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
-
- /* The imaging subset of 1.2 isn't supported by any mesa driver.
- */
- gl_extensions_disable( ctx, "ARB_imaging" );
- gl_extensions_disable( ctx, "GL_ARB_texture_compression" );
- gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );
- gl_extensions_disable( ctx, "GL_EXT_blend_color" );
- gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
- gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
- gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
- gl_extensions_disable( ctx, "GL_EXT_convolution" );
- gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" );
- gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
- gl_extensions_disable( ctx, "GL_MESA_resize_buffers" );
- gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );
- gl_extensions_disable( ctx, "GL_SGI_color_matrix" );
- gl_extensions_disable( ctx, "GL_SGI_color_table" );
-
- /* We do support tex_env_add, however
- */
- gl_extensions_enable( ctx, "GL_EXT_texture_env_add" );
-}
-
-
-
-
-void i810DDInitDriverFuncs( GLcontext *ctx )
-{
- ctx->Driver.GetBufferSize = i810BufferSize;
- ctx->Driver.GetString = i810DDGetString;
- ctx->Driver.GetParameteri = i810GetParameteri;
- ctx->Driver.RegisterVB = i810DDRegisterVB;
- ctx->Driver.UnregisterVB = i810DDUnregisterVB;
- ctx->Driver.Clear = i810Clear;
-
-
- ctx->Driver.BuildPrecalcPipeline = i810DDBuildPrecalcPipeline;
-}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c b/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
deleted file mode 100644
index 459c9e6f0..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810fastpath.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/i810/i810fastpath.c,v 1.6 2001/08/27 21:12:19 dawes Exp $ */
-
-#include <stdio.h>
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-
-/* #include "mmath.h" */
-
-#include "i810context.h"
-#include "i810pipeline.h"
-#include "i810tris.h"
-#include "i810state.h"
-#include "i810vb.h"
-#include "vbcull.h"
-
-
-struct i810_fast_tab {
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
- void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
-};
-
-
-
-
-#define POINT(x) i810_draw_point(imesa, &ivert[x], psize)
-#define LINE(x,y) i810_draw_line(imesa, &ivert[x], &ivert[y] )
-#define TRI(x,y,z) i810_draw_triangle(imesa, &ivert[x], &ivert[y], &ivert[z])
-
-
-
-
-/* Direct, and no clipping required. I haven't written the clip funcs
- * yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for(e=start;e<count;e++) \
- POINT(elt[e]); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
-do { \
-{ GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \
- TRI(e2, e1, e); \
-}} while (0)
-
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI(e3, e2, e); \
- TRI(e2, e1, e); \
-} while (0)
-
-#define LOCAL_VARS \
- i810VertexPtr ivert = I810_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- i810ContextPtr imesa = I810_CONTEXT(ctx); \
- const GLfloat psize = ctx->Point.Size; \
- (void)psize; (void) ivert;
-
-
-#define TAG(x) x##_i810_smooth_indirect
-#include "render_tmp.h"
-
-
-
-static void i810_render_elements_direct( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = render_tab_i810_smooth_indirect[prim];
- GLuint p = 0;
-
- if (imesa->new_state)
- i810DDUpdateHwState( ctx );
-
- do {
- func( VB, 0, nr, 0 );
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
-}
-
-
-
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-#define INTERP_RGBA(t, out, a, b) { \
- int i; \
- for (i = 0; i < 4; i++) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
- GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
- } \
-}
-
-
-#define CLIP(SGN,V,PLANE) \
-if (mask & PLANE) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- inlist[0] = vlist1; \
- for (i = n = 0 ; i < nr ; i++) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t, *in, *out; \
- \
- if (NEGATIVE(dpI)) { \
- t = dpI / (dpI - dpJ); \
- in = I; \
- out = J; \
- } \
- else \
- { \
- t = dpJ / (dpJ - dpI); \
- in = J; \
- out = I; \
- } \
- \
- interp(t, O, in, out); \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if (!NEGATIVE(dpI)) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return; \
-}
-
-#define LINE_CLIP(x,y,z,w,PLANE) \
-if (mask & PLANE) { \
- GLfloat dpI = DOT4V(I,x,y,z,w); \
- GLfloat dpJ = DOT4V(J,x,y,z,w); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- \
- interp(t, O, I, J); \
- \
- clipmask[next_vert] = 0; \
- \
- if (NEGATIVE(dpI)) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; elts[1] = next_vert++; \
- } \
- } \
- else if (NEGATIVE(dpI)) \
- return; \
-}
-
-
-static __inline void i810_tri_clip( GLuint **p_elts,
- i810Vertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- i810_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint in = 0;
- GLuint n = 3;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP(-,0,CLIP_RIGHT_BIT);
- CLIP(+,0,CLIP_LEFT_BIT);
- CLIP(-,1,CLIP_TOP_BIT);
- CLIP(+,1,CLIP_BOTTOM_BIT);
- CLIP(-,2,CLIP_FAR_BIT);
- CLIP(+,2,CLIP_NEAR_BIT);
-
- /* Convert the planar polygon to a list of triangles.
- */
- out = inlist[in];
-
- for (i = 2 ; i < n ; i++) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static __inline void i810_line_clip( GLuint **p_elts,
- i810Vertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- i810_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT);
- LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT);
- LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT);
- LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT);
- LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT);
- LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT);
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-
-#define CLIP_POINT( e ) \
- if (mask[e]) \
- *out++ = e
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out+=2; \
- if (ormask) { \
- out-=2; \
- if (!(mask[e0] & mask[e1])) { \
- i810_line_clip( &out, verts, mask, &next_vert, ormask, interp); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if (ormask) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0])) { \
- i810_tri_clip( &out, verts, mask, &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-
-
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-#define LOCAL_VARS \
- i810ContextPtr imesa = I810_CONTEXT( VB->ctx ); \
- GLuint *elt = VB->EltPtr->data; \
- i810Vertex *verts = I810_DRIVER_DATA(VB)->verts; \
- GLuint next_vert = I810_DRIVER_DATA(VB)->last_vert; \
- GLuint *out = I810_DRIVER_DATA(VB)->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
- i810_interp_func interp = imesa->interp; \
- (void) interp; (void) verts;
-
-#define POSTFIX \
- I810_DRIVER_DATA(VB)->clipped_elements.count = \
- out - I810_DRIVER_DATA(VB)->clipped_elements.data; \
- I810_DRIVER_DATA(VB)->last_vert = next_vert;
-
-
-#define INIT(x)
-
-#define RENDER_POINTS(start, count) \
-do { \
- GLuint i; \
- for (i = start ; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE(i1, i0) \
- CLIP_LINE(elt[i1], elt[i0])
-
-#define RENDER_TRI(i2, i1, i0, pv, parity) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if (parity) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i0, pv ) \
- CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \
- CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
-
-#define TAG(x) i810_clip_##x##_elt
-#include "render_tmp.h"
-
-
-
-static void i810_project_vertices( struct vertex_buffer *VB )
-{
- i810VertexBufferPtr i810VB = I810_DRIVER_DATA(VB);
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat m[16];
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] - .5;
- m[MAT_SY] = (- mat->m[MAT_SY]);
- m[MAT_TY] = (- mat->m[MAT_TY]) + I810_CONTEXT(ctx)->driDrawable->h - .5;
- m[MAT_SZ] = mat->m[MAT_SZ] * (1.0 / 0x10000);
- m[MAT_TZ] = mat->m[MAT_TZ] * (1.0 / 0x10000);
-
- gl_project_v16( i810VB->verts[VB->CopyStart].f,
- i810VB->verts[i810VB->last_vert].f,
- m,
- 16 * 4 );
-}
-
-static void i810_project_clipped_vertices( struct vertex_buffer *VB )
-{
- i810VertexBufferPtr i810VB = I810_DRIVER_DATA(VB);
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat m[16];
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] - .5;
- m[MAT_SY] = (- mat->m[MAT_SY]);
- m[MAT_TY] = (- mat->m[MAT_TY]) + I810_CONTEXT(ctx)->driDrawable->h - .5;
- m[MAT_SZ] = mat->m[MAT_SZ] * (1.0 / 0x10000);
- m[MAT_TZ] = mat->m[MAT_TZ] * (1.0 / 0x10000);
-
- gl_project_clipped_v16( i810VB->verts[VB->CopyStart].f,
- i810VB->verts[i810VB->last_vert].f,
- m,
- 16 * 4,
- VB->ClipMask + VB->CopyStart );
-}
-
-
-/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_UBYTE_COLOR 4
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define TYPE (0)
-#define TAG(x) x
-#include "i810fasttmp.h"
-
-#define TYPE (I810_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "i810fasttmp.h"
-
-#define TYPE (I810_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "i810fasttmp.h"
-
-#define TYPE (I810_RGBA_BIT|I810_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "i810fasttmp.h"
-
-#define TYPE (I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "i810fasttmp.h"
-
-/* This one *could* get away with sneaking TEX1 into the color and
- * specular slots, thus fitting inside a cache line. Would be even
- * better to switch to a smaller vertex.
- */
-#define TYPE (I810_TEX0_BIT|I810_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "i810fasttmp.h"
-
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct i810_fast_tab i810FastTab[0x80];
-
-void i810DDFastPathInit( void )
-{
- i810_clip_render_init_elt();
- render_init_i810_smooth_indirect();
-
- i810_init_fastpath( &i810FastTab[0] );
- i810_init_fastpath_RGBA( &i810FastTab[I810_RGBA_BIT] );
- i810_init_fastpath_TEX0( &i810FastTab[I810_TEX0_BIT] );
- i810_init_fastpath_RGBA_TEX0( &i810FastTab[I810_RGBA_BIT|I810_TEX0_BIT] );
- i810_init_fastpath_TEX0_TEX1( &i810FastTab[I810_TEX0_BIT|I810_TEX1_BIT] );
- i810_init_fastpath_RGBA_TEX0_TEX1( &i810FastTab[I810_RGBA_BIT|I810_TEX0_BIT|
- I810_TEX1_BIT] );
-}
-
-#define VALID_SETUP (I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
-
-
-void i810DDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- struct i810_fast_tab *tab = &i810FastTab[imesa->setupindex & VALID_SETUP];
- GLuint do_cliptest = 1;
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- /* Reserve enough space for the pathological case.
- */
- if (VB->EltPtr->count * 12 > I810_DRIVER_DATA(VB)->size) {
- i810DDResizeVB( VB, VB->EltPtr->count * 12 );
- do_cliptest = 1;
- }
-
- tab->build_vertices( VB, do_cliptest ); /* object->clip space */
-
- if (imesa->new_state)
- i810DDUpdateHwState( ctx );
-
- if (VB->ClipOrMask) {
- if (!VB->ClipAndMask) {
- render_func *clip = i810_clip_render_tab_elt;
-
- imesa->interp = tab->interp;
-
- clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(I810_DRIVER_DATA(VB)->clipped_elements);
-
- i810_project_clipped_vertices( VB ); /* clip->device space */
- i810_render_elements_direct( VB ); /* render using new list */
- }
- } else {
- i810_project_vertices( VB ); /* clip->device space */
- i810_render_elements_direct( VB ); /* render using orig list */
- }
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810fasttmp.h b/xc/lib/GL/mesa/src/drv/i810/i810fasttmp.h
deleted file mode 100644
index 115fe7b24..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810fasttmp.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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 first part of setup is applied to all vertices, clipped or
- * unclipped. This data w!ill be used for clipping, and then all
- * vertices with a zero clipmask will be projected to device space.
- *
- * This could be split into several loops, but - it seems that the
- * large stride of the fxVertices makes cache issues the big
- * performance factor, and that multiple loops mean multiple cache
- * misses....
- */
-static void TAG(i810_setup_full)( struct vertex_buffer *VB, GLuint do_cliptest )
-{
- GLcontext *ctx = VB->ctx;
- const GLfloat * const m = ctx->ModelProjectMatrix.m;
- GLuint start = VB->CopyStart;
- GLuint count = VB->Count;
- GLuint i;
-
- gl_xform_points3_v16_general(I810_DRIVER_DATA(VB)->verts[start].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count - start);
-
- if (do_cliptest)
- {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16(I810_DRIVER_DATA(VB)->verts[start].f,
- I810_DRIVER_DATA(VB)->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask + start);
- }
-
- /* These branches are all resolved at compile time. Hopefully all
- * the pointers are valid addresses even when not enabled.
- */
- if (TYPE) {
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
-
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
-
- GLfloat *f = I810_DRIVER_DATA(VB)->verts[start].f;
-
- for (i = start ; i < count ; i++, f += 16) {
- if (TYPE & I810_RGBA_BIT) {
- GLubyte *b = (GLubyte *)&f[CLIP_UBYTE_COLOR];
- GLubyte *col = color; color += color_stride;
- b[CLIP_UBYTE_R] = col[0];
- b[CLIP_UBYTE_G] = col[1];
- b[CLIP_UBYTE_B] = col[2];
- b[CLIP_UBYTE_A] = col[3];
- }
- if (TYPE & I810_TEX0_BIT) {
- f[CLIP_S0] = tex0_data[0];
- f[CLIP_T0] = tex0_data[1];
- STRIDE_F(tex0_data, tex0_stride);
- }
- if (TYPE & I810_TEX1_BIT) {
- f[CLIP_S1] = tex1_data[0];
- f[CLIP_T1] = tex1_data[1];
- STRIDE_F(tex1_data, tex1_stride);
- }
- }
- }
-
- I810_DRIVER_DATA(VB)->clipped_elements.count = start;
- I810_DRIVER_DATA(VB)->last_vert = count;
-}
-
-
-/* Changed to just put the interp func instead of the whole clip
- * routine into the header. Less code and better chance of doing some
- * of this stuff in assembly.
- */
-static void TAG(i810_interp_vert)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP(t, I[0], J[0]);
- O[1] = LINTERP(t, I[1], J[1]);
- O[2] = LINTERP(t, I[2], J[2]);
- O[3] = LINTERP(t, I[3], J[3]);
-
- if (TYPE & I810_RGBA_BIT) {
- INTERP_RGBA(t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])));
- }
-
- if (TYPE & I810_TEX0_BIT) {
- O[6] = LINTERP(t, I[6], J[6]);
- O[7] = LINTERP(t, I[7], J[7]);
- }
-
- if (TYPE & I810_TEX1_BIT) {
- O[8] = LINTERP(t, I[8], J[8]);
- O[9] = LINTERP(t, I[9], J[9]);
- }
-}
-
-
-static void TAG(i810_init_fastpath)( struct i810_fast_tab *tab )
-{
- tab->interp = TAG(i810_interp_vert);
- tab->build_vertices = TAG(i810_setup_full);
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
index eb2d9a4df..89dd769bd 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.c
@@ -3,52 +3,44 @@
#include <stdio.h>
#include <unistd.h>
-#include "types.h"
-#include "pb.h"
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
#include "dd.h"
+#include "swrast/swrast.h"
#include "mm.h"
#include "i810context.h"
-#include "i810log.h"
#include "i810ioctl.h"
+#include "i810state.h"
#include "drm.h"
#include <sys/ioctl.h>
-drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
+static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
{
drm_i810_dma_t dma;
drmBufPtr buf;
- int retcode;
+ int retcode, i = 0;
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "Getting dma buffer\n");
-
while (1) {
retcode = ioctl(imesa->driFd, DRM_IOCTL_I810_GETBUF, &dma);
if (dma.granted == 1 && retcode == 0)
break;
-
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "Retcode : %d, granted : %d\n", retcode, dma.granted);
-
- ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+
+ if (++i > 1000) {
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+ i = 0;
+ }
}
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr,
- "imesa->i810Screen->bufs->list : %p, "
- "dma.request_idx : %d\n",
- imesa->i810Screen->bufs->list, dma.request_idx);
-
buf = &(imesa->i810Screen->bufs->list[dma.request_idx]);
buf->idx = dma.request_idx;
- buf->used = 4; /* leave room for instruction header */
+ buf->used = 0;
buf->total = dma.request_size;
+ buf->address = (drmAddress)dma.virtual;
- if(imesa->i810Screen->use_copy_buf != 1)
- buf->address = (drmAddress)dma.virtual;
return buf;
}
@@ -56,8 +48,8 @@ drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
#define DEPTH_SCALE ((1<<16)-1)
-GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch )
+static void i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
@@ -69,7 +61,7 @@ GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
clear.clear_color = imesa->ClearColor;
clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE);
- FLUSH_BATCH( imesa );
+ I810_FIREVERTICES( imesa );
if ((mask & DD_FRONT_LEFT_BIT) && colorMask == ~0) {
clear.flags |= I810_FRONT;
@@ -81,68 +73,65 @@ GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
mask &= ~DD_BACK_LEFT_BIT;
}
- if ((mask & DD_DEPTH_BIT) && ctx->Depth.Mask) {
- clear.flags |= I810_DEPTH;
+ if (mask & DD_DEPTH_BIT) {
+ if (ctx->Depth.Mask)
+ clear.flags |= I810_DEPTH;
mask &= ~DD_DEPTH_BIT;
}
- if (!clear.flags)
- return mask;
+ if (clear.flags) {
+ LOCK_HARDWARE( imesa );
- LOCK_HARDWARE( imesa );
+ /* flip top to bottom */
+ cy = dPriv->h-cy-ch;
+ cx += imesa->drawX;
+ cy += imesa->drawY;
- /* flip top to bottom */
- cy = dPriv->h-cy-ch;
- cx += imesa->drawX;
- cy += imesa->drawY;
-
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "Clear, bufs %x nbox %d\n",
- (int)clear.flags, (int)imesa->numClipRects);
-
- for (i = 0 ; i < imesa->numClipRects ; )
- {
- int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects);
- XF86DRIClipRectRec *box = imesa->pClipRects;
- drm_clip_rect_t *b = imesa->sarea->boxes;
- int n = 0;
-
- if (!all) {
- for ( ; i < nr ; i++) {
- GLint x = box[i].x1;
- GLint y = box[i].y1;
- GLint w = box[i].x2 - x;
- GLint h = box[i].y2 - y;
-
- if (x < cx) w -= cx - x, x = cx;
- if (y < cy) h -= cy - y, y = cy;
- if (x + w > cx + cw) w = cx + cw - x;
- if (y + h > cy + ch) h = cy + ch - y;
- if (w <= 0) continue;
- if (h <= 0) continue;
-
- b->x1 = x;
- b->y1 = y;
- b->x2 = x + w;
- b->y2 = y + h;
- b++;
- n++;
- }
- } else {
- for ( ; i < nr ; i++) {
- *b++ = *(drm_clip_rect_t *)&box[i];
- n++;
+ for (i = 0 ; i < imesa->numClipRects ; )
+ {
+ int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects);
+ XF86DRIClipRectRec *box = imesa->pClipRects;
+ drm_clip_rect_t *b = imesa->sarea->boxes;
+ int n = 0;
+
+ if (!all) {
+ for ( ; i < nr ; i++) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ if (x < cx) w -= cx - x, x = cx;
+ if (y < cy) h -= cy - y, y = cy;
+ if (x + w > cx + cw) w = cx + cw - x;
+ if (y + h > cy + ch) h = cy + ch - y;
+ if (w <= 0) continue;
+ if (h <= 0) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++) {
+ *b++ = *(drm_clip_rect_t *)&box[i];
+ n++;
+ }
}
+
+ imesa->sarea->nbox = n;
+ ioctl(imesa->driFd, DRM_IOCTL_I810_CLEAR, &clear);
}
- imesa->sarea->nbox = n;
- ioctl(imesa->driFd, DRM_IOCTL_I810_CLEAR, &clear);
+ UNLOCK_HARDWARE( imesa );
+ imesa->upload_cliprects = GL_TRUE;
}
- UNLOCK_HARDWARE( imesa );
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
-
- return mask;
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
}
@@ -151,15 +140,19 @@ GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
/*
* Copy the back buffer to the front buffer.
*/
-void i810SwapBuffers( i810ContextPtr imesa )
+void i810CopyBuffer( const __DRIdrawablePrivate *dPriv )
{
- __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i810ContextPtr imesa;
XF86DRIClipRectPtr pbox;
- int nbox;
- int i;
- int tmp;
+ int nbox, i, tmp;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate;
- FLUSH_BATCH( imesa );
+ I810_FIREVERTICES( imesa );
LOCK_HARDWARE( imesa );
pbox = dPriv->pClipRects;
@@ -181,120 +174,89 @@ void i810SwapBuffers( i810ContextPtr imesa )
tmp = GET_ENQUEUE_AGE(imesa);
UNLOCK_HARDWARE( imesa );
- if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap)
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
i810WaitAge(imesa, imesa->lastSwap);
+ }
imesa->lastSwap = tmp;
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
+ imesa->upload_cliprects = GL_TRUE;
}
-
-
+/*
+ * XXX implement when full-screen extension is done.
+ */
+void i810PageFlip( const __DRIdrawablePrivate *dPriv )
+{
+ (void) dPriv;
+/* _mesa_problem(NULL, "i810PageFlip should not be called!\n"); */
+ return;
+}
/* This waits for *everybody* to finish rendering -- overkill.
*/
void i810DmaFinish( i810ContextPtr imesa )
{
- FLUSH_BATCH( imesa );
-
- if (imesa->sarea->last_quiescent != imesa->sarea->last_enqueue) {
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "i810DmaFinish\n");
+ I810_FIREVERTICES( imesa );
- LOCK_HARDWARE( imesa );
- i810RegetLockQuiescent( imesa );
- UNLOCK_HARDWARE( imesa );
- imesa->sarea->last_quiescent = imesa->sarea->last_enqueue;
- }
+ LOCK_HARDWARE( imesa );
+ i810RegetLockQuiescent( imesa );
+ UNLOCK_HARDWARE( imesa );
}
void i810RegetLockQuiescent( i810ContextPtr imesa )
{
- /* XXX I disabled this conditional. Doing so fixes all the readpixels
- * problems. The problem was that we'd sometimes read from the frame
- * buffer (via the span functions) before rendering was completed.
- * Taking out this conditional solves that problem. (BrianP)
- *
- if (imesa->sarea->last_quiescent != imesa->sarea->last_enqueue) {
- */
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "i810RegetLockQuiescent\n");
-
- drmUnlock(imesa->driFd, imesa->hHWContext);
- i810GetLock( imesa, DRM_LOCK_QUIESCENT );
- imesa->sarea->last_quiescent = imesa->sarea->last_enqueue;
- /*
- }
- */
+ drmUnlock(imesa->driFd, imesa->hHWContext);
+ i810GetLock( imesa, DRM_LOCK_QUIESCENT );
}
void i810WaitAgeLocked( i810ContextPtr imesa, int age )
{
- int i = 0;
-
+ int i = 0, j;
- while (++i < 500000 && GET_DISPATCH_AGE(imesa) < age) {
+ while (++i < 5000) {
ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+ for (j = 0 ; j < 1000 ; j++)
+ ;
}
- if (GET_DISPATCH_AGE(imesa) < age) {
- if (0)
- fprintf(stderr, "wait locked %d %d\n", age, GET_DISPATCH_AGE(imesa));
- ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
- }
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
}
void i810WaitAge( i810ContextPtr imesa, int age )
{
- int i = 0;
+ int i = 0, j;
- while (++i < 500000 && GET_DISPATCH_AGE(imesa) < age) {
+ while (++i < 5000) {
ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+ for (j = 0 ; j < 1000 ; j++)
+ ;
}
- if (GET_DISPATCH_AGE(imesa) >= age)
- return;
-
i = 0;
- while (++i < 1000 && GET_DISPATCH_AGE(imesa) < age) {
+ while (++i < 1000) {
ioctl(imesa->driFd, DRM_IOCTL_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
usleep(1000);
}
-
- /* To be effective at letting other clients at the hardware,
- * particularly the X server which regularly needs quiescence to
- * touch the framebuffer, we really need to sleep *beyond* the
- * point where our last buffer clears the hardware.
- */
- if (imesa->any_contend) {
- usleep(3000);
- }
-
- imesa->any_contend = 0;
- if (GET_DISPATCH_AGE(imesa) < age) {
- LOCK_HARDWARE(imesa);
- if (GET_DISPATCH_AGE(imesa) < age)
- ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
- UNLOCK_HARDWARE(imesa);
- }
+ LOCK_HARDWARE(imesa);
+ ioctl(imesa->driFd, DRM_IOCTL_I810_FLUSH);
+ UNLOCK_HARDWARE(imesa);
}
-void i810FlushVertices( i810ContextPtr imesa )
-{
- if (!imesa->vertex_dma_buffer) return;
-
- LOCK_HARDWARE( imesa );
- i810FlushVerticesLocked( imesa );
- UNLOCK_HARDWARE( imesa );
-}
-
static int intersect_rect( drm_clip_rect_t *out,
drm_clip_rect_t *a,
@@ -302,91 +264,110 @@ static int intersect_rect( drm_clip_rect_t *out,
{
*out = *a;
if (b->x1 > out->x1) out->x1 = b->x1;
- if (b->y1 > out->y1) out->y1 = b->y1;
if (b->x2 < out->x2) out->x2 = b->x2;
- if (b->y2 < out->y2) out->y2 = b->y2;
if (out->x1 >= out->x2) return 0;
+
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->y2 < out->y2) out->y2 = b->y2;
if (out->y1 >= out->y2) return 0;
return 1;
}
+static void emit_state( i810ContextPtr imesa )
+{
+ GLuint dirty = imesa->dirty;
+ drm_i810_sarea_t *sarea = imesa->sarea;
+
+ if (dirty & I810_UPLOAD_BUFFERS) {
+ memcpy( sarea->BufferState, imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+ }
+
+ if (dirty & I810_UPLOAD_CTX) {
+ memcpy( sarea->ContextState, imesa->Setup,
+ sizeof(imesa->Setup) );
+ }
+
+ if (dirty & I810_UPLOAD_TEX0) {
+ memcpy(sarea->TexState[0],
+ imesa->CurrentTexObj[0]->Setup,
+ sizeof(imesa->CurrentTexObj[0]->Setup));
+ }
+
+ if (dirty & I810_UPLOAD_TEX1) {
+ GLuint *setup = sarea->TexState[1];
+
+ memcpy( setup,
+ imesa->CurrentTexObj[1]->Setup,
+ sizeof(imesa->CurrentTexObj[1]->Setup));
+
+ /* Need this for the case where both units are bound to the same
+ * texobj.
+ */
+ setup[I810_TEXREG_MI1] ^= (MI1_MAP_0 ^ MI1_MAP_1);
+ setup[I810_TEXREG_MLC] ^= (MLC_MAP_0 ^ MLC_MAP_1);
+ setup[I810_TEXREG_MLL] ^= (MLL_MAP_0 ^ MLL_MAP_1);
+ setup[I810_TEXREG_MCS] ^= (MCS_COORD_0 ^ MCS_COORD_1);
+ setup[I810_TEXREG_MF] ^= (MF_MAP_0 ^ MF_MAP_1);
+ }
+
+ sarea->dirty = dirty;
+ imesa->dirty = 0;
+}
+
+
static void age_imesa( i810ContextPtr imesa, int age )
{
if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->age = age;
if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->age = age;
}
-void i810FlushVerticesLocked( i810ContextPtr imesa )
+
+void i810FlushPrimsLocked( i810ContextPtr imesa )
{
drm_clip_rect_t *pbox = (drm_clip_rect_t *)imesa->pClipRects;
int nbox = imesa->numClipRects;
- drmBufPtr buffer = imesa->vertex_dma_buffer;
+ drmBufPtr buffer = imesa->vertex_buffer;
+ drm_i810_sarea_t *sarea = imesa->sarea;
drm_i810_vertex_t vertex;
int i;
-
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "i810FlushVerticesLocked, buf->used %d\n",
- buffer->used);
-
- if (!buffer)
- return;
-
- if (imesa->dirty & ~I810_UPLOAD_CLIPRECTS)
- i810EmitHwStateLocked( imesa );
-
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "i810FlushVerticesLocked, used %d\n",
- buffer->used);
-
- imesa->vertex_dma_buffer = 0;
+
+ if (imesa->dirty)
+ emit_state( imesa );
vertex.idx = buffer->idx;
- vertex.used = buffer->used;
+ vertex.used = imesa->vertex_low;
vertex.discard = 0;
+ sarea->vertex_prim = imesa->hw_primitive;
- if (!nbox)
+ if (!nbox) {
vertex.used = 0;
-
- if (nbox > I810_NR_SAREA_CLIPRECTS)
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
-
- if(imesa->i810Screen->use_copy_buf == 1 && vertex.used) {
- drm_i810_copy_t copy;
-
- copy.idx = buffer->idx;
- copy.used = buffer->used;
- copy.address = buffer->address;
- ioctl(imesa->driFd, DRM_IOCTL_I810_COPY, &copy);
+ }
+ else if (nbox > I810_NR_SAREA_CLIPRECTS) {
+ imesa->upload_cliprects = GL_TRUE;
}
-
- imesa->sarea->vertex_prim = imesa->vertex_prim;
-
- if (!nbox || !(imesa->dirty & I810_UPLOAD_CLIPRECTS))
+ if (!nbox || !imesa->upload_cliprects)
{
if (nbox == 1)
- imesa->sarea->nbox = 0;
+ sarea->nbox = 0;
else
- imesa->sarea->nbox = nbox;
-
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "DRM_IOCTL_I810_VERTEX CASE1 nbox %d used %d\n",
- nbox, vertex.used);
+ sarea->nbox = nbox;
- vertex.discard = 1;
+ vertex.discard = 1;
ioctl(imesa->driFd, DRM_IOCTL_I810_VERTEX, &vertex);
- age_imesa(imesa, imesa->sarea->last_enqueue);
+ age_imesa(imesa, sarea->last_enqueue);
}
else
{
for (i = 0 ; i < nbox ; )
{
int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, nbox);
- drm_clip_rect_t *b = imesa->sarea->boxes;
+ drm_clip_rect_t *b = sarea->boxes;
if (imesa->scissor) {
- imesa->sarea->nbox = 0;
+ sarea->nbox = 0;
for ( ; i < nr ; i++) {
b->x1 = pbox[i].x1 - imesa->drawX;
@@ -395,19 +376,19 @@ void i810FlushVerticesLocked( i810ContextPtr imesa )
b->y2 = pbox[i].y2 - imesa->drawY;
if (intersect_rect(b, b, &imesa->scissor_rect)) {
- imesa->sarea->nbox++;
+ sarea->nbox++;
b++;
}
}
/* Culled?
*/
- if (!imesa->sarea->nbox) {
+ if (!sarea->nbox) {
if (nr < nbox) continue;
vertex.used = 0;
}
} else {
- imesa->sarea->nbox = nr - i;
+ sarea->nbox = nr - i;
for ( ; i < nr ; i++, b++) {
b->x1 = pbox[i].x1 - imesa->drawX;
b->y1 = pbox[i].y1 - imesa->drawY;
@@ -421,66 +402,69 @@ void i810FlushVerticesLocked( i810ContextPtr imesa )
if (nr == nbox)
vertex.discard = 1;
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "DRM_IOCTL_I810_VERTEX nbox %d used %d\n",
- nbox, vertex.used);
-
ioctl(imesa->driFd, DRM_IOCTL_I810_VERTEX, &vertex);
age_imesa(imesa, imesa->sarea->last_enqueue);
}
}
+ /* Reset imesa vars:
+ */
+ imesa->vertex_buffer = 0;
+ imesa->vertex_addr = 0;
+ imesa->vertex_low = 0;
+ imesa->vertex_high = 0;
+ imesa->vertex_last_prim = 0;
imesa->dirty = 0;
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL)
- fprintf(stderr, "finished i810FlushVerticesLocked\n");
+ imesa->upload_cliprects = GL_FALSE;
}
-
-GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords )
+void i810FlushPrimsGetBuffer( i810ContextPtr imesa )
{
- GLuint *start;
+ LOCK_HARDWARE(imesa);
- if (!imesa->vertex_dma_buffer)
- {
- LOCK_HARDWARE(imesa);
- imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
- UNLOCK_HARDWARE(imesa);
- }
- else if (imesa->vertex_dma_buffer->used + dwords * 4 >
- imesa->vertex_dma_buffer->total)
- {
- LOCK_HARDWARE(imesa);
- i810FlushVerticesLocked( imesa );
- imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
- UNLOCK_HARDWARE(imesa);
- }
+ if (imesa->vertex_buffer)
+ i810FlushPrimsLocked( imesa );
+
+ imesa->vertex_buffer = i810_get_buffer_ioctl( imesa );
+ imesa->vertex_high = imesa->vertex_buffer->total;
+ imesa->vertex_addr = (char *)imesa->vertex_buffer->address;
+ imesa->vertex_low = 4; /* leave room for instruction header */
+ imesa->vertex_last_prim = imesa->vertex_low;
+ UNLOCK_HARDWARE(imesa);
+}
- start = (GLuint *)((char *)imesa->vertex_dma_buffer->address +
- imesa->vertex_dma_buffer->used);
- imesa->vertex_dma_buffer->used += dwords * 4;
- return start;
+void i810FlushPrims( i810ContextPtr imesa )
+{
+ if (imesa->vertex_buffer) {
+ LOCK_HARDWARE( imesa );
+ i810FlushPrimsLocked( imesa );
+ UNLOCK_HARDWARE( imesa );
+ }
}
+
+
int i810_check_copy(int fd)
{
return(ioctl(fd, DRM_IOCTL_I810_DOCOPY));
}
-static void i810DDFlush( GLcontext *ctx )
+static void i810Flush( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- FLUSH_BATCH( imesa );
+ I810_FIREVERTICES( imesa );
}
-static void i810DDFinish( GLcontext *ctx )
+static void i810Finish( GLcontext *ctx )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
i810DmaFinish( imesa );
}
-void i810DDInitIoctlFuncs( GLcontext *ctx )
+void i810InitIoctlFuncs( GLcontext *ctx )
{
- ctx->Driver.Flush = i810DDFlush;
- ctx->Driver.Finish = i810DDFinish;
+ ctx->Driver.Flush = i810Flush;
+ ctx->Driver.Clear = i810Clear;
+ ctx->Driver.Finish = i810Finish;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
index 6f74526ae..add49d93c 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810ioctl.h
@@ -6,64 +6,45 @@
#include "i810context.h"
-GLuint *i810AllocDwords( i810ContextPtr imesa, int dwords );
+void i810EmitPrim( i810ContextPtr imesa );
+void i810FlushPrims( i810ContextPtr mmesa );
+void i810FlushPrimsLocked( i810ContextPtr mmesa );
+void i810FlushPrimsGetBuffer( i810ContextPtr imesa );
-void i810GetGeneralDmaBufferLocked( i810ContextPtr mmesa );
-
-void i810FlushVertices( i810ContextPtr mmesa );
-void i810FlushVerticesLocked( i810ContextPtr mmesa );
-
-void i810FlushGeneralLocked( i810ContextPtr imesa );
void i810WaitAgeLocked( i810ContextPtr imesa, int age );
void i810WaitAge( i810ContextPtr imesa, int age );
-
void i810DmaFinish( i810ContextPtr imesa );
-
void i810RegetLockQuiescent( i810ContextPtr imesa );
-
-void i810DDInitIoctlFuncs( GLcontext *ctx );
-
-void i810SwapBuffers( i810ContextPtr imesa );
-
+void i810InitIoctlFuncs( GLcontext *ctx );
+void i810CopyBuffer( const __DRIdrawablePrivate *dpriv );
+void i810PageFlip( const __DRIdrawablePrivate *dpriv );
int i810_check_copy(int fd);
-GLbitfield i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch );
+#define I810_STATECHANGE(imesa, flag) \
+do { \
+ if (imesa->vertex_low != imesa->vertex_last_prim) \
+ i810FlushPrims(imesa); \
+ imesa->dirty |= flag; \
+} while (0) \
-#define FLUSH_BATCH(imesa) do { \
- if (I810_DEBUG&DEBUG_VERBOSE_IOCTL) \
- fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
- if (imesa->vertex_dma_buffer) i810FlushVertices(imesa); \
-} while (0)
-extern drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa );
+#define I810_FIREVERTICES(imesa) \
+do { \
+ if (imesa->vertex_buffer) { \
+ i810FlushPrims(imesa); \
+ } \
+} while (0)
-static __inline
-GLuint *i810AllocDwordsInline( i810ContextPtr imesa, int dwords )
+static __inline GLuint *i810AllocDmaLow( i810ContextPtr imesa, int bytes )
{
- int bytes = dwords * 4;
- GLuint *start;
+ if (imesa->vertex_low + bytes > imesa->vertex_high)
+ i810FlushPrimsGetBuffer( imesa );
- if (!imesa->vertex_dma_buffer)
{
- LOCK_HARDWARE(imesa);
- imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
- UNLOCK_HARDWARE(imesa);
- }
- else if (imesa->vertex_dma_buffer->used + bytes >
- imesa->vertex_dma_buffer->total)
- {
- LOCK_HARDWARE(imesa);
- i810FlushVerticesLocked( imesa );
- imesa->vertex_dma_buffer = i810_get_buffer_ioctl( imesa );
- UNLOCK_HARDWARE(imesa);
+ GLuint *start = (GLuint *)(imesa->vertex_addr + imesa->vertex_low);
+ imesa->vertex_low += bytes;
+ return start;
}
-
- start = (GLuint *)((char *)imesa->vertex_dma_buffer->address +
- imesa->vertex_dma_buffer->used);
-
- imesa->vertex_dma_buffer->used += bytes;
- return start;
}
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810log.h b/xc/lib/GL/mesa/src/drv/i810/i810log.h
deleted file mode 100644
index 707cd618f..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810log.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * GLX Hardware Device Driver for Matrox Millenium G200
- * Copyright (C) 1999 Wittawat Yamwong
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
- * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Wittawat Yamwong <Wittawat.Yamwong@stud.uni-hannover.de>
- */
-
-/* Usage:
- * - use i810Error for error messages. Always write to X error and log file.
- * - use i810Msg for debugging. Can be disabled by undefining I810_LOG_ENABLED.
- */
-
-#ifndef I810LOG_INC
-#define I810LOG_INC
-#include "hwlog.h"
-
-/* Mapping between old function names and new common code: */
-/* (Feel free to replace all i810Msg with hwMsg etc. in all *.c
- * files, I was to lazy to do this...) */
-#define i810OpenLog(f) hwOpenLog(f,"[i810] ")
-#define i810CloseLog hwCloseLog
-#define i810IsLogReady hwIsLogReady
-#define i810SetLogLevel hwSetLogLevel
-#define i810GetLogLevel hwGetLogLevel
-#define i810Msg hwMsg
-#define i810Error hwError
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c
deleted file mode 100644
index 34171d943..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/* #include "i810pipeline.h" */
-
-#include <stdio.h>
-
-#include "types.h"
-#include "fog.h"
-
-#include "i810vb.h"
-#include "i810dd.h"
-#include "i810tris.h"
-#include "i810pipeline.h"
-
-
-static struct gl_pipeline_stage i810_fast_stage = {
- "I810 fast path",
- (PIPE_OP_VERT_XFORM|PIPE_OP_RAST_SETUP_0|
- PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER),
- PIPE_PRECALC,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- i810DDFastPath
-};
-
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D| \
- TEXTURE1_3D| \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-
-/* The driver gets first shot at building the pipeline - make some
- * quick tests to see if we can use the fast path.
- */
-GLboolean i810DDBuildPrecalcPipeline( GLcontext *ctx )
-{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- struct gl_pipeline *pipe = &ctx->CVA.pre;
-
- if (imesa->renderindex == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Flags & (VERT_OBJ_234|
- VERT_TEX0_4|
- VERT_TEX1_4|
- VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
- {
- pipe->stages[0] = &i810_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
- imesa->using_fast_path = 1;
- return 1;
- }
-
- if (imesa->using_fast_path)
- {
- imesa->using_fast_path = 0;
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
- ctx->Array.NewArrayState |= ctx->Array.Summary;
- return 0;
- }
-
- return 0;
-}
-
-
-
-GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- GLuint i, o;
-
- for (i = o = 0 ; i < nr ; i++) {
- switch (in[i].ops) {
-
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
- out[o].state_change = ~0;
- out[o].check = i810DDCheckPartialRasterSetup;
- out[o].run = i810DDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].run = i810DDDoRasterSetup;
- o++;
- break;
-
- /* Completely replace Mesa's fog processing to generate fog
- * coordinates instead of messing with colors.
- */
- case PIPE_OP_FOG:
- out[o] = gl_fog_coord_stage;
- o++;
- break;
-
-
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
-
-
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h b/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h
deleted file mode 100644
index 87b95455d..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810pipeline.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef _I810_PIPELINE_H
-#define _I810_PIPELINE_H
-
-extern GLuint i810DDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
-
-extern GLboolean i810DDBuildPrecalcPipeline( GLcontext *ctx );
-
-extern void i810DDFastPath( struct vertex_buffer *VB );
-extern void i810DDFastPathInit( void );
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810render.c b/xc/lib/GL/mesa/src/drv/i810/i810render.c
new file mode 100644
index 000000000..afc6b1c48
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810render.c
@@ -0,0 +1,214 @@
+/* $Id: i810render.c,v 1.2 2002/02/14 01:59:53 dawes Exp $ */
+
+/*
+ * Intel i810 DRI driver for Mesa 3.5
+ *
+ * Copyright (C) 1999-2000 Keith Whitwell All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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 KEITH WHITWELL BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Author:
+ * Keith Whitwell <keithw@valinux.com>
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mem.h"
+#include "mtypes.h"
+#include "mmath.h"
+
+#include "tnl/t_context.h"
+
+#include "i810context.h"
+#include "i810tris.h"
+#include "i810state.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 0
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0
+
+
+static GLuint hw_prim[GL_POLYGON+1] = {
+ 0,
+ PR_LINES,
+ 0,
+ PR_LINESTRIP,
+ PR_TRIANGLES,
+ PR_TRISTRIP_0,
+ PR_TRIFAN,
+ 0,
+ 0,
+ PR_POLYGON
+};
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+/* Fallback to normal rendering.
+ */
+static void VERT_FALLBACK( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+ tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
+ tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start,
+ count, flags );
+ I810_CONTEXT(ctx)->SetupNewInputs = VERT_CLIP;
+}
+
+
+
+#define LOCAL_VARS i810ContextPtr imesa = I810_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ I810_STATECHANGE(imesa, 0); \
+ i810RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] ); \
+} while (0)
+#define NEW_PRIMITIVE() I810_STATECHANGE( imesa, 0 )
+#define NEW_BUFFER() I810_FIREVERTICES( imesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (I810_DMA_BUF_SZ-4) / (imesa->vertex_size * 4)
+
+
+#define EMIT_VERTS( ctx, j, nr ) \
+ i810_emit_contiguous_verts(ctx, j, (j)+(nr))
+
+
+#define TAG(x) i810_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean i810_run_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i, length, flags = 0;
+
+ /* Don't handle clipping or indexed vertices.
+ */
+ if (VB->ClipOrMask || imesa->RenderIndex != 0 || VB->Elts) {
+ return GL_TRUE;
+ }
+
+ imesa->SetupNewInputs = VERT_CLIP;
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length)
+ {
+ flags = VB->Primitive[i];
+ length= VB->PrimitiveLength[i];
+ if (length)
+ i810_render_tab_verts[flags & PRIM_MODE_MASK]( ctx, i, i + length,
+ flags );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+static void i810_check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
+{
+ GLuint inputs = VERT_CLIP|VERT_RGBA;
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ inputs |= VERT_SPEC_RGB;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled)
+ inputs |= VERT_TEX(0);
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled)
+ inputs |= VERT_TEX(1);
+
+ if (ctx->Fog.Enabled)
+ inputs |= VERT_FOG_COORD;
+ }
+
+ stage->inputs = inputs;
+}
+
+
+static void dtr( struct gl_pipeline_stage *stage )
+{
+ (void)stage;
+}
+
+
+const struct gl_pipeline_stage _i810_render_stage =
+{
+ "i810 render",
+ (_DD_NEW_SEPARATE_SPECULAR |
+ _NEW_TEXTURE|
+ _NEW_FOG|
+ _NEW_RENDERMODE), /* re-check (new inputs) */
+ 0, /* re-run (always runs) */
+ GL_TRUE, /* active */
+ 0, 0, /* inputs (set in check_render), outputs */
+ 0, 0, /* changed_inputs, private */
+ dtr, /* destructor */
+ i810_check_render, /* check - initially set to alloc data */
+ i810_run_render /* run */
+};
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810screen.c b/xc/lib/GL/mesa/src/drv/i810/i810screen.c
new file mode 100644
index 000000000..b83c683a8
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810screen.c
@@ -0,0 +1,321 @@
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c,v 1.9 2000/12/07 20:26:06 dawes Exp $ */
+
+/*
+ * Authors:
+ * Keith Whitwell <keithw@precisioninsight.com>
+ *
+ */
+
+
+#include <X11/Xlibint.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810span.h"
+#include "i810tris.h"
+#include "i810ioctl.h"
+
+#include "i810_dri.h"
+
+
+
+/* static int i810_malloc_proxy_buf(drmBufMapPtr buffers) */
+/* { */
+/* char *buffer; */
+/* drmBufPtr buf; */
+/* int i; */
+
+/* buffer = Xmalloc(I810_DMA_BUF_SZ); */
+/* if(buffer == NULL) return -1; */
+/* for(i = 0; i < I810_DMA_BUF_NR; i++) { */
+/* buf = &(buffers->list[i]); */
+/* buf->address = (drmAddress)buffer; */
+/* } */
+/* return 0; */
+/* } */
+
+static drmBufMapPtr i810_create_empty_buffers(void)
+{
+ drmBufMapPtr retval;
+
+ retval = (drmBufMapPtr)Xmalloc(sizeof(drmBufMap));
+ if(retval == NULL) return NULL;
+ memset(retval, 0, sizeof(drmBufMap));
+ retval->list = (drmBufPtr)Xmalloc(sizeof(drmBuf) * I810_DMA_BUF_NR);
+ if(retval->list == NULL) {
+ Xfree(retval);
+ return NULL;
+ }
+ memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR);
+ return retval;
+}
+
+
+static GLboolean
+i810InitDriver(__DRIscreenPrivate *sPriv)
+{
+ i810ScreenPrivate *i810Screen;
+ I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
+ if (major != 4 || minor < 0) {
+ __driUtilMessage("i810 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
+ return GL_FALSE;
+ }
+ }
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if (sPriv->ddxMajor != 1 ||
+ sPriv->ddxMinor < 0) {
+ __driUtilMessage("i810 DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if (sPriv->drmMajor != 1 ||
+ sPriv->drmMinor < 2) {
+ __driUtilMessage("i810 DRI driver expected DRM driver version 1.2.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ i810Screen = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate));
+ if (!i810Screen) {
+ __driUtilMessage("i810InitDriver: alloc i810ScreenPrivate struct failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->driScrnPriv = sPriv;
+ sPriv->private = (void *)i810Screen;
+
+ i810Screen->deviceID=gDRIPriv->deviceID;
+ i810Screen->width=gDRIPriv->width;
+ i810Screen->height=gDRIPriv->height;
+ i810Screen->mem=gDRIPriv->mem;
+ i810Screen->cpp=gDRIPriv->cpp;
+ i810Screen->fbStride=gDRIPriv->fbStride;
+ i810Screen->fbOffset=gDRIPriv->fbOffset;
+
+ if (gDRIPriv->bitsPerPixel == 15)
+ i810Screen->fbFormat = DV_PF_555;
+ else
+ i810Screen->fbFormat = DV_PF_565;
+
+ i810Screen->backOffset=gDRIPriv->backOffset;
+ i810Screen->depthOffset=gDRIPriv->depthOffset;
+ i810Screen->backPitch = gDRIPriv->auxPitch;
+ i810Screen->backPitchBits = gDRIPriv->auxPitchBits;
+ i810Screen->textureOffset=gDRIPriv->textureOffset;
+ i810Screen->textureSize=gDRIPriv->textureSize;
+ i810Screen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+
+ i810Screen->bufs = i810_create_empty_buffers();
+ if (i810Screen->bufs == NULL) {
+ __driUtilMessage("i810InitDriver: i810_create_empty_buffers() failed");
+ Xfree(i810Screen);
+ return GL_FALSE;
+ }
+
+ i810Screen->back.handle = gDRIPriv->backbuffer;
+ i810Screen->back.size = gDRIPriv->backbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i810Screen->back.handle,
+ i810Screen->back.size,
+ (drmAddress *)&i810Screen->back.map) != 0) {
+ Xfree(i810Screen);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->depth.handle = gDRIPriv->depthbuffer;
+ i810Screen->depth.size = gDRIPriv->depthbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i810Screen->depth.handle,
+ i810Screen->depth.size,
+ (drmAddress *)&i810Screen->depth.map) != 0) {
+ Xfree(i810Screen);
+ drmUnmap(i810Screen->back.map, i810Screen->back.size);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap (2) failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->tex.handle = gDRIPriv->textures;
+ i810Screen->tex.size = gDRIPriv->textureSize;
+
+ if (drmMap(sPriv->fd,
+ i810Screen->tex.handle,
+ i810Screen->tex.size,
+ (drmAddress *)&i810Screen->tex.map) != 0) {
+ Xfree(i810Screen);
+ drmUnmap(i810Screen->back.map, i810Screen->back.size);
+ drmUnmap(i810Screen->depth.map, i810Screen->depth.size);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap (3) failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
+
+ return GL_TRUE;
+}
+
+static void
+i810DestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+
+ /* Need to unmap all the bufs and maps here:
+ */
+ drmUnmap(i810Screen->back.map, i810Screen->back.size);
+ drmUnmap(i810Screen->depth.map, i810Screen->depth.size);
+ drmUnmap(i810Screen->tex.map, i810Screen->tex.size);
+
+ Xfree(i810Screen);
+ sPriv->private = NULL;
+}
+
+
+static GLboolean
+i810CreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+#if 0
+/* Initialize the fullscreen mode.
+ */
+GLboolean
+XMesaOpenFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+ i810ContextPtr imesa = (i810ContextPtr)driContextPriv->driverPrivate;
+ imesa->doPageFlip = 1;
+ imesa->currentPage = 0;
+ return GL_TRUE;
+}
+
+/* Shut down the fullscreen mode.
+ */
+GLboolean
+XMesaCloseFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+ i810ContextPtr imesa = (i810ContextPtr)driContextPriv->driverPrivate;
+
+ if (imesa->currentPage == 1) {
+ /* Move the frontbuffer image to page zero? */
+/* i810SwapBuffers( imesa ); */
+ i810PageFlip( imesa );
+ imesa->currentPage = 0;
+ }
+
+ imesa->doPageFlip = GL_FALSE;
+ imesa->Setup[I810_DESTREG_DI0] = imesa->driScreen->front_offset;
+ return GL_TRUE;
+}
+
+#else
+
+static GLboolean
+i810OpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+static GLboolean
+i810CloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+#endif
+
+
+static struct __DriverAPIRec i810API = {
+ i810InitDriver,
+ i810DestroyScreen,
+ i810CreateContext,
+ i810DestroyContext,
+ i810CreateBuffer,
+ i810DestroyBuffer,
+ i810SwapBuffers,
+ i810MakeCurrent,
+ i810UnbindContext,
+ i810OpenFullScreen,
+ i810CloseFullScreen
+};
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &i810API);
+ return (void *) psp;
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_init.h b/xc/lib/GL/mesa/src/drv/i810/i810screen.h
index 21c4f78d5..26e0976a8 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810_init.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810screen.h
@@ -34,13 +34,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _I810_INIT_H_
#define _I810_INIT_H_
-#ifdef GLX_DIRECT_RENDERING
-
#include <sys/time.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "types.h"
+#include "dri_util.h"
typedef struct {
drmHandle handle;
@@ -78,54 +73,27 @@ typedef struct {
__DRIscreenPrivate *driScrnPriv;
drmBufMapPtr bufs;
- int use_copy_buf;
unsigned int sarea_priv_offset;
} i810ScreenPrivate;
-#include "i810context.h"
-
-extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
-extern void i810EmitHwStateLocked( i810ContextPtr imesa );
-extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
-extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
-extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
-extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
-
+extern GLboolean
+i810CreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
-#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
-#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
+extern void
+i810DestroyContext(__DRIcontextPrivate *driContextPriv);
+extern GLboolean
+i810UnbindContext(__DRIcontextPrivate *driContextPriv);
-/* Lock the hardware and validate our state.
- */
-#define LOCK_HARDWARE( imesa ) \
- do { \
- char __ret=0; \
- DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
- (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
- if (__ret) \
- i810GetLock( imesa, 0 ); \
- } while (0)
-
+extern GLboolean
+i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+extern void
+i810SwapBuffers(Display *dpy, void *drawablePrivate);
-/* Unlock the hardware using the global current context
- */
-#define UNLOCK_HARDWARE(imesa) \
- DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
-
-
-/* This is the wrong way to do it, I'm sure. Otherwise the drm
- * bitches that I've already got the heavyweight lock. At worst,
- * this is 3 ioctls. The best solution probably only gets me down
- * to 2 ioctls in the worst case.
- */
-#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
- LOCK_HARDWARE( imesa ); \
- i810RegetLockQuiescent( imesa ); \
-} while(0)
-
-
-#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810span.c b/xc/lib/GL/mesa/src/drv/i810/i810span.c
index 4bf02ad13..6971eb145 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810span.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810span.c
@@ -1,9 +1,9 @@
-#include "types.h"
-#include "i810dd.h"
-#include "i810log.h"
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
#include "i810span.h"
#include "i810ioctl.h"
-
+#include "swrast/swrast.h"
#define DBG 0
@@ -12,13 +12,13 @@
i810ScreenPrivate *i810Screen = imesa->i810Screen; \
GLuint pitch = i810Screen->backPitch; \
GLuint height = dPriv->h; \
+ GLushort p; \
char *buf = (char *)(imesa->drawMap + \
dPriv->x * 2 + \
dPriv->y * pitch); \
char *read_buf = (char *)(imesa->readMap + \
dPriv->x * 2 + \
- dPriv->y * pitch); \
- GLushort p = I810_CONTEXT( ctx )->MonoColor; \
+ dPriv->y * pitch); \
(void) read_buf; (void) buf; (void) p
#define LOCAL_DEPTH_VARS \
@@ -30,7 +30,8 @@
dPriv->x * 2 + \
dPriv->y * pitch)
-#define INIT_MONO_PIXEL(p)
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
_y >= miny && _y < maxy)
@@ -50,7 +51,7 @@
#define HW_LOCK() \
i810ContextPtr imesa = I810_CONTEXT(ctx); \
- FLUSH_BATCH(imesa); \
+ I810_FIREVERTICES(imesa); \
i810DmaFinish(imesa); \
LOCK_HARDWARE_QUIESCENT(imesa);
@@ -84,13 +85,13 @@
#define WRITE_PIXEL( _x, _y, p ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = p
-#define READ_RGBA( rgba, _x, _y ) \
-do { \
- GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
- rgba[0] = (((p >> 11) & 0x1f) * 255) / 31; \
- rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \
- rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \
- rgba[3] = 255; \
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
+ rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
+ rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+ rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+ rgba[3] = 255; \
} while(0)
#define TAG(x) i810##x##_565
@@ -98,32 +99,6 @@ do { \
-
-/* 15 bit, 555 rgb color spanline and pixel functions
- */
-#define WRITE_RGBA( _x, _y, r, g, b, a ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \
- ((g & 0xf8) << 3) | \
- ((b & 0xf8) >> 3))
-
-#define WRITE_PIXEL( _x, _y, p ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = p
-
-#define READ_RGBA( rgba, _x, _y ) \
-do { \
- GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
- rgba[0] = (p >> 7) & 0xf8; \
- rgba[1] = (p >> 3) & 0xf8; \
- rgba[2] = (p << 3) & 0xf8; \
- rgba[3] = 255; \
-} while(0)
-
-#define TAG(x) i810##x##_555
-#include "spantmp.h"
-
-
-
-
/* 16 bit depthbuffer functions.
*/
#define WRITE_DEPTH( _x, _y, d ) \
@@ -132,43 +107,43 @@ do { \
#define READ_DEPTH( d, _x, _y ) \
d = *(GLushort *)(buf + _x*2 + _y*pitch);
-/* d = 0xffff; */
-
#define TAG(x) i810##x##_16
#include "depthtmp.h"
-
-void i810DDInitSpanFuncs( GLcontext *ctx )
+static void i810SetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLenum mode )
{
- if (1) {
- ctx->Driver.WriteRGBASpan = i810WriteRGBASpan_565;
- ctx->Driver.WriteRGBSpan = i810WriteRGBSpan_565;
- ctx->Driver.WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
- ctx->Driver.WriteRGBAPixels = i810WriteRGBAPixels_565;
- ctx->Driver.WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
- ctx->Driver.ReadRGBASpan = i810ReadRGBASpan_565;
- ctx->Driver.ReadRGBAPixels = i810ReadRGBAPixels_565;
- } else {
- ctx->Driver.WriteRGBASpan = i810WriteRGBASpan_555;
- ctx->Driver.WriteRGBSpan = i810WriteRGBSpan_555;
- ctx->Driver.WriteMonoRGBASpan = i810WriteMonoRGBASpan_555;
- ctx->Driver.WriteRGBAPixels = i810WriteRGBAPixels_555;
- ctx->Driver.WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_555;
- ctx->Driver.ReadRGBASpan = i810ReadRGBASpan_555;
- ctx->Driver.ReadRGBAPixels = i810ReadRGBAPixels_555;
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ if (mode == GL_FRONT_LEFT) {
+ imesa->readMap = (char *)imesa->driScreen->pFB;
}
+ else if (mode == GL_BACK_LEFT) {
+ imesa->readMap = imesa->i810Screen->back.map;
+ }
+ else {
+ ASSERT(0);
+ }
+}
- ctx->Driver.ReadDepthSpan = i810ReadDepthSpan_16;
- ctx->Driver.WriteDepthSpan = i810WriteDepthSpan_16;
- ctx->Driver.ReadDepthPixels = i810ReadDepthPixels_16;
- ctx->Driver.WriteDepthPixels = i810WriteDepthPixels_16;
-
- ctx->Driver.WriteCI8Span =NULL;
- ctx->Driver.WriteCI32Span =NULL;
- ctx->Driver.WriteMonoCISpan =NULL;
- ctx->Driver.WriteCI32Pixels =NULL;
- ctx->Driver.WriteMonoCIPixels =NULL;
- ctx->Driver.ReadCI32Span =NULL;
- ctx->Driver.ReadCI32Pixels =NULL;
+
+void i810InitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetReadBuffer = i810SetReadBuffer;
+
+ swdd->WriteRGBASpan = i810WriteRGBASpan_565;
+ swdd->WriteRGBSpan = i810WriteRGBSpan_565;
+ swdd->WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
+ swdd->WriteRGBAPixels = i810WriteRGBAPixels_565;
+ swdd->WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
+ swdd->ReadRGBASpan = i810ReadRGBASpan_565;
+ swdd->ReadRGBAPixels = i810ReadRGBAPixels_565;
+
+ swdd->ReadDepthSpan = i810ReadDepthSpan_16;
+ swdd->WriteDepthSpan = i810WriteDepthSpan_16;
+ swdd->ReadDepthPixels = i810ReadDepthPixels_16;
+ swdd->WriteDepthPixels = i810WriteDepthPixels_16;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810span.h b/xc/lib/GL/mesa/src/drv/i810/i810span.h
index 17a52085b..a7b809bf1 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810span.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810span.h
@@ -1,6 +1,6 @@
#ifndef _I810_SPAN_H
#define _I810_SPAN_H
-extern void i810DDInitSpanFuncs( GLcontext *ctx );
+extern void i810InitSpanFuncs( GLcontext *ctx );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810state.c b/xc/lib/GL/mesa/src/drv/i810/i810state.c
index dba30cc69..de66fb6a8 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810state.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810state.c
@@ -2,32 +2,36 @@
#include <stdio.h>
-#include "types.h"
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
#include "enums.h"
-#include "pb.h"
#include "dd.h"
#include "mm.h"
-#include "i810dd.h"
#include "i810context.h"
#include "i810state.h"
#include "i810tex.h"
-#include "i810log.h"
#include "i810vb.h"
#include "i810tris.h"
#include "i810ioctl.h"
-
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
-static __inline__ GLuint i810PackColor(GLuint format,
- GLubyte r, GLubyte g,
+#include "tnl/t_pipeline.h"
+
+static __inline__ GLuint i810PackColor(GLuint format,
+ GLubyte r, GLubyte g,
GLubyte b, GLubyte a)
{
switch (format) {
case DV_PF_555:
- return I810PACKCOLOR1555(r,g,b,a);
+ return PACK_COLOR_1555( a, r, g, b );
case DV_PF_565:
- return I810PACKCOLOR565(r,g,b);
+ return PACK_COLOR_565( r, g, b );
default:
fprintf(stderr, "unknown format %d\n", (int)format);
return 0;
@@ -35,12 +39,10 @@ static __inline__ GLuint i810PackColor(GLuint format,
}
-static void i810DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+static void i810AlphaFunc(GLcontext *ctx, GLenum func, GLchan ref)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- CARD32 a = (ZA_UPDATE_ALPHAFUNC|ZA_UPDATE_ALPHAREF);
-
- FLUSH_BATCH(imesa);
+ GLuint a = (ZA_UPDATE_ALPHAFUNC|ZA_UPDATE_ALPHAREF);
switch (ctx->Color.AlphaFunc) {
case GL_NEVER: a |= ZA_ALPHA_NEVER; break;
@@ -54,34 +56,31 @@ static void i810DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
default: return;
}
- a |= ctx->Color.AlphaRef << ZA_ALPHAREF_SHIFT;
+ a |= ((ref & 0xfc) << ZA_ALPHAREF_SHIFT);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_ZA] &= ~(ZA_ALPHA_MASK|ZA_ALPHAREF_MASK);
imesa->Setup[I810_CTXREG_ZA] |= a;
}
-static void i810DDBlendEquation(GLcontext *ctx, GLenum mode)
+static void i810BlendEquation(GLcontext *ctx, GLenum mode)
{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
+ /* Can only do GL_ADD equation in hardware */
+ FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_BLEND_EQ, mode != GL_FUNC_ADD_EXT);
- if (mode != GL_FUNC_ADD_EXT) {
- ctx->Color.BlendEquation = GL_FUNC_ADD_EXT;
- if (0) fprintf(stderr, "Unsupported blend equation: %s\n",
- gl_lookup_enum_by_nr(mode));
- }
-
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- imesa->Fallback |= I810_FALLBACK_LOGICOP;
- else
- imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
}
-static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+static void i810BlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
GLuint a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND;
- FLUSH_BATCH(imesa);
+ GLboolean fallback = GL_FALSE;
switch (ctx->Color.BlendSrcRGB) {
case GL_ZERO: a |= SDM_SRC_ZERO; break;
@@ -92,8 +91,15 @@ static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_SRC_INV_SRC_ALPHA; break;
case GL_DST_ALPHA: a |= SDM_SRC_ONE; break;
case GL_ONE_MINUS_DST_ALPHA: a |= SDM_SRC_ZERO; break;
- case GL_SRC_ALPHA_SATURATE: a |= SDM_SRC_SRC_ALPHA; break;
- default: return;
+ case GL_SRC_ALPHA_SATURATE: /*a |= SDM_SRC_SRC_ALPHA; break;*/
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ return;
}
switch (ctx->Color.BlendDstRGB) {
@@ -105,41 +111,49 @@ static void i810DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
case GL_ONE_MINUS_SRC_COLOR: a |= SDM_DST_INV_SRC_COLOR; break;
case GL_DST_ALPHA: a |= SDM_DST_ONE; break;
case GL_ONE_MINUS_DST_ALPHA: a |= SDM_DST_ZERO; break;
- default: return;
- }
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ return;
+ }
- imesa->dirty |= I810_UPLOAD_CTX;
- imesa->Setup[I810_CTXREG_SDM] &= ~(SDM_SRC_MASK|SDM_DST_MASK);
- imesa->Setup[I810_CTXREG_SDM] |= a;
+ FALLBACK( imesa, I810_FALLBACK_BLEND_FUNC, fallback);
+ if (!fallback) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_SDM] &= ~(SDM_SRC_MASK|SDM_DST_MASK);
+ imesa->Setup[I810_CTXREG_SDM] |= a;
+ }
}
/* Shouldn't be called as the extension is disabled.
*/
-static void i810DDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
+static void i810BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
GLenum dfactorRGB, GLenum sfactorA,
GLenum dfactorA )
{
if (dfactorRGB != dfactorA || sfactorRGB != sfactorA) {
- gl_error( ctx, GL_INVALID_OPERATION, "glBlendEquation (disabled)");
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBlendEquation (disabled)");
}
- i810DDBlendFunc( ctx, sfactorRGB, dfactorRGB );
+ i810BlendFunc( ctx, sfactorRGB, dfactorRGB );
}
-static void i810DDDepthFunc(GLcontext *ctx, GLenum func)
+static void i810DepthFunc(GLcontext *ctx, GLenum func)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
int zmode;
- FLUSH_BATCH(imesa);
-
- switch(func) {
+ switch(func) {
case GL_NEVER: zmode = LCS_Z_NEVER; break;
case GL_ALWAYS: zmode = LCS_Z_ALWAYS; break;
- case GL_LESS: zmode = LCS_Z_LESS; break;
+ case GL_LESS: zmode = LCS_Z_LESS; break;
case GL_LEQUAL: zmode = LCS_Z_LEQUAL; break;
case GL_EQUAL: zmode = LCS_Z_EQUAL; break;
case GL_GREATER: zmode = LCS_Z_GREATER; break;
@@ -147,48 +161,42 @@ static void i810DDDepthFunc(GLcontext *ctx, GLenum func)
case GL_NOTEQUAL: zmode = LCS_Z_NOTEQUAL; break;
default: return;
}
-
+
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_Z_MASK;
- imesa->Setup[I810_CTXREG_LCS] |= LCS_UPDATE_ZMODE | zmode;
- imesa->dirty |= I810_UPLOAD_CTX;
+ imesa->Setup[I810_CTXREG_LCS] |= zmode;
}
-static void i810DDDepthMask(GLcontext *ctx, GLboolean flag)
+static void i810DepthMask(GLcontext *ctx, GLboolean flag)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
-
- FLUSH_BATCH(imesa);
-
- imesa->dirty |= I810_UPLOAD_CTX;
- imesa->Setup[I810_CTXREG_B2] &= ~B2_ZB_WRITE_ENABLE;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
if (flag)
- imesa->Setup[I810_CTXREG_B2] |= B2_ZB_WRITE_ENABLE;
+ imesa->Setup[I810_CTXREG_B2] |= B2_ZB_WRITE_ENABLE;
+ else
+ imesa->Setup[I810_CTXREG_B2] &= ~B2_ZB_WRITE_ENABLE;
}
/* =============================================================
- * Polygon stipple
- *
- * The i810 supports a 4x4 stipple natively, GL wants 32x32.
- * Fortunately stipple is usually a repeating pattern. Could
- * also consider using a multitexturing mechanism for this, but
- * that has real issues, too.
+ * Polygon stipple
+ *
+ * The i810 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
*/
-static void i810DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+static void i810PolygonStipple( GLcontext *ctx, const GLubyte *mask )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
const GLubyte *m = mask;
GLubyte p[4];
int i,j,k;
- int active = (ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON);
+ int active = (ctx->Polygon.StippleFlag &&
+ imesa->reduced_primitive == GL_TRIANGLES);
GLuint newMask;
- FLUSH_BATCH(imesa);
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
-
if (active) {
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
}
@@ -198,10 +206,10 @@ static void i810DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
for (k = 0 ; k < 8 ; k++)
- for (j = 0 ; j < 4; j++)
- for (i = 0 ; i < 4 ; i++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++)
if (*m++ != p[j]) {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ imesa->stipple_in_hw = 0;
return;
}
@@ -209,14 +217,16 @@ static void i810DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
((p[1] & 0xf) << 4) |
((p[2] & 0xf) << 8) |
((p[3] & 0xf) << 12);
+
if (newMask == 0xffff) {
- /* do opaque stipple in software for conformance */
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
+ /* this is needed to make conform pass */
+ imesa->stipple_in_hw = 0;
return;
}
imesa->Setup[I810_CTXREG_ST1] &= ~0xffff;
imesa->Setup[I810_CTXREG_ST1] |= newMask;
+ imesa->stipple_in_hw = 1;
if (active)
imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
@@ -229,120 +239,81 @@ static void i810DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
*/
-static void i810DDScissor( GLcontext *ctx, GLint x, GLint y,
- GLsizei w, GLsizei h )
-{
+static void i810Scissor( GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h )
+{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- FLUSH_BATCH(imesa);
+ if (ctx->Scissor.Enabled) {
+ I810_FIREVERTICES(imesa); /* don't pipeline cliprect changes */
+ imesa->upload_cliprects = GL_TRUE;
+ }
+
imesa->scissor_rect.x1 = x;
- imesa->scissor_rect.y1 = imesa->driDrawable->h - (y+h);
- imesa->scissor_rect.x2 = x+w;
+ imesa->scissor_rect.y1 = imesa->driDrawable->h - (y + h);
+ imesa->scissor_rect.x2 = x + w;
imesa->scissor_rect.y2 = imesa->driDrawable->h - y;
-
-
- if (I810_DEBUG&DEBUG_VERBOSE_2D)
- fprintf(stderr, "SET SCISSOR %d,%d-%d,%d\n",
- imesa->scissor_rect.x1,
- imesa->scissor_rect.y1,
- imesa->scissor_rect.x2,
- imesa->scissor_rect.y2);
-
-
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
}
-static void i810DDDither(GLcontext *ctx, GLboolean enable)
+static void i810LogicOp( GLcontext *ctx, GLenum opcode )
{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled && opcode != GL_COPY) );
}
-static void i810DDLogicOp( GLcontext *ctx, GLenum opcode )
+/* Fallback to swrast for select and feedback.
+ */
+static void i810RenderMode( GLcontext *ctx, GLenum mode )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
-
- if (ctx->Color.ColorLogicOpEnabled)
- {
- FLUSH_BATCH( imesa );
-
- if (opcode == GL_COPY)
- imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
- else
- imesa->Fallback |= I810_FALLBACK_LOGICOP;
- }
- else
- imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
+ FALLBACK( imesa, I810_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
}
-static GLboolean i810DDSetDrawBuffer(GLcontext *ctx, GLenum mode )
+
+static GLboolean i810SetDrawBuffer(GLcontext *ctx, GLenum mode )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- FLUSH_BATCH(imesa);
-
- imesa->Fallback &= ~I810_FALLBACK_DRAW_BUFFER;
-
- if (mode == GL_FRONT_LEFT)
+ if (mode == GL_FRONT_LEFT)
{
+ I810_FIREVERTICES(imesa);
+ I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS);
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset |
+ imesa->i810Screen->backPitchBits);
imesa->drawMap = (char *)imesa->driScreen->pFB;
imesa->readMap = (char *)imesa->driScreen->pFB;
- imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset |
- imesa->i810Screen->backPitchBits);
- imesa->dirty |= I810_UPLOAD_BUFFERS;
i810XMesaSetFrontClipRects( imesa );
+ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
- }
- else if (mode == GL_BACK_LEFT)
+ }
+ else if (mode == GL_BACK_LEFT)
{
+ I810_FIREVERTICES(imesa);
+ I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS);
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset |
+ imesa->i810Screen->backPitchBits);
imesa->drawMap = imesa->i810Screen->back.map;
imesa->readMap = imesa->i810Screen->back.map;
- imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset |
- imesa->i810Screen->backPitchBits);
- imesa->dirty |= I810_UPLOAD_BUFFERS;
i810XMesaSetBackClipRects( imesa );
+ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
}
-
- imesa->Fallback |= I810_FALLBACK_DRAW_BUFFER;
- return GL_FALSE;
-}
-
-static void i810DDSetReadBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
- GLenum mode )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
-
- if (mode == GL_FRONT_LEFT)
- {
- imesa->readMap = (char *)imesa->driScreen->pFB;
- imesa->Fallback &= ~I810_FALLBACK_READ_BUFFER;
- }
- else if (mode == GL_BACK_LEFT)
- {
- imesa->readMap = imesa->i810Screen->back.map;
- imesa->Fallback &= ~I810_FALLBACK_READ_BUFFER;
+ else {
+ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return GL_FALSE;
}
- else
- imesa->Fallback |= I810_FALLBACK_READ_BUFFER;
}
-static void i810DDSetColor(GLcontext *ctx,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
+static void i810ClearColor(GLcontext *ctx, const GLchan color[4] )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- imesa->MonoColor = i810PackColor( imesa->i810Screen->fbFormat, r, g, b, a );
-}
-
-
-static void i810DDClearColor(GLcontext *ctx,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- imesa->ClearColor = i810PackColor( imesa->i810Screen->fbFormat, r, g, b, a );
+ imesa->ClearColor = i810PackColor( imesa->i810Screen->fbFormat,
+ color[0], color[1],
+ color[2], color[3] );
}
@@ -350,12 +321,10 @@ static void i810DDClearColor(GLcontext *ctx,
* Culling - the i810 isn't quite as clean here as the rest of
* its interfaces, but it's not bad.
*/
-static void i810DDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
+static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
GLuint mode = LCS_CULL_BOTH;
-
- FLUSH_BATCH(imesa);
if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
mode = LCS_CULL_CW;
@@ -367,146 +336,125 @@ static void i810DDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
imesa->LcsCullMode = mode;
- if (ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON)
+ if (ctx->Polygon.CullFlag)
{
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
imesa->Setup[I810_CTXREG_LCS] |= mode;
}
}
-static void i810DDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
+static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- FLUSH_BATCH(imesa);
-
- imesa->dirty |= I810_UPLOAD_CTX;
- imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
- imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
- imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
- imesa->vertex_prim = PR_TRIANGLES;
-
- switch (ctx->PB->primitive) {
- case GL_POLYGON:
- if (ctx->Polygon.StippleFlag &&
- (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE))
- imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
- if (ctx->Polygon.CullFlag)
- imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
- else
- imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
- if (ctx->Polygon.SmoothFlag)
- imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
- break;
- case GL_LINES:
- if (ctx->Line.SmoothFlag)
- imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
- imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
- imesa->vertex_prim = PR_LINES;
- break;
- case GL_POINTS:
- if (ctx->Point.SmoothFlag)
- imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
- imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
- break;
- default:
- imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
- break;
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ int width = (int)ctx->Line._Width;
+
+ imesa->LcsLineWidth = 0;
+ if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0;
+ if (width & 2) imesa->LcsLineWidth |= LCS_LINEWIDTH_2_0;
+
+ if (imesa->reduced_primitive == GL_LINES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsLineWidth;
}
}
-
-static void i810DDLineWidth( GLcontext *ctx, GLfloat widthf )
+static void i810PointSize( GLcontext *ctx, GLfloat sz )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- int width = (int)widthf;
-
- if (width > 3) width = 3;
- if (width < 1) width = 1;
-
- imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+ int size = (int)ctx->Point._Size;
- if (width & 1) imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_1_0;
- if (width & 2) imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_2_0;
+ imesa->LcsPointSize = 0;
+ if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0;
+ if (size & 2) imesa->LcsPointSize |= LCS_LINEWIDTH_2_0;
- imesa->dirty |= I810_UPLOAD_CTX;
+ if (imesa->reduced_primitive == GL_POINTS) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsPointSize;
+ }
}
/* =============================================================
* Color masks
*/
-/* Mesa calls this from the wrong place - it is called a very large
- * number of redundant times.
- *
- * Colormask can be simulated by multipass or multitexture techniques.
- */
-static GLboolean i810DDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+static void i810ColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- GLuint tmp;
-
- if (r && g && b)
- imesa->Fallback &= ~I810_FALLBACK_COLORMASK;
- else
- imesa->Fallback |= I810_FALLBACK_COLORMASK;
-
- tmp = imesa->Setup[I810_CTXREG_B2] |
- (B2_FB_WRITE_ENABLE | B2_UPDATE_FB_WRITE_ENABLE);
+ GLuint tmp = 0;
+
+ if (r && g && b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] | B2_FB_WRITE_ENABLE;
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_FALSE );
+ } else if (!r && !g && !b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] & ~B2_FB_WRITE_ENABLE;
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_FALSE );
+ } else {
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_TRUE );
+ return;
+ }
if (tmp != imesa->Setup[I810_CTXREG_B2]) {
- FLUSH_BATCH(imesa);
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_B2] = tmp;
imesa->dirty |= I810_UPLOAD_CTX;
}
-
- return GL_FALSE; /* makes s/w path always do s/w masking */
}
-/* Seperate specular not fully implemented in hardware... Needs
- * some interaction with material state? Just punt to software
- * in all cases?
+/* Seperate specular not fully implemented on the i810.
*/
-static void i810DDLightModelfv(GLcontext *ctx, GLenum pname,
- const GLfloat *param)
+static void i810LightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
{
- if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
- {
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
+ {
i810ContextPtr imesa = I810_CONTEXT( ctx );
- FLUSH_BATCH(imesa);
-
- imesa->Fallback &= ~I810_FALLBACK_SPECULAR;
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- imesa->Fallback |= I810_FALLBACK_SPECULAR;
+ FALLBACK( imesa, I810_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
}
}
-/* The 815 has it...
+/* But the 815 has it...
*/
-static void i810DDLightModelfv_i815(GLcontext *ctx, GLenum pname,
- const GLfloat *param)
+static void i810LightModelfv_i815(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
{
- if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
- {
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
+ {
i810ContextPtr imesa = I810_CONTEXT( ctx );
- FLUSH_BATCH(imesa);
-
- imesa->Setup[I810_CTXREG_B1] &= ~B1_SPEC_ENABLE;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
imesa->Setup[I810_CTXREG_B1] |= B1_SPEC_ENABLE;
+ else
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_SPEC_ENABLE;
}
}
-
+
+/* In Mesa 3.5 we can reliably do native flatshading.
+ */
+static void i810ShadeModel(GLcontext *ctx, GLenum mode)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ if (mode == GL_FLAT)
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_INTERP_FLAT;
+ else
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_INTERP_FLAT;
+}
+
+
/* =============================================================
* Fog
*/
-
-static void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+static void i810Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
@@ -515,7 +463,7 @@ static void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_FOG] = ((GFX_OP_FOG_COLOR | color) &
~FOG_RESERVED_MASK);
}
@@ -524,60 +472,57 @@ static void i810DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
/* =============================================================
*/
-
-static void i810DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+static void i810Enable(GLcontext *ctx, GLenum cap, GLboolean state)
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
switch(cap) {
case GL_ALPHA_TEST:
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_B1] &= ~B1_ALPHA_TEST_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_ALPHA_TEST_ENABLE;
break;
case GL_BLEND:
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_B1] &= ~B1_BLEND_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_BLEND_ENABLE;
/* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
*/
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- imesa->Fallback |= I810_FALLBACK_LOGICOP;
- else
- imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
break;
case GL_DEPTH_TEST:
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_B1] &= ~B1_Z_TEST_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_Z_TEST_ENABLE;
break;
case GL_SCISSOR_TEST:
- FLUSH_BATCH(imesa);
+ /* XXX without these next two lines, conform's scissor test fails */
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS);
+ I810_FIREVERTICES(imesa); /* don't pipeline cliprect changes */
+ imesa->upload_cliprects = GL_TRUE;
imesa->scissor = state;
- imesa->dirty |= I810_UPLOAD_CLIPRECTS;
break;
- case GL_POLYGON_STIPPLE:
- if ((ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
- ctx->PB->primitive == GL_POLYGON)
+ case GL_POLYGON_STIPPLE:
+ if (imesa->stipple_in_hw && imesa->reduced_primitive == GL_TRIANGLES)
{
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
}
break;
case GL_LINE_SMOOTH:
- if (ctx->PB->primitive == GL_LINE) {
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ /* Need to fatten the lines by .5, or they disappear...
+ */
+ if (imesa->reduced_primitive == GL_LINES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
if (state) {
@@ -587,96 +532,90 @@ static void i810DDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
}
break;
case GL_POINT_SMOOTH:
- if (ctx->PB->primitive == GL_POINT) {
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ if (imesa->reduced_primitive == GL_POINTS) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
- if (state)
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
+ if (state) {
imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
+ }
}
break;
case GL_POLYGON_SMOOTH:
- if (ctx->PB->primitive == GL_POLYGON) {
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ if (imesa->reduced_primitive == GL_TRIANGLES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
- if (state)
+ if (state)
imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
}
break;
case GL_FOG:
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_B1] &= ~B1_FOG_ENABLE;
if (state)
imesa->Setup[I810_CTXREG_B1] |= B1_FOG_ENABLE;
break;
case GL_CULL_FACE:
- if (ctx->PB->primitive == GL_POLYGON) {
- FLUSH_BATCH(imesa);
- imesa->dirty |= I810_UPLOAD_CTX;
- imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
+ if (state)
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
+ else
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ break;
+ case GL_TEXTURE_2D:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ if (ctx->Texture.CurrentUnit == 0) {
+ imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL0_ENABLE;
if (state)
- imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
- else
- imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL0_ENABLE;
+ } else {
+ imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL1_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL1_ENABLE;
}
break;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_3D:
- FLUSH_BATCH(imesa);
- imesa->new_state |= I810_NEW_TEXTURE;
- break;
- case GL_TEXTURE_2D:
- FLUSH_BATCH(imesa);
- imesa->new_state |= I810_NEW_TEXTURE;
- break;
case GL_COLOR_LOGIC_OP:
- FLUSH_BATCH( imesa );
- imesa->Fallback &= ~I810_FALLBACK_LOGICOP;
- if (state && ctx->Color.LogicOp != GL_COPY)
- imesa->Fallback |= I810_FALLBACK_LOGICOP;
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (state && ctx->Color.LogicOp != GL_COPY));
+ break;
+ case GL_STENCIL_TEST:
+ FALLBACK( imesa, I810_FALLBACK_STENCIL, state );
break;
default:
- ;
- }
+ ;
+ }
}
-/* =============================================================
- */
-void i810DDUpdateHwState( GLcontext *ctx )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- if (imesa->new_state & I810_NEW_TEXTURE) {
- FLUSH_BATCH(imesa);
- i810UpdateTextureState( ctx );
- }
- imesa->new_state = 0;
-}
+/* =============================================================
+ */
+
+
void i810EmitDrawingRectangle( i810ContextPtr imesa )
{
__DRIdrawablePrivate *dPriv = imesa->driDrawable;
i810ScreenPrivate *i810Screen = imesa->i810Screen;
-
int x0 = imesa->drawX;
int y0 = imesa->drawY;
int x1 = x0 + dPriv->w;
int y1 = y0 + dPriv->h;
+ GLuint dr2, dr3, dr4;
/* Coordinate origin of the window - may be offscreen.
*/
- imesa->BufferSetup[I810_DESTREG_DR4] = ((y0<<16) |
- (((unsigned)x0)&0xFFFF));
-
+ dr4 = imesa->BufferSetup[I810_DESTREG_DR4] = ((y0<<16) |
+ (((unsigned)x0)&0xFFFF));
+
/* Clip to screen.
*/
if (x0 < 0) x0 = 0;
@@ -687,80 +626,69 @@ void i810EmitDrawingRectangle( i810ContextPtr imesa )
/* Onscreen drawing rectangle.
*/
- imesa->BufferSetup[I810_DESTREG_DR2] = ((y0<<16) | x0);
- imesa->BufferSetup[I810_DESTREG_DR3] = (((y1+1)<<16) | (x1+1));
+ dr2 = imesa->BufferSetup[I810_DESTREG_DR2] = ((y0<<16) | x0);
+ dr3 = imesa->BufferSetup[I810_DESTREG_DR3] = (((y1+1)<<16) | (x1+1));
+
+
imesa->dirty |= I810_UPLOAD_BUFFERS;
}
-static void i810DDPrintDirty( const char *msg, GLuint state )
+
+static void i810CalcViewport( GLcontext *ctx )
{
- fprintf(stderr, "%s (0x%x): %s%s%s%s%s\n",
- msg,
- (unsigned int) state,
- (state & I810_UPLOAD_TEX0IMAGE) ? "upload-tex0, " : "",
- (state & I810_UPLOAD_TEX1IMAGE) ? "upload-tex1, " : "",
- (state & I810_UPLOAD_CTX) ? "upload-ctx, " : "",
- (state & I810_UPLOAD_BUFFERS) ? "upload-bufs, " : "",
- (state & I810_UPLOAD_CLIPRECTS) ? "upload-cliprects, " : ""
- );
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = imesa->ViewportMatrix.m;
+
+ /* See also i810_translate_vertex. SUBPIXEL adjustments can be done
+ * via state vars, too.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * (1.0 / 0xffff);
+ m[MAT_TZ] = v[MAT_TZ] * (1.0 / 0xffff);
}
+static void i810Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ i810CalcViewport( ctx );
+}
-/* Push the state into the sarea and/or texture memory.
- */
-void i810EmitHwStateLocked( i810ContextPtr imesa )
+static void i810DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
{
- if (I810_DEBUG & DEBUG_VERBOSE_API)
- i810DDPrintDirty( "\n\n\ni810EmitHwStateLocked", imesa->dirty );
+ i810CalcViewport( ctx );
+}
- if (imesa->dirty & ~I810_UPLOAD_CLIPRECTS)
- {
- if ((imesa->dirty & I810_UPLOAD_TEX0IMAGE) && imesa->CurrentTexObj[0])
- i810UploadTexImages(imesa, imesa->CurrentTexObj[0]);
-
- if ((imesa->dirty & I810_UPLOAD_TEX1IMAGE) && imesa->CurrentTexObj[1])
- i810UploadTexImages(imesa, imesa->CurrentTexObj[1]);
-
- if (imesa->dirty & I810_UPLOAD_CTX)
- memcpy( imesa->sarea->ContextState,
- imesa->Setup,
- sizeof(imesa->Setup) );
-
- if ((imesa->dirty & I810_UPLOAD_TEX0) && imesa->CurrentTexObj[0]) {
- imesa->sarea->dirty |= I810_UPLOAD_TEX0;
- memcpy(imesa->sarea->TexState[0],
- imesa->CurrentTexObj[0]->Setup,
- sizeof(imesa->sarea->TexState[0]));
- }
- if ((imesa->dirty & I810_UPLOAD_TEX1) && imesa->CurrentTexObj[1]) {
- imesa->sarea->dirty |= I810_UPLOAD_TEX1;
- memcpy(imesa->sarea->TexState[1],
- imesa->CurrentTexObj[1]->Setup,
- sizeof(imesa->sarea->TexState[1]));
- }
-
- if (imesa->dirty & I810_UPLOAD_BUFFERS)
- memcpy( imesa->sarea->BufferState,
- imesa->BufferSetup,
- sizeof(imesa->BufferSetup) );
-
- imesa->sarea->dirty |= (imesa->dirty &
- ~(I810_UPLOAD_TEX1|I810_UPLOAD_TEX0));
- imesa->dirty &= I810_UPLOAD_CLIPRECTS;
- }
+
+void i810PrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%x): %s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & I810_UPLOAD_TEX0) ? "upload-tex0, " : "",
+ (state & I810_UPLOAD_TEX1) ? "upload-tex1, " : "",
+ (state & I810_UPLOAD_CTX) ? "upload-ctx, " : "",
+ (state & I810_UPLOAD_BUFFERS) ? "upload-bufs, " : ""
+ );
}
-void i810DDInitState( i810ContextPtr imesa )
+void i810InitState( GLcontext *ctx )
{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
i810ScreenPrivate *i810Screen = imesa->i810Screen;
memset(imesa->Setup, 0, sizeof(imesa->Setup));
- imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0;
+ imesa->Setup[I810_CTXREG_VF] = 0;
imesa->Setup[I810_CTXREG_MT] = (GFX_OP_MAP_TEXELS |
MT_UPDATE_TEXEL1_STATE |
@@ -777,7 +705,7 @@ void i810DDInitState( i810ContextPtr imesa )
MC_UPDATE_DEST |
MC_DEST_CURRENT |
MC_UPDATE_ARG1 |
- MC_ARG1_ITERATED_COLOR |
+ MC_ARG1_ITERATED_COLOR |
MC_ARG1_DONT_REPLICATE_ALPHA |
MC_ARG1_DONT_INVERT |
MC_UPDATE_ARG2 |
@@ -786,13 +714,13 @@ void i810DDInitState( i810ContextPtr imesa )
MC_ARG2_DONT_INVERT |
MC_UPDATE_OP |
MC_OP_ARG1 );
-
+
imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
MC_STAGE_1 |
MC_UPDATE_DEST |
MC_DEST_CURRENT |
MC_UPDATE_ARG1 |
- MC_ARG1_ONE |
+ MC_ARG1_ONE |
MC_ARG1_DONT_REPLICATE_ALPHA |
MC_ARG1_DONT_INVERT |
MC_UPDATE_ARG2 |
@@ -801,14 +729,14 @@ void i810DDInitState( i810ContextPtr imesa )
MC_ARG2_DONT_INVERT |
MC_UPDATE_OP |
MC_OP_DISABLE );
-
+
imesa->Setup[I810_CTXREG_MC2] = ( GFX_OP_MAP_COLOR_STAGES |
MC_STAGE_2 |
MC_UPDATE_DEST |
MC_DEST_CURRENT |
MC_UPDATE_ARG1 |
- MC_ARG1_CURRENT_COLOR |
+ MC_ARG1_CURRENT_COLOR |
MC_ARG1_REPLICATE_ALPHA |
MC_ARG1_DONT_INVERT |
MC_UPDATE_ARG2 |
@@ -817,12 +745,12 @@ void i810DDInitState( i810ContextPtr imesa )
MC_ARG2_DONT_INVERT |
MC_UPDATE_OP |
MC_OP_DISABLE );
-
+
imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
MA_STAGE_0 |
MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
+ MA_ARG1_ITERATED_ALPHA |
MA_ARG1_DONT_INVERT |
MA_UPDATE_ARG2 |
MA_ARG2_CURRENT_ALPHA |
@@ -858,7 +786,7 @@ void i810DDInitState( i810ContextPtr imesa )
imesa->Setup[I810_CTXREG_SDM] = ( GFX_OP_SRC_DEST_MONO |
SDM_UPDATE_MONO_ENABLE |
0 |
- SDM_UPDATE_SRC_BLEND |
+ SDM_UPDATE_SRC_BLEND |
SDM_SRC_ONE |
SDM_UPDATE_DST_BLEND |
SDM_DST_ZERO );
@@ -876,7 +804,7 @@ void i810DDInitState( i810ContextPtr imesa )
ZA_UPDATE_ALPHAREF |
0x0);
- imesa->Setup[I810_CTXREG_FOG] = (GFX_OP_FOG_COLOR |
+ imesa->Setup[I810_CTXREG_FOG] = (GFX_OP_FOG_COLOR |
(0xffffff & ~FOG_RESERVED_MASK));
/* Choose a pipe
@@ -936,16 +864,18 @@ void i810DDInitState( i810ContextPtr imesa )
LCS_CULL_DISABLE);
imesa->LcsCullMode = LCS_CULL_CW;
-
+ imesa->LcsLineWidth = LCS_LINEWIDTH_1_0;
+ imesa->LcsPointSize = LCS_LINEWIDTH_1_0;
+
imesa->Setup[I810_CTXREG_PV] = ( GFX_OP_PV_RULE |
PV_UPDATE_PIXRULE |
PV_PIXRULE_ENABLE |
PV_UPDATE_LINELIST |
- PV_LINELIST_PV0 |
+ PV_LINELIST_PV1 |
PV_UPDATE_TRIFAN |
- PV_TRIFAN_PV0 |
+ PV_TRIFAN_PV2 |
PV_UPDATE_TRISTRIP |
- PV_TRISTRIP_PV0 );
+ PV_TRISTRIP_PV2 );
imesa->Setup[I810_CTXREG_ST0] = GFX_OP_STIPPLE;
@@ -953,7 +883,7 @@ void i810DDInitState( i810ContextPtr imesa )
imesa->Setup[I810_CTXREG_AA] = ( GFX_OP_ANTIALIAS |
AA_UPDATE_EDGEFLAG |
- AA_ENABLE_EDGEFLAG | /* ? */
+ 0 |
AA_UPDATE_POLYWIDTH |
AA_POLYWIDTH_05 |
AA_UPDATE_LINEWIDTH |
@@ -969,12 +899,12 @@ void i810DDInitState( i810ContextPtr imesa )
if (imesa->glCtx->Color.DriverDrawBuffer == GL_BACK_LEFT) {
imesa->drawMap = i810Screen->back.map;
imesa->readMap = i810Screen->back.map;
- imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset |
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset |
i810Screen->backPitchBits);
} else {
imesa->drawMap = (char *)imesa->driScreen->pFB;
imesa->readMap = (char *)imesa->driScreen->pFB;
- imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset |
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset |
i810Screen->backPitchBits);
}
@@ -988,77 +918,66 @@ void i810DDInitState( i810ContextPtr imesa )
}
-#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
- NEW_TEXTURE_MATRIX|\
- NEW_USER_CLIP|NEW_CLIENT_STATE))
-
-
-void i810DDUpdateState( GLcontext *ctx )
+static void i810InvalidateState( GLcontext *ctx, GLuint new_state )
{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
-
- /* Have to do this here to detect texture fallbacks in time:
- */
- if (I810_CONTEXT(ctx)->new_state & I810_NEW_TEXTURE)
- i810DDUpdateHwState( ctx );
-
-
- if (ctx->NewState & INTERESTED) {
- i810DDChooseRenderState(ctx);
- i810ChooseRasterSetupFunc(ctx);
- }
-
- if (0)
- fprintf(stderr, "IndirectTriangles %x Fallback %x\n",
- imesa->IndirectTriangles, imesa->Fallback);
-
- if (!imesa->Fallback)
- {
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
- ctx->IndirectTriangles |= imesa->IndirectTriangles;
-
- ctx->Driver.PointsFunc=imesa->PointsFunc;
- ctx->Driver.LineFunc=imesa->LineFunc;
- ctx->Driver.TriangleFunc=imesa->TriangleFunc;
- ctx->Driver.QuadFunc=imesa->QuadFunc;
- }
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ I810_CONTEXT(ctx)->new_state |= new_state;
}
-void i810DDInitStateFuncs(GLcontext *ctx)
+void i810InitStateFuncs(GLcontext *ctx)
{
- ctx->Driver.UpdateState = i810DDUpdateState;
- ctx->Driver.Enable = i810DDEnable;
- ctx->Driver.AlphaFunc = i810DDAlphaFunc;
- ctx->Driver.BlendEquation = i810DDBlendEquation;
- ctx->Driver.BlendFunc = i810DDBlendFunc;
- ctx->Driver.BlendFuncSeparate = i810DDBlendFuncSeparate;
- ctx->Driver.DepthFunc = i810DDDepthFunc;
- ctx->Driver.DepthMask = i810DDDepthMask;
- ctx->Driver.Fogfv = i810DDFogfv;
- ctx->Driver.Scissor = i810DDScissor;
- ctx->Driver.CullFace = i810DDCullFaceFrontFace;
- ctx->Driver.FrontFace = i810DDCullFaceFrontFace;
- ctx->Driver.ColorMask = i810DDColorMask;
- ctx->Driver.ReducedPrimitiveChange = i810DDReducedPrimitiveChange;
- ctx->Driver.RenderStart = i810DDUpdateHwState;
- ctx->Driver.RenderFinish = 0;
- ctx->Driver.PolygonStipple = i810DDPolygonStipple;
- ctx->Driver.LineStipple = 0;
- ctx->Driver.LineWidth = i810DDLineWidth;
- ctx->Driver.LogicOpcode = i810DDLogicOp;
- ctx->Driver.SetReadBuffer = i810DDSetReadBuffer;
- ctx->Driver.SetDrawBuffer = i810DDSetDrawBuffer;
- ctx->Driver.Color = i810DDSetColor;
- ctx->Driver.ClearColor = i810DDClearColor;
- ctx->Driver.Dither = i810DDDither;
- ctx->Driver.Index = 0;
- ctx->Driver.ClearIndex = 0;
- ctx->Driver.IndexMask = 0;
+ /* Callbacks for internal Mesa events.
+ */
+ ctx->Driver.UpdateState = i810InvalidateState;
+
+ /* API callbacks
+ */
+ ctx->Driver.AlphaFunc = i810AlphaFunc;
+ ctx->Driver.BlendEquation = i810BlendEquation;
+ ctx->Driver.BlendFunc = i810BlendFunc;
+ ctx->Driver.BlendFuncSeparate = i810BlendFuncSeparate;
+ ctx->Driver.ClearColor = i810ClearColor;
+ ctx->Driver.ColorMask = i810ColorMask;
+ ctx->Driver.CullFace = i810CullFaceFrontFace;
+ ctx->Driver.DepthFunc = i810DepthFunc;
+ ctx->Driver.DepthMask = i810DepthMask;
+ ctx->Driver.Enable = i810Enable;
+ ctx->Driver.Fogfv = i810Fogfv;
+ ctx->Driver.FrontFace = i810CullFaceFrontFace;
+ ctx->Driver.LineWidth = i810LineWidth;
+ ctx->Driver.LogicOpcode = i810LogicOp;
+ ctx->Driver.PolygonStipple = i810PolygonStipple;
+ ctx->Driver.RenderMode = i810RenderMode;
+ ctx->Driver.Scissor = i810Scissor;
+ ctx->Driver.SetDrawBuffer = i810SetDrawBuffer;
+ ctx->Driver.ShadeModel = i810ShadeModel;
+ ctx->Driver.DepthRange = i810DepthRange;
+ ctx->Driver.Viewport = i810Viewport;
+ ctx->Driver.PointSize = i810PointSize;
if (IS_I815(I810_CONTEXT(ctx))) {
- ctx->Driver.LightModelfv = i810DDLightModelfv_i815;
+ ctx->Driver.LightModelfv = i810LightModelfv_i815;
} else {
- ctx->Driver.LightModelfv = i810DDLightModelfv;
+ ctx->Driver.LightModelfv = i810LightModelfv;
}
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810state.h b/xc/lib/GL/mesa/src/drv/i810/i810state.h
index b43a1a4ff..673747718 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810state.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810state.h
@@ -3,10 +3,12 @@
#include "i810context.h"
-extern void i810DDUpdateHwState( GLcontext *ctx );
-extern void i810DDUpdateState( GLcontext *ctx );
-extern void i810DDInitState( i810ContextPtr imesa );
-extern void i810DDInitStateFuncs( GLcontext *ctx );
+extern void i810InitState( GLcontext *ctx );
+extern void i810InitStateFuncs( GLcontext *ctx );
+extern void i810PrintDirty( const char *msg, GLuint state );
+
+extern void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) i810Fallback( imesa, bit, mode )
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.c b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
index e7634ec00..e54e7bf97 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tex.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.c
@@ -26,1405 +26,401 @@
#include <stdlib.h>
#include <stdio.h>
-#include <GL/gl.h>
+#include "glheader.h"
+#include "mtypes.h"
+#include "mem.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "swrast/swrast.h"
#include "mm.h"
#include "i810context.h"
#include "i810tex.h"
-#include "i810log.h"
+#include "i810state.h"
#include "i810ioctl.h"
-#include "simple_list.h"
-#include "enums.h"
-static void i810SetTexWrapping(i810TextureObjectPtr tex, GLenum s, GLenum t)
+
+/*
+ * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
+ */
+static GLuint i810ComputeLodBias(GLfloat bias)
+{
+ int b = (int) (bias * 16.0) + 12;
+ if (b > 63)
+ b = 63;
+ else if (b < -64)
+ b = -64;
+ return (GLuint) (b & MLC_LOD_BIAS_MASK);
+}
+
+
+static void i810SetTexWrapping(i810TextureObjectPtr t,
+ GLenum wraps, GLenum wrapt)
{
- unsigned int val = tex->Setup[I810_TEXREG_MCS];
+ t->Setup[I810_TEXREG_MCS] &= ~(MCS_U_STATE_MASK| MCS_V_STATE_MASK);
+ t->Setup[I810_TEXREG_MCS] |= (MCS_U_WRAP|MCS_V_WRAP);
- val &= ~(MCS_U_STATE_MASK|MCS_V_STATE_MASK);
- val |= (MCS_U_WRAP|MCS_V_WRAP);
-
- if (s != GL_REPEAT)
- val ^= (MCS_U_WRAP^MCS_U_CLAMP);
+ if (wraps != GL_REPEAT)
+ t->Setup[I810_TEXREG_MCS] ^= (MCS_U_WRAP^MCS_U_CLAMP);
- if (t != GL_REPEAT)
- val ^= (MCS_V_WRAP^MCS_V_CLAMP);
+ if (wrapt != GL_REPEAT)
+ t->Setup[I810_TEXREG_MCS] ^= (MCS_V_WRAP^MCS_V_CLAMP);
- tex->Setup[I810_TEXREG_MCS] = val;
}
+
static void i810SetTexFilter(i810ContextPtr imesa,
i810TextureObjectPtr t,
- GLenum minf, GLenum magf)
+ GLenum minf, GLenum magf,
+ GLfloat bias)
{
- GLuint LastLevel;
+ t->Setup[I810_TEXREG_MF] &= ~(MF_MIN_MASK|
+ MF_MAG_MASK|
+ MF_MIP_MASK);
+ t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
switch (minf) {
case GL_NEAREST:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_NEAREST | MF_MIP_NONE);
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_NONE;
break;
case GL_LINEAR:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_LINEAR | MF_MIP_NONE);
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NONE;
break;
case GL_NEAREST_MIPMAP_NEAREST:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_NEAREST | MF_MIP_NEAREST);
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_NEAREST;
+ if (magf == GL_LINEAR) {
+ /*bias -= 0.5;*/ /* this doesn't work too good */
+ }
break;
case GL_LINEAR_MIPMAP_NEAREST:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_LINEAR | MF_MIP_NEAREST);
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
- /* This is quite a performance hit - may want to make this
- * choice user-configurable, otherwise the 815 may look slower
- * than the 810 (despite having much better image quality).
- */
- if (IS_I815(imesa)) {
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_NEAREST | MF_MIP_LINEAR );
- } else {
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_NEAREST | MF_MIP_DITHER );
+ if (IS_I815(imesa))
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_LINEAR;
+ else
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_DITHER;
+ /*
+ if (magf == GL_LINEAR) {
+ bias -= 0.5;
}
+ */
+ bias -= 0.5; /* always biasing here looks better */
break;
case GL_LINEAR_MIPMAP_LINEAR:
- if (IS_I815(imesa)) {
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_LINEAR | MF_MIP_LINEAR );
- } else {
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MIN_MASK | MF_MIP_MASK,
- MF_MIN_LINEAR | MF_MIP_DITHER );
- }
+ if (IS_I815(imesa))
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_LINEAR;
+ else
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_DITHER;
break;
default:
- i810Error("i810SetTexFilter(): not supported min. filter %d\n",(int)minf);
- break;
+ return;
}
switch (magf) {
- case GL_NEAREST:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MAG_MASK,MF_MAG_NEAREST);
- break;
- case GL_LINEAR:
- I810_SET_FIELD(t->Setup[I810_TEXREG_MF],
- MF_MAG_MASK,MF_MAG_LINEAR);
- break;
- default:
- i810Error("i810SetTexFilter(): not supported mag. filter %d\n",(int)magf);
- break;
- }
-
- if (t->globj->MinFilter != GL_NEAREST &&
- t->globj->MinFilter != GL_LINEAR) {
- LastLevel = t->max_level;
- } else {
- LastLevel = t->min_level;
- }
-
- I810_SET_FIELD(t->Setup[I810_TEXREG_MLL],
- MLL_MAX_MIP_MASK,
- (t->min_level << (MLL_MAX_MIP_SHIFT+4)));
-
- I810_SET_FIELD(t->Setup[I810_TEXREG_MLL],
- MLL_MIN_MIP_MASK,
- (LastLevel << MLL_MIN_MIP_SHIFT));
-
- /* See OpenGL 1.2 specification */
- if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
- minf == GL_NEAREST_MIPMAP_LINEAR))
- {
- /* c = 0.5 */
- I810_SET_FIELD(t->Setup[I810_TEXREG_MLC],
- MLC_LOD_BIAS_MASK,
- 0x10);
- } else {
- /* c = 0 */
- I810_SET_FIELD(t->Setup[I810_TEXREG_MLC],
- MLC_LOD_BIAS_MASK,
- 0x0);
- }
-}
-
-
-/* Need a fallback ?
- */
-static void i810SetTexBorderColor(i810TextureObjectPtr t, GLubyte color[4])
-{
-/* t->Setup[I810_TEXREG_TEXBORDERCOL] = */
-/* I810PACKCOLOR8888(color[0],color[1],color[2],color[3]); */
-}
-
-
-
-static void ReplicateMesaTexState(i810ContextPtr imesa,
- i810TextureObjectPtr t,
- struct gl_texture_object *mesatex)
-{
- i810SetTexWrapping(t,mesatex->WrapS,mesatex->WrapT);
- i810SetTexFilter(imesa, t,mesatex->MinFilter,mesatex->MagFilter);
- i810SetTexBorderColor(t,mesatex->BorderColor);
-}
-
-static i810TextureObjectPtr i810CreateTexObj(i810ContextPtr imesa,
- struct gl_texture_object *tObj)
-{
- i810TextureObjectPtr t;
- GLuint height, width, pitch, i, textureFormat, log_pitch;
- struct gl_texture_image *image;
-
- image = tObj->Image[ 0 ];
- if ( !image ) {
- fprintf(stderr, "no image at level zero - not creating texobj\n");
- return 0;
- }
-
- t = (i810TextureObjectPtr) calloc(1,sizeof(*t));
- if (!t)
- return 0;
-
- switch( image->Format ) {
- case GL_RGB:
- case GL_LUMINANCE:
- t->texelBytes = 2;
- textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565;
+ case GL_NEAREST:
+ t->Setup[I810_TEXREG_MF] |= MF_MAG_NEAREST;
break;
- case GL_ALPHA:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- case GL_RGBA:
- t->texelBytes = 2;
- textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB4444;
+ case GL_LINEAR:
+ t->Setup[I810_TEXREG_MF] |= MF_MAG_LINEAR;
break;
- case GL_COLOR_INDEX:
- textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
- t->texelBytes = 1;
- break;
- default:
- i810Error( "i810CreateTexObj: bad image->Format\n" );
- free( t );
- return 0;
- }
-
-
- /* Figure out the size now (and count the levels). Upload won't be done
- * until later.
- */
- width = image->Width * t->texelBytes;
- for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
- log_pitch++;
-
- t->dirty_images = 0;
- t->bound = 0;
-
- for ( height = i = 0 ; i < I810_TEX_MAXLEVELS && tObj->Image[i] ; i++ ) {
- t->image[i].image = tObj->Image[i];
- t->image[i].offset = height * pitch;
- t->image[i].internalFormat = image->Format;
- t->dirty_images |= (1<<i);
- height += t->image[i].image->Height;
- }
-
- t->Pitch = pitch;
- t->totalSize = height*pitch;
- t->max_level = i-1;
- t->min_level = 0;
- t->globj = tObj;
- t->age = 0;
-
- t->Setup[I810_TEXREG_MI0] = GFX_OP_MAP_INFO;
-
- t->Setup[I810_TEXREG_MI1] = (MI1_MAP_0 |
- textureFormat |
- log_pitch);
-
- t->Setup[I810_TEXREG_MI2] = (MI2_DIMENSIONS_ARE_LOG2 |
- (image->HeightLog2 << 16) |
- (image->WidthLog2));
-
- t->Setup[I810_TEXREG_MI3] = 0;
-
- t->Setup[I810_TEXREG_MLC] = (GFX_OP_MAP_LOD_CTL |
- MLC_MAP_0 |
- MLC_DITHER_WEIGHT_FULL |
- MLC_UPDATE_LOD_BIAS |
- 0x0);
-
- t->Setup[I810_TEXREG_MLL] = (GFX_OP_MAP_LOD_LIMITS |
- MLL_MAP_0 |
- MLL_UPDATE_MAX_MIP |
- (t->min_level << MLL_MAX_MIP_SHIFT) |
- MLL_UPDATE_MIN_MIP |
- t->max_level);
-
- /* I think this is context state, really.
- */
- t->Setup[I810_TEXREG_MCS] = (GFX_OP_MAP_COORD_SETS |
- MCS_COORD_0 |
- MCS_UPDATE_NORMALIZED |
- MCS_NORMALIZED_COORDS |
- MCS_UPDATE_V_STATE |
- MCS_V_WRAP |
- MCS_UPDATE_U_STATE |
- MCS_U_WRAP);
-
- t->Setup[I810_TEXREG_MF] = (GFX_OP_MAP_FILTER |
- MF_MAP_0 |
- MF_UPDATE_ANISOTROPIC |
- 0 |
- MF_UPDATE_MIP_FILTER |
- MF_MIP_NEAREST |
- MF_UPDATE_MAG_FILTER |
- MF_MAG_NEAREST |
- MF_UPDATE_MIN_FILTER |
- MF_MIN_NEAREST);
-
- t->current_unit = 0;
-
- ReplicateMesaTexState(imesa, t,tObj);
- tObj->DriverData = t;
- imesa->dirty |= I810_UPLOAD_CTX;
- make_empty_list( t );
- return t;
-}
-
-void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
-{
- if (!t) return;
-
- /* This is sad - need to sync *in case* we upload a texture
- * to this newly free memory...
- */
- if (t->MemBlock) {
- mmFreeMem(t->MemBlock);
- t->MemBlock = 0;
-
- if (t->age > imesa->dirtyAge)
- imesa->dirtyAge = t->age;
- }
-
- if (t->globj)
- t->globj->DriverData = 0;
-
- if (t->bound)
- imesa->CurrentTexObj[t->bound - 1] = 0;
-
- remove_from_list(t);
- free(t);
-}
-
-
-static void i810SwapOutTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
-{
- if (t->MemBlock) {
- mmFreeMem(t->MemBlock);
- t->MemBlock = 0;
-
- if (t->age > imesa->dirtyAge)
- imesa->dirtyAge = t->age;
- }
-
- t->dirty_images = ~0;
- move_to_tail(&(imesa->SwappedOut), t);
-}
-
-
-
-/* Upload an image from mesa's internal copy.
- */
-static void i810UploadTexLevel( i810TextureObjectPtr t, int level )
-{
- const struct gl_texture_image *image = t->image[level].image;
- int i,j;
-
- if (I810_DEBUG & DEBUG_VERBOSE_LRU)
- fprintf(stderr, "i810UploadTexLevel %d, BufAddr %p offset %x\n",
- level, t->BufAddr, t->image[level].offset);
-
- /* Need triangle (rather than pixel) fallbacks to simulate this using
- * normal textured triangles.
- *
- * DO THIS IN DRIVER STATE MANAGMENT, not hardware state.
- *
- if (image->Border != 0)
- i810Error("Not supported texture border %d.\n", (int) image->Border);
- */
-
- switch (t->image[level].internalFormat) {
- case GL_RGB:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR565(src[0],src[1],src[2]);
- src += 3;
- }
- }
- }
- break;
-
- case GL_RGBA:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR4444(src[0],src[1],src[2],src[3]);
- src += 4;
- }
- }
- }
- break;
-
- case GL_LUMINANCE:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR565(src[0],src[0],src[0]);
- src ++;
- }
- }
- }
- break;
-
- case GL_INTENSITY:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
- int i;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR4444(src[0],src[0],src[0],src[0]);
- src ++;
- }
- }
- }
- break;
-
- case GL_LUMINANCE_ALPHA:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR4444(src[0],src[0],src[0],src[1]);
- src += 2;
- }
- }
- }
- break;
-
- case GL_ALPHA:
- {
- GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = I810PACKCOLOR4444(255,255,255,src[0]);
- src += 1;
- }
- }
- }
- break;
-
- /* TODO: Translate color indices *now*:
- */
- case GL_COLOR_INDEX:
- {
- GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
- GLubyte *src = (GLubyte *)image->Data;
-
- for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
- for (i = 0 ; i < image->Width ; i++) {
- dst[i] = src[0];
- src += 1;
- }
- }
- }
- break;
-
- default:
- i810Error("Not supported texture format %s\n",
- gl_lookup_enum_by_nr(image->Format));
- }
-}
-
-
-
-void i810PrintLocalLRU( i810ContextPtr imesa )
-{
- i810TextureObjectPtr t;
- int sz = 1 << (imesa->i810Screen->logTextureGranularity);
-
- foreach( t, &imesa->TexObjList ) {
- if (!t->globj)
- fprintf(stderr, "Placeholder %d at %x sz %x\n",
- t->MemBlock->ofs / sz,
- t->MemBlock->ofs,
- t->MemBlock->size);
- else
- fprintf(stderr, "Texture (bound %d) at %x sz %x\n",
- t->bound,
- t->MemBlock->ofs,
- t->MemBlock->size);
-
- }
-}
-
-void i810PrintGlobalLRU( i810ContextPtr imesa )
-{
- int i, j;
- drm_i810_tex_region_t *list = imesa->sarea->texList;
-
- for (i = 0, j = I810_NR_TEX_REGIONS ; i < I810_NR_TEX_REGIONS ; i++) {
- fprintf(stderr, "list[%d] age %d next %d prev %d\n",
- j, list[j].age, list[j].next, list[j].prev);
- j = list[j].next;
- if (j == I810_NR_TEX_REGIONS) break;
- }
-
- if (j != I810_NR_TEX_REGIONS)
- fprintf(stderr, "Loop detected in global LRU\n");
-}
-
-
-void i810ResetGlobalLRU( i810ContextPtr imesa )
-{
- drm_i810_tex_region_t *list = imesa->sarea->texList;
- int sz = 1 << imesa->i810Screen->logTextureGranularity;
- int i;
-
- /* (Re)initialize the global circular LRU list. The last element
- * in the array (I810_NR_TEX_REGIONS) is the sentinal. Keeping it
- * at the end of the array allows it to be addressed rationally
- * when looking up objects at a particular location in texture
- * memory.
- */
- for (i = 0 ; (i+1) * sz <= imesa->i810Screen->textureSize ; i++) {
- list[i].prev = i-1;
- list[i].next = i+1;
- list[i].age = 0;
+ default:
+ return;
}
- i--;
- list[0].prev = I810_NR_TEX_REGIONS;
- list[i].prev = i-1;
- list[i].next = I810_NR_TEX_REGIONS;
- list[I810_NR_TEX_REGIONS].prev = i;
- list[I810_NR_TEX_REGIONS].next = 0;
- imesa->sarea->texAge = 0;
+ t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(bias);
}
-static void i810UpdateTexLRU( i810ContextPtr imesa, i810TextureObjectPtr t )
+static void i810SetTexBorderColor(i810TextureObjectPtr t,
+ GLubyte color[4])
{
- int i;
- int logsz = imesa->i810Screen->logTextureGranularity;
- int start = t->MemBlock->ofs >> logsz;
- int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
- drm_i810_tex_region_t *list = imesa->sarea->texList;
-
- imesa->texAge = ++imesa->sarea->texAge;
-
- /* Update our local LRU
- */
- move_to_head( &(imesa->TexObjList), t );
-
- /* Update the global LRU
+ /* Need a fallback.
*/
- for (i = start ; i <= end ; i++) {
-
- list[i].in_use = 1;
- list[i].age = imesa->texAge;
-
- /* remove_from_list(i)
- */
- list[(unsigned)list[i].next].prev = list[i].prev;
- list[(unsigned)list[i].prev].next = list[i].next;
-
- /* insert_at_head(list, i)
- */
- list[i].prev = I810_NR_TEX_REGIONS;
- list[i].next = list[I810_NR_TEX_REGIONS].next;
- list[(unsigned)list[I810_NR_TEX_REGIONS].next].prev = i;
- list[I810_NR_TEX_REGIONS].next = i;
- }
-}
-
-
-/* Called for every shared texture region which has increased in age
- * since we last held the lock.
- *
- * Figures out which of our textures have been ejected by other clients,
- * and pushes a placeholder texture onto the LRU list to represent
- * the other client's textures.
- */
-void i810TexturesGone( i810ContextPtr imesa,
- GLuint offset,
- GLuint size,
- GLuint in_use )
-{
- i810TextureObjectPtr t, tmp;
-
- foreach_s ( t, tmp, &imesa->TexObjList ) {
-
- if (t->MemBlock->ofs >= offset + size ||
- t->MemBlock->ofs + t->MemBlock->size <= offset)
- continue;
-
- /* It overlaps - kick it off. Need to hold onto the currently bound
- * objects, however.
- */
- if (t->bound)
- i810SwapOutTexObj( imesa, t );
- else
- i810DestroyTexObj( imesa, t );
- }
-
-
- if (in_use) {
- t = (i810TextureObjectPtr) calloc(1,sizeof(*t));
- if (!t) return;
-
- t->MemBlock = mmAllocMem( imesa->texHeap, size, 0, offset);
- insert_at_head( &imesa->TexObjList, t );
- }
}
-
-
-
-/* This is called with the lock held. May have to eject our own and/or
- * other client's texture objects to make room for the upload.
- */
-int i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t )
-{
- int i;
- int ofs;
-
- /* Do we need to eject LRU texture objects?
- */
- if (!t->MemBlock) {
- while (1)
- {
- t->MemBlock = mmAllocMem( imesa->texHeap, t->totalSize, 12, 0 );
- if (t->MemBlock)
- break;
-
- if (imesa->TexObjList.prev->bound) {
- fprintf(stderr, "Hit bound texture in upload\n");
- i810PrintLocalLRU( imesa );
- return -1;
- }
-
- if (imesa->TexObjList.prev == &(imesa->TexObjList)) {
- fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
- mmDumpMemInfo( imesa->texHeap );
- return -1;
- }
-
- i810DestroyTexObj( imesa, imesa->TexObjList.prev );
- }
-
- ofs = t->MemBlock->ofs;
- t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;
- t->BufAddr = imesa->i810Screen->tex.map + ofs;
- imesa->dirty |= I810_UPLOAD_CTX;
- }
-
- /* Let the world know we've used this memory recently.
- */
- i810UpdateTexLRU( imesa, t );
-
- if (I810_DEBUG & DEBUG_VERBOSE_LRU)
- fprintf(stderr, "dispatch age: %d age freed memory: %d\n",
- GET_DISPATCH_AGE(imesa), imesa->dirtyAge);
-
- if (imesa->dirtyAge >= GET_DISPATCH_AGE(imesa))
- i810WaitAgeLocked( imesa, imesa->dirtyAge );
-
-
- if (t->dirty_images) {
- if (I810_DEBUG & DEBUG_VERBOSE_LRU)
- fprintf(stderr, "*");
-
- for (i = t->min_level ; i <= t->max_level ; i++)
- if (t->dirty_images & (1<<i))
- i810UploadTexLevel( t, i );
- }
-
-
- t->dirty_images = 0;
- return 0;
-}
-
-static void i810TexSetUnit( i810TextureObjectPtr t, GLuint unit )
-{
- if (t->current_unit == unit) return;
-
- t->Setup[I810_TEXREG_MI1] ^= (MI1_MAP_0 ^ MI1_MAP_1);
- t->Setup[I810_TEXREG_MLC] ^= (MLC_MAP_0 ^ MLC_MAP_1);
- t->Setup[I810_TEXREG_MLL] ^= (MLL_MAP_0 ^ MLL_MAP_1);
- t->Setup[I810_TEXREG_MCS] ^= (MCS_COORD_0 ^ MCS_COORD_1);
- t->Setup[I810_TEXREG_MF] ^= (MF_MAP_0 ^ MF_MAP_1);
-
- t->current_unit = unit;
-}
-
-
-
-
-static void i810UpdateTex0State( GLcontext *ctx )
+static void i810TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
{
i810ContextPtr imesa = I810_CONTEXT(ctx);
- struct gl_texture_object *tObj;
- i810TextureObjectPtr t;
- int ma_modulate_op;
- int format;
-
- /* disable */
- imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL0_ENABLE;
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_ITERATED_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_UPDATE_OP |
- MC_OP_ARG1 );
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
-
- if (ctx->Texture.Unit[0].ReallyEnabled == 0) {
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+ if (!t)
return;
- }
- tObj = ctx->Texture.Unit[0].Current;
- if (ctx->Texture.Unit[0].ReallyEnabled != TEXTURE0_2D ||
- tObj->Image[tObj->BaseLevel]->Border > 0) {
- /* 1D or 3D texturing enabled, or texture border - fallback */
- imesa->Fallback |= I810_FALLBACK_TEXTURE;
+ if ( target != GL_TEXTURE_2D )
return;
- }
-
- /* Do 2D texture setup */
-
- imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL0_ENABLE;
-
- t = tObj->DriverData;
- if (!t) {
- t = i810CreateTexObj( imesa, tObj );
- if (!t)
- return;
- }
- if (t->current_unit != 0)
- i810TexSetUnit( t, 0 );
-
- if (t->dirty_images)
- imesa->dirty |= I810_UPLOAD_TEX0IMAGE;
-
- imesa->CurrentTexObj[0] = t;
- t->bound = 1;
-
- if (t->MemBlock)
- i810UpdateTexLRU( imesa, t );
-
- format = t->image[0].internalFormat;
-
- switch (ctx->Texture.Unit[0].EnvMode) {
- case GL_REPLACE:
- if (format == GL_ALPHA)
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_ARG2 );
- else
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_UPDATE_OP |
- MC_OP_ARG1 );
-
- if (format == GL_RGB) {
- ma_modulate_op = MA_OP_ARG1;
- } else {
- ma_modulate_op = MA_OP_ARG2;
- }
-
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- ma_modulate_op );
- break;
- case GL_MODULATE:
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_MODULATE );
-
- if (format == GL_RGB) {
- ma_modulate_op = MA_OP_ARG1;
- } else {
- ma_modulate_op = MA_OP_MODULATE;
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting imesa->new_state means that
+ * i810UpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ i810SetTexFilter( imesa, t, tObj->MinFilter, tObj->MagFilter, bias );
}
-
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- MA_OP_MODULATE );
break;
- case GL_ADD:
- if (format == GL_ALPHA) {
- /* Cv = Cf */
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_ARG2 );
- }
- else {
- /* Cv = Cf + Ct */
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_ADD );
- }
-
- /* alpha */
- if (format == GL_ALPHA ||
- format == GL_LUMINANCE_ALPHA ||
- format == GL_RGBA) {
- /* Av = Af * At */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- MA_OP_MODULATE );
- }
- else if (format == GL_LUMINANCE || format == GL_RGB) {
- /* Av = Af */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
- }
- else {
- /* Av = Af + At */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX0_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ADD );
- }
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ i810SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
break;
-
- case GL_DECAL:
- if (format == GL_RGB) {
- /* C = Ct */
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_COLOR_FACTOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_TEX0_COLOR |
- MC_UPDATE_OP |
- MC_OP_ARG2 );
-
- } else {
- /* RGBA or undefined result */
- /* C = Cf*(1-At)+Ct*At */
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_LIN_BLEND_TEX0_ALPHA );
- }
-
- /* Av = Af */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
+
+ case GL_TEXTURE_BORDER_COLOR:
+ i810SetTexBorderColor( t, tObj->BorderColor );
break;
- case GL_BLEND:
- if (format == GL_ALPHA)
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX0_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_ARG2 );
- else
- imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_0 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_COLOR_FACTOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ITERATED_COLOR |
- MC_UPDATE_OP |
- MC_OP_LIN_BLEND_TEX0_COLOR );
- /* alpha */
- if (format == GL_LUMINANCE || format == GL_RGB) {
- /* Av = Af */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ITERATED_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
- }
- else if (format == GL_INTENSITY) {
- /* Av = Af(1-It)+AcIt */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ALPHA_FACTOR |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_LIN_BLEND_TEX0_ALPHA );
- } else {
- /* Av = AfAt */
- imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_0 |
- MA_UPDATE_ARG1 |
- MA_ARG1_TEX0_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_MODULATE );
- }
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Radeon. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ i810SwapOutTexObj( imesa, t );
break;
default:
- fprintf(stderr, "unknown tex env mode");
- exit(1);
- break;
- }
-}
-
-
-
-static void i810UpdateTex1State( GLcontext *ctx )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- struct gl_texture_object *tObj;
- i810TextureObjectPtr t;
- int ma_modulate_op, format;
-
- /* disable */
- imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL1_ENABLE;
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_ONE |
- MC_ARG1_DONT_REPLICATE_ALPHA |
- MC_ARG1_DONT_INVERT |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_ARG2_DONT_REPLICATE_ALPHA |
- MC_ARG2_DONT_INVERT |
- MC_UPDATE_OP |
- MC_OP_DISABLE );
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
- MA_ARG1_DONT_INVERT |
- MA_UPDATE_ARG2 |
- MA_ARG2_CURRENT_ALPHA |
- MA_ARG2_DONT_INVERT |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
-
- if (ctx->Texture.Unit[1].ReallyEnabled == 0) {
return;
}
- tObj = ctx->Texture.Unit[1].Current;
- if (ctx->Texture.Unit[1].ReallyEnabled != TEXTURE0_2D ||
- tObj->Image[tObj->BaseLevel]->Border > 0) {
- /* 1D or 3D texturing enabled, or texture border - fallback */
- imesa->Fallback |= I810_FALLBACK_TEXTURE;
- return;
+ if (t == imesa->CurrentTexObj[0]) {
+ I810_STATECHANGE( imesa, I810_UPLOAD_TEX0 );
}
- /* Do 2D texture setup */
-
- imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL1_ENABLE;
-
- t = tObj->DriverData;
- if (!t) {
- t = i810CreateTexObj( imesa, tObj );
- if (!t)
- return;
- }
-
- if (t->current_unit != 1)
- i810TexSetUnit( t, 1 );
-
- if (t->dirty_images)
- imesa->dirty |= I810_UPLOAD_TEX1IMAGE;
-
- imesa->CurrentTexObj[1] = t;
- t->bound = 2;
-
- if (t->MemBlock)
- i810UpdateTexLRU( imesa, t );
-
- format = t->image[0].internalFormat;
-
- switch (ctx->Texture.Unit[1].EnvMode) {
- case GL_REPLACE:
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX1_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_ONE |
- MC_UPDATE_OP |
- MC_OP_ARG1 );
-
- if (format == GL_RGB) {
- ma_modulate_op = MA_OP_ARG1;
- } else {
- ma_modulate_op = MA_OP_ARG2;
- }
-
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX1_ALPHA |
- MA_UPDATE_OP |
- ma_modulate_op );
- break;
- case GL_MODULATE:
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX1_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_CURRENT_COLOR |
- MC_UPDATE_OP |
- MC_OP_MODULATE );
-
- if (format == GL_RGB) {
- ma_modulate_op = MA_OP_ARG1;
- } else {
- ma_modulate_op = MA_OP_MODULATE;
- }
-
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX1_ALPHA |
- MA_UPDATE_OP |
- ma_modulate_op );
- break;
-
- case GL_ADD:
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_TEX1_COLOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_CURRENT_COLOR |
- MC_UPDATE_OP |
- MC_OP_ADD );
-
- if (format == GL_RGB) {
- ma_modulate_op = MA_OP_ARG1;
- } else {
- ma_modulate_op = MA_OP_ADD;
- }
-
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_CURRENT_ALPHA |
- MA_UPDATE_ARG2 |
- MA_ARG2_TEX1_ALPHA |
- MA_UPDATE_OP |
- ma_modulate_op );
- break;
-
-
- case GL_DECAL:
- if (format == GL_RGB) {
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_COLOR_FACTOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_TEX1_COLOR |
- MC_UPDATE_OP |
- MC_OP_ARG2 );
-
- } else {
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_COLOR_FACTOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_TEX1_COLOR |
- MC_UPDATE_OP |
- MC_OP_LIN_BLEND_TEX1_ALPHA );
- }
-
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ALPHA_FACTOR |
- MA_UPDATE_ARG2 |
- MA_ARG2_ALPHA_FACTOR |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
- break;
-
- case GL_BLEND:
- imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
- MC_STAGE_1 |
- MC_UPDATE_DEST |
- MC_DEST_CURRENT |
- MC_UPDATE_ARG1 |
- MC_ARG1_COLOR_FACTOR |
- MC_UPDATE_ARG2 |
- MC_ARG2_CURRENT_COLOR |
- MC_UPDATE_OP |
- MC_OP_LIN_BLEND_TEX1_COLOR );
-
- if (format == GL_RGB) {
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ALPHA_FACTOR |
- MA_UPDATE_ARG2 |
- MA_ARG2_CURRENT_ALPHA |
- MA_UPDATE_OP |
- MA_OP_ARG1 );
- } else {
- imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
- MA_STAGE_1 |
- MA_UPDATE_ARG1 |
- MA_ARG1_ALPHA_FACTOR |
- MA_UPDATE_ARG2 |
- MA_ARG2_ITERATED_ALPHA |
- MA_UPDATE_OP |
- MA_OP_LIN_BLEND_TEX1_ALPHA );
- }
- break;
-
- default:
- fprintf(stderr, "unkown tex 1 env mode\n");
- exit(1);
- break;
+ if (t == imesa->CurrentTexObj[1]) {
+ I810_STATECHANGE( imesa, I810_UPLOAD_TEX1 );
}
}
-void i810UpdateTextureState( GLcontext *ctx )
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound = 0;
- if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound = 0;
- imesa->CurrentTexObj[0] = 0;
- imesa->CurrentTexObj[1] = 0;
- imesa->Fallback &= ~I810_FALLBACK_TEXTURE;
- i810UpdateTex0State( ctx );
- i810UpdateTex1State( ctx );
- I810_CONTEXT( ctx )->dirty |= (I810_UPLOAD_CTX |
- I810_UPLOAD_TEX0 |
- I810_UPLOAD_TEX1);
-}
-
-
-
-/*****************************************
- * DRIVER functions
- *****************************************/
-
static void i810TexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
- if (pname == GL_TEXTURE_ENV_MODE) {
-
- FLUSH_BATCH(imesa);
- imesa->new_state |= I810_NEW_TEXTURE;
-
- } else if (pname == GL_TEXTURE_ENV_COLOR) {
-
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- const GLfloat *fc = texUnit->EnvColor;
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLfloat *fc = texUnit->EnvColor;
GLuint r, g, b, a, col;
- FLOAT_COLOR_TO_UBYTE_COLOR(r, fc[0]);
- FLOAT_COLOR_TO_UBYTE_COLOR(g, fc[1]);
- FLOAT_COLOR_TO_UBYTE_COLOR(b, fc[2]);
- FLOAT_COLOR_TO_UBYTE_COLOR(a, fc[3]);
+ CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
+ CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
col = ((a << 24) |
(r << 16) |
(g << 8) |
(b << 0));
-
+
if (imesa->Setup[I810_CTXREG_CF1] != col) {
- FLUSH_BATCH(imesa);
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
imesa->Setup[I810_CTXREG_CF1] = col;
- imesa->dirty |= I810_UPLOAD_CTX;
}
- }
-}
-
-static void i810TexImage( GLcontext *ctx,
- GLenum target,
- struct gl_texture_object *tObj,
- GLint level,
- GLint internalFormat,
- const struct gl_texture_image *image )
-{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- i810TextureObjectPtr t;
-
- if (target != GL_TEXTURE_2D)
- return;
+ break;
+ }
+ case GL_TEXTURE_ENV_MODE:
+ imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
- if (level >= I810_TEX_MAXLEVELS)
- return;
+ case GL_TEXTURE_LOD_BIAS_EXT:
+ {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+ t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
+ t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param);
+ }
+ break;
- t = (i810TextureObjectPtr) tObj->DriverData;
+ default:
+ break;
+ }
+}
+
+#if 0
+static void i810TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData;
if (t) {
- if (t->bound) FLUSH_BATCH(imesa);
- /* if this is the current object, it will force an update */
- i810DestroyTexObj( imesa, t );
- tObj->DriverData = 0;
- imesa->new_state |= I810_NEW_TEXTURE;
+ i810SwapOutTexObj( imesa, t );
}
}
-static void i810TexSubImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLint internalFormat,
- const struct gl_texture_image *image )
+static void i810TexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- i810TextureObjectPtr t;
+}
+#endif
- if ( target != GL_TEXTURE_2D )
- return;
-
- t = (i810TextureObjectPtr) tObj->DriverData;
+
+static void i810TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData;
if (t) {
- if (t->bound) FLUSH_BATCH( imesa );
- i810DestroyTexObj( imesa, t );
- tObj->DriverData = 0;
- imesa->new_state |= I810_NEW_TEXTURE;
+ i810SwapOutTexObj( I810_CONTEXT(ctx), t );
}
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
}
-static void i810TexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
+static void i810TexSubImage2D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
- i810ContextPtr imesa = I810_CONTEXT( ctx );
-
- if (!t || target != GL_TEXTURE_2D)
- return;
-
- switch (pname) {
- case GL_TEXTURE_MIN_FILTER:
- case GL_TEXTURE_MAG_FILTER:
- if (t->bound) FLUSH_BATCH( imesa );
- i810SetTexFilter(imesa, t,tObj->MinFilter,tObj->MagFilter);
- break;
-
- case GL_TEXTURE_WRAP_S:
- case GL_TEXTURE_WRAP_T:
- if (t->bound) FLUSH_BATCH( imesa );
- i810SetTexWrapping(t,tObj->WrapS,tObj->WrapT);
- break;
-
- case GL_TEXTURE_BORDER_COLOR:
- if (t->bound) FLUSH_BATCH( imesa );
- i810SetTexBorderColor(t,tObj->BorderColor);
- break;
-
- default:
- return;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData;
+ if (t) {
+ i810SwapOutTexObj( I810_CONTEXT(ctx), t );
}
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
- imesa->new_state |= I810_NEW_TEXTURE;
}
+
static void i810BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj )
{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
-
- FLUSH_BATCH(imesa);
-
- if (imesa->CurrentTexObj[ctx->Texture.CurrentUnit]) {
- imesa->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0;
- imesa->CurrentTexObj[ctx->Texture.CurrentUnit] = 0;
+ if (target == GL_TEXTURE_2D) {
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+
+ if (!t) {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ t = CALLOC_STRUCT(i810_texture_object_t);
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->globj = tObj;
+ t->Setup[I810_TEXREG_MI0] = GFX_OP_MAP_INFO;
+ t->Setup[I810_TEXREG_MI1] = MI1_MAP_0;
+ t->Setup[I810_TEXREG_MI2] = MI2_DIMENSIONS_ARE_LOG2;
+ t->Setup[I810_TEXREG_MLC] = (GFX_OP_MAP_LOD_CTL |
+ MLC_MAP_0 |
+ /*MLC_DITHER_WEIGHT_FULL |*/
+ MLC_DITHER_WEIGHT_12 |
+ MLC_UPDATE_LOD_BIAS |
+ 0x0);
+ t->Setup[I810_TEXREG_MCS] = (GFX_OP_MAP_COORD_SETS |
+ MCS_COORD_0 |
+ MCS_UPDATE_NORMALIZED |
+ MCS_NORMALIZED_COORDS |
+ MCS_UPDATE_V_STATE |
+ MCS_V_WRAP |
+ MCS_UPDATE_U_STATE |
+ MCS_U_WRAP);
+ t->Setup[I810_TEXREG_MF] = (GFX_OP_MAP_FILTER |
+ MF_MAP_0 |
+ MF_UPDATE_ANISOTROPIC |
+ MF_UPDATE_MIP_FILTER |
+ MF_UPDATE_MAG_FILTER |
+ MF_UPDATE_MIN_FILTER);
+
+ t->dirty_images = ~0;
+
+ tObj->DriverData = t;
+ make_empty_list( t );
+
+ i810SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ i810SetTexFilter( imesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ i810SetTexBorderColor( t, tObj->BorderColor );
+ }
}
-
- imesa->new_state |= I810_NEW_TEXTURE;
}
+
static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
{
i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData;
- i810ContextPtr imesa = I810_CONTEXT( ctx );
if (t) {
-
- if (t->bound) {
- FLUSH_BATCH(imesa);
- imesa->CurrentTexObj[t->bound-1] = 0;
- imesa->new_state |= I810_NEW_TEXTURE;
- }
-
- i810DestroyTexObj(imesa,t);
- tObj->DriverData=0;
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ if (imesa)
+ I810_FIREVERTICES( imesa );
+ i810DestroyTexObj( imesa, t );
+ tObj->DriverData = 0;
}
}
-
static GLboolean i810IsTextureResident( GLcontext *ctx,
- struct gl_texture_object *t )
+ struct gl_texture_object *tObj )
{
- i810TextureObjectPtr mt;
-
-/* LOCK_HARDWARE; */
- mt = (i810TextureObjectPtr)t->DriverData;
-/* UNLOCK_HARDWARE; */
-
- return mt && mt->MemBlock;
+ i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData;
+ return t && t->MemBlock;
}
-void i810DDInitTextureFuncs( GLcontext *ctx )
+void i810InitTextureFuncs( GLcontext *ctx )
{
ctx->Driver.TexEnv = i810TexEnv;
- ctx->Driver.TexImage = i810TexImage;
- ctx->Driver.TexSubImage = i810TexSubImage;
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = i810TexImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = i810TexSubImage2D;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
ctx->Driver.BindTexture = i810BindTexture;
ctx->Driver.DeleteTexture = i810DeleteTexture;
ctx->Driver.TexParameter = i810TexParameter;
ctx->Driver.UpdateTexturePalette = 0;
ctx->Driver.IsTextureResident = i810IsTextureResident;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
+ {
+ GLuint tmp = ctx->Texture.CurrentUnit;
+ ctx->Texture.CurrentUnit = 0;
+ i810BindTexture( ctx, GL_TEXTURE_2D, ctx->Texture.Unit[0].Current2D);
+ ctx->Texture.CurrentUnit = 1;
+ i810BindTexture( ctx, GL_TEXTURE_2D, ctx->Texture.Unit[1].Current2D);
+ ctx->Texture.CurrentUnit = tmp;
+ }
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tex.h b/xc/lib/GL/mesa/src/drv/i810/i810tex.h
index a16733ec1..be30ce233 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tex.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tex.h
@@ -26,14 +26,13 @@
#ifndef I810TEX_INC
#define I810TEX_INC
-#include "types.h"
+#include "mtypes.h"
#include "mmath.h"
#include "mm.h"
#include "i810context.h"
#include "i810_3d_reg.h"
-#define VALID_I810_TEXTURE_OBJECT(tobj) (tobj)
#define I810_TEX_MAXLEVELS 10
@@ -61,12 +60,10 @@ struct i810_texture_object_t {
int Height;
int texelBytes;
int totalSize;
- int bound;
PMemBlock MemBlock;
char *BufAddr;
- GLuint min_level;
GLuint max_level;
GLuint dirty_images;
@@ -77,22 +74,18 @@ struct i810_texture_object_t {
int internalFormat;
} image[I810_TEX_MAXLEVELS];
- /* Support for multitexture.
- */
- GLuint current_unit;
GLuint Setup[I810_TEX_SETUP_SIZE];
-};
+ GLuint dirty;
-#define I810_NO_PALETTE 0x0
-#define I810_USE_PALETTE 0x1
-#define I810_UPDATE_PALETTE 0x2
-#define I810_FALLBACK_PALETTE 0x4
+ GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
+};
void i810UpdateTextureState( GLcontext *ctx );
-void i810DDInitTextureFuncs( GLcontext *ctx );
+void i810InitTextureFuncs( GLcontext *ctx );
-void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t);
-int i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t );
+void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t );
+void i810SwapOutTexObj( i810ContextPtr imesa, i810TextureObjectPtr t );
+void i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t );
void i810ResetGlobalLRU( i810ContextPtr imesa );
void i810TexturesGone( i810ContextPtr imesa,
@@ -101,6 +94,7 @@ void i810TexturesGone( i810ContextPtr imesa,
void i810PrintLocalLRU( i810ContextPtr imesa );
void i810PrintGlobalLRU( i810ContextPtr imesa );
+void i810UpdateTexLRU( i810ContextPtr imesa, i810TextureObjectPtr t );
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810texmem.c b/xc/lib/GL/mesa/src/drv/i810/i810texmem.c
new file mode 100644
index 000000000..a4467ec3c
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810texmem.c
@@ -0,0 +1,410 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
+{
+ if (!t) return;
+
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (imesa && t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
+ }
+
+ if (t->globj)
+ t->globj->DriverData = 0;
+
+ if (imesa) {
+ if (imesa->CurrentTexObj[0] == t) {
+ imesa->CurrentTexObj[0] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX0;
+ }
+
+ if (imesa->CurrentTexObj[1] == t) {
+ imesa->CurrentTexObj[1] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX1;
+ }
+ }
+
+ remove_from_list(t);
+ free(t);
+}
+
+
+void i810SwapOutTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (t->age > imesa->dirtyAge)
+ imesa->dirtyAge = t->age;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail(&(imesa->SwappedOut), t);
+}
+
+
+
+/* Upload an image from mesa's internal copy.
+ */
+static void i810UploadTexLevel( i810TextureObjectPtr t, int level )
+{
+ const struct gl_texture_image *image = t->image[level].image;
+ int i,j;
+
+ switch (t->image[level].internalFormat) {
+ case GL_RGB:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_565( src[0], src[1], src[2] );
+ src += 3;
+ }
+ }
+ }
+ break;
+
+ case GL_RGBA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[3], src[0], src[1], src[2] );
+ src += 4;
+ }
+ }
+ }
+ break;
+
+ case GL_LUMINANCE:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_565( src[0], src[0], src[0] );
+ src ++;
+ }
+ }
+ }
+ break;
+
+ case GL_INTENSITY:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+ int i;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[0], src[0], src[0], src[0] );
+ src ++;
+ }
+ }
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[1], src[0], src[0], src[0] );
+ src += 2;
+ }
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = PACK_COLOR_4444( src[0], 255, 255, 255 );
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ /* TODO: Translate color indices *now*:
+ */
+ case GL_COLOR_INDEX:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = src[0];
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Not supported texture format %s\n",
+ _mesa_lookup_enum_by_nr(image->Format));
+ }
+}
+
+
+
+void i810PrintLocalLRU( i810ContextPtr imesa )
+{
+ i810TextureObjectPtr t;
+ int sz = 1 << (imesa->i810Screen->logTextureGranularity);
+
+ foreach( t, &imesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture at %x sz %x\n",
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void i810PrintGlobalLRU( i810ContextPtr imesa )
+{
+ int i, j;
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+
+ for (i = 0, j = I810_NR_TEX_REGIONS ; i < I810_NR_TEX_REGIONS ; i++) {
+ fprintf(stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev);
+ j = list[j].next;
+ if (j == I810_NR_TEX_REGIONS) break;
+ }
+
+ if (j != I810_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void i810ResetGlobalLRU( i810ContextPtr imesa )
+{
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+ int sz = 1 << imesa->i810Screen->logTextureGranularity;
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (I810_NR_TEX_REGIONS) is the sentinal. Keeping it
+ * at the end of the array allows it to be addressed rationally
+ * when looking up objects at a particular location in texture
+ * memory.
+ */
+ for (i = 0 ; (i+1) * sz <= imesa->i810Screen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = I810_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = I810_NR_TEX_REGIONS;
+ list[I810_NR_TEX_REGIONS].prev = i;
+ list[I810_NR_TEX_REGIONS].next = 0;
+ imesa->sarea->texAge = 0;
+}
+
+
+void i810UpdateTexLRU( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int logsz = imesa->i810Screen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ drm_i810_tex_region_t *list = imesa->sarea->texList;
+
+ imesa->texAge = ++imesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(imesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = imesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = I810_NR_TEX_REGIONS;
+ list[i].next = list[I810_NR_TEX_REGIONS].next;
+ list[(unsigned)list[I810_NR_TEX_REGIONS].next].prev = i;
+ list[I810_NR_TEX_REGIONS].next = i;
+ }
+}
+
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void i810TexturesGone( i810ContextPtr imesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ i810TextureObjectPtr t, tmp;
+
+ foreach_s ( t, tmp, &imesa->TexObjList ) {
+
+ if (t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it off. Need to hold onto the currently bound
+ * objects, however.
+ */
+ i810SwapOutTexObj( imesa, t );
+ }
+
+ if (in_use) {
+ t = (i810TextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( imesa->texHeap, size, 0, offset);
+ insert_at_head( &imesa->TexObjList, t );
+ }
+}
+
+
+
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+void i810UploadTexImages( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+
+ LOCK_HARDWARE( imesa );
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+ while (1)
+ {
+ t->MemBlock = mmAllocMem( imesa->texHeap, t->totalSize, 12, 0 );
+ if (t->MemBlock)
+ break;
+
+ if (imesa->TexObjList.prev == imesa->CurrentTexObj[0] ||
+ imesa->TexObjList.prev == imesa->CurrentTexObj[1]) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ i810PrintLocalLRU( imesa );
+ return;
+ }
+
+ if (imesa->TexObjList.prev == &(imesa->TexObjList)) {
+ fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ mmDumpMemInfo( imesa->texHeap );
+ return;
+ }
+
+ i810SwapOutTexObj( imesa, imesa->TexObjList.prev );
+ }
+
+ ofs = t->MemBlock->ofs;
+ t->BufAddr = imesa->i810Screen->tex.map + ofs;
+ t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;
+
+ if (t == imesa->CurrentTexObj[0])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX0);
+
+ if (t == imesa->CurrentTexObj[1])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX1);
+
+ i810UpdateTexLRU( imesa, t );
+ }
+
+ if (imesa->dirtyAge >= GET_DISPATCH_AGE(imesa))
+ i810WaitAgeLocked( imesa, imesa->dirtyAge );
+
+ numLevels = t->lastLevel - t->firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->dirty_images & (1<<i))
+ i810UploadTexLevel( t, i );
+
+ t->dirty_images = 0;
+
+ UNLOCK_HARDWARE( imesa );
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810texstate.c b/xc/lib/GL/mesa/src/drv/i810/i810texstate.c
new file mode 100644
index 000000000..2fdd336f6
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/i810/i810texstate.c
@@ -0,0 +1,754 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+
+
+static void i810SetTexImages( i810ContextPtr imesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint height, width, pitch, i, textureFormat, log_pitch;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+ GLint log2Width, log2Height;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ switch (baseImage->Format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ t->texelBytes = 2;
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565;
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ t->texelBytes = 2;
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB4444;
+ break;
+ case GL_COLOR_INDEX:
+ textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
+ t->texelBytes = 1;
+ break;
+ default:
+ fprintf(stderr, "i810SetTexImages: bad image->Format\n" );
+ return;
+ }
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
+ firstLevel = lastLevel = tObj->BaseLevel;
+ }
+ else {
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ log2Width = tObj->Image[firstLevel]->WidthLog2;
+ log2Height = tObj->Image[firstLevel]->HeightLog2;
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ width = tObj->Image[firstLevel]->Width * t->texelBytes;
+ for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
+ log_pitch++;
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[i].image = tObj->Image[firstLevel + i];
+ t->image[i].offset = height * pitch;
+ t->image[i].internalFormat = baseImage->Format;
+ height += t->image[i].image->Height;
+ }
+
+ t->Pitch = pitch;
+ t->totalSize = height*pitch;
+ t->max_level = i-1;
+ t->dirty = I810_UPLOAD_TEX0 | I810_UPLOAD_TEX1;
+ t->Setup[I810_TEXREG_MI1] = (MI1_MAP_0 | textureFormat | log_pitch);
+ t->Setup[I810_TEXREG_MI2] = (MI2_DIMENSIONS_ARE_LOG2 |
+ (log2Height << 16) | log2Width);
+ t->Setup[I810_TEXREG_MLL] = (GFX_OP_MAP_LOD_LIMITS |
+ MLL_MAP_0 |
+ MLL_UPDATE_MAX_MIP |
+ MLL_UPDATE_MIN_MIP |
+ ((numLevels - 1) << MLL_MIN_MIP_SHIFT));
+
+ i810UploadTexImages( imesa, t );
+}
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+#define I810_DISABLE 0
+#define I810_PASSTHRU 1
+#define I810_REPLACE 2
+#define I810_MODULATE 3
+#define I810_DECAL 4
+#define I810_BLEND 5
+#define I810_ALPHA_BLEND 6
+#define I810_ADD 7
+#define I810_MAX_COMBFUNC 8
+
+
+static GLuint i810_color_combine[][I810_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ), /* actually passthru */
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_TEX0_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_COLOR ),
+
+ /* GL_BLEND according to alpha
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_ADD ),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* Disable combiner stage (Note: disables all subsequent stages)
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ONE |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_DISABLE ),
+
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_CURRENT_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_TEX1_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_COLOR ),
+
+ /* GL_BLEND according to alpha
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_ADD ),
+ }
+};
+
+static GLuint i810_alpha_combine[][I810_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG2 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ALPHA_FACTOR |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_BLEND according to alpha (same as above)
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ADD ),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG2 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ALPHA_FACTOR |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_BLEND according to alpha (same as above)
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ADD ),
+ }
+
+};
+
+
+
+static void i810UpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLuint format = tObj->Image[tObj->BaseLevel]->Format;
+ GLuint color_combine, alpha_combine;
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ if (format == GL_ALPHA) {
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_REPLACE];
+ } else if (format == GL_LUMINANCE || format == GL_RGB) {
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ } else {
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_REPLACE];
+ }
+ break;
+
+ case GL_MODULATE:
+ if (format == GL_ALPHA) {
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ } else {
+ color_combine = i810_color_combine[unit][I810_MODULATE];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ }
+ break;
+
+ case GL_DECAL:
+ switch (format) {
+ case GL_RGBA:
+ color_combine = i810_color_combine[unit][I810_ALPHA_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGB:
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ switch (format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_ALPHA:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_BLEND];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_ADD:
+ switch (format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_ALPHA:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_ADD];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ if (alpha_combine != imesa->Setup[I810_CTXREG_MA0 + unit] ||
+ color_combine != imesa->Setup[I810_CTXREG_MC0 + unit])
+ {
+ I810_STATECHANGE( imesa, I810_UPLOAD_CTX );
+ imesa->Setup[I810_CTXREG_MA0 + unit] = alpha_combine;
+ imesa->Setup[I810_CTXREG_MC0 + unit] = color_combine;
+ }
+}
+
+
+
+
+static void i810UpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (texUnit->_ReallyEnabled == TEXTURE0_2D)
+ {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->dirty_images) {
+ I810_FIREVERTICES(imesa);
+ i810SetTexImages( imesa, tObj );
+ if (!t->MemBlock) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ }
+
+ if (tObj->Image[tObj->BaseLevel]->Border > 0) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (imesa->CurrentTexObj[unit] != t) {
+ I810_STATECHANGE(imesa, (I810_UPLOAD_TEX0<<unit));
+ imesa->CurrentTexObj[unit] = t;
+ i810UpdateTexLRU( imesa, t ); /* done too often */
+ }
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ */
+ if (tObj->Image[tObj->BaseLevel]->Format != imesa->TexEnvImageFmt[unit]) {
+ imesa->TexEnvImageFmt[unit] = tObj->Image[tObj->BaseLevel]->Format;
+ i810UpdateTexEnv( ctx, unit );
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else /*if (imesa->CurrentTexObj[unit])*/ {
+ imesa->CurrentTexObj[unit] = 0;
+ imesa->TexEnvImageFmt[unit] = 0;
+ imesa->dirty &= ~(I810_UPLOAD_TEX0<<unit);
+ imesa->Setup[I810_CTXREG_MA0 + unit] =
+ i810_alpha_combine[unit][I810_DISABLE];
+ imesa->Setup[I810_CTXREG_MC0 + unit] =
+ i810_color_combine[unit][I810_DISABLE];
+ I810_STATECHANGE( imesa, I810_UPLOAD_CTX );
+ }
+}
+
+
+void i810UpdateTextureState( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_FALSE );
+ i810UpdateTexUnit( ctx, 0 );
+ i810UpdateTexUnit( ctx, 1 );
+}
+
+
+
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
index e97e7e644..1fb67e0d5 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c
@@ -1,166 +1,804 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, California.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to 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.
+
+**************************************************************************/
+
/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.c,v 1.5 2000/09/24 13:51:04 alanh Exp $ */
#include <stdio.h>
#include <math.h>
-#include "types.h"
-#include "vb.h"
-#include "pipeline.h"
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
-#include "mm.h"
#include "i810tris.h"
+#include "i810state.h"
#include "i810vb.h"
-#include "i810log.h"
+#include "i810ioctl.h"
-/* Used in i810tritmp.h
- */
-#define I810_COLOR(to, from) { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
- (to)[3] = (from)[3]; \
+static void i810RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
+} while (0)
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
+} while (0)
+#endif
+
+static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1,
+ i810VertexPtr v2 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 3 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
}
-static triangle_func tri_tab[0x10];
-static quad_func quad_tab[0x10];
-static line_func line_tab[0x10];
-static points_func points_tab[0x10];
-#define IND (0)
+static void __inline__ i810_draw_quad( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1,
+ i810VertexPtr v2,
+ i810VertexPtr v3 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 6 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+
+
+static __inline__ void i810_draw_point( i810ContextPtr imesa,
+ i810VertexPtr tmp )
+{
+ GLfloat sz = imesa->glCtx->Point._Size * .5;
+ int vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize );
+ int j;
+
+ /* Draw a point as a horizontal line.
+ */
+ *(float *)&vb[0] = tmp->v.x - sz + 0.125;
+ for (j = 1 ; j < vertsize ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertsize;
+
+ *(float *)&vb[0] = tmp->v.x + sz + 0.125;
+ for (j = 1 ; j < vertsize ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertsize;
+}
+
+
+static __inline__ void i810_draw_line( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+}
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (0) fprintf(stderr, "hw TRI\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_tri( imesa, a, b, c ); \
+ else \
+ i810_draw_triangle( imesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (0) fprintf(stderr, "hw QUAD\n"); \
+ if (DO_FALLBACK) { \
+ imesa->draw_tri( imesa, a, b, d ); \
+ imesa->draw_tri( imesa, b, c, d ); \
+ } else \
+ i810_draw_quad( imesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (0) fprintf(stderr, "hw LINE\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_line( imesa, v0, v1 ); \
+ else \
+ i810_draw_line( imesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (0) fprintf(stderr, "hw POINT\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_point( imesa, v0 ); \
+ else \
+ i810_draw_point( imesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define I810_OFFSET_BIT 0x01
+#define I810_TWOSIDE_BIT 0x02
+#define I810_UNFILLED_BIT 0x04
+#define I810_FALLBACK_BIT 0x08
+#define I810_MAX_TRIFUNC 0x10
+
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[I810_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & I810_FALLBACK_BIT)
+#define DO_OFFSET (IND & I810_OFFSET_BIT)
+#define DO_UNFILLED (IND & I810_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & I810_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX i810Vertex
+#define TAB rast_tab
+
+/* Only used to pull back colors into vertices (ie, we know color is
+ * floating point).
+ */
+#define I810_COLOR( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+} while (0)
+
+#define I810_SPEC( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+} while (0)
+
+
+#define DEPTH_SCALE (1.0/0xffff)
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (imesa->verts + (e<<imesa->vertex_stride_shift))
+
+#define VERT_SET_RGBA( v, c ) I810_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) I810_SPEC( v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (imesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (imesa->vertex_size > 4); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PR_LINES,
+ PR_LINES,
+ PR_LINES,
+ PR_LINES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES
+};
+
+#define RASTERIZE(x) if (imesa->hw_primitive != hw_prim[x]) \
+ i810RasterPrimitive( ctx, x, hw_prim[x] )
+#define RENDER_PRIMITIVE imesa->render_primitive
#define TAG(x) x
-#include "i810tritmp.h"
+#define IND I810_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
-#define IND (I810_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "i810tritmp.h"
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
-#define IND (I810_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "i810tritmp.h"
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (I810_OFFSET_BIT|I810_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "i810tritmp.h"
+#define IND (I810_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (I810_TWOSIDE_BIT)
+#define IND (I810_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "i810tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "i810tritmp.h"
-
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT)
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT)
#define TAG(x) x##_twoside_offset
-#include "i810tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "i810tritmp.h"
+#define IND (I810_OFFSET_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (I810_TWOSIDE_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
-void i810DDTrifuncInit()
+#define IND (I810_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT|I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_UNFILLED_BIT| \
+ I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
{
init();
- init_flat();
init_offset();
- init_offset_flat();
init_twoside();
- init_twoside_flat();
init_twoside_offset();
- init_twoside_offset_flat();
-}
-
-
-
-#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL)
-#define POINT_FALLBACK (ALL_FALLBACK)
-#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_STIPPLE)
-#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_UNFILLED)
-#define ANY_FALLBACK (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
-#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET)
-
-void i810DDChooseRenderState(GLcontext *ctx)
-{
- i810ContextPtr imesa = I810_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
- CARD32 index = 0;
-
- if (imesa->Fallback) {
- imesa->renderindex = I810_FALLBACK_BIT;
- return;
- }
-
- if (flags & ANY_RASTER_FLAGS) {
- if (flags & DD_FLATSHADE) index |= I810_FLAT_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE) index |= I810_TWOSIDE_BIT;
- if (flags & DD_TRI_OFFSET) index |= I810_OFFSET_BIT;
- }
-
- imesa->PointsFunc = points_tab[index];
- imesa->LineFunc = line_tab[index];
- imesa->TriangleFunc = tri_tab[index];
- imesa->QuadFunc = quad_tab[index];
- imesa->renderindex = index;
- imesa->IndirectTriangles = 0;
-
- if (flags & ANY_FALLBACK) {
- if (flags & POINT_FALLBACK) {
- imesa->renderindex |= I810_FALLBACK_BIT;
- imesa->PointsFunc = 0;
- imesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- }
-
- if (flags & LINE_FALLBACK) {
- imesa->renderindex |= I810_FALLBACK_BIT;
- imesa->LineFunc = 0;
- imesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- }
-
- if (flags & TRI_FALLBACK) {
- imesa->renderindex |= I810_FALLBACK_BIT;
- imesa->TriangleFunc = 0;
- imesa->QuadFunc = 0;
- imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- }
- /* Special cases:
- */
- if ((flags & DD_TRI_STIPPLE) &&
- (ctx->IndirectTriangles & DD_TRI_STIPPLE)) {
- imesa->renderindex |= I810_FALLBACK_BIT;
- imesa->TriangleFunc = 0;
- imesa->QuadFunc = 0;
- imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- }
- }
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+i810_fallback_tri( i810ContextPtr imesa,
+ i810Vertex *v0,
+ i810Vertex *v1,
+ i810Vertex *v2 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[3];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ i810_translate_vertex( ctx, v1, &v[1] );
+ i810_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+i810_fallback_line( i810ContextPtr imesa,
+ i810Vertex *v0,
+ i810Vertex *v1 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[2];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ i810_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+i810_fallback_point( i810ContextPtr imesa,
+ i810Vertex *v0 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[1];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
}
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define IND 0
+#define V(x) (i810Vertex *)(vertptr + ((x)<<vertshift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) POINT( V(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) )
+#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
+#define INIT(x) i810RenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)imesa->verts; \
+ const GLuint vertshift = imesa->vertex_stride_shift; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) i810_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) i810_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void i810RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = imesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void i810RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void i810FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, (n-2) * 3 * 4 * vertsize );
+ GLubyte *vertptr = (GLubyte *)imesa->verts;
+ const GLuint vertshift = imesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)V(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, start );
+ COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, V(elts[i]) );
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+#define _I810_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+#define POINT_FALLBACK (0)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|\
+ DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void i810ChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= I810_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= I810_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= I810_UNFILLED_BIT;
+ }
+
+ imesa->draw_point = i810_draw_point;
+ imesa->draw_line = i810_draw_line;
+ imesa->draw_tri = i810_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ imesa->draw_point = i810_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ imesa->draw_line = i810_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ imesa->draw_tri = i810_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !imesa->stipple_in_hw)
+ imesa->draw_tri = i810_fallback_tri;
+
+ index |= I810_FALLBACK_BIT;
+ }
+ }
+
+ if (imesa->RenderIndex != index) {
+ imesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = i810_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = i810_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = i810FastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = i810RenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = i810RenderClippedPoly;
+ }
+ }
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in i810render.c.
+ */
+static void i810RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ imesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (imesa->reduced_primitive != rprim ||
+ hw_prim[prim] != imesa->hw_primitive) {
+ i810RasterPrimitive( ctx, rprim, hw_prim[prim] );
+ }
+}
+
+static void i810RunPipeline( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ if (imesa->new_state) {
+ if (imesa->new_state & _NEW_TEXTURE)
+ i810UpdateTextureState( ctx ); /* may modify imesa->new_state */
+
+ if (!imesa->Fallback) {
+ if (imesa->new_state & _I810_NEW_VERTEX)
+ i810ChooseVertexState( ctx );
+
+ if (imesa->new_state & _I810_NEW_RENDERSTATE)
+ i810ChooseRenderState( ctx );
+ }
+
+ imesa->new_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void i810RenderStart( GLcontext *ctx )
+{
+ /* Check for projective textureing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ i810CheckTexSizes( ctx );
+}
+
+static void i810RenderFinish( GLcontext *ctx )
+{
+ if (I810_CONTEXT(ctx)->RenderIndex & I810_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+
+/* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+void i810RasterPrimitive( GLcontext *ctx,
+ GLenum rprim,
+ GLuint hwprim )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint st1 = imesa->Setup[I810_CTXREG_ST1];
+ GLuint aa = imesa->Setup[I810_CTXREG_AA];
+ GLuint lcs = imesa->Setup[I810_CTXREG_LCS];
+
+ st1 &= ~ST1_ENABLE;
+ aa &= ~AA_ENABLE;
+
+ switch (rprim) {
+ case GL_TRIANGLES:
+ if (ctx->Polygon.StippleFlag)
+ st1 |= ST1_ENABLE;
+ if (ctx->Polygon.SmoothFlag)
+ aa |= AA_ENABLE;
+ break;
+ case GL_LINES:
+ lcs &= ~(LCS_LINEWIDTH_3_0|LCS_LINEWIDTH_0_5);
+ lcs |= imesa->LcsLineWidth;
+ if (ctx->Line.SmoothFlag) {
+ aa |= AA_ENABLE;
+ lcs |= LCS_LINEWIDTH_0_5;
+ }
+ break;
+ case GL_POINTS:
+ lcs &= ~(LCS_LINEWIDTH_3_0|LCS_LINEWIDTH_0_5);
+ lcs |= imesa->LcsPointSize;
+ if (ctx->Point.SmoothFlag) {
+ aa |= AA_ENABLE;
+ lcs |= LCS_LINEWIDTH_0_5;
+ }
+ break;
+ default:
+ return;
+ }
+
+ imesa->reduced_primitive = rprim;
+
+ if (st1 != imesa->Setup[I810_CTXREG_ST1] ||
+ aa != imesa->Setup[I810_CTXREG_AA] ||
+ lcs != imesa->Setup[I810_CTXREG_LCS])
+ {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->hw_primitive = hwprim;
+ imesa->Setup[I810_CTXREG_LCS] = lcs;
+ imesa->Setup[I810_CTXREG_ST1] = st1;
+ imesa->Setup[I810_CTXREG_AA] = aa;
+ }
+ else if (hwprim != imesa->hw_primitive) {
+ I810_STATECHANGE(imesa, 0);
+ imesa->hw_primitive = hwprim;
+ }
+}
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = imesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = imesa->Fallback;
+
+ if (0) fprintf(stderr, "%s old %x bit %x mode %d\n", __FUNCTION__,
+ imesa->Fallback, bit, mode );
+
+ if (mode) {
+ imesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ if (0) fprintf(stderr, "ENTER FALLBACK\n");
+ I810_FIREVERTICES(imesa);
+ _swsetup_Wakeup( ctx );
+ imesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ imesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ if (0) fprintf(stderr, "LEAVE FALLBACK\n");
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = i810RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = i810RenderPrimitive;
+ tnl->Driver.Render.Finish = i810RenderFinish;
+ tnl->Driver.Render.BuildVertices = i810BuildVertices;
+ imesa->new_state |= (_I810_NEW_RENDERSTATE|_I810_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void i810InitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = i810RunPipeline;
+ tnl->Driver.Render.Start = i810RenderStart;
+ tnl->Driver.Render.Finish = i810RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = i810RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = i810BuildVertices;
+}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.h b/xc/lib/GL/mesa/src/drv/i810/i810tris.h
index 335566bba..986b98745 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810tris.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.h
@@ -27,153 +27,10 @@
#ifndef I810TRIS_INC
#define I810TRIS_INC
-#include "types.h"
-#include "i810ioctl.h"
-#include "i810vb.h"
+#include "mtypes.h"
extern void i810PrintRenderState( const char *msg, GLuint state );
-extern void i810DDChooseRenderState(GLcontext *ctx);
-extern void i810DDTrifuncInit( void );
-
-
-#define I810_FLAT_BIT 0x1
-#define I810_OFFSET_BIT 0x2
-#define I810_TWOSIDE_BIT 0x4
-#define I810_FALLBACK_BIT 0x8
-
-
-
-
-static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
- i810VertexPtr v0,
- i810VertexPtr v1,
- i810VertexPtr v2 )
-{
- GLuint vertsize = imesa->vertsize;
- GLuint *vb = i810AllocDwordsInline( imesa, 3 * vertsize );
- int j;
-
-#if defined(USE_X86_ASM)
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
-#else
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v0->ui[j];
-
- vb += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v1->ui[j];
-
- vb += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v2->ui[j];
-#endif
-}
-
-
-static __inline__ void i810_draw_point( i810ContextPtr imesa,
- i810VertexPtr tmp,
- float sz )
-{
- int vertsize = imesa->vertsize;
- GLuint *vb = i810AllocDwordsInline( imesa, 6 * vertsize );
- const GLfloat x = tmp->v.x + 0.125;
- const GLfloat y = tmp->v.y - 0.5F;
- int j;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
-}
-
-
-static __inline__ void i810_draw_line( i810ContextPtr imesa,
- i810VertexPtr v0,
- i810VertexPtr v1 )
-{
- GLuint vertsize = imesa->vertsize;
- GLuint *vb = i810AllocDwordsInline( imesa, 2 * vertsize );
- int j;
-
-#if defined(USE_X86_ASM)
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
-#elif 0
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v0->ui[j];
-
- vb += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v1->ui[j];
-#else
- const GLfloat dx = -0.5;
- const GLfloat dy = -0.5;
-
- v0->v.x += dx;
- v0->v.y += dy;
- v1->v.x += dx;
- v1->v.y += dy;
-
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v0->ui[j];
-
- vb += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- vb[j] = v1->ui[j];
-
- v0->v.x -= dx;
- v0->v.y -= dy;
- v1->v.x -= dx;
- v1->v.y -= dy;
-#endif
-}
-
+extern void i810InitTriFuncs( GLcontext *ctx );
+extern void i810RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h b/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
deleted file mode 100644
index c9cf18124..000000000
--- a/xc/lib/GL/mesa/src/drv/i810/i810tritmp.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tritmp.h,v 1.5 2000/12/05 21:18:33 dawes Exp $ */
-
-static __inline void TAG(triangle)(GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv)
-{
- i810ContextPtr i810ctx = I810_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- i810VertexPtr i810verts = I810_DRIVER_DATA(VB)->verts;
- i810Vertex *v[3];
-
-#if (IND & I810_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[3];
-#endif
-
-#if (IND & (I810_TWOSIDE_BIT | I810_FLAT_BIT))
- GLuint c[3];
-#endif
-
- v[0] = &i810verts[e0];
- v[1] = &i810verts[e1];
- v[2] = &i810verts[e2];
-
-#if (IND & (I810_TWOSIDE_BIT | I810_FLAT_BIT))
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
-#endif
-
-
-#if (IND & (I810_TWOSIDE_BIT | I810_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & I810_TWOSIDE_BIT)
- {
- GLuint facing = (cc > 0.0) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if (IND & I810_FLAT_BIT) {
- I810_COLOR((char *)&v[0]->ui[4], vbcolor[pv]);
- v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- I810_COLOR((char *)&v[0]->ui[4], vbcolor[e0]);
- I810_COLOR((char *)&v[1]->ui[4], vbcolor[e1]);
- I810_COLOR((char *)&v[2]->ui[4], vbcolor[e2]);
- }
- }
-#endif
-
-#if (IND & I810_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * 1.0/0x10000;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- if (cc * cc > 1e-16) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if (ac < 0.0f) ac = -ac;
- if (bc < 0.0f) bc = -bc;
- offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- }
-#endif
- }
-#elif (IND & I810_FLAT_BIT)
- {
- GLuint color = i810verts[pv].ui[4];
- v[0]->ui[4] = color;
- v[1]->ui[4] = color;
- v[2]->ui[4] = color;
- }
-#endif
-
- i810_draw_triangle( i810ctx, v[0], v[1], v[2] );
-
-#if (IND & I810_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
-#endif
-
-#if (IND & (I810_FLAT_BIT | I810_TWOSIDE_BIT))
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
-#endif
-
-}
-
-
-static void TAG(quad)( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3,
- GLuint pv )
-{
- TAG(triangle)( ctx, v0, v1, v3, pv );
- TAG(triangle)( ctx, v1, v2, v3, pv );
-}
-
-static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
-{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- i810VertexPtr i810VB = I810_DRIVER_DATA(ctx->VB)->verts;
-
-#if (IND & (I810_TWOSIDE_BIT|I810_FLAT_BIT|I810_OFFSET_BIT))
- i810Vertex tmp0 = i810VB[v0];
- i810Vertex tmp1 = i810VB[v1];
-
- if (IND & I810_TWOSIDE_BIT) {
- GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
-
- if (IND & I810_FLAT_BIT) {
- I810_COLOR((char *)&tmp0.v.color,vbcolor[pv]);
- *(int *)&tmp1.v.color = *(int *)&tmp0.v.color;
- } else {
- I810_COLOR((char *)&tmp0.v.color,vbcolor[v0]);
- I810_COLOR((char *)&tmp1.v.color,vbcolor[v1]);
- }
-
- } else if (IND & I810_FLAT_BIT) {
- *(int *)&tmp0.v.color = *(int *)&i810VB[pv].v.color;
- *(int *)&tmp1.v.color = *(int *)&i810VB[pv].v.color;
- }
-
- /* Relies on precomputed LineZoffset from vbrender.c
- */
- if (IND & I810_OFFSET_BIT) {
- GLfloat offset = ctx->LineZoffset * (1.0 / 0x10000);
- tmp0.v.z += offset;
- tmp1.v.z += offset;
- }
-
- i810_draw_line( imesa, &tmp0, &tmp1 );
-#else
- i810_draw_line( imesa, &i810VB[v0], &i810VB[v1] );
-#endif
-}
-
-
-static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
-{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- struct vertex_buffer *VB = ctx->VB;
- i810VertexPtr i810VB = I810_DRIVER_DATA(VB)->verts;
- GLfloat sz = ctx->Point.Size * .5;
- int i;
-
- /* Culling is disabled automatically via. the
- * ctx->Driver.ReducedPrimitiveChange() callback.
- */
-
- for(i=first;i<last;i++) {
- if(VB->ClipMask[i]==0) {
- if (IND & I810_TWOSIDE_BIT) {
- i810Vertex tmp0 = i810VB[i];
- if (IND & I810_TWOSIDE_BIT) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
- I810_COLOR((char *)&tmp0.v.color, vbcolor[i]);
- }
- if (IND & I810_OFFSET_BIT) {
- GLfloat offset = ctx->PointZoffset * (1.0 / 0x10000);
- tmp0.v.z += offset;
- }
- i810_draw_point( imesa, &tmp0, sz );
- } else
- i810_draw_point( imesa, &i810VB[i], sz );
- }
- }
-}
-
-
-
-static void TAG(init)( void )
-{
- tri_tab[IND] = TAG(triangle);
- quad_tab[IND] = TAG(quad);
- line_tab[IND] = TAG(line);
- points_tab[IND] = TAG(points);
-}
-
-
-#undef IND
-#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.c b/xc/lib/GL/mesa/src/drv/i810/i810vb.c
index 802c56dc2..dd8f09a3f 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810vb.c
+++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.c
@@ -15,454 +15,479 @@
* THE SOFTWARE IS PROVIDED "AS 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.8 2001/03/21 16:14:21 dawes Exp $ */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "i810context.h"
-#include "i810vb.h"
-#include "i810log.h"
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.7 2000/11/08 05:02:43 dawes Exp $ */
+
+#include "glheader.h"
+#include "mtypes.h"
#include "mem.h"
-#include "stages.h"
+#include "macros.h"
+#include "colormac.h"
+#include "mmath.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "i810context.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+#include "i810tris.h"
+#include "i810state.h"
+
+
+#define I810_TEX1_BIT 0x1
+#define I810_TEX0_BIT 0x2
+#define I810_RGBA_BIT 0x4
+#define I810_SPEC_BIT 0x8
+#define I810_FOG_BIT 0x10
+#define I810_XYZW_BIT 0x20
+#define I810_PTEX_BIT 0x40
+#define I810_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[I810_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_0 | \
+ VF_RGBA_ENABLE | \
+ VF_XYZ)
+
+#define NOTEX_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_0 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define TEX0_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_1 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define TEX1_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_2 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & I810_XYZW_BIT)
+#define DO_RGBA (IND & I810_RGBA_BIT)
+#define DO_SPEC (IND & I810_SPEC_BIT)
+#define DO_FOG (IND & I810_FOG_BIT)
+#define DO_TEX0 (IND & I810_TEX0_BIT)
+#define DO_TEX1 (IND & I810_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & I810_PTEX_BIT)
+
+#define VERTEX i810Vertex
+#define GET_VIEWPORT_MAT() I810_CONTEXT(ctx)->ViewportMatrix.m
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() I810_CONTEXT(ctx)->Setup[I810_CTXREG_VF]
+#define GET_VERTEX_STORE() I810_CONTEXT(ctx)->verts
+#define GET_VERTEX_STRIDE_SHIFT() I810_CONTEXT(ctx)->vertex_stride_shift
+#define GET_UBYTE_COLOR_STORE() &I810_CONTEXT(ctx)->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &I810_CONTEXT(ctx)->UbyteSecondaryColor
+#define INVALIDATE_STORED_VERTICES()
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS GLfloat h = I810_CONTEXT(ctx)->driDrawable->h
+#define UNVIEWPORT_X(x) x - SUBPIXEL_X
+#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
+#define UNVIEWPORT_Z(z) z * (float)0xffff
+
+#define PTEX_FALLBACK() FALLBACK(I810_CONTEXT(ctx), I810_FALLBACK_TEXTURE, 1)
+
+#define IMPORT_FLOAT_COLORS i810_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS i810_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[I810_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[I810_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) i810_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|\
+ I810_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
-#define TEX0 { \
- v->v.tu0 = tc0[i][0]; \
- v->v.tv0 = tc0[i][1]; \
-}
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-#define TEX1 { \
- v->v.tu1 = tc1[i][0]; \
- v->v.tv1 = tc1[i][1]; \
-}
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT|I810_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
-/* Doesn't seem to work very well (golly).
- */
-#define SPC { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.red = spec[0]; \
- v->v.specular.green = spec[1]; \
- v->v.specular.blue = spec[2]; \
-}
+#define IND (I810_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
-#define FOG { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.alpha = spec[3]; \
-}
+#define IND (I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-#define COL { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->v.color.blue = col[2]; \
- v->v.color.green = col[1]; \
- v->v.color.red = col[0]; \
- v->v.color.alpha = col[3]; \
-}
+#define IND (I810_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
-/* The vertex formats we have don't seem to support projective texturing
- * in the multitexture case. (Would require another 1/w value for the
- * second set of texcoords).
- */
-#define TEX0_4 \
- if (VB->TexCoordPtr[0]->size == 4) \
- { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
- v = &(I810_DRIVER_DATA(VB)->verts[start]); \
- imesa->setupdone &= ~I810_WIN_BIT; \
- for (i=start; i < end; i++, v++) { \
- float oow = 1.0 / tc[i][3]; \
- v->v.oow *= tc[i][3]; \
- v->v.tu0 *= oow; \
- v->v.tv0 *= oow; \
- } \
- }
-
-
-#define COORD \
- GLfloat *win = VB->Win.data[i]; \
- v->v.x = xoffset + win[0]; \
- v->v.y = yoffset - win[1]; \
- v->v.z = (1.0/0x10000) * win[2]; \
- v->v.oow = win[3];
-
-
-
-#define NOP
-
-#define SUBPIXEL_X -0.5
-#define SUBPIXEL_Y -0.375
-
-
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,spec,fog) \
-static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
-{ \
- i810ContextPtr imesa = I810_CONTEXT( VB->ctx ); \
- __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
- i810VertexPtr v; \
- GLfloat (*tc0)[4]; \
- GLfloat (*tc1)[4]; \
- const GLfloat xoffset = SUBPIXEL_X; \
- const GLfloat yoffset = dPriv->h + SUBPIXEL_Y; \
- int i; \
- (void) xoffset; \
- (void) yoffset; \
- (void) imesa; \
- \
- \
- gl_import_client_data( VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE|VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE)); \
- \
- tc0 = VB->TexCoordPtr[0]->data; \
- tc1 = VB->TexCoordPtr[1]->data; \
- \
- v = &(I810_DRIVER_DATA(VB)->verts[start]); \
- \
- if (VB->ClipOrMask == 0) \
- for (i=start; i < end; i++, v++) { \
- win; \
- col; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- else \
- for (i=start; i < end; i++, v++) { \
- if (VB->ClipMask[i] == 0) { \
- win; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- col; \
- } \
- tex0_4; \
-}
+#define IND (I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (I810_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
-
-SETUPFUNC(rs_wt0, COORD,NOP,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wt0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wft0, COORD,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wft0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wg, COORD,COL,NOP,NOP,NOP,NOP,NOP)
-SETUPFUNC(rs_wgs, COORD,COL,NOP,NOP,NOP,SPC,NOP)
-SETUPFUNC(rs_wgt0, COORD,COL,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wgt0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wgst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_wgst0t1, COORD,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_wgf, COORD,COL,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_wgfs, COORD,COL,NOP,NOP,NOP,SPC,FOG)
-SETUPFUNC(rs_wgft0, COORD,COL,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wgft0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wgfst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,FOG)
-SETUPFUNC(rs_wgfst0t1, COORD,COL,TEX0,TEX1,TEX0_4,SPC,FOG)
-
-SETUPFUNC(rs_t0, NOP,NOP,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_t0t1, NOP,NOP,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_f, NOP,NOP,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_ft0, NOP,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_ft0t1, NOP,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_g, NOP,COL,NOP,NOP,NOP,NOP,NOP)
-SETUPFUNC(rs_gs, NOP,COL,NOP,NOP,NOP,SPC,NOP)
-SETUPFUNC(rs_gt0, NOP,COL,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_gt0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_gst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_gst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_gf, NOP,COL,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_gfs, NOP,COL,NOP,NOP,NOP,SPC,FOG)
-SETUPFUNC(rs_gft0, NOP,COL,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_gft0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_gfst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,FOG)
-SETUPFUNC(rs_gfst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,FOG)
-
-
-
-static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
-{
-
- fprintf(stderr, "i810RasterSetup(): invalid setup function\n");
-}
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
-typedef void (*setupFunc)(struct vertex_buffer *,GLuint,GLuint);
+#define IND (I810_RGBA_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-static setupFunc setup_func[0x80];
-void i810DDSetupInit( void )
+static void init_setup_tab( void )
{
- int i;
-
- for (i = 0 ; i < 0x80 ; i++)
- setup_func[i] = rs_invalid;
-
- /* Functions to build vert's from scratch */
- setup_func[I810_WIN_BIT|I810_TEX0_BIT] = rs_wt0;
- setup_func[I810_WIN_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wt0t1;
- setup_func[I810_WIN_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_wft0;
- setup_func[I810_WIN_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wft0t1;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT] = rs_wg;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT] = rs_wgs;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_TEX0_BIT] = rs_wgt0;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgt0t1;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_wgst0;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgst0t1;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT] = rs_wgf;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT] = rs_wgfs;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_wgft0;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgft0t1;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_wgfst0;
- setup_func[I810_WIN_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_wgfst0t1;
-
- /* Repair functions */
- setup_func[I810_TEX0_BIT] = rs_t0;
- setup_func[I810_TEX0_BIT|I810_TEX1_BIT] = rs_t0t1;
- setup_func[I810_FOG_BIT] = rs_f;
- setup_func[I810_FOG_BIT|I810_TEX0_BIT] = rs_ft0;
- setup_func[I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_ft0t1;
- setup_func[I810_RGBA_BIT] = rs_g;
- setup_func[I810_RGBA_BIT|I810_SPEC_BIT] = rs_gs;
- setup_func[I810_RGBA_BIT|I810_TEX0_BIT] = rs_gt0;
- setup_func[I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gt0t1;
- setup_func[I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_gst0;
- setup_func[I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gst0t1;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT] = rs_gf;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT] = rs_gfs;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT] = rs_gft0;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gft0t1;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT] = rs_gfst0;
- setup_func[I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT] = rs_gfst0t1;
-
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
}
+
void i810PrintSetupFlags(char *msg, GLuint flags )
{
- fprintf(stderr, "%s: %d %s%s%s%s%s%s%s\n",
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
msg,
(int)flags,
- (flags & I810_WIN_BIT) ? " xyzw," : "",
+ (flags & I810_XYZW_BIT) ? " xyzw," : "",
(flags & I810_RGBA_BIT) ? " rgba," : "",
(flags & I810_SPEC_BIT) ? " spec," : "",
(flags & I810_FOG_BIT) ? " fog," : "",
(flags & I810_TEX0_BIT) ? " tex-0," : "",
- (flags & I810_TEX1_BIT) ? " tex-1," : "",
- (flags & I810_ALPHA_BIT) ? " alpha," : "");
+ (flags & I810_TEX1_BIT) ? " tex-1," : "");
}
-
-void i810ChooseRasterSetupFunc(GLcontext *ctx)
+void i810CheckTexSizes( GLcontext *ctx )
{
- i810ContextPtr imesa = I810_CONTEXT( ctx );
- int funcindex = (I810_WIN_BIT | I810_RGBA_BIT);
-
- imesa->vertsize = 8;
- imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0;
-
- if (ctx->Texture.ReallyEnabled & 0xf)
- funcindex |= I810_TEX0_BIT;
-
- if (ctx->Texture.ReallyEnabled & 0xf0) {
- funcindex |= (I810_TEX0_BIT | I810_TEX1_BIT);
- imesa->vertsize = 10;
- imesa->Setup[I810_CTXREG_VF] = I810_VFMT_T0T1;
- }
-
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- funcindex |= I810_SPEC_BIT;
-
- if (ctx->FogMode == FOG_FRAGMENT)
- funcindex |= I810_FOG_BIT;
-
- if (MESA_VERBOSE)
- i810PrintSetupFlags("xsmesa: full setup function", funcindex);
-
- imesa->setupindex = funcindex;
- ctx->Driver.RasterSetup = setup_func[funcindex];
-}
-
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) {
+ /* Invalidate stored verts
+ */
+ imesa->SetupNewInputs = ~0;
+ imesa->SetupIndex |= I810_PTEX_BIT;
+ if (!imesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[imesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[imesa->SetupIndex].copy_pv;
+ }
+ }
+}
-void i810DDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d )
+void i810BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
{
i810ContextPtr imesa = I810_CONTEXT( ctx );
- GLuint tmp = imesa->setupdone;
+ GLubyte *v = ((GLubyte *)imesa->verts + (start<<imesa->vertex_stride_shift));
+ GLuint stride = 1<<imesa->vertex_stride_shift;
- d->type = 0;
- imesa->setupdone = 0; /* cleared if we return */
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
- if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
- return;
+ newinputs |= imesa->SetupNewInputs;
+ imesa->SetupNewInputs = 0;
- if (ctx->IndirectTriangles)
+ if (!newinputs)
return;
- imesa->setupdone = tmp;
-
- /* disabled until we have a merge&render op */
- /* d->inputs = available; */
- /* d->outputs = VERT_RAST_SETUP_PART; */
- /* d->type = PIPE_PRECALC; */
-}
+ if (newinputs & VERT_CLIP) {
+ setup_tab[imesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+ if (newinputs & VERT_RGBA)
+ ind |= I810_RGBA_BIT;
-/* Repair existing precalculated vertices with new data.
- */
-void i810DDPartialRasterSetup( struct vertex_buffer *VB )
-{
- i810ContextPtr imesa = I810_CONTEXT( VB->ctx );
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
- GLuint ind = 0;
-
- if (new & VERT_WIN) {
- new = available;
- ind |= I810_WIN_BIT | I810_FOG_BIT;
- }
-
- if (new & VERT_RGBA)
- ind |= I810_RGBA_BIT | I810_SPEC_BIT;
+ if (newinputs & VERT_SPEC_RGB)
+ ind |= I810_SPEC_BIT;
- if (new & VERT_TEX0_ANY)
- ind |= I810_TEX0_BIT;
+ if (newinputs & VERT_TEX0)
+ ind |= I810_TEX0_BIT;
- if (new & VERT_TEX1_ANY)
- ind |= I810_TEX1_BIT;
+ if (newinputs & VERT_TEX1)
+ ind |= I810_TEX1_BIT;
- if (new & VERT_FOG_COORD)
- ind |= I810_FOG_BIT;
+ if (newinputs & VERT_FOG_COORD)
+ ind |= I810_FOG_BIT;
- imesa->setupdone &= ~ind;
- ind &= imesa->setupindex;
- imesa->setupdone |= ind;
+ if (imesa->SetupIndex & I810_PTEX_BIT)
+ ind = ~0;
- if (0) i810PrintSetupFlags("xsmesa: partial setup function", ind);
+ ind &= imesa->SetupIndex;
- if (ind)
- setup_func[ind&~I810_ALPHA_BIT]( VB, VB->Start, VB->Count );
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
}
-
-void i810DDDoRasterSetup( struct vertex_buffer *VB )
+void i810ChooseVertexState( GLcontext *ctx )
{
- GLcontext *ctx = VB->ctx;
-
- if (VB->Type == VB_CVA_PRECALC)
- i810DDPartialRasterSetup( VB );
- else if (ctx->Driver.RasterSetup)
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
-}
-
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint ind = I810_XYZW_BIT|I810_RGBA_BIT;
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= I810_SPEC_BIT;
+ if (ctx->Fog.Enabled)
+ ind |= I810_FOG_BIT;
-void i810DDResizeVB( struct vertex_buffer *VB, GLuint size )
-{
- i810VertexBufferPtr mvb = I810_DRIVER_DATA(VB);
+ if (ctx->Texture._ReallyEnabled & 0xf0)
+ ind |= I810_TEX1_BIT|I810_TEX0_BIT;
+ else if (ctx->Texture._ReallyEnabled & 0xf)
+ ind |= I810_TEX0_BIT;
- while (mvb->size < size)
- mvb->size *= 2;
+ imesa->SetupIndex = ind;
- free( mvb->vert_store );
- mvb->vert_store = malloc( sizeof(i810Vertex) * mvb->size + 31);
- if (!mvb->vert_store) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = i810_interp_extras;
+ tnl->Driver.Render.CopyPV = i810_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}
- mvb->verts = (i810VertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
-
- gl_vector1ui_free( &mvb->clipped_elements );
- gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
+ if (setup_tab[ind].vertex_format != imesa->Setup[I810_CTXREG_VF]) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_VF] = setup_tab[ind].vertex_format;
+ imesa->vertex_size = setup_tab[ind].vertex_size;
+ imesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
}
+}
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
- if (!VB->ClipMask) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
- }
- if (VB->Type == VB_IMMEDIATE) {
- free( mvb->primitive );
- free( mvb->next_primitive );
- mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
- }
- }
+void i810_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint vertex_size = imesa->vertex_size * 4;
+ GLuint *dest = i810AllocDmaLow( imesa, (count-start) * vertex_size);
+ setup_tab[imesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
}
-void i810DDRegisterVB( struct vertex_buffer *VB )
+
+void i810InitVB( GLcontext *ctx )
{
- i810VertexBufferPtr mvb;
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- mvb = (i810VertexBufferPtr)calloc( 1, sizeof(*mvb) );
+ imesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
- mvb->size = VB->Size * 2;
- mvb->vert_store = malloc( sizeof(i810Vertex) * mvb->size + 31);
- if (!mvb->vert_store) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
}
-
- mvb->verts = (i810VertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
+}
- gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
- }
-
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 4);
- if (!VB->ClipMask) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
- }
- mvb->primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- mvb->next_primitive = (GLuint *)malloc( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive) {
- fprintf(stderr, "i810-glx: out of memory !\n");
- exit(1);
+void i810FreeVB( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ if (imesa->verts) {
+ ALIGN_FREE(imesa->verts);
+ imesa->verts = 0;
}
- VB->driver_data = mvb;
-}
-
+ if (imesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE(imesa->UbyteSecondaryColor.Ptr);
+ imesa->UbyteSecondaryColor.Ptr = 0;
+ }
-void i810DDUnregisterVB( struct vertex_buffer *VB )
-{
- i810VertexBufferPtr mvb = I810_DRIVER_DATA(VB);
-
- if (mvb) {
- if (mvb->vert_store) free(mvb->vert_store);
- if (mvb->primitive) free(mvb->primitive);
- if (mvb->next_primitive) free(mvb->next_primitive);
- gl_vector1ui_free( &mvb->clipped_elements );
- free(mvb);
- VB->driver_data = 0;
- }
+ if (imesa->UbyteColor.Ptr) {
+ ALIGN_FREE(imesa->UbyteColor.Ptr);
+ imesa->UbyteColor.Ptr = 0;
+ }
}
diff --git a/xc/lib/GL/mesa/src/drv/i810/i810vb.h b/xc/lib/GL/mesa/src/drv/i810/i810vb.h
index 0da60344e..2a722f8ce 100644
--- a/xc/lib/GL/mesa/src/drv/i810/i810vb.h
+++ b/xc/lib/GL/mesa/src/drv/i810/i810vb.h
@@ -15,9 +15,9 @@
* THE SOFTWARE IS PROVIDED "AS 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
@@ -27,92 +27,36 @@
#ifndef I810VB_INC
#define I810VB_INC
-#include "vb.h"
-#include "types.h"
+#include "mtypes.h"
+#include "swrast/swrast.h"
-/*
- * color type for the vertex data
- * we probably want to use an internal datatype here?
- */
-typedef struct {
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
-} i810_color;
-
-
-/* A basic fixed format vertex to kick things off. Move to dynamic
- * layouts later on. (see also the i810_full_vertex struct in
- * i810_3d_reg.h)
- */
-typedef struct {
- GLfloat x,y,z; /* coordinates in screen space*/
- GLfloat oow; /* reciprocal homogeneous w */
- i810_color color; /* vertex color */
- i810_color specular; /* specular color, alpha is fog */
- GLfloat tu0,tv0; /* texture 0 */
- GLfloat tu1,tv1; /* texture 1 */
-} i810_vertex;
-
-
-/* Unfortunately only have assembly for 16-stride vertices.
- */
-union i810_vertex_t {
- i810_vertex v;
- float f[16];
- GLuint ui[16];
-};
+#define _I810_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
-typedef union i810_vertex_t i810Vertex;
-typedef union i810_vertex_t *i810VertexPtr;
-struct i810_vertex_buffer_t {
- GLvector1ui clipped_elements;
- i810VertexPtr verts;
- int last_vert;
- GLuint *primitive;
- GLuint *next_primitive;
- void *vert_store;
- GLuint size;
-};
-
-typedef struct i810_vertex_buffer_t *i810VertexBufferPtr;
+extern void i810ChooseVertexState( GLcontext *ctx );
+extern void i810CheckTexSizes( GLcontext *ctx );
+extern void i810BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
-#define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
-#define I810_DRIVER_DATA(vb) ((i810VertexBufferPtr)((vb)->driver_data))
+extern void i810_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+extern void i810_translate_vertex( GLcontext *ctx,
+ const i810Vertex *src,
+ SWvertex *dst );
-#define I810_SPEC_BIT 0x1
-#define I810_FOG_BIT 0x2
-#define I810_ALPHA_BIT 0x4 /* GL_BLEND, not used */
-#define I810_TEX1_BIT 0x8
-#define I810_TEX0_BIT 0x10
-#define I810_RGBA_BIT 0x20
-#define I810_WIN_BIT 0x40
+extern void i810InitVB( GLcontext *ctx );
+extern void i810FreeVB( GLcontext *ctx );
-
-extern void i810ChooseRasterSetupFunc(GLcontext *ctx);
+extern void i810_print_vertex( GLcontext *ctx, const i810Vertex *v );
extern void i810PrintSetupFlags(char *msg, GLuint flags );
-extern void i810DDDoRasterSetup( struct vertex_buffer *VB );
-extern void i810DDPartialRasterSetup( struct vertex_buffer *VB );
-extern void i810DDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d );
-
-extern void i810DDViewport( GLcontext *ctx,
- GLint x, GLint y,
- GLsizei width, GLsizei height );
-
-extern void i810DDDepthRange( GLcontext *ctx,
- GLclampd nearval, GLclampd farval );
-
-
-extern void i810DDUnregisterVB( struct vertex_buffer *VB );
-extern void i810DDRegisterVB( struct vertex_buffer *VB );
-extern void i810DDResizeVB( struct vertex_buffer *VB, GLuint size );
-
-extern void i810DDSetupInit( void );
-
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile b/xc/lib/GL/mesa/src/drv/mga/Imakefile
index b1e1923f8..81b377006 100644
--- a/xc/lib/GL/mesa/src/drv/mga/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile
@@ -22,12 +22,15 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/mga/Imakefile,v 1.20 2001/05/10 16:56:11
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
+
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
diff --git a/xc/lib/GL/mesa/src/drv/mga/Imakefile.inc b/xc/lib/GL/mesa/src/drv/mga/Imakefile.inc
index 5d4ac8b63..90e9d4a8a 100644
--- a/xc/lib/GL/mesa/src/drv/mga/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/mga/Imakefile.inc
@@ -16,16 +16,17 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
-I$(GLXLIBSRC)/glx \
-I$(INCLUDESRC) \
-I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/mga \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
MESA_INCLUDES = -I$(MESASRCDIR)/src \
@@ -35,10 +36,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
MGASRCS = $(MESADRVMGABUILDDIR)mgabuffers.c \
$(MESADRVMGABUILDDIR)mgadd.c \
- $(MESADRVMGABUILDDIR)mgaeltpath.c \
- $(MESADRVMGABUILDDIR)mgafastpath.c \
+ $(MESADRVMGABUILDDIR)mgarender.c \
$(MESADRVMGABUILDDIR)mgaioctl.c \
- $(MESADRVMGABUILDDIR)mgapipeline.c \
+ $(MESADRVMGABUILDDIR)mgapixel.c \
$(MESADRVMGABUILDDIR)mgaspan.c \
$(MESADRVMGABUILDDIR)mgastate.c \
$(MESADRVMGABUILDDIR)mgatex.c \
@@ -50,10 +50,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
MGAOBJS = $(MESADRVMGABUILDDIR)mgabuffers.o \
$(MESADRVMGABUILDDIR)mgadd.o \
- $(MESADRVMGABUILDDIR)mgaeltpath.o \
- $(MESADRVMGABUILDDIR)mgafastpath.o \
+ $(MESADRVMGABUILDDIR)mgarender.o \
$(MESADRVMGABUILDDIR)mgaioctl.o \
- $(MESADRVMGABUILDDIR)mgapipeline.o \
+ $(MESADRVMGABUILDDIR)mgapixel.o \
$(MESADRVMGABUILDDIR)mgaspan.o \
$(MESADRVMGABUILDDIR)mgastate.o \
$(MESADRVMGABUILDDIR)mgatex.o \
@@ -65,10 +64,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
MGAUOBJS = $(MESADRVMGABUILDDIR)unshared/mgabuffers.o \
$(MESADRVMGABUILDDIR)unshared/mgadd.o \
- $(MESADRVMGABUILDDIR)unshared/mgaeltpath.o \
- $(MESADRVMGABUILDDIR)unshared/mgafastpath.o \
+ $(MESADRVMGABUILDDIR)unshared/mgarender.o \
$(MESADRVMGABUILDDIR)unshared/mgaioctl.o \
- $(MESADRVMGABUILDDIR)unshared/mgapipeline.o \
+ $(MESADRVMGABUILDDIR)unshared/mgapixel.o \
$(MESADRVMGABUILDDIR)unshared/mgaspan.o \
$(MESADRVMGABUILDDIR)unshared/mgastate.o \
$(MESADRVMGABUILDDIR)unshared/mgatex.o \
@@ -80,10 +78,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
MGADOBJS = $(MESADRVMGABUILDDIR)debugger/mgabuffers.o \
$(MESADRVMGABUILDDIR)debugger/mgadd.o \
- $(MESADRVMGABUILDDIR)debugger/mgaeltpath.o \
- $(MESADRVMGABUILDDIR)debugger/mgafastpath.o \
+ $(MESADRVMGABUILDDIR)debugger/mgarender.o \
$(MESADRVMGABUILDDIR)debugger/mgaioctl.o \
- $(MESADRVMGABUILDDIR)debugger/mgapipeline.o \
+ $(MESADRVMGABUILDDIR)debugger/mgapixel.o \
$(MESADRVMGABUILDDIR)debugger/mgaspan.o \
$(MESADRVMGABUILDDIR)debugger/mgastate.o \
$(MESADRVMGABUILDDIR)debugger/mgatex.o \
@@ -95,10 +92,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
MGAPOBJS = $(MESADRVMGABUILDDIR)profiled/mgabuffers.o \
$(MESADRVMGABUILDDIR)profiled/mgadd.o \
- $(MESADRVMGABUILDDIR)profiled/mgaeltpath.o \
- $(MESADRVMGABUILDDIR)profiled/mgafastpath.o \
+ $(MESADRVMGABUILDDIR)profiled/mgarender.o \
$(MESADRVMGABUILDDIR)profiled/mgaioctl.o \
- $(MESADRVMGABUILDDIR)profiled/mgapipeline.o \
+ $(MESADRVMGABUILDDIR)profiled/mgapixel.o \
$(MESADRVMGABUILDDIR)profiled/mgaspan.o \
$(MESADRVMGABUILDDIR)profiled/mgastate.o \
$(MESADRVMGABUILDDIR)profiled/mgatex.o \
@@ -111,10 +107,9 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
#ifdef NeedToLinkMesaSrc
LinkSourceFile(mgabuffers.c, $(MESADRVSRCDIR)/mga)
LinkSourceFile(mgadd.c, $(MESADRVSRCDIR)/mga)
-LinkSourceFile(mgaeltpath.c, $(MESADRVSRCDIR)/mga)
-LinkSourceFile(mgafastpath.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgarender.c, $(MESADRVSRCDIR)/mga)
LinkSourceFile(mgaioctl.c, $(MESADRVSRCDIR)/mga)
-LinkSourceFile(mgapipeline.c, $(MESADRVSRCDIR)/mga)
+LinkSourceFile(mgapixel.c, $(MESADRVSRCDIR)/mga)
LinkSourceFile(mgaspan.c, $(MESADRVSRCDIR)/mga)
LinkSourceFile(mgastate.c, $(MESADRVSRCDIR)/mga)
LinkSourceFile(mgatex.c, $(MESADRVSRCDIR)/mga)
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
index a15baa737..74e66f231 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c
@@ -1,4 +1,31 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.12 2001/04/10 16:07:50 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.8 2000/12/07 20:26:06 dawes Exp $ */
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+
/*
* Copyright 2000-2001 VA Linux Systems, Inc.
* All Rights Reserved.
@@ -34,18 +61,25 @@
#include "drm.h"
#include "mga_xmesa.h"
#include "context.h"
-#include "vbxform.h"
#include "matrix.h"
#include "mmath.h"
#include "simple_list.h"
#include "mem.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
#include "mgadd.h"
#include "mgastate.h"
#include "mgatex.h"
#include "mgaspan.h"
+#include "mgaioctl.h"
#include "mgatris.h"
-#include "mgapipeline.h"
+#include "mgavb.h"
#include "mgabuffers.h"
#include "mgapixel.h"
@@ -68,41 +102,21 @@ int MGA_DEBUG = (0
#endif
-static mgaContextPtr mgaCtx = 0;
-
-
-/* These functions are accessed externally to the driver:
- *
- * XMesaInitDriver
- * XMesaResetDriver
- * XMesaCreateVisual
- * XMesaDestroyVisual
- * XMesaCreateContext
- * XMesaDestroyContext
- * XMesaCreateWindowBuffer
- * XMesaCreatePixmapBuffer
- * XMesaDestroyBuffer
- * XMesaSwapBuffers
- * XMesaMakeCurrent
- *
- */
-
-GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
+static GLboolean
+mgaInitDriver(__DRIscreenPrivate *sPriv)
{
mgaScreenPrivate *mgaScreen;
MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaInitDriver\n");
+ fprintf(stderr, "mgaInitDriver\n");
/* Check the DRI version */
{
int major, minor, patch;
if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
if (major != 4 || minor < 0) {
- char msg[1000];
- sprintf(msg, "MGA DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
- __driMesaMessage(msg);
+ __driUtilMessage("MGA DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch);
return GL_FALSE;
}
}
@@ -111,18 +125,14 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
/* Check that the DDX driver version is compatible */
if (sPriv->ddxMajor != 1 ||
sPriv->ddxMinor < 0) {
- char msg[1000];
- sprintf(msg, "MGA DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
- __driMesaMessage(msg);
+ __driUtilMessage("MGA DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
return GL_FALSE;
}
/* Check that the DRM driver version is compatible */
if (sPriv->drmMajor != 3 ||
sPriv->drmMinor < 0) {
- char msg[1000];
- sprintf(msg, "MGA DRI driver expected DRM driver version 3.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
- __driMesaMessage(msg);
+ __driUtilMessage("MGA DRI driver expected DRM driver version 3.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
return GL_FALSE;
}
@@ -130,7 +140,7 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
/* Allocate the private area */
mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate));
if (!mgaScreen) {
- __driMesaMessage("Couldn't malloc screen struct");
+ __driUtilMessage("Couldn't malloc screen struct");
return GL_FALSE;
}
@@ -141,7 +151,7 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
serverInfo->chipset != MGA_CARD_TYPE_G400) {
XFree(mgaScreen);
sPriv->private = NULL;
- __driMesaMessage("Unrecognized chipset");
+ __driUtilMessage("Unrecognized chipset");
return GL_FALSE;
}
@@ -168,24 +178,10 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
&mgaScreen->mmio.map ) < 0 ) {
FREE( mgaScreen );
sPriv->private = NULL;
- __driMesaMessage( "Couldn't map MMIO registers" );
+ __driUtilMessage( "Couldn't map MMIO registers" );
return GL_FALSE;
}
-#if 0
- mgaScreen->status.handle = serverInfo->status.handle;
- mgaScreen->status.size = serverInfo->status.size;
- if ( drmMap( sPriv->fd,
- mgaScreen->status.handle, mgaScreen->status.size,
- &mgaScreen->status.map ) < 0 ) {
- drmUnmap( mgaScreen->mmio.map, mgaScreen->mmio.size );
- FREE( mgaScreen );
- sPriv->private = NULL;
- __driMesaMessage( "Couldn't map status page" );
- return GL_FALSE;
- }
-#endif
-
mgaScreen->primary.handle = serverInfo->primary.handle;
mgaScreen->primary.size = serverInfo->primary.size;
mgaScreen->buffers.handle = serverInfo->buffers.handle;
@@ -202,7 +198,7 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
{
Xfree(mgaScreen);
sPriv->private = NULL;
- __driMesaMessage("Couldn't map agp region");
+ __driUtilMessage("Couldn't map agp region");
return GL_FALSE;
}
#endif
@@ -248,28 +244,22 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv)
/*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
XFree(mgaScreen);
sPriv->private = NULL;
- __driMesaMessage("Couldn't map dma buffers");
+ __driUtilMessage("Couldn't map dma buffers");
return GL_FALSE;
}
mgaScreen->sarea_priv_offset = serverInfo->sarea_priv_offset;
- mgaDDFastPathInit();
- mgaDDEltPathInit();
- mgaDDTrifuncInit();
- mgaDDSetupInit();
-
return GL_TRUE;
}
-/* Accessed by dlsym from dri_mesa_init.c
- */
-void XMesaResetDriver(__DRIscreenPrivate *sPriv)
+static void
+mgaDestroyScreen(__DRIscreenPrivate *sPriv)
{
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaResetDriver\n");
+ fprintf(stderr, "mgaDestroyScreen\n");
/*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/
Xfree(mgaScreen);
@@ -277,56 +267,60 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv)
}
-GLvisual *XMesaCreateVisual(Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config)
-{
- if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaCreateVisual\n");
+extern const struct gl_pipeline_stage _mga_render_stage;
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount(visinfo->red_mask),
- _mesa_bitcount(visinfo->green_mask),
- _mesa_bitcount(visinfo->blue_mask),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
+static const struct gl_pipeline_stage *mga_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 0
+ &_mga_render_stage, /* ADD: unclipped rastersetup-to-dma */
+ /* Need new ioctl for wacceptseq */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
-GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
+static GLboolean
+mgaCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
{
int i;
- GLcontext *ctx;
+ GLcontext *ctx, *shareCtx;
mgaContextPtr mmesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
- MGASAREAPrivPtr saPriv = (MGASAREAPrivPtr)(((char*)sPriv->pSAREA)+
+ drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+
mgaScreen->sarea_priv_offset);
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaCreateContext\n");
+ fprintf(stderr, "mgaCreateContext\n");
- mmesa = (mgaContextPtr)CALLOC(sizeof(mgaContext));
+ /* allocate mga context */
+ mmesa = (mgaContextPtr) CALLOC(sizeof(mgaContext));
if (!mmesa) {
return GL_FALSE;
}
- ctx = driContextPriv->mesaContext;
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx, mmesa, GL_TRUE);
+ if (!mmesa->glCtx) {
+ FREE(mmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = mmesa;
+ /* Init mga state */
mmesa->display = dpy;
mmesa->hHWContext = driContextPriv->hHWContext;
mmesa->driFd = sPriv->fd;
@@ -350,7 +344,8 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
* that both texture units can bind a maximal texture and have them
* on the card at once.
*/
- {
+ ctx = mmesa->glCtx;
+ {
int nr = 2;
if (mgaScreen->chipset == MGA_CARD_TYPE_G200)
@@ -358,21 +353,26 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
if (mgaScreen->textureSize[0] < nr*1024*1024) {
ctx->Const.MaxTextureLevels = 9;
- ctx->Const.MaxTextureSize = 1<<8;
} else if (mgaScreen->textureSize[0] < nr*4*1024*1024) {
ctx->Const.MaxTextureLevels = 10;
- ctx->Const.MaxTextureSize = 1<<9;
} else {
ctx->Const.MaxTextureLevels = 11;
- ctx->Const.MaxTextureSize = 1<<10;
}
+
+ ctx->Const.MaxTextureUnits = nr;
}
- mmesa->hw_stencil = mesaVis->StencilBits && mesaVis->DepthBits == 24;
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 10.0;
+ ctx->Const.MaxLineWidthAA = 10.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
- switch (mesaVis->DepthBits) {
- case 16:
- mmesa->depth_scale = 1.0/(GLdouble)0xffff;
+ switch (mesaVis->depthBits) {
+ case 16:
+ mmesa->depth_scale = 1.0/(GLdouble)0xffff;
mmesa->depth_clear_mask = ~0;
mmesa->ClearDepth = 0xffff;
break;
@@ -392,20 +392,37 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
break;
};
- mmesa->canDoStipple = GL_FALSE;
- mmesa->renderindex = -1; /* impossible value */
+ mmesa->haveHwStipple = GL_FALSE;
+ mmesa->RenderIndex = -1; /* impossible value */
mmesa->new_state = ~0;
mmesa->dirty = ~0;
- mmesa->warp_pipe = 0;
+ mmesa->vertex_format = 0;
mmesa->CurrentTexObj[0] = 0;
mmesa->CurrentTexObj[1] = 0;
+ mmesa->tmu_source[0] = 0;
+ mmesa->tmu_source[1] = 1;
mmesa->texAge[0] = 0;
mmesa->texAge[1] = 0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, mga_pipeline );
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
-#if 0
- mmesa->status = (GLuint *)mmesa->mgaScreen->status.map;
-#endif
mmesa->primary_offset = mmesa->mgaScreen->primary.handle;
ctx->DriverCtx = (void *) mmesa;
@@ -418,26 +435,10 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
mgaDDInitSpanFuncs( ctx );
mgaDDInitDriverFuncs( ctx );
mgaDDInitIoctlFuncs( ctx );
-/* mgaDDInitPixelFuncs( ctx );*/
-
- ctx->Driver.TriangleCaps = (DD_TRI_CULL|
- DD_TRI_LIGHT_TWOSIDE|
- DD_TRI_STIPPLE|
- DD_TRI_OFFSET);
-
- /* Ask mesa to clip fog coordinates for us.
- */
- ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
-
- if (ctx->VB)
- mgaDDRegisterVB( ctx->VB );
-
- if (ctx->NrPipelineStages)
- ctx->NrPipelineStages =
- mgaDDRegisterPipelineStages(ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages);
+ mgaDDInitPixelFuncs( ctx );
+ mgaDDInitTriFuncs( ctx );
+ mgaInitVB( ctx );
mgaInitState( mmesa );
driContextPriv->driverPrivate = (void *) mmesa;
@@ -445,70 +446,67 @@ GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
return GL_TRUE;
}
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
+static void
+mgaDestroyContext(__DRIcontextPrivate *driContextPriv)
{
mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaDestroyContext\n");
+ fprintf(stderr, "mgaDestroyContext\n");
+ assert(mmesa); /* should never be null */
if (mmesa) {
- Xfree(mmesa);
- driContextPriv->driverPrivate = NULL;
+ _swsetup_DestroyContext( mmesa->glCtx );
+ _tnl_DestroyContext( mmesa->glCtx );
+ _ac_DestroyContext( mmesa->glCtx );
+ _swrast_DestroyContext( mmesa->glCtx );
+
+ mgaFreeVB( mmesa->glCtx );
+
+ /* free the Mesa context */
+ mmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(mmesa->glCtx);
+ /* free the mga context */
+ FREE(mmesa);
}
}
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
+static GLboolean
+mgaCreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
{
- GLboolean swStencil = mesaVis->StencilBits > 0 && mesaVis->DepthBits != 24;
-
- if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
- fprintf(stderr, "XMesaCreateWindowBuffer\n");
-
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- swStencil,
- mesaVis->AccumRedBits > 0,
- GL_FALSE /* software alpha buffer/ */
- );
-}
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis)
-{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer(mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0
- );
-#else
- return NULL; /* not implemented yet */
-#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
}
-void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+static void
+mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
{
- /* XXX should do swap according to the buffer, not the context! */
- mgaContextPtr mmesa = mgaCtx;
- FLUSH_VB( mmesa->glCtx, "swap buffers" );
- mgaSwapBuffers(mmesa);
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
}
-GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
{
mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
if (mmesa)
@@ -517,14 +515,14 @@ GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv)
return GL_TRUE;
}
-GLboolean
-XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+mgaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
-GLboolean
-XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+static GLboolean
+mgaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
{
return GL_TRUE;
}
@@ -536,28 +534,31 @@ XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
*
* But why are we doing context initialization here???
*/
-GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv)
+static GLboolean
+mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
{
if (driContextPriv) {
- mgaCtx = (mgaContextPtr) driContextPriv->driverPrivate;
+ mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
- gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer);
+ _mesa_make_current2(mmesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
- if (mgaCtx->driDrawable != driDrawPriv) {
- mgaCtx->driDrawable = driDrawPriv;
- mgaCtx->dirty = ~0;
- mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+ if (mmesa->driDrawable != driDrawPriv) {
+ mmesa->driDrawable = driDrawPriv;
+ mmesa->dirty = ~0;
+ mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
}
- if (!mgaCtx->glCtx->Viewport.Width)
- gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h);
+ if (!mmesa->glCtx->Viewport.Width)
+ _mesa_set_viewport(mmesa->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
}
else {
- gl_make_current(0,0);
- mgaCtx = NULL;
+ _mesa_make_current(NULL, NULL);
}
return GL_TRUE;
@@ -575,7 +576,7 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
if (*(dPriv->pStamp) != mmesa->lastStamp) {
mmesa->lastStamp = *(dPriv->pStamp);
- mmesa->setupdone = 0;
+ mmesa->SetupNewInputs |= VERT_CLIP;
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) );
}
@@ -599,5 +600,35 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
+static const struct __DriverAPIRec mgaAPI = {
+ mgaInitDriver,
+ mgaDestroyScreen,
+ mgaCreateContext,
+ mgaDestroyContext,
+ mgaCreateBuffer,
+ mgaDestroyBuffer,
+ mgaSwapBuffers,
+ mgaMakeCurrent,
+ mgaUnbindContext,
+ mgaOpenFullScreen,
+ mgaCloseFullScreen
+};
+
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &mgaAPI);
+ return (void *) psp;
+}
+
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
index 68c075555..366d4fe5e 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h
@@ -32,10 +32,8 @@
#ifdef GLX_DIRECT_RENDERING
#include <sys/time.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "types.h"
+#include "dri_util.h"
+#include "mtypes.h"
#include "mgaregs.h"
typedef struct mga_screen_private_s {
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
index 236ca59c5..c1790b9a5 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.c
@@ -31,6 +31,7 @@
#include "mgabuffers.h"
#include "mgastate.h"
#include "mgaioctl.h"
+#include "mgatris.h"
static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
{
@@ -131,8 +132,9 @@ static void mgaUpdateRectsFromSarea( mgaContextPtr mmesa )
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK) & ~(sarea->exported_buffers);
}
+#endif
-
+#if 1
static void printSareaRects( mgaContextPtr mmesa )
{
__DRIscreenPrivate *driScreen = mmesa->driScreen;
@@ -202,6 +204,7 @@ static void printMmesaRects( mgaContextPtr mmesa )
#endif
+
void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
{
__DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
@@ -209,22 +212,22 @@ void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
/* fprintf(stderr, "%s\n", __FUNCTION__); */
- XMESA_VALIDATE_DRAWABLE_INFO(mmesa->display,
- mmesa->driScreen,
- driDrawable);
- mmesa->dirty_cliprects = 0;
+ DRI_VALIDATE_DRAWABLE_INFO(mmesa->display, mmesa->driScreen, driDrawable);
+ mmesa->dirty_cliprects = 0;
if (mmesa->draw_buffer == MGA_FRONT)
mgaXMesaSetFrontClipRects( mmesa );
else
mgaXMesaSetBackClipRects( mmesa );
-/* printMmesaRects(mmesa); */
+ if (0)
+ printMmesaRects(mmesa);
sarea->req_drawable = driDrawable->draw;
sarea->req_draw_buffer = mmesa->draw_buffer;
mgaUpdateClipping( mmesa->glCtx );
+ mgaCalcViewport( mmesa->glCtx );
mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
}
@@ -237,7 +240,6 @@ GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
FLUSH_BATCH( MGA_CONTEXT(ctx) );
- mmesa->Fallback &= ~MGA_FALLBACK_BUFFER;
if (mode == GL_FRONT_LEFT)
{
@@ -247,6 +249,7 @@ GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
mmesa->draw_buffer = MGA_FRONT;
mgaXMesaSetFrontClipRects( mmesa );
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
}
else if (mode == GL_BACK_LEFT)
@@ -257,28 +260,13 @@ GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode )
mmesa->draw_buffer = MGA_BACK;
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
mgaXMesaSetBackClipRects( mmesa );
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
}
else
{
- mmesa->Fallback |= MGA_FALLBACK_BUFFER;
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
return GL_FALSE;
}
}
-void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode )
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
- if (mode == GL_FRONT_LEFT)
- {
- mmesa->readOffset = mmesa->mgaScreen->frontOffset;
- mmesa->read_buffer = MGA_FRONT;
- }
- else
- {
- mmesa->readOffset = mmesa->mgaScreen->backOffset;
- mmesa->read_buffer = MGA_BACK;
- }
-}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
index 28dba8735..d3d5f9502 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgabuffers.h
@@ -29,9 +29,6 @@
#ifndef MGA_BUFFERS_H
#define MGA_BUFFERS_H
-void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
- GLenum mode );
-
GLboolean mgaDDSetDrawBuffer(GLcontext *ctx, GLenum mode );
void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers );
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
index 2462a54a7..fee1adae6 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgacontext.h
@@ -30,21 +30,14 @@
#define MGALIB_INC
#include <X11/Xlibint.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-
-#include "xf86drm.h"
-#include "xf86drmMga.h"
-
-#include "types.h"
-
+#include "dri_util.h"
+#include "mtypes.h"
+#include "drm.h"
#include "mm.h"
#include "mem.h"
-
-#include "mgavb.h"
#include "mga_sarea.h"
+
#define MGA_SET_FIELD(reg,mask,val) reg = ((reg) & (mask)) | ((val) & ~(mask))
#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
#define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT))
@@ -59,34 +52,39 @@
* - incomplete textures
* - GL_DEPTH_FUNC == GL_NEVER not in h/w
*/
-#define MGA_FALLBACK_TEXTURE 0x1
-#define MGA_FALLBACK_BUFFER 0x2
-#define MGA_FALLBACK_LOGICOP 0x4
-#define MGA_FALLBACK_STENCIL 0x8
-#define MGA_FALLBACK_DEPTH 0x10
+#define MGA_FALLBACK_TEXTURE 0x1
+#define MGA_FALLBACK_DRAW_BUFFER 0x2
+#define MGA_FALLBACK_READ_BUFFER 0x4
+#define MGA_FALLBACK_LOGICOP 0x8
+#define MGA_FALLBACK_RENDERMODE 0x10
+#define MGA_FALLBACK_STENCIL 0x20
+#define MGA_FALLBACK_DEPTH 0x40
/* For mgaCtx->new_state.
*/
#define MGA_NEW_DEPTH 0x1
#define MGA_NEW_ALPHA 0x2
-#define MGA_NEW_FOG 0x4
#define MGA_NEW_CLIP 0x8
-#define MGA_NEW_MASK 0x10
#define MGA_NEW_TEXTURE 0x20
#define MGA_NEW_CULL 0x40
#define MGA_NEW_WARP 0x80
#define MGA_NEW_STENCIL 0x100
#define MGA_NEW_CONTEXT 0x200
+/* Use the templated vertex formats:
+ */
+#define TAG(x) mga##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
-typedef void (*mga_interp_func)( GLfloat t,
- GLfloat *result,
- const GLfloat *in,
- const GLfloat *out );
-
-
+typedef struct mga_context_t mgaContext;
+typedef struct mga_context_t *mgaContextPtr;
+typedef void (*mga_tri_func)( mgaContextPtr, mgaVertex *, mgaVertex *,
+ mgaVertex * );
+typedef void (*mga_line_func)( mgaContextPtr, mgaVertex *, mgaVertex * );
+typedef void (*mga_point_func)( mgaContextPtr, mgaVertex * );
@@ -95,7 +93,6 @@ typedef void (*mga_interp_func)( GLfloat t,
#define MGA_BLEND_ENV_COLOR 0x1
#define MGA_BLEND_MULTITEX 0x2
-struct mga_elt_tab;
struct mga_texture_object_s;
struct mga_screen_private_s;
@@ -140,51 +137,55 @@ struct mga_context_t {
/* Map GL texture units onto hardware.
*/
- GLuint multitex;
GLuint tmu_source[2];
- GLuint tex_dest[2];
-
+
GLboolean default32BitTextures;
/* Manage fallbacks
*/
- GLuint IndirectTriangles;
- int Fallback;
+ GLuint Fallback;
- /* Support for CVA and the fastpath
+ /* Temporaries for translating away float colors:
*/
- unsigned int setupdone;
- unsigned int setupindex;
- unsigned int renderindex;
- unsigned int using_fast_path;
- mga_interp_func interp;
-
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
/* Support for limited GL_BLEND fallback
*/
unsigned int blend_flags;
unsigned int envcolor;
-
- /* Shortcircuit some state changes
+ /* Rasterization state
*/
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLuint RenderIndex;
+
+ GLuint hw_primitive;
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ char *verts;
+ GLint vertex_stride_shift;
+ GLuint vertex_format;
+ GLuint vertex_size;
+
+ /* Fallback rasterization functions
+ */
+ mga_point_func draw_point;
+ mga_line_func draw_line;
+ mga_tri_func draw_tri;
/* Manage driver and hardware state
*/
- GLuint new_state;
+ GLuint new_gl_state;
+ GLuint new_state;
GLuint dirty;
mga_context_regs_t setup;
- GLuint warp_pipe;
- GLuint vertsize;
- GLuint MonoColor;
GLuint ClearColor;
GLuint ClearDepth;
GLuint poly_stipple;
@@ -193,7 +194,8 @@ struct mga_context_t {
GLuint depth_clear_mask;
GLuint stencil_clear_mask;
GLuint hw_stencil;
- GLboolean canDoStipple;
+ GLuint haveHwStipple;
+ GLfloat hw_viewport[16];
/* Dma buffers
*/
@@ -237,20 +239,9 @@ struct mga_context_t {
__DRIscreenPrivate *driScreen;
struct mga_screen_private_s *mgaScreen;
MGASAREAPrivPtr sarea;
-
-
- /* New setupdma path
- */
- drmBufPtr elt_buf, retained_buf;
- GLuint *first_elt, *next_elt;
- GLfloat *next_vert;
- GLuint next_vert_phys;
- GLuint first_vert_phys;
- struct mga_elt_tab *elt_tab;
- GLfloat device_matrix[16];
};
-
+#define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx))
#define MGAPACKCOLOR555(r,g,b,a) \
((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
@@ -307,23 +298,10 @@ static __inline__ GLuint mgaPackColor(GLuint cpp,
#define SUBPIXEL_Y (-0.5F + 0.125)
-typedef struct mga_context_t mgaContext;
-typedef struct mga_context_t *mgaContextPtr;
-
-struct mga_elt_tab {
- void (*emit_unclipped_verts)( struct vertex_buffer *VB );
-
- void (*build_tri_verts)( mgaContextPtr mmesa,
- struct vertex_buffer *VB,
- GLfloat *O, GLuint *elt );
-
- void (*interp)( GLfloat t, GLfloat *O,
- const GLfloat *I, const GLfloat *J );
-
- void (*project_and_emit_verts)( mgaContextPtr mmesa,
- const GLfloat *verts,
- GLuint *elts,
- int nr );
-};
+#define MGA_WA_TRIANGLES 0x18000000
+#define MGA_WA_TRISTRIP_T0 0x02010200
+#define MGA_WA_TRIFAN_T0 0x01000408
+#define MGA_WA_TRISTRIP_T0T1 0x02010400
+#define MGA_WA_TRIFAN_T0T1 0x01000810
#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
index 34c9750f4..84c566909 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c
@@ -24,11 +24,10 @@
* Authors:
* Keith Whitwell <keithw@valinux.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.11 2001/08/18 02:51:05 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.10 2001/04/10 16:07:50 dawes Exp $ */
-#include "types.h"
-#include "vbrender.h"
+#include "mtypes.h"
#include <stdio.h>
@@ -42,17 +41,13 @@
#include "mgatex.h"
#include "mgatris.h"
#include "mgavb.h"
-#include "mgapipeline.h"
+#include "mga_xmesa.h"
#include "extensions.h"
-#include "vb.h"
-#include "dd.h"
-
-#if defined(USE_X86_ASM) || defined(USE_3DNOW_ASM) || defined(USE_KATMAI_ASM)
+#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#endif
-#define MGA_DATE "20010622"
-
+#define MGA_DATE "20010624"
/***************************************
@@ -91,7 +86,7 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
/* Append any CPU-specific information.
*/
#ifdef USE_X86_ASM
- if ( gl_x86_cpu_features ) {
+ if ( _mesa_x86_cpu_features ) {
strncat( buffer, " x86", 4 );
}
#endif
@@ -105,7 +100,7 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
strncat( buffer, "/3DNow!", 7 );
}
#endif
-#ifdef USE_KATMAI_ASM
+#ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
strncat( buffer, "/SSE", 4 );
}
@@ -118,17 +113,6 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name )
}
-static GLint mgaGetParameteri(const GLcontext *ctx, GLint param)
-{
- switch (param) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- fprintf(stderr, "mgaGetParameteri(): unknown parameter!\n");
- return 0;
- }
-}
-
static void mgaBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
{
@@ -147,53 +131,31 @@ static void mgaBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)
void mgaDDExtensionsInit( GLcontext *ctx )
{
/* paletted_textures currently doesn't work, but we could fix them later */
- gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
- gl_extensions_disable( ctx, "GL_EXT_paletted_texture" );
+ /*
+ _mesa_enable_extension( ctx, "GL_EXT_shared_texture_palette" );
+ _mesa_enable_extension( ctx, "GL_EXT_paletted_texture" );
+ */
/* Support multitexture only on the g400.
*/
- if (!MGA_IS_G400(MGA_CONTEXT(ctx)))
- {
- gl_extensions_disable( ctx, "GL_ARB_multitexture" );
+ if (MGA_IS_G400(MGA_CONTEXT(ctx))) {
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
}
/* Turn on texenv_add for the G400.
*/
- if (MGA_IS_G400(MGA_CONTEXT(ctx)))
- {
- gl_extensions_enable( ctx, "GL_EXT_texture_env_add" );
+ if (MGA_IS_G400(MGA_CONTEXT(ctx))) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
#if defined (MESA_packed_depth_stencil)
- gl_extensions_enable( ctx, "GL_MESA_packed_depth_stencil" );
+ _mesa_enable_extension( ctx, "GL_MESA_packed_depth_stencil" );
#endif
#if defined (MESA_experimetal_agp_allocator)
- if (!getenv("MGA_DISABLE_AGP_ALLOCATOR"))
- gl_extensions_enable( ctx, "GL_MESA_experimental_agp_allocator" );
+ if (!getenv("MGA_DISABLE_AGP_ALLOCATOR"))
+ _mesa_enable_extension( ctx, "GL_MESA_experimental_agp_allocator" );
#endif
}
-
- /* we don't support point parameters in hardware yet */
- gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
-
- /* No support for fancy imaging stuff. This should kill off
- * a few rogue fallbacks.
- */
- gl_extensions_disable( ctx, "ARB_imaging" );
- gl_extensions_disable( ctx, "GL_EXT_blend_color" );
- gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
- gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
- gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
- gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
- gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" );
- gl_extensions_disable( ctx, "GL_MESA_resize_buffers" );
-
- gl_extensions_disable( ctx, "GL_SGI_color_matrix" );
- gl_extensions_disable( ctx, "GL_SGI_color_table" );
- gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );
- gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );
- gl_extensions_disable( ctx, "GL_ARB_texture_compression" );
- gl_extensions_disable( ctx, "GL_EXT_convolution" );
}
@@ -202,8 +164,4 @@ void mgaDDInitDriverFuncs( GLcontext *ctx )
{
ctx->Driver.GetBufferSize = mgaBufferSize;
ctx->Driver.GetString = mgaDDGetString;
- ctx->Driver.GetParameteri = mgaGetParameteri;
- ctx->Driver.RegisterVB = mgaDDRegisterVB;
- ctx->Driver.UnregisterVB = mgaDDUnregisterVB;
- ctx->Driver.BuildPrecalcPipeline = mgaDDBuildPrecalcPipeline;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c b/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c
deleted file mode 100644
index 254d0b168..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c
+++ /dev/null
@@ -1,460 +0,0 @@
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
- */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaeltpath.c,v 1.7 2001/04/10 16:07:50 dawes Exp $ */
-
-#include <stdio.h>
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-#include "mmath.h"
-#include "xform.h"
-
-#include "mgacontext.h"
-#include "mgapipeline.h"
-#include "mgatris.h"
-#include "mgastate.h"
-#include "mgavb.h"
-
-
-/* Always use a full-sized stride for vertices. [FIXME]
- * Stride in the buffers must be a quadword multiple.
- */
-#define BUFFER_STRIDE 12
-#define CLIP_STRIDE 10
-
-
-static void fire_elts( mgaContextPtr mmesa )
-{
- LOCK_HARDWARE( mmesa );
-
- /* Fire queued elements and discard that buffer if its contents
- * won't be referenced by future elements.
- */
- if (mmesa->elt_buf) {
- GLuint retain = (mmesa->elt_buf == mmesa->retained_buf);
-
- if (mmesa->first_elt != mmesa->next_elt) {
- mgaFireEltsLocked( mmesa,
- ((char *)mmesa->first_elt -
- (char *)mmesa->elt_buf->address),
- ((char *)mmesa->next_elt -
- (char *)mmesa->elt_buf->address),
- !retain );
- } else if (!retain)
- mgaReleaseBufLocked( mmesa, mmesa->elt_buf );
-
- mmesa->elt_buf = 0;
- }
- else if (mmesa->vertex_dma_buffer)
- {
- mgaFlushVerticesLocked( mmesa );
- }
-
- mgaGetEltBufLocked( mmesa );
-
- UNLOCK_HARDWARE( mmesa );
-
- mmesa->next_vert = (GLfloat *)((char *)mmesa->elt_buf->address +
- mmesa->elt_buf->total -
- BUFFER_STRIDE * sizeof(GLfloat));
-
- mmesa->next_vert_phys = (mmesa->mgaScreen->dmaOffset +
- mmesa->elt_buf->idx * MGA_BUFFER_SIZE +
- mmesa->elt_buf->total -
- BUFFER_STRIDE * sizeof(GLfloat));
-
- mmesa->first_elt = (GLuint *)mmesa->elt_buf->address;
- mmesa->next_elt = (GLuint *)mmesa->elt_buf->address;
-
-}
-
-
-static void release_bufs( mgaContextPtr mmesa )
-{
- if (mmesa->retained_buf && mmesa->retained_buf != mmesa->elt_buf)
- {
- LOCK_HARDWARE( mmesa );
- if (mmesa->first_elt != mmesa->next_elt) {
- mgaFireEltsLocked( mmesa,
- ((char *)mmesa->first_elt -
- (char *)mmesa->elt_buf->address),
- ((char *)mmesa->next_elt -
- (char *)mmesa->elt_buf->address),
- 0 );
-
- mmesa->first_elt = mmesa->next_elt;
- }
-
- mgaReleaseBufLocked( mmesa, mmesa->retained_buf );
- UNLOCK_HARDWARE( mmesa );
- }
-
- mmesa->retained_buf = 0;
-}
-
-
-
-
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-#define INTERP_RGBA(t, out, a, b) { \
- int i; \
- for (i = 0; i < 4; i++) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
- GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
- } \
-}
-
-
-#define CLIP(SGN,V,PLANE) \
-if (mask & PLANE) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]]; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- for (i = n = 0 ; i < nr ; i++) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i]; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLfloat *O = verts[next_vert]; \
- outdata[n++] = next_vert++; \
- \
- if (NEGATIVE(dpI)) { \
- GLfloat t = dpI / (dpI - dpJ); \
- interp(t, O, I, J); \
- } \
- else \
- { \
- GLfloat t = dpJ / (dpJ - dpI); \
- interp(t, O, J, I); \
- } \
- } \
- \
- if (!NEGATIVE(dpI)) \
- outdata[n++] = elt_i; \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return; \
-}
-
-
-static void mga_tri_clip( mgaContextPtr mmesa,
- struct vertex_buffer *VB,
- GLuint *elt,
- GLubyte mask )
-{
- struct mga_elt_tab *tab = mmesa->elt_tab;
- mga_interp_func interp = tab->interp;
- GLuint inlist[2][VB_MAX_CLIPPED_VERTS];
- GLuint in = 0;
- GLuint n = 3, next_vert = 3;
- GLuint i;
- GLfloat verts[VB_MAX_CLIPPED_VERTS][CLIP_STRIDE];
-
- /* Build temporary vertices in clipspace. This is the potential
- * downside to this path.
- */
- tab->build_tri_verts( mmesa, VB, (GLfloat *)verts, elt );
-
- inlist[0][0] = 0;
- inlist[0][1] = 1;
- inlist[0][2] = 2;
-
- CLIP(-,0,CLIP_RIGHT_BIT);
- CLIP(+,0,CLIP_LEFT_BIT);
- CLIP(-,1,CLIP_TOP_BIT);
- CLIP(+,1,CLIP_BOTTOM_BIT);
- CLIP(-,2,CLIP_FAR_BIT);
- CLIP(+,2,CLIP_NEAR_BIT);
-
-
- {
- GLuint *out = inlist[in];
- GLuint space = (char *)mmesa->next_vert - (char *)mmesa->next_elt;
-
- if (space < n * (BUFFER_STRIDE + 3) * sizeof(GLuint))
- fire_elts(mmesa);
-
- /* Project the new vertices and emit to dma buffers. Translate
- * out values to physical addresses for setup dma.
- */
- tab->project_and_emit_verts( mmesa, (GLfloat *)verts, out, n );
-
- /* Convert the planar polygon to a list of triangles and emit to
- * elt buffers.
- */
- for (i = 2 ; i < n ; i++) {
- mmesa->next_elt[0] = out[0];
- mmesa->next_elt[1] = out[i-1];
- mmesa->next_elt[2] = out[i];
- mmesa->next_elt += 3;
- }
- }
-}
-
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-
-#define INIT(x)
-
-#define TRI_THRESHOLD (3 * sizeof(GLuint))
-
-#define UNCLIPPED_VERT(x) (mmesa->first_vert_phys - x * BUFFER_STRIDE * 4)
-
-#define TRIANGLE( e2, e1, e0 ) \
-do { \
- if (((char *)mmesa->next_vert - \
- (char *)mmesa->next_elt) < TRI_THRESHOLD) \
- fire_elts(mmesa); \
- mmesa->next_elt[0] = UNCLIPPED_VERT(e2); \
- mmesa->next_elt[1] = UNCLIPPED_VERT(e1); \
- mmesa->next_elt[2] = UNCLIPPED_VERT(e0); \
- mmesa->next_elt+=3; \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask = mask[e2] | mask[e1] | mask[e0]; \
- if (ormask == 0) { \
- TRIANGLE( e2, e1, e0 ); \
- } else if ((mask[e2] & mask[e1] & mask[e0]) == 0) { \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- mga_tri_clip( mmesa, VB, out, ormask ); \
- } \
-} while (0)
-
-#define LOCAL_VARS \
- mgaContextPtr mmesa = MGA_CONTEXT( VB->ctx ); \
- GLuint *elt = VB->EltPtr->data; \
- GLuint out[VB_MAX_CLIPPED_VERTS]; \
- GLubyte *mask = VB->ClipMask; \
- (void) mask; (void) out; (void) elt; (void) mmesa;
-
-
-
-#define RENDER_POINTS(start, count)
-#define RENDER_LINE(i1, i0)
-#define RENDER_TRI(i2, i1, i0, pv, parity) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if (parity) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i0, pv ) \
- CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \
- CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
-
-#define TAG(x) mga_##x##_elt
-#include "render_tmp.h"
-
-
-
-#define LOCAL_VARS \
- mgaContextPtr mmesa = MGA_CONTEXT( VB->ctx ); \
- GLuint *elt = VB->EltPtr->data; \
- (void) elt; (void) mmesa;
-
-#define RENDER_POINTS(start, count)
-#define RENDER_LINE(i1, i0)
-#define RENDER_TRI(i2, i1, i0, pv, parity) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if (parity) e2 = elt[i1], e1 = elt[i2]; \
- TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i0, pv ) \
- TRIANGLE(elt[i3], elt[i2], elt[i0]); \
- TRIANGLE(elt[i2], elt[i1], elt[i0])
-
-#define TAG(x) mga_##x##_elt_unclipped
-#include "render_tmp.h"
-
-
-
-
-static void refresh_projection_matrix( GLcontext *ctx )
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLfloat *m = mmesa->device_matrix;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
-
- REFRESH_DRAWABLE_INFO(mmesa);
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX + .5;
- m[MAT_SY] = (- mat->m[MAT_SY]);
- m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - .5;
- m[MAT_SZ] = mat->m[MAT_SZ] * mmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * mmesa->depth_scale;
-}
-
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-
-
-#define TYPE (0)
-#define TAG(x) x
-#include "mgaelttmp.h"
-
-#define TYPE (MGA_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "mgaelttmp.h"
-
-#define TYPE (MGA_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "mgaelttmp.h"
-
-#define TYPE (MGA_RGBA_BIT|MGA_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "mgaelttmp.h"
-
-#define TYPE (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "mgaelttmp.h"
-
-#define TYPE (MGA_TEX0_BIT|MGA_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "mgaelttmp.h"
-
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct mga_elt_tab mgaEltTab[0x80];
-
-void mgaDDEltPathInit( void )
-{
- mga_render_init_elt();
- mga_render_init_elt_unclipped();
-
- mga_init_eltpath( &mgaEltTab[0] );
- mga_init_eltpath_RGBA( &mgaEltTab[MGA_RGBA_BIT] );
- mga_init_eltpath_TEX0( &mgaEltTab[MGA_TEX0_BIT] );
- mga_init_eltpath_RGBA_TEX0( &mgaEltTab[MGA_RGBA_BIT|MGA_TEX0_BIT] );
- mga_init_eltpath_TEX0_TEX1( &mgaEltTab[MGA_TEX0_BIT|MGA_TEX1_BIT] );
- mga_init_eltpath_RGBA_TEX0_TEX1( &mgaEltTab[MGA_RGBA_BIT|MGA_TEX0_BIT|
- MGA_TEX1_BIT] );
-}
-
-#define VALID_SETUP (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
-
-
-
-/* Use a temporary array for device coordinates, so that we can easily
- * tap into existing mesa assembly. Otherwise consider emitting
- * device coordinates to dma buffers directly from the project/cliptest
- * routine. (requires output stride, potential loss of writecombining
- * efficiency?)
- *
- * This path is a lot closer to the standard vertex path in the
- * initial stages than the original fastpath. A slightly more optimal
- * path could be constructed, but would require us to write new
- * assembly.
- */
-void mgaDDEltPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- struct mga_elt_tab *tab = &mgaEltTab[mmesa->setupindex & VALID_SETUP];
-
- VB->ClipPtr = TransformRaw(&VB->Clip, &ctx->ModelProjectMatrix, VB->ObjPtr );
-
- refresh_projection_matrix( ctx );
-
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- VB->Projected = gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &VB->Win,
- VB->ClipMask,
- &VB->ClipOrMask,
- &VB->ClipAndMask );
-
- if (VB->ClipAndMask)
- return;
-
- if (mmesa->vertex_dma_buffer)
- mgaFlushVertices( mmesa );
-
- if (mmesa->new_state)
- mgaDDUpdateHwState( ctx );
-
- /* Allocate a single buffer to hold unclipped vertices. All
- * unclipped vertices must be contiguous.
- */
- if ((char *)mmesa->next_vert - (char *)mmesa->next_elt <
- VB->Count * BUFFER_STRIDE * sizeof(GLuint))
- fire_elts( mmesa );
-
- mmesa->retained_buf = mmesa->elt_buf;
-
- /* Emit unclipped vertices to the buffer.
- */
- tab->emit_unclipped_verts( VB );
-
- /* Emit indices and clipped vertices to one or more buffers.
- */
- if (VB->ClipOrMask) {
- mmesa->elt_tab = tab;
- mga_render_tab_elt[prim]( VB, 0, VB->EltPtr->count, 0 );
- } else
- mga_render_tab_elt_unclipped[prim]( VB, 0, VB->EltPtr->count, 0 );
-
- /* Send to hardware and release any retained buffers.
- */
- release_bufs( mmesa );
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h b/xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h
deleted file mode 100644
index 4016b12ca..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaelttmp.h,v 1.4 2001/04/10 16:07:50 dawes Exp $ */
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
- */
-
-/* Buffers fill from high addresses down with vertices and from low
- * addresses up with elements.
- */
-
-
-/* Emit the bulk of the vertices to the first dma buffer. Leave
- * empty slots for clipped vertices so that we can still address
- * vertices by index.
- */
-static void TAG(emit_unclipped_verts)( struct vertex_buffer *VB )
-{
- GLuint i;
- mgaContextPtr mmesa = MGA_CONTEXT(VB->ctx);
- GLfloat *dev = VB->Projected->start;
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
-
- GLfloat *f = mmesa->next_vert;
- GLuint count = VB->Count;
- GLubyte *clipmask = VB->ClipMask;
-
- const GLfloat *m = mmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
-
- mmesa->retained_buf = mmesa->elt_buf;
- mmesa->first_vert_phys = mmesa->next_vert_phys;
-
- for (i = 0 ; i < count ; f -= BUFFER_STRIDE, i++)
- {
- if (!clipmask[i])
- {
- f[0] = sx * dev[0] + tx;
- f[1] = sy * dev[1] + ty;
- f[2] = sz * dev[2] + tz;
- f[3] = dev[3];
-
- if (TYPE & MGA_RGBA_BIT) {
-#if defined(USE_X86_ASM)
- __asm__ (
- "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (f)
- : "%eax" );
-#else
- GLubyte *b = (GLubyte *)&f[4];
- b[CLIP_UBYTE_B] = color[2];
- b[CLIP_UBYTE_G] = color[1];
- b[CLIP_UBYTE_R] = color[0];
- b[CLIP_UBYTE_A] = color[3];
-#endif
- }
-
- if (TYPE & MGA_TEX0_BIT) {
- *(int*)&f[6] = *(int*)&tex0_data[0];
- *(int*)&f[7] = *(int*)&tex0_data[1];
- }
-
- if (TYPE & MGA_TEX1_BIT) {
- *(int*)&f[8] = *(int*)&tex1_data[0];
- *(int*)&f[9] = *(int*)&tex1_data[1];
- }
- }
-
- STRIDE_F(dev, 16);
- if (TYPE & MGA_RGBA_BIT) color += color_stride;
- if (TYPE & MGA_TEX0_BIT) STRIDE_F(tex0_data, tex0_stride);
- if (TYPE & MGA_TEX1_BIT) STRIDE_F(tex1_data, tex1_stride);
- }
-
- mmesa->next_vert = f;
- mmesa->next_vert_phys -= count * BUFFER_STRIDE * sizeof(GLuint);
-}
-
-
-/* Build three temporary clipspace vertex for clipping a triangle.
- * Recreate from the VB data rather than trying to read back from
- * uncached memory.
- */
-static void TAG(build_tri_verts)( mgaContextPtr mmesa,
- struct vertex_buffer *VB,
- GLfloat *O,
- GLuint *elt )
-{
- int i;
-
- for (i = 0 ; i < 3 ; i++, O += CLIP_STRIDE) {
- GLfloat *clip = VB->Clip.start + elt[i]*4;
-
- O[0] = clip[0];
- O[1] = clip[1];
- O[2] = clip[2];
- O[3] = clip[3];
-
- if (TYPE & MGA_RGBA_BIT) {
- GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, elt[i]);
-#if defined(USE_X86_ASM)
- __asm__ (
- "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (O)
- : "%eax" );
-#else
- GLubyte *b = (GLubyte *)&O[4];
- b[CLIP_UBYTE_B] = color[2];
- b[CLIP_UBYTE_G] = color[1];
- b[CLIP_UBYTE_R] = color[0];
- b[CLIP_UBYTE_A] = color[3];
-#endif
- }
-
- *(GLuint *)&O[5] = UNCLIPPED_VERT(elt[i]);
-
- if (TYPE & MGA_TEX0_BIT) {
- GLfloat *tex0_data = VEC_ELT(VB->TexCoordPtr[0], GLfloat, elt[i]);
- *(int*)&O[6] = *(int*)&tex0_data[0];
- *(int*)&O[7] = *(int*)&tex0_data[1];
- }
-
- if (TYPE & MGA_TEX1_BIT) {
- GLfloat *tex1_data = VEC_ELT(VB->TexCoordPtr[1], GLfloat, elt[i]);
- *(int*)&O[8] = *(int*)&tex1_data[0];
- *(int*)&O[9] = *(int*)&tex1_data[1];
- }
- }
-}
-
-
-/* Interpolate between two of the vertices constructed above.
- */
-static void TAG(interp)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP(t, I[0], J[0]);
- O[1] = LINTERP(t, I[1], J[1]);
- O[2] = LINTERP(t, I[2], J[2]);
- O[3] = LINTERP(t, I[3], J[3]);
-
- if (TYPE & MGA_RGBA_BIT) {
- INTERP_RGBA(t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])));
- }
-
- *(GLuint *)&O[5] = ~0; /* note that this is a new vertex */
-
- if (TYPE & MGA_TEX0_BIT) {
- O[6] = LINTERP(t, I[6], J[6]);
- O[7] = LINTERP(t, I[7], J[7]);
- }
-
- if (TYPE & MGA_TEX1_BIT) {
- O[8] = LINTERP(t, I[8], J[8]);
- O[9] = LINTERP(t, I[9], J[9]);
- }
-}
-
-
-
-/* When clipping is complete, scan the final vertex list and emit any
- * new ones to dma buffers. Update the element list to a format
- * suitable for sending to hardware.
- */
-static void TAG(project_and_emit_verts)( mgaContextPtr mmesa,
- const GLfloat *verts,
- GLuint *elt,
- int nr)
-{
-
- GLfloat *O = mmesa->next_vert;
- GLuint phys = mmesa->next_vert_phys;
-
- const GLfloat *m = mmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
- GLuint i;
-
- for (i = 0 ; i < nr ; i++) {
- const GLfloat *I = &verts[elt[i] * CLIP_STRIDE];
- GLuint tmp = *(GLuint *)&I[5];
-
- if ((elt[i] = tmp) == ~0)
- {
- GLfloat oow = 1.0/I[3];
-
- elt[i] = phys;
- phys -= BUFFER_STRIDE * sizeof(GLuint);
-
- O[0] = sx * I[0] * oow + tx;
- O[1] = sy * I[1] * oow + ty;
- O[2] = sz * I[2] * oow + tz;
- O[3] = oow;
-
- if (TYPE & MGA_RGBA_BIT) {
- *(int*)&O[4] = *(int*)&I[4];
- }
-
- if (TYPE & MGA_TEX0_BIT) {
- *(int*)&O[6] = *(int*)&I[6];
- *(int*)&O[7] = *(int*)&I[7];
- }
-
- if (TYPE & MGA_TEX1_BIT) {
- *(int*)&O[8] = *(int*)&I[8];
- *(int*)&O[9] = *(int*)&I[9];
- }
-
- O -= BUFFER_STRIDE;
- }
- }
-
- mmesa->next_vert = O;
- mmesa->next_vert_phys = phys;
-}
-
-
-
-static void TAG(mga_init_eltpath)( struct mga_elt_tab *tab )
-{
- tab->emit_unclipped_verts = TAG(emit_unclipped_verts);
- tab->build_tri_verts = TAG(build_tri_verts);
- tab->interp = TAG(interp);
- tab->project_and_emit_verts = TAG(project_and_emit_verts);
-}
-
-#undef TYPE
-#undef TAG
-#undef STRIDE
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
deleted file mode 100644
index 30e840ef3..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
- */
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgafastpath.c,v 1.9 2001/08/27 21:12:19 dawes Exp $ */
-
-#include <stdio.h>
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-#include "mmath.h"
-
-#include "mgacontext.h"
-#include "mgapipeline.h"
-#include "mgatris.h"
-#include "mgastate.h"
-#include "mgavb.h"
-#include "vbcull.h"
-
-
-struct mga_fast_tab {
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
- void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
-};
-
-
-
-
-#define POINT(x) mga_draw_point(mmesa, &ivert[x], psize)
-#define LINE(x,y) mga_draw_line(mmesa, &ivert[x], &ivert[y], lwidth)
-#define TRI(x,y,z) mga_draw_triangle(mmesa, &ivert[x], &ivert[y], &ivert[z])
-
-
-
-
-/* Direct, and no clipping required. I haven't written the clip funcs
- * yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for(e=start;e<count;e++) \
- POINT(elt[e]); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-
-#define RENDER_TRI( i2, i1, i, pv, parity) \
-do { \
-{ GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if (parity) {GLuint tmp = e2; e2 = e1; e1 = tmp;} \
- TRI(e2, e1, e); \
-}} while (0)
-
-
-#define RENDER_QUAD( i3, i2, i1, i, pv) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI(e3, e2, e); \
- TRI(e2, e1, e); \
-} while (0)
-
-#define LOCAL_VARS \
- mgaVertexPtr ivert = MGA_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
- const GLfloat lwidth = ctx->Line.Width; \
- const GLfloat psize = ctx->Point.Size; \
- (void) lwidth; (void)psize; (void) ivert;
-
-
-#define TAG(x) x##_mga_smooth_indirect
-#include "render_tmp.h"
-
-
-
-static void mga_render_elements_direct( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = render_tab_mga_smooth_indirect[prim];
- GLuint p = 0;
-
- if (mmesa->new_state)
- mgaDDUpdateHwState( ctx );
-
- do {
- func( VB, 0, nr, 0 );
- } while (ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ));
-}
-
-
-
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-#define INTERP_RGBA(t, out, a, b) { \
- int i; \
- for (i = 0; i < 4; i++) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
- GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
- } \
-}
-
-
-#define CLIP(SGN,V,PLANE) \
-if (mask & PLANE) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- inlist[0] = vlist1; \
- for (i = n = 0 ; i < nr ; i++) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t, *in, *out; \
- \
- if (NEGATIVE(dpI)) { \
- t = dpI / (dpI - dpJ); \
- in = I; \
- out = J; \
- } \
- else \
- { \
- t = dpJ / (dpJ - dpI); \
- in = J; \
- out = I; \
- } \
- \
- interp(t, O, in, out); \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if (!NEGATIVE(dpI)) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if (n < 3) return; \
-}
-
-#define LINE_CLIP(x,y,z,w,PLANE) \
-if (mask & PLANE) { \
- GLfloat dpI = DOT4V(I,x,y,z,w); \
- GLfloat dpJ = DOT4V(J,x,y,z,w); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- \
- interp(t, O, I, J); \
- \
- clipmask[next_vert] = 0; \
- \
- if (NEGATIVE(dpI)) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; elts[1] = next_vert++; \
- } \
- } \
- else if (NEGATIVE(dpI)) \
- return; \
-}
-
-
-static __inline void mga_tri_clip( GLuint **p_elts,
- mgaVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- mga_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint in = 0;
- GLuint n = 3;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP(-,0,CLIP_RIGHT_BIT);
- CLIP(+,0,CLIP_LEFT_BIT);
- CLIP(-,1,CLIP_TOP_BIT);
- CLIP(+,1,CLIP_BOTTOM_BIT);
- CLIP(-,2,CLIP_FAR_BIT);
- CLIP(+,2,CLIP_NEAR_BIT);
-
- /* Convert the planar polygon to a list of triangles.
- */
- out = inlist[in];
-
- for (i = 2 ; i < n ; i++) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static __inline void mga_line_clip( GLuint **p_elts,
- mgaVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- mga_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT);
- LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT);
- LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT);
- LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT);
- LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT);
- LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT);
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-
-#define CLIP_POINT( e ) \
- if (mask[e]) \
- *out++ = e
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out+=2; \
- if (ormask) { \
- out-=2; \
- if (!(mask[e0] & mask[e1])) { \
- mga_line_clip( &out, verts, mask, &next_vert, ormask, interp); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if (ormask) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0])) { \
- mga_tri_clip( &out, verts, mask, &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-
-
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-#define LOCAL_VARS \
- mgaContextPtr mmesa = MGA_CONTEXT( VB->ctx ); \
- GLuint *elt = VB->EltPtr->data; \
- mgaVertex *verts = MGA_DRIVER_DATA(VB)->verts; \
- GLuint next_vert = MGA_DRIVER_DATA(VB)->last_vert; \
- GLuint *out = MGA_DRIVER_DATA(VB)->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
- mga_interp_func interp = mmesa->interp; \
- (void) interp; (void) verts;
-
-#define POSTFIX \
- MGA_DRIVER_DATA(VB)->clipped_elements.count = \
- out - MGA_DRIVER_DATA(VB)->clipped_elements.data; \
- MGA_DRIVER_DATA(VB)->last_vert = next_vert;
-
-
-#define INIT(x)
-
-#define RENDER_POINTS(start, count) \
-do { \
- GLuint i; \
- for (i = start ; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE(i1, i0) \
- CLIP_LINE(elt[i1], elt[i0])
-
-#define RENDER_TRI(i2, i1, i0, pv, parity) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if (parity) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD(i3, i2, i1, i0, pv ) \
- CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \
- CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0])
-
-#define TAG(x) mga_clip_##x##_elt
-#include "render_tmp.h"
-
-
-
-static void mga_project_vertices( struct vertex_buffer *VB )
-{
- mgaVertexBufferPtr mgaVB = MGA_DRIVER_DATA(VB);
- GLcontext *ctx = VB->ctx;
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat m[16];
-
- REFRESH_DRAWABLE_INFO(mmesa);
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
- m[MAT_SY] = (- mat->m[MAT_SY]);
- m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y;
- m[MAT_SZ] = mat->m[MAT_SZ] * mmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * mmesa->depth_scale;
-
- gl_project_v16( mgaVB->verts[VB->CopyStart].f,
- mgaVB->verts[mgaVB->last_vert].f,
- m,
- 16 * 4 );
-}
-
-static void mga_project_clipped_vertices( struct vertex_buffer *VB )
-{
- mgaVertexBufferPtr mgaVB = MGA_DRIVER_DATA(VB);
- GLcontext *ctx = VB->ctx;
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat m[16];
-
- REFRESH_DRAWABLE_INFO(mmesa);
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
- m[MAT_SY] = (- mat->m[MAT_SY]);
- m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - SUBPIXEL_Y;
- m[MAT_SZ] = mat->m[MAT_SZ] * mmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * mmesa->depth_scale;
-
- gl_project_clipped_v16( mgaVB->verts[VB->CopyStart].f,
- mgaVB->verts[mgaVB->last_vert].f,
- m,
- 16 * 4,
- VB->ClipMask + VB->CopyStart );
-}
-
-
-/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_UBYTE_COLOR 4
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define TYPE (0)
-#define TAG(x) x
-#include "mgafasttmp.h"
-
-#define TYPE (MGA_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "mgafasttmp.h"
-
-#define TYPE (MGA_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "mgafasttmp.h"
-
-#define TYPE (MGA_RGBA_BIT|MGA_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "mgafasttmp.h"
-
-#define TYPE (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "mgafasttmp.h"
-
-#define TYPE (MGA_TEX0_BIT|MGA_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "mgafasttmp.h"
-
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct mga_fast_tab mgaFastTab[0x80];
-
-void mgaDDFastPathInit( void )
-{
- mga_clip_render_init_elt();
- render_init_mga_smooth_indirect();
-
- mga_init_fastpath( &mgaFastTab[0] );
- mga_init_fastpath_RGBA( &mgaFastTab[MGA_RGBA_BIT] );
- mga_init_fastpath_TEX0( &mgaFastTab[MGA_TEX0_BIT] );
- mga_init_fastpath_RGBA_TEX0( &mgaFastTab[MGA_RGBA_BIT|MGA_TEX0_BIT] );
- mga_init_fastpath_TEX0_TEX1( &mgaFastTab[MGA_TEX0_BIT|MGA_TEX1_BIT] );
- mga_init_fastpath_RGBA_TEX0_TEX1( &mgaFastTab[MGA_RGBA_BIT|MGA_TEX0_BIT|
- MGA_TEX1_BIT] );
-}
-
-#define VALID_SETUP (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
-
-void mgaDDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- struct mga_fast_tab *tab = &mgaFastTab[mmesa->setupindex & VALID_SETUP];
- GLuint do_cliptest = 1;
-
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- if (gl_reduce_prim[prim] == GL_TRIANGLES &&
- VB->Count < (MGA_BUFFER_SIZE / 48) &&
- (ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL|
- MAT_FLAG_PERSPECTIVE)) &&
- mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400)
- {
- mgaDDEltPath( VB );
- return;
- }
-
- /* Reserve enough space for the pathological case.
- */
- if (VB->EltPtr->count * 12 > MGA_DRIVER_DATA(VB)->size) {
- mgaDDResizeVB( VB, VB->EltPtr->count * 12 );
- do_cliptest = 1;
- }
-
- tab->build_vertices( VB, do_cliptest ); /* object->clip space */
-
- if (mmesa->new_state)
- mgaDDUpdateHwState( ctx );
-
- if (VB->ClipOrMask) {
- if (!VB->ClipAndMask) {
- render_func *clip = mga_clip_render_tab_elt;
-
- mmesa->interp = tab->interp;
-
- clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(MGA_DRIVER_DATA(VB)->clipped_elements);
-
- mga_project_clipped_vertices( VB ); /* clip->device space */
- mga_render_elements_direct( VB ); /* render using new list */
- }
- } else {
- mga_project_vertices( VB ); /* clip->device space */
- mga_render_elements_direct( VB ); /* render using orig list */
- }
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h b/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h
deleted file mode 100644
index b49105a8c..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgafasttmp.h,v 1.3 2001/04/10 16:07:50 dawes Exp $ */
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
- */
-
-
-/* The first part of setup is applied to all vertices, clipped or
- * unclipped. This data will be used for clipping, and then all
- * vertices with a zero clipmask will be projected to device space.
- *
- * This could be split into several loops, but - it seems that the
- * large stride of the fxVertices makes cache issues the big
- * performance factor, and that multiple loops mean multiple cache
- * misses....
- */
-static void TAG(mga_setup_full)( struct vertex_buffer *VB, GLuint do_cliptest )
-{
- GLcontext *ctx = VB->ctx;
- const GLfloat * const m = ctx->ModelProjectMatrix.m;
- GLuint start = VB->CopyStart;
- GLuint count = VB->Count;
-
- gl_xform_points3_v16_general(MGA_DRIVER_DATA(VB)->verts[start].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count - start);
-
- if (do_cliptest)
- {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16(MGA_DRIVER_DATA(VB)->verts[start].f,
- MGA_DRIVER_DATA(VB)->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask + start);
- }
-
- /* These branches are all resolved at compile time. Hopefully all
- * the pointers are valid addresses even when not enabled.
- */
- if (TYPE) {
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
-
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
-
- GLfloat *f = MGA_DRIVER_DATA(VB)->verts[start].f;
- GLfloat *end = f+(16*(count-start));
- while (f != end) {
- if (TYPE & MGA_RGBA_BIT) {
-#if defined(USE_X86_ASM)
- __asm__ (
- "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (f)
- : "%eax" );
-#else
- GLubyte *col = color;
- GLubyte *b = (GLubyte *)&f[CLIP_UBYTE_COLOR];
- b[CLIP_UBYTE_B] = col[2];
- b[CLIP_UBYTE_G] = col[1];
- b[CLIP_UBYTE_R] = col[0];
- b[CLIP_UBYTE_A] = col[3];
-#endif
- }
- if (TYPE & MGA_TEX0_BIT) {
-#if defined (USE_X86_ASM)
- __asm__ (
- "movl (%%ecx), %%eax \n"
- "movl %%eax, 24(%%edi) \n"
- "movl 4(%%ecx), %%eax \n"
- "movl %%eax, 28(%%edi)"
- :
- : "c" (tex0_data), "D" (f)
- : "%eax");
-#else
- *(unsigned int *)(f+CLIP_S0) = *(unsigned int *)tex0_data;
- *(unsigned int *)(f+CLIP_T0) = *(unsigned int *)(tex0_data+1);
-#endif
- }
- if (TYPE & MGA_TEX1_BIT) {
- /* Hits a second cache line.
- */
-#if defined (USE_X86_ASM)
- __asm__ (
- "movl (%%esi), %%eax \n"
- "movl %%eax, 32(%%edi) \n"
- "movl 4(%%esi), %%eax \n"
- "movl %%eax, 36(%%edi)"
- :
- : "S" (tex1_data), "D" (f)
- : "%eax");
-#else
- *(unsigned int *)(f+CLIP_S1) = *(unsigned int *)tex1_data;
- *(unsigned int *)(f+CLIP_T1) = *(unsigned int *)(tex1_data+1);
-#endif
- }
- if(TYPE & MGA_RGBA_BIT)color += color_stride;
- if(TYPE & MGA_TEX0_BIT)STRIDE_F(tex0_data, tex0_stride);
- if(TYPE & MGA_TEX1_BIT)STRIDE_F(tex1_data, tex1_stride);
- f += 16;
- }
- }
-
- MGA_DRIVER_DATA(VB)->clipped_elements.count = start;
- MGA_DRIVER_DATA(VB)->last_vert = count;
-}
-
-
-/* Changed to just put the interp func instead of the whole clip
- * routine into the header. Less code and better chance of doing some
- * of this stuff in assembly.
- */
-static void TAG(mga_interp_vert)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP(t, I[0], J[0]);
- O[1] = LINTERP(t, I[1], J[1]);
- O[2] = LINTERP(t, I[2], J[2]);
- O[3] = LINTERP(t, I[3], J[3]);
-
- if (TYPE & MGA_RGBA_BIT) {
- INTERP_RGBA(t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])));
- }
-
- if (TYPE & MGA_TEX0_BIT) {
- O[6] = LINTERP(t, I[6], J[6]);
- O[7] = LINTERP(t, I[7], J[7]);
- }
-
- if (TYPE & MGA_TEX1_BIT) {
- O[8] = LINTERP(t, I[8], J[8]);
- O[9] = LINTERP(t, I[9], J[9]);
- }
-}
-
-
-static void TAG(mga_init_fastpath)( struct mga_fast_tab *tab )
-{
- tab->interp = TAG(mga_interp_vert);
- tab->build_vertices = TAG(mga_setup_full);
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
index d5524c372..4e8d0de81 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c
@@ -29,9 +29,10 @@
#include <stdio.h>
-#include "types.h"
-#include "pb.h"
+#include "mtypes.h"
+#include "macros.h"
#include "dd.h"
+#include "swrast/swrast.h"
#include "mm.h"
#include "mgacontext.h"
@@ -39,12 +40,13 @@
#include "mgastate.h"
#include "mgatex.h"
#include "mgavb.h"
+#include "mgaioctl.h"
#include "mgatris.h"
#include "mgabuffers.h"
#include "drm.h"
-#include <sys/ioctl.h>
+#include "xf86drmMga.h"
static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
unsigned long dest,
@@ -139,7 +141,7 @@ drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
-static GLbitfield
+static void
mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch )
{
@@ -182,81 +184,81 @@ mgaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
mask &= ~DD_STENCIL_BIT;
}
- if ( !flags )
- return mask;
+ if ( flags ) {
+ LOCK_HARDWARE( mmesa );
- LOCK_HARDWARE( mmesa );
+ if ( mmesa->dirty_cliprects )
+ mgaUpdateRects( mmesa, (MGA_FRONT | MGA_BACK) );
- if ( mmesa->dirty_cliprects )
- mgaUpdateRects( mmesa, (MGA_FRONT | MGA_BACK) );
+ /* flip top to bottom */
+ cy = dPriv->h-cy-ch;
+ cx += mmesa->drawX;
+ cy += mmesa->drawY;
- /* flip top to bottom */
- cy = dPriv->h-cy-ch;
- cx += mmesa->drawX;
- cy += mmesa->drawY;
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr, "Clear, bufs %x nbox %d\n",
+ (int)flags, (int)mmesa->numClipRects );
- if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
- fprintf( stderr, "Clear, bufs %x nbox %d\n",
- (int)flags, (int)mmesa->numClipRects );
+ for (i = 0 ; i < mmesa->numClipRects ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, mmesa->numClipRects);
+ XF86DRIClipRectPtr box = mmesa->pClipRects;
+ XF86DRIClipRectPtr b = mmesa->sarea->boxes;
+ int n = 0;
- for (i = 0 ; i < mmesa->numClipRects ; )
- {
- int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, mmesa->numClipRects);
- XF86DRIClipRectPtr box = mmesa->pClipRects;
- XF86DRIClipRectPtr b = mmesa->sarea->boxes;
- int n = 0;
-
- if (!all) {
- for ( ; i < nr ; i++) {
- GLint x = box[i].x1;
- GLint y = box[i].y1;
- GLint w = box[i].x2 - x;
- GLint h = box[i].y2 - y;
-
- if (x < cx) w -= cx - x, x = cx;
- if (y < cy) h -= cy - y, y = cy;
- if (x + w > cx + cw) w = cx + cw - x;
- if (y + h > cy + ch) h = cy + ch - y;
- if (w <= 0) continue;
- if (h <= 0) continue;
-
- b->x1 = x;
- b->y1 = y;
- b->x2 = x + w;
- b->y2 = y + h;
- b++;
- n++;
- }
- } else {
- for ( ; i < nr ; i++) {
- *b++ = *(XF86DRIClipRectPtr)&box[i];
- n++;
+ if (!all) {
+ for ( ; i < nr ; i++) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ if (x < cx) w -= cx - x, x = cx;
+ if (y < cy) h -= cy - y, y = cy;
+ if (x + w > cx + cw) w = cx + cw - x;
+ if (y + h > cy + ch) h = cy + ch - y;
+ if (w <= 0) continue;
+ if (h <= 0) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++) {
+ *b++ = *(XF86DRIClipRectPtr)&box[i];
+ n++;
+ }
}
- }
- if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
- fprintf( stderr,
- "DRM_IOCTL_MGA_CLEAR flag 0x%x color %x depth %x nbox %d\n",
- flags, clear_color, clear_depth, mmesa->sarea->nbox );
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr,
+ "DRM_IOCTL_MGA_CLEAR flag 0x%x color %x depth %x nbox %d\n",
+ flags, clear_color, clear_depth, mmesa->sarea->nbox );
- mmesa->sarea->nbox = n;
+ mmesa->sarea->nbox = n;
- ret = drmMGAClear( mmesa->driFd, flags,
- clear_color, clear_depth,
- color_mask, depth_mask );
- if ( ret ) {
- fprintf( stderr, "send clear retcode = %d\n", ret );
- exit( 1 );
+ ret = drmMGAClear( mmesa->driFd, flags,
+ clear_color, clear_depth,
+ color_mask, depth_mask );
+ if ( ret ) {
+ fprintf( stderr, "send clear retcode = %d\n", ret );
+ exit( 1 );
+ }
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr, "finished clear %d\n", ++nrclears );
}
- if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
- fprintf( stderr, "finished clear %d\n", ++nrclears );
- }
- UNLOCK_HARDWARE( mmesa );
- mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+ UNLOCK_HARDWARE( mmesa );
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+ }
- return mask;
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
}
@@ -267,15 +269,22 @@ int nrswaps;
/*
* Copy the back buffer to the front buffer.
*/
-void mgaSwapBuffers( mgaContextPtr mmesa )
+void mgaSwapBuffers(Display *dpy, void *drawablePrivate)
{
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ mgaContextPtr mmesa;
XF86DRIClipRectPtr pbox;
GLint nbox;
GLint ret, wait = 0;
GLint i;
GLuint last_frame, last_wrap;
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate;
+
FLUSH_BATCH( mmesa );
LOCK_HARDWARE( mmesa );
@@ -512,55 +521,6 @@ void mgaFlushVertices( mgaContextPtr mmesa )
UNLOCK_HARDWARE( mmesa );
}
-void mgaFlushEltsLocked( mgaContextPtr mmesa )
-{
- if (mmesa->first_elt != mmesa->next_elt) {
- mgaFireEltsLocked( mmesa,
- ((char *)mmesa->first_elt -
- (char *)mmesa->elt_buf->address),
- ((char *)mmesa->next_elt -
- (char *)mmesa->elt_buf->address),
- 0 );
- mmesa->first_elt = mmesa->next_elt;
- }
-}
-
-void mgaFlushElts( mgaContextPtr mmesa )
-{
- LOCK_HARDWARE( mmesa );
- mgaFlushEltsLocked( mmesa );
- UNLOCK_HARDWARE( mmesa );
-}
-
-
-GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords )
-{
- int bytes = dwords * 4;
- GLuint *head;
-
- if (!mmesa->vertex_dma_buffer) {
- LOCK_HARDWARE( mmesa );
-
- if (mmesa->first_elt != mmesa->next_elt)
- mgaFlushEltsLocked(mmesa);
-
- mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
- UNLOCK_HARDWARE( mmesa );
- } else if (mmesa->vertex_dma_buffer->used + bytes >
- mmesa->vertex_dma_buffer->total) {
- LOCK_HARDWARE( mmesa );
- mgaFlushVerticesLocked( mmesa );
- mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
- UNLOCK_HARDWARE( mmesa );
- }
-
- head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address +
- mmesa->vertex_dma_buffer->used);
-
- mmesa->vertex_dma_buffer->used += bytes;
- return head;
-}
-
void mgaFireILoadLocked( mgaContextPtr mmesa,
GLuint offset, GLuint length )
@@ -591,12 +551,6 @@ drmBufPtr mgaGetBufferLocked( mgaContextPtr mmesa )
return mga_get_buffer_ioctl( mmesa );
}
-void mgaGetEltBufLocked( mgaContextPtr mmesa )
-{
- mmesa->elt_buf = mga_get_buffer_ioctl( mmesa );
-}
-
-
void mgaDDFlush( GLcontext *ctx )
@@ -618,92 +572,6 @@ void mgaDDFlush( GLcontext *ctx )
-void mgaFireEltsLocked( mgaContextPtr mmesa,
- GLuint start,
- GLuint end,
- GLuint discard )
-{
- XF86DRIClipRectPtr pbox = mmesa->pClipRects;
- int nbox = mmesa->numClipRects;
- drmBufPtr buffer = mmesa->elt_buf;
- int i;
-
- if (!buffer)
- return;
-
- if (mmesa->dirty_cliprects & mmesa->draw_buffer)
- mgaUpdateRects( mmesa, mmesa->draw_buffer );
-
- if (mmesa->dirty & ~MGA_UPLOAD_CLIPRECTS)
- mgaEmitHwStateLocked( mmesa );
-
- /* FIXME: Workaround bug in kernel module.
- */
- mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT;
-
- if (!nbox)
- end = start;
-
- if (nbox >= MGA_NR_SAREA_CLIPRECTS)
- mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
-
- if ( end == start || !(mmesa->dirty & MGA_UPLOAD_CLIPRECTS))
- {
- if (nbox == 1)
- mmesa->sarea->nbox = 0;
- else
- mmesa->sarea->nbox = nbox;
-
-
- drmMGAFlushIndices( mmesa->driFd, buffer->idx, start, end, discard );
- age_mmesa(mmesa, mmesa->sarea->last_enqueue);
- }
- else
- {
- for (i = 0 ; i < nbox ; )
- {
- int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox);
- XF86DRIClipRectPtr b = mmesa->sarea->boxes;
- int d = 0;
-
- if (mmesa->scissor) {
- mmesa->sarea->nbox = 0;
-
- for ( ; i < nr ; i++) {
- *b = pbox[i];
- if (intersect_rect(b, b, &mmesa->scissor_rect)) {
- mmesa->sarea->nbox++;
- b++;
- }
- }
-
- /* Culled?
- */
- if (!mmesa->sarea->nbox) {
- if (nr < nbox) continue;
- end = start;
- }
- } else {
- mmesa->sarea->nbox = nr - i;
- for ( ; i < nr ; i++)
- *b++ = pbox[i];
- }
-
- /* Potentially finished with the buffer?
- */
- if (nr == nbox)
- d = discard;
-
-
- mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS;
- drmMGAFlushIndices( mmesa->driFd, buffer->idx, start, end, d );
- age_mmesa(mmesa, mmesa->sarea->last_enqueue);
- }
- }
-
- mmesa->dirty &= ~MGA_UPLOAD_CLIPRECTS;
-}
-
void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer )
{
@@ -715,7 +583,7 @@ void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer )
void mgaDDInitIoctlFuncs( GLcontext *ctx )
{
- ctx->Driver.Clear = mgaDDClear;
- ctx->Driver.Flush = mgaDDFlush;
- ctx->Driver.Finish = mgaDDFinish;
+ ctx->Driver.Clear = mgaDDClear;
+ ctx->Driver.Flush = mgaDDFlush;
+ ctx->Driver.Finish = mgaDDFinish;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
index ad2e6d1ed..47c08ba3a 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.h
@@ -33,13 +33,7 @@
#include "mgacontext.h"
#include "mga_xmesa.h"
-GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch );
-
-
-void mgaSwapBuffers( mgaContextPtr mmesa );
-
-
+void mgaSwapBuffers( Display *dpy, void *drawablePrivate );
GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords );
@@ -56,23 +50,8 @@ void mgaWaitAge( mgaContextPtr mmesa, int age );
void mgaFlushVertices( mgaContextPtr mmesa );
void mgaFlushVerticesLocked( mgaContextPtr mmesa );
-
-
-void mgaFireEltsLocked( mgaContextPtr mmesa,
- GLuint start,
- GLuint end,
- GLuint discard );
-
-void mgaGetEltBufLocked( mgaContextPtr mmesa );
void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer );
-void mgaFlushEltsLocked( mgaContextPtr mmesa );
-void mgaFlushElts( mgaContextPtr mmesa ) ;
-
-
-/* upload texture
- */
-
void mgaDDFlush( GLcontext *ctx );
void mgaDDFinish( GLcontext *ctx );
@@ -82,23 +61,23 @@ void mgaDDInitIoctlFuncs( GLcontext *ctx );
if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
if (mmesa->vertex_dma_buffer) mgaFlushVertices(mmesa); \
- else if (mmesa->next_elt != mmesa->first_elt) mgaFlushElts(mmesa); \
} while (0)
+#define MGA_STATECHANGE(mmesa, flag) do { \
+ FLUSH_BATCH(mmesa); \
+ mmesa->dirty |= flag; \
+} while (0)
+
+
extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa );
static __inline
-GLuint *mgaAllocVertexDwordsInline( mgaContextPtr mmesa, int dwords )
+GLuint *mgaAllocDmaLow( mgaContextPtr mmesa, int bytes )
{
- int bytes = dwords * 4;
GLuint *head;
if (!mmesa->vertex_dma_buffer) {
LOCK_HARDWARE( mmesa );
-
- if (mmesa->first_elt != mmesa->next_elt)
- mgaFlushEltsLocked(mmesa);
-
mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
UNLOCK_HARDWARE( mmesa );
} else if (mmesa->vertex_dma_buffer->used + bytes >
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapipeline.c b/xc/lib/GL/mesa/src/drv/mga/mgapipeline.c
deleted file mode 100644
index cf2843df5..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgapipeline.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapipeline.c,v 1.4 2001/04/10 16:07:50 dawes Exp $ */
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
- */
-
-#include <stdio.h>
-#include "mgavb.h"
-#include "mgadd.h"
-#include "mgacontext.h"
-#include "mgatris.h"
-#include "mgapipeline.h"
-#include "fog.h"
-
-static struct gl_pipeline_stage mga_fast_stage = {
- "MGA fast path",
- (PIPE_OP_VERT_XFORM|PIPE_OP_RAST_SETUP_0|
- PIPE_OP_RAST_SETUP_1|PIPE_OP_RENDER),
- PIPE_PRECALC,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- mgaDDFastPath
-};
-
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D| \
- TEXTURE1_3D| \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-
-/* The driver gets first shot at building the pipeline - make some
- * quick tests to see if we can use the fast path.
- */
-GLboolean mgaDDBuildPrecalcPipeline( GLcontext *ctx )
-{
- struct gl_pipeline *pipe = &ctx->CVA.pre;
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-
- if (mmesa->renderindex == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Flags & (VERT_OBJ_234|
- VERT_TEX0_4|
- VERT_TEX1_4|
- VERT_ELT)) == (VERT_OBJ_23|VERT_ELT))
- {
- pipe->stages[0] = &mga_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
- mmesa->using_fast_path = 1;
- return 1;
- }
-
- if (mmesa->using_fast_path)
- {
- mmesa->using_fast_path = 0;
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
- ctx->Array.NewArrayState |= ctx->Array.Summary;
- return 0;
- }
-
- return 0;
-}
-
-
-
-
-/* Still do the normal fixup and copy-to-current, so this isn't so
- * bad.
- */
-#define ILLEGAL_INPUTS_IMM (VERT_OBJ_4| \
- VERT_TEX0_4| \
- VERT_TEX1_4| \
- VERT_MATERIAL)
-
-
-static void mgaDDCheckRasterSetup( GLcontext *ctx, struct gl_pipeline_stage *d )
-{
- d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
- d->inputs = ctx->RenderFlags;
-
- /* MGA requires an extra input:
- */
- if (ctx->FogMode == FOG_FRAGMENT)
- d->inputs |= VERT_FOG_COORD;
-
- d->outputs = VERT_SETUP_FULL;
-
- if (ctx->IndirectTriangles & DD_SW_SETUP)
- d->type = PIPE_IMMEDIATE;
-}
-
-
-GLuint mgaDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- GLuint i, o;
-
- for (i = o = 0 ; i < nr ; i++) {
- switch (in[i].ops) {
-
- /* Completely replace Mesa's fog processing to generate fog
- * coordinates instead of messing with colors.
- */
- case PIPE_OP_FOG:
- out[o] = gl_fog_coord_stage;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS;
- out[o].state_change = ~0;
- out[o].check = mgaDDCheckPartialRasterSetup;
- out[o].run = mgaDDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].check = mgaDDCheckRasterSetup;
- out[o].run = mgaDDDoRasterSetup;
- o++;
- break;
-
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
index 231d7b9e7..e5256e253 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgapixel.c
@@ -28,7 +28,8 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapixel.c,v 1.3 2001/04/10 16:07:51 dawes Exp $ */
#include "enums.h"
-#include "types.h"
+#include "mtypes.h"
+#include "macros.h"
#include "texutil.h"
#include "mgadd.h"
#include "mgacontext.h"
@@ -37,12 +38,14 @@
#include "mgabuffers.h"
#include "drm.h"
+#include "xf86drmMga.h"
+
+#include "swrast/swrast.h"
#define IS_AGP_MEM( mmesa, p ) \
((GLuint)mmesa->mgaScreen->buffers.map <= ((GLuint)p) && \
(GLuint)mmesa->mgaScreen->buffers.map + \
(GLuint)mmesa->mgaScreen->buffers.size > ((GLuint)p))
-
#define AGP_OFFSET( mmesa, p ) \
(((GLuint)p) - (GLuint)mmesa->mgaScreen->buffers.map )
@@ -113,25 +116,30 @@ check_color( const GLcontext *ctx, GLenum type, GLenum format,
cpp == 2 && format == GL_RGB ) ) ) )
return GL_FALSE;
- return ( ctx->ColorMatrix.type == MATRIX_IDENTITY &&
- !ctx->Pixel.ScaleOrBiasRGBA &&
- !ctx->Pixel.ScaleOrBiasRGBApcm &&
- !ctx->Pixel.MapColorFlag &&
- !ctx->Pixel.ColorTableEnabled &&
- !ctx->Pixel.PostColorMatrixColorTableEnabled &&
- !ctx->Pixel.MinMaxEnabled &&
- !ctx->Pixel.HistogramEnabled &&
- !packing->SwapBytes &&
- !packing->LsbFirst );
+ return (!ctx->_ImageTransferState &&
+ !packing->SwapBytes &&
+ !packing->LsbFirst);
}
static GLboolean
check_color_per_fragment_ops( const GLcontext *ctx )
{
- return ( !(ctx->RasterMask & ~(SCISSOR_BIT|WINCLIP_BIT|MULTI_DRAW_BIT)) &&
- ctx->Current.RasterPosValid &&
- ctx->Pixel.ZoomX == 1.0F &&
- ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) );
+ return (!( ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._ReallyEnabled ||
+ ctx->Depth.OcclusionTest
+ ) &&
+ ctx->Current.RasterPosValid &&
+ ctx->Pixel.ZoomX == 1.0F &&
+ (ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F));
}
static GLboolean
@@ -171,29 +179,29 @@ clip_pixelrect( const GLcontext *ctx,
*width = MIN2(*width, MAX_WIDTH); /* redundant? */
/* left clipping */
- if (*x < buffer->Xmin) {
- *skipPixels += (buffer->Xmin - *x);
- *width -= (buffer->Xmin - *x);
- *x = buffer->Xmin;
+ if (*x < buffer->_Xmin) {
+ *skipPixels += (buffer->_Xmin - *x);
+ *width -= (buffer->_Xmin - *x);
+ *x = buffer->_Xmin;
}
/* right clipping */
- if (*x + *width > buffer->Xmax)
- *width -= (*x + *width - buffer->Xmax - 1);
+ if (*x + *width > buffer->_Xmax)
+ *width -= (*x + *width - buffer->_Xmax - 1);
if (*width <= 0)
return GL_FALSE;
/* bottom clipping */
- if (*y < buffer->Ymin) {
- *skipRows += (buffer->Ymin - *y);
- *height -= (buffer->Ymin - *y);
- *y = buffer->Ymin;
+ if (*y < buffer->_Ymin) {
+ *skipRows += (buffer->_Ymin - *y);
+ *height -= (buffer->_Ymin - *y);
+ *y = buffer->_Ymin;
}
/* top clipping */
- if (*y + *height > buffer->Ymax)
- *height -= (*y + *height - buffer->Ymax - 1);
+ if (*y + *height > buffer->_Ymax)
+ *height -= (*y + *height - buffer->_Ymax - 1);
if (*height <= 0)
return GL_FALSE;
@@ -205,11 +213,11 @@ clip_pixelrect( const GLcontext *ctx,
}
static GLboolean
-mgaDDReadPixels( GLcontext *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *pack,
- GLvoid *pixels )
+mgaTryReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
drm_mga_blit_t blit;
@@ -256,7 +264,7 @@ mgaDDReadPixels( GLcontext *ctx,
* Could get the acclerator to solid fill the destination with
* zeros first... Or get the cpu to do it...
*/
- if (ctx->Visual->DepthBits == 24)
+ if (ctx->Visual.depthBits == 24)
return GL_FALSE;
planemask = ~0;
@@ -283,6 +291,7 @@ mgaDDReadPixels( GLcontext *ctx,
LOCK_HARDWARE( mmesa );
+#if 0
{
__DRIdrawablePrivate *dPriv = mmesa->driDrawable;
int nbox, retcode, i;
@@ -353,12 +362,25 @@ mgaDDReadPixels( GLcontext *ctx,
UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
}
+#endif
UNLOCK_HARDWARE( mmesa );
return GL_TRUE;
}
+static void
+mgaDDReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ if (!mgaTryReadPixels( ctx, x, y, width, height, format, type, pack, pixels))
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, pixels);
+}
+
+
static void do_draw_pix( GLcontext *ctx,
@@ -378,6 +400,7 @@ static void do_draw_pix( GLcontext *ctx,
x += mmesa->drawX;
y += mmesa->drawY;
+#if 0
blit.dest = dest;
blit.planemask = planemask;
blit.source = ((mmesa->mgaScreen->agp.handle + AGP_OFFSET(mmesa, pixels))
@@ -436,17 +459,18 @@ static void do_draw_pix( GLcontext *ctx,
exit(1);
}
}
+#endif
}
static GLboolean
-mgaDDDrawPixels( GLcontext *ctx,
- GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *unpack,
- const GLvoid *pixels )
+mgaTryDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
GLint size, skipPixels, skipRows;
@@ -476,7 +500,7 @@ mgaDDDrawPixels( GLcontext *ctx,
case GL_DEPTH_COMPONENT:
dest = mmesa->mgaScreen->depthOffset;
- if (ctx->Visual->DepthBits == 24)
+ if (ctx->Visual.depthBits == 24)
planemask = ~0xff;
else
planemask = ~0;
@@ -532,7 +556,8 @@ mgaDDDrawPixels( GLcontext *ctx,
*/
/* drmBufPtr buf = mgaGetBufferLocked(mmesa); */
GLuint bufferpitch = (width*cpp+31)&~31;
- char *address = mmesa->mgaScreen->agp.map;
+
+ char *address = 0; /* mmesa->mgaScreen->agp.map; */
do {
/* GLuint rows = MIN2( height, MGA_DMA_BUF_SZ / bufferpitch ); */
@@ -548,23 +573,19 @@ mgaDDDrawPixels( GLcontext *ctx,
*/
#if 0
if (cpp == 2) {
- if (!_mesa_convert_teximage( MESA_FORMAT_RGB565,
- width, rows,
- address, bufferpitch,
- width, rows,
- format, type,
- pixels, unpack )) {
+ if (!_mesa_convert_texsubimage2d( MESA_FORMAT_RGB565,
+ 0, 0, width, rows,
+ bufferpitch, format, type,
+ unpack, pixels, address )) {
/* mgaReleaseBufLocked( mmesa, buf ); */
UNLOCK_HARDWARE(mmesa);
return GL_FALSE;
}
} else {
- if (!_mesa_convert_teximage( MESA_FORMAT_ARGB8888,
- width, rows,
- address, bufferpitch,
- width, rows,
- format, type,
- pixels, unpack )) {
+ if (!_mesa_convert_texsubimage2d( MESA_FORMAT_ARGB8888,
+ 0, 0, width, rows,
+ bufferpitch, format, type,
+ unpack, pixels, address )) {
/* mgaReleaseBufLocked( mmesa, buf ); */
UNLOCK_HARDWARE(mmesa);
return GL_FALSE;
@@ -595,6 +616,18 @@ mgaDDDrawPixels( GLcontext *ctx,
return GL_TRUE;
}
+static void
+mgaDDDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ if (!mgaTryDrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels ))
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+}
@@ -637,6 +670,16 @@ void mgaDDInitPixelFuncs( GLcontext *ctx )
ctx->Driver.GetAgpOffset = mgaDDGetAgpOffset;
ctx->Driver.FreeAgpMemory = mgaDDFreeAgpMemory;
#endif
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
if (getenv("MGA_BLIT_PIXELS")) {
ctx->Driver.ReadPixels = mgaDDReadPixels; /* requires agp dest */
ctx->Driver.DrawPixels = mgaDDDrawPixels; /* works with agp/normal mem */
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapixel.h b/xc/lib/GL/mesa/src/drv/mga/mgapixel.h
index c7bb04d92..5a406e0d9 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgapixel.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgapixel.h
@@ -29,7 +29,7 @@
#ifndef MGA_PIXELS_H
#define MGA_PIXELS_H
-#include "types.h"
+#include "mtypes.h"
extern void mgaDDInitPixelFuncs( GLcontext *ctx );
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaregs.h b/xc/lib/GL/mesa/src/drv/mga/mgaregs.h
index 91aacba44..6e381a9cc 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaregs.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaregs.h
@@ -14,12 +14,11 @@
* THE SOFTWARE IS PROVIDED "AS 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
- * STEPHEN CROWLEY, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * STEPHEN CROWLEY, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/mga/mgaregs.h,v 1.4 2001/08/18 11:55:47 tsi Exp $ */
#ifndef _MGAREGS_H_
#define _MGAREGS_H_
@@ -35,1346 +34,1347 @@
* Power Graphic Mode Memory Space Registers
*/
-#define MGAREG_MGA_EXEC 0x0100
-#define MGAREG_AGP_PLL 0x1e4c
-
- #define AGP_PLL_agp2xpllen_MASK 0xfffffffe /* bit 0 */
- #define AGP_PLL_agp2xpllen_disable 0x0
- #define AGP_PLL_agp2xpllen_enable 0x1
-
-#define MGAREG_CFG_OR 0x1e4c
-
- #define CFG_OR_comp_or_MASK 0xfffffff7 /* bit 3 */
- #define CFG_OR_comp_or_disable 0x0
- #define CFG_OR_comp_or_enable 0x8
- #define CFG_OR_compfreq_MASK 0xffffff0f /* bits 4-7 */
- #define CFG_OR_compfreq_SHIFT 4
- #define CFG_OR_comporup_MASK 0xfffff0ff /* bits 8-11 */
- #define CFG_OR_comporup_SHIFT 8
- #define CFG_OR_compordn_MASK 0xffff0fff /* bits 12-15 */
- #define CFG_OR_compordn_SHIFT 12
- #define CFG_OR_e2pq_MASK 0xfffeffff /* bit 16 */
- #define CFG_OR_e2pq_disable 0x0
- #define CFG_OR_e2pq_enable 0x10000
- #define CFG_OR_e2pqbypcsn_MASK 0xfffdffff /* bit 17 */
- #define CFG_OR_e2pqbypcsn_disable 0x0
- #define CFG_OR_e2pqbypcsn_enable 0x20000
- #define CFG_OR_e2pqbypd_MASK 0xfffbffff /* bit 18 */
- #define CFG_OR_e2pqbypd_disable 0x0
- #define CFG_OR_e2pqbypd_enable 0x40000
- #define CFG_OR_e2pbypclk_MASK 0xfff7ffff /* bit 19 */
- #define CFG_OR_e2pbypclk_disable 0x0
- #define CFG_OR_e2pbypclk_enable 0x80000
- #define CFG_OR_e2pbyp_MASK 0xffefffff /* bit 20 */
- #define CFG_OR_e2pbyp_disable 0x0
- #define CFG_OR_e2pbyp_enable 0x100000
- #define CFG_OR_rate_cap_or_MASK 0xff1fffff /* bits 21-23 */
- #define CFG_OR_rate_cap_or_SHIFT 21
- #define CFG_OR_rq_or_MASK 0xe0ffffff /* bits 24-28 */
- #define CFG_OR_rq_or_SHIFT 24
-
-#define MGAREG_ALPHACTRL 0x2c7c
-
- #define AC_src_MASK 0xfffffff0 /* bits 0-3 */
- #define AC_src_zero 0x0 /* val 0, shift 0 */
- #define AC_src_one 0x1 /* val 1, shift 0 */
- #define AC_src_dst_color 0x2 /* val 2, shift 0 */
- #define AC_src_om_dst_color 0x3 /* val 3, shift 0 */
- #define AC_src_src_alpha 0x4 /* val 4, shift 0 */
- #define AC_src_om_src_alpha 0x5 /* val 5, shift 0 */
- #define AC_src_dst_alpha 0x6 /* val 6, shift 0 */
- #define AC_src_om_dst_alpha 0x7 /* val 7, shift 0 */
- #define AC_src_src_alpha_sat 0x8 /* val 8, shift 0 */
- #define AC_dst_MASK 0xffffff0f /* bits 4-7 */
- #define AC_dst_zero 0x0 /* val 0, shift 4 */
- #define AC_dst_one 0x10 /* val 1, shift 4 */
- #define AC_dst_src_color 0x20 /* val 2, shift 4 */
- #define AC_dst_om_src_color 0x30 /* val 3, shift 4 */
- #define AC_dst_src_alpha 0x40 /* val 4, shift 4 */
- #define AC_dst_om_src_alpha 0x50 /* val 5, shift 4 */
- #define AC_dst_dst_alpha 0x60 /* val 6, shift 4 */
- #define AC_dst_om_dst_alpha 0x70 /* val 7, shift 4 */
- #define AC_amode_MASK 0xfffffcff /* bits 8-9 */
- #define AC_amode_FCOL 0x0 /* val 0, shift 8 */
- #define AC_amode_alpha_channel 0x100 /* val 1, shift 8 */
- #define AC_amode_video_alpha 0x200 /* val 2, shift 8 */
- #define AC_amode_RSVD 0x300 /* val 3, shift 8 */
- #define AC_astipple_MASK 0xfffff7ff /* bit 11 */
- #define AC_astipple_disable 0x0
- #define AC_astipple_enable 0x800
- #define AC_aten_MASK 0xffffefff /* bit 12 */
- #define AC_aten_disable 0x0
- #define AC_aten_enable 0x1000
- #define AC_atmode_MASK 0xffff1fff /* bits 13-15 */
- #define AC_atmode_noacmp 0x0 /* val 0, shift 13 */
- #define AC_atmode_ae 0x4000 /* val 2, shift 13 */
- #define AC_atmode_ane 0x6000 /* val 3, shift 13 */
- #define AC_atmode_alt 0x8000 /* val 4, shift 13 */
- #define AC_atmode_alte 0xa000 /* val 5, shift 13 */
- #define AC_atmode_agt 0xc000 /* val 6, shift 13 */
- #define AC_atmode_agte 0xe000 /* val 7, shift 13 */
- #define AC_atref_MASK 0xff00ffff /* bits 16-23 */
- #define AC_atref_SHIFT 16
- #define AC_alphasel_MASK 0xfcffffff /* bits 24-25 */
- #define AC_alphasel_fromtex 0x0 /* val 0, shift 24 */
- #define AC_alphasel_diffused 0x1000000 /* val 1, shift 24 */
- #define AC_alphasel_modulated 0x2000000 /* val 2, shift 24 */
- #define AC_alphasel_trans 0x3000000 /* val 3, shift 24 */
-
-#define MGAREG_ALPHASTART 0x2c70
-#define MGAREG_ALPHAXINC 0x2c74
-#define MGAREG_ALPHAYINC 0x2c78
-#define MGAREG_AR0 0x1c60
-
- #define AR0_ar0_MASK 0xfffc0000 /* bits 0-17 */
- #define AR0_ar0_SHIFT 0
-
-#define MGAREG_AR1 0x1c64
-
- #define AR1_ar1_MASK 0xff000000 /* bits 0-23 */
- #define AR1_ar1_SHIFT 0
-
-#define MGAREG_AR2 0x1c68
-
- #define AR2_ar2_MASK 0xfffc0000 /* bits 0-17 */
- #define AR2_ar2_SHIFT 0
-
-#define MGAREG_AR3 0x1c6c
-
- #define AR3_ar3_MASK 0xff000000 /* bits 0-23 */
- #define AR3_ar3_SHIFT 0
- #define AR3_spage_MASK 0xf8ffffff /* bits 24-26 */
- #define AR3_spage_SHIFT 24
-
-#define MGAREG_AR4 0x1c70
-
- #define AR4_ar4_MASK 0xfffc0000 /* bits 0-17 */
- #define AR4_ar4_SHIFT 0
-
-#define MGAREG_AR5 0x1c74
-
- #define AR5_ar5_MASK 0xfffc0000 /* bits 0-17 */
- #define AR5_ar5_SHIFT 0
-
-#define MGAREG_AR6 0x1c78
-
- #define AR6_ar6_MASK 0xfffc0000 /* bits 0-17 */
- #define AR6_ar6_SHIFT 0
-
-#define MGAREG_BCOL 0x1c20
-#define MGAREG_BESA1CORG 0x3d10
-#define MGAREG_BESA1ORG 0x3d00
-#define MGAREG_BESA2CORG 0x3d14
-#define MGAREG_BESA2ORG 0x3d04
-#define MGAREG_BESB1CORG 0x3d18
-#define MGAREG_BESB1ORG 0x3d08
-#define MGAREG_BESB2CORG 0x3d1c
-#define MGAREG_BESB2ORG 0x3d0c
-#define MGAREG_BESCTL 0x3d20
-
- #define BC_besen_MASK 0xfffffffe /* bit 0 */
- #define BC_besen_disable 0x0
- #define BC_besen_enable 0x1
- #define BC_besv1srcstp_MASK 0xffffffbf /* bit 6 */
- #define BC_besv1srcstp_even 0x0
- #define BC_besv1srcstp_odd 0x40
- #define BC_besv2srcstp_MASK 0xfffffeff /* bit 8 */
- #define BC_besv2srcstp_disable 0x0
- #define BC_besv2srcstp_enable 0x100
- #define BC_beshfen_MASK 0xfffffbff /* bit 10 */
- #define BC_beshfen_disable 0x0
- #define BC_beshfen_enable 0x400
- #define BC_besvfen_MASK 0xfffff7ff /* bit 11 */
- #define BC_besvfen_disable 0x0
- #define BC_besvfen_enable 0x800
- #define BC_beshfixc_MASK 0xffffefff /* bit 12 */
- #define BC_beshfixc_weight 0x0
- #define BC_beshfixc_coeff 0x1000
- #define BC_bescups_MASK 0xfffeffff /* bit 16 */
- #define BC_bescups_disable 0x0
- #define BC_bescups_enable 0x10000
- #define BC_bes420pl_MASK 0xfffdffff /* bit 17 */
- #define BC_bes420pl_422 0x0
- #define BC_bes420pl_420 0x20000
- #define BC_besdith_MASK 0xfffbffff /* bit 18 */
- #define BC_besdith_disable 0x0
- #define BC_besdith_enable 0x40000
- #define BC_beshmir_MASK 0xfff7ffff /* bit 19 */
- #define BC_beshmir_disable 0x0
- #define BC_beshmir_enable 0x80000
- #define BC_besbwen_MASK 0xffefffff /* bit 20 */
- #define BC_besbwen_color 0x0
- #define BC_besbwen_bw 0x100000
- #define BC_besblank_MASK 0xffdfffff /* bit 21 */
- #define BC_besblank_disable 0x0
- #define BC_besblank_enable 0x200000
- #define BC_besfselm_MASK 0xfeffffff /* bit 24 */
- #define BC_besfselm_soft 0x0
- #define BC_besfselm_hard 0x1000000
- #define BC_besfsel_MASK 0xf9ffffff /* bits 25-26 */
- #define BC_besfsel_a1 0x0 /* val 0, shift 25 */
- #define BC_besfsel_a2 0x2000000 /* val 1, shift 25 */
- #define BC_besfsel_b1 0x4000000 /* val 2, shift 25 */
- #define BC_besfsel_b2 0x6000000 /* val 3, shift 25 */
-
-#define MGAREG_BESGLOBCTL 0x3dc0
-
- #define BGC_beshzoom_MASK 0xfffffffe /* bit 0 */
- #define BGC_beshzoom_disable 0x0
- #define BGC_beshzoom_enable 0x1
- #define BGC_beshzoomf_MASK 0xfffffffd /* bit 1 */
- #define BGC_beshzoomf_disable 0x0
- #define BGC_beshzoomf_enable 0x2
- #define BGC_bescorder_MASK 0xfffffff7 /* bit 3 */
- #define BGC_bescorder_even 0x0
- #define BGC_bescorder_odd 0x8
- #define BGC_besreghup_MASK 0xffffffef /* bit 4 */
- #define BGC_besreghup_disable 0x0
- #define BGC_besreghup_enable 0x10
- #define BGC_besvcnt_MASK 0xf000ffff /* bits 16-27 */
- #define BGC_besvcnt_SHIFT 16
-
-#define MGAREG_BESHCOORD 0x3d28
-
- #define BHC_besright_MASK 0xfffff800 /* bits 0-10 */
- #define BHC_besright_SHIFT 0
- #define BHC_besleft_MASK 0xf800ffff /* bits 16-26 */
- #define BHC_besleft_SHIFT 16
-
-#define MGAREG_BESHISCAL 0x3d30
-
- #define BHISF_beshiscal_MASK 0xffe00003 /* bits 2-20 */
- #define BHISF_beshiscal_SHIFT 2
-
-#define MGAREG_BESHSRCEND 0x3d3c
-
- #define BHSE_beshsrcend_MASK 0xfc000003 /* bits 2-25 */
- #define BHSE_beshsrcend_SHIFT 2
-
-#define MGAREG_BESHSRCLST 0x3d50
-
- #define BHSL_beshsrclst_MASK 0xfc00ffff /* bits 16-25 */
- #define BHSL_beshsrclst_SHIFT 16
-
-#define MGAREG_BESHSRCST 0x3d38
-
- #define BHSS_beshsrcst_MASK 0xfc000003 /* bits 2-25 */
- #define BHSS_beshsrcst_SHIFT 2
-
-#define MGAREG_BESPITCH 0x3d24
-
- #define BP_bespitch_MASK 0xfffff000 /* bits 0-11 */
- #define BP_bespitch_SHIFT 0
-
-#define MGAREG_BESSTATUS 0x3dc4
-
- #define BS_besstat_MASK 0xfffffffc /* bits 0-1 */
- #define BS_besstat_a1 0x0 /* val 0, shift 0 */
- #define BS_besstat_a2 0x1 /* val 1, shift 0 */
- #define BS_besstat_b1 0x2 /* val 2, shift 0 */
- #define BS_besstat_b2 0x3 /* val 3, shift 0 */
-
-#define MGAREG_BESV1SRCLST 0x3d54
-
- #define BSF_besv1srclast_MASK 0xfffffc00 /* bits 0-9 */
- #define BSF_besv1srclast_SHIFT 0
-
-#define MGAREG_BESV2SRCLST 0x3d58
-
- #define BSF_besv2srclst_MASK 0xfffffc00 /* bits 0-9 */
- #define BSF_besv2srclst_SHIFT 0
-
-#define MGAREG_BESV1WGHT 0x3d48
-
- #define BSF_besv1wght_MASK 0xffff0003 /* bits 2-15 */
- #define BSF_besv1wght_SHIFT 2
- #define BSF_besv1wghts_MASK 0xfffeffff /* bit 16 */
- #define BSF_besv1wghts_disable 0x0
- #define BSF_besv1wghts_enable 0x10000
-
-#define MGAREG_BESV2WGHT 0x3d4c
-
- #define BSF_besv2wght_MASK 0xffff0003 /* bits 2-15 */
- #define BSF_besv2wght_SHIFT 2
- #define BSF_besv2wghts_MASK 0xfffeffff /* bit 16 */
- #define BSF_besv2wghts_disable 0x0
- #define BSF_besv2wghts_enable 0x10000
-
-#define MGAREG_BESVCOORD 0x3d2c
-
- #define BVC_besbot_MASK 0xfffff800 /* bits 0-10 */
- #define BVC_besbot_SHIFT 0
- #define BVC_bestop_MASK 0xf800ffff /* bits 16-26 */
- #define BVC_bestop_SHIFT 16
-
-#define MGAREG_BESVISCAL 0x3d34
-
- #define BVISF_besviscal_MASK 0xffe00003 /* bits 2-20 */
- #define BVISF_besviscal_SHIFT 2
-
-#define MGAREG_CODECADDR 0x3e44
-#define MGAREG_CODECCTL 0x3e40
-#define MGAREG_CODECHARDPTR 0x3e4c
-#define MGAREG_CODECHOSTPTR 0x3e48
-#define MGAREG_CODECLCODE 0x3e50
-#define MGAREG_CXBNDRY 0x1c80
-
- #define CXB_cxleft_MASK 0xfffff000 /* bits 0-11 */
- #define CXB_cxleft_SHIFT 0
- #define CXB_cxright_MASK 0xf000ffff /* bits 16-27 */
- #define CXB_cxright_SHIFT 16
-
-#define MGAREG_CXLEFT 0x1ca0
-#define MGAREG_CXRIGHT 0x1ca4
-#define MGAREG_DMAMAP30 0x1e30
-#define MGAREG_DMAMAP74 0x1e34
-#define MGAREG_DMAMAPB8 0x1e38
-#define MGAREG_DMAMAPFC 0x1e3c
-#define MGAREG_DMAPAD 0x1c54
-#define MGAREG_DR0_Z32LSB 0x2c50
-#define MGAREG_DR0_Z32MSB 0x2c54
-#define MGAREG_DR2_Z32LSB 0x2c60
-#define MGAREG_DR2_Z32MSB 0x2c64
-#define MGAREG_DR3_Z32LSB 0x2c68
-#define MGAREG_DR3_Z32MSB 0x2c6c
-#define MGAREG_DR0 0x1cc0
-#define MGAREG_DR2 0x1cc8
-#define MGAREG_DR3 0x1ccc
-#define MGAREG_DR4 0x1cd0
-#define MGAREG_DR6 0x1cd8
-#define MGAREG_DR7 0x1cdc
-#define MGAREG_DR8 0x1ce0
-#define MGAREG_DR10 0x1ce8
-#define MGAREG_DR11 0x1cec
-#define MGAREG_DR12 0x1cf0
-#define MGAREG_DR14 0x1cf8
-#define MGAREG_DR15 0x1cfc
-#define MGAREG_DSTORG 0x2cb8
-
- #define DO_dstmap_MASK 0xfffffffe /* bit 0 */
- #define DO_dstmap_fb 0x0
- #define DO_dstmap_sys 0x1
- #define DO_dstacc_MASK 0xfffffffd /* bit 1 */
- #define DO_dstacc_pci 0x0
- #define DO_dstacc_agp 0x2
- #define DO_dstorg_MASK 0x7 /* bits 3-31 */
- #define DO_dstorg_SHIFT 3
-
-#define MGAREG_DWG_INDIR_WT 0x1e80
-#define MGAREG_DWGCTL 0x1c00
-
- #define DC_opcod_MASK 0xfffffff0 /* bits 0-3 */
- #define DC_opcod_line_open 0x0 /* val 0, shift 0 */
- #define DC_opcod_autoline_open 0x1 /* val 1, shift 0 */
- #define DC_opcod_line_close 0x2 /* val 2, shift 0 */
- #define DC_opcod_autoline_close 0x3 /* val 3, shift 0 */
- #define DC_opcod_trap 0x4 /* val 4, shift 0 */
- #define DC_opcod_texture_trap 0x6 /* val 6, shift 0 */
- #define DC_opcod_bitblt 0x8 /* val 8, shift 0 */
- #define DC_opcod_iload 0x9 /* val 9, shift 0 */
- #define DC_atype_MASK 0xffffff8f /* bits 4-6 */
- #define DC_atype_rpl 0x0 /* val 0, shift 4 */
- #define DC_atype_rstr 0x10 /* val 1, shift 4 */
- #define DC_atype_zi 0x30 /* val 3, shift 4 */
- #define DC_atype_blk 0x40 /* val 4, shift 4 */
- #define DC_atype_i 0x70 /* val 7, shift 4 */
- #define DC_linear_MASK 0xffffff7f /* bit 7 */
- #define DC_linear_xy 0x0
- #define DC_linear_linear 0x80
- #define DC_zmode_MASK 0xfffff8ff /* bits 8-10 */
- #define DC_zmode_nozcmp 0x0 /* val 0, shift 8 */
- #define DC_zmode_ze 0x200 /* val 2, shift 8 */
- #define DC_zmode_zne 0x300 /* val 3, shift 8 */
- #define DC_zmode_zlt 0x400 /* val 4, shift 8 */
- #define DC_zmode_zlte 0x500 /* val 5, shift 8 */
- #define DC_zmode_zgt 0x600 /* val 6, shift 8 */
- #define DC_zmode_zgte 0x700 /* val 7, shift 8 */
- #define DC_solid_MASK 0xfffff7ff /* bit 11 */
- #define DC_solid_disable 0x0
- #define DC_solid_enable 0x800
- #define DC_arzero_MASK 0xffffefff /* bit 12 */
- #define DC_arzero_disable 0x0
- #define DC_arzero_enable 0x1000
- #define DC_sgnzero_MASK 0xffffdfff /* bit 13 */
- #define DC_sgnzero_disable 0x0
- #define DC_sgnzero_enable 0x2000
- #define DC_shftzero_MASK 0xffffbfff /* bit 14 */
- #define DC_shftzero_disable 0x0
- #define DC_shftzero_enable 0x4000
- #define DC_bop_MASK 0xfff0ffff /* bits 16-19 */
- #define DC_bop_SHIFT 16
- #define DC_trans_MASK 0xff0fffff /* bits 20-23 */
- #define DC_trans_SHIFT 20
- #define DC_bltmod_MASK 0xe1ffffff /* bits 25-28 */
- #define DC_bltmod_bmonolef 0x0 /* val 0, shift 25 */
- #define DC_bltmod_bmonowf 0x8000000 /* val 4, shift 25 */
- #define DC_bltmod_bplan 0x2000000 /* val 1, shift 25 */
- #define DC_bltmod_bfcol 0x4000000 /* val 2, shift 25 */
- #define DC_bltmod_bu32bgr 0x6000000 /* val 3, shift 25 */
- #define DC_bltmod_bu32rgb 0xe000000 /* val 7, shift 25 */
- #define DC_bltmod_bu24bgr 0x16000000 /* val 11, shift 25 */
- #define DC_bltmod_bu24rgb 0x1e000000 /* val 15, shift 25 */
- #define DC_pattern_MASK 0xdfffffff /* bit 29 */
- #define DC_pattern_disable 0x0
- #define DC_pattern_enable 0x20000000
- #define DC_transc_MASK 0xbfffffff /* bit 30 */
- #define DC_transc_disable 0x0
- #define DC_transc_enable 0x40000000
- #define DC_clipdis_MASK 0x7fffffff /* bit 31 */
- #define DC_clipdis_disable 0x0
- #define DC_clipdis_enable 0x80000000
-
-#define MGAREG_DWGSYNC 0x2c4c
-
- #define DS_dwgsyncaddr_MASK 0x3 /* bits 2-31 */
- #define DS_dwgsyncaddr_SHIFT 2
-
-#define MGAREG_FCOL 0x1c24
-#define MGAREG_FIFOSTATUS 0x1e10
-
- #define FS_fifocount_MASK 0xffffff80 /* bits 0-6 */
- #define FS_fifocount_SHIFT 0
- #define FS_bfull_MASK 0xfffffeff /* bit 8 */
- #define FS_bfull_disable 0x0
- #define FS_bfull_enable 0x100
- #define FS_bempty_MASK 0xfffffdff /* bit 9 */
- #define FS_bempty_disable 0x0
- #define FS_bempty_enable 0x200
-
-#define MGAREG_FOGCOL 0x1cf4
-#define MGAREG_FOGSTART 0x1cc4
-#define MGAREG_FOGXINC 0x1cd4
-#define MGAREG_FOGYINC 0x1ce4
-#define MGAREG_FXBNDRY 0x1c84
-
- #define XA_fxleft_MASK 0xffff0000 /* bits 0-15 */
- #define XA_fxleft_SHIFT 0
- #define XA_fxright_MASK 0xffff /* bits 16-31 */
- #define XA_fxright_SHIFT 16
-
-#define MGAREG_FXLEFT 0x1ca8
-#define MGAREG_FXRIGHT 0x1cac
-#define MGAREG_ICLEAR 0x1e18
-
- #define IC_softrapiclr_MASK 0xfffffffe /* bit 0 */
- #define IC_softrapiclr_disable 0x0
- #define IC_softrapiclr_enable 0x1
- #define IC_pickiclr_MASK 0xfffffffb /* bit 2 */
- #define IC_pickiclr_disable 0x0
- #define IC_pickiclr_enable 0x4
- #define IC_vlineiclr_MASK 0xffffffdf /* bit 5 */
- #define IC_vlineiclr_disable 0x0
- #define IC_vlineiclr_enable 0x20
- #define IC_wiclr_MASK 0xffffff7f /* bit 7 */
- #define IC_wiclr_disable 0x0
- #define IC_wiclr_enable 0x80
- #define IC_wciclr_MASK 0xfffffeff /* bit 8 */
- #define IC_wciclr_disable 0x0
- #define IC_wciclr_enable 0x100
-
-#define MGAREG_IEN 0x1e1c
-
- #define IE_softrapien_MASK 0xfffffffe /* bit 0 */
- #define IE_softrapien_disable 0x0
- #define IE_softrapien_enable 0x1
- #define IE_pickien_MASK 0xfffffffb /* bit 2 */
- #define IE_pickien_disable 0x0
- #define IE_pickien_enable 0x4
- #define IE_vlineien_MASK 0xffffffdf /* bit 5 */
- #define IE_vlineien_disable 0x0
- #define IE_vlineien_enable 0x20
- #define IE_extien_MASK 0xffffffbf /* bit 6 */
- #define IE_extien_disable 0x0
- #define IE_extien_enable 0x40
- #define IE_wien_MASK 0xffffff7f /* bit 7 */
- #define IE_wien_disable 0x0
- #define IE_wien_enable 0x80
- #define IE_wcien_MASK 0xfffffeff /* bit 8 */
- #define IE_wcien_disable 0x0
- #define IE_wcien_enable 0x100
-
-#define MGAREG_LEN 0x1c5c
-#define MGAREG_MACCESS 0x1c04
-
- #define MA_pwidth_MASK 0xfffffffc /* bits 0-1 */
- #define MA_pwidth_8 0x0 /* val 0, shift 0 */
- #define MA_pwidth_16 0x1 /* val 1, shift 0 */
- #define MA_pwidth_32 0x2 /* val 2, shift 0 */
- #define MA_pwidth_24 0x3 /* val 3, shift 0 */
- #define MA_zwidth_MASK 0xffffffe7 /* bits 3-4 */
- #define MA_zwidth_16 0x0 /* val 0, shift 3 */
- #define MA_zwidth_32 0x8 /* val 1, shift 3 */
- #define MA_zwidth_15 0x10 /* val 2, shift 3 */
- #define MA_zwidth_24 0x18 /* val 3, shift 3 */
- #define MA_memreset_MASK 0xffff7fff /* bit 15 */
- #define MA_memreset_disable 0x0
- #define MA_memreset_enable 0x8000
- #define MA_fogen_MASK 0xfbffffff /* bit 26 */
- #define MA_fogen_disable 0x0
- #define MA_fogen_enable 0x4000000
- #define MA_tlutload_MASK 0xdfffffff /* bit 29 */
- #define MA_tlutload_disable 0x0
- #define MA_tlutload_enable 0x20000000
- #define MA_nodither_MASK 0xbfffffff /* bit 30 */
- #define MA_nodither_disable 0x0
- #define MA_nodither_enable 0x40000000
- #define MA_dit555_MASK 0x7fffffff /* bit 31 */
- #define MA_dit555_disable 0x0
- #define MA_dit555_enable 0x80000000
-
-#define MGAREG_MCTLWTST 0x1c08
-
- #define MCWS_casltncy_MASK 0xfffffff8 /* bits 0-2 */
- #define MCWS_casltncy_SHIFT 0
- #define MCWS_rrddelay_MASK 0xffffffcf /* bits 4-5 */
- #define MCWS_rcddelay_MASK 0xfffffe7f /* bits 7-8 */
- #define MCWS_rasmin_MASK 0xffffe3ff /* bits 10-12 */
- #define MCWS_rasmin_SHIFT 10
- #define MCWS_rpdelay_MASK 0xffff3fff /* bits 14-15 */
- #define MCWS_wrdelay_MASK 0xfff3ffff /* bits 18-19 */
- #define MCWS_rddelay_MASK 0xffdfffff /* bit 21 */
- #define MCWS_rddelay_disable 0x0
- #define MCWS_rddelay_enable 0x200000
- #define MCWS_smrdelay_MASK 0xfe7fffff /* bits 23-24 */
- #define MCWS_bwcdelay_MASK 0xf3ffffff /* bits 26-27 */
- #define MCWS_bpldelay_MASK 0x1fffffff /* bits 29-31 */
- #define MCWS_bpldelay_SHIFT 29
-
-#define MGAREG_MEMRDBK 0x1e44
-
- #define MRB_mclkbrd0_MASK 0xfffffff0 /* bits 0-3 */
- #define MRB_mclkbrd0_SHIFT 0
- #define MRB_mclkbrd1_MASK 0xfffffe1f /* bits 5-8 */
- #define MRB_mclkbrd1_SHIFT 5
- #define MRB_strmfctl_MASK 0xff3fffff /* bits 22-23 */
- #define MRB_mrsopcod_MASK 0xe1ffffff /* bits 25-28 */
- #define MRB_mrsopcod_SHIFT 25
-
-#define MGAREG_OPMODE 0x1e54
-
- #define OM_dmamod_MASK 0xfffffff3 /* bits 2-3 */
- #define OM_dmamod_general 0x0 /* val 0, shift 2 */
- #define OM_dmamod_blit 0x4 /* val 1, shift 2 */
- #define OM_dmamod_vector 0x8 /* val 2, shift 2 */
- #define OM_dmamod_vertex 0xc /* val 3, shift 2 */
- #define OM_dmadatasiz_MASK 0xfffffcff /* bits 8-9 */
- #define OM_dmadatasiz_8 0x0 /* val 0, shift 8 */
- #define OM_dmadatasiz_16 0x100 /* val 1, shift 8 */
- #define OM_dmadatasiz_32 0x200 /* val 2, shift 8 */
- #define OM_dirdatasiz_MASK 0xfffcffff /* bits 16-17 */
- #define OM_dirdatasiz_8 0x0 /* val 0, shift 16 */
- #define OM_dirdatasiz_16 0x10000 /* val 1, shift 16 */
- #define OM_dirdatasiz_32 0x20000 /* val 2, shift 16 */
-
-#define MGAREG_PAT0 0x1c10
-#define MGAREG_PAT1 0x1c14
-#define MGAREG_PITCH 0x1c8c
-
- #define P_iy_MASK 0xffffe000 /* bits 0-12 */
- #define P_iy_SHIFT 0
- #define P_ylin_MASK 0xffff7fff /* bit 15 */
- #define P_ylin_disable 0x0
- #define P_ylin_enable 0x8000
-
-#define MGAREG_PLNWT 0x1c1c
-#define MGAREG_PRIMADDRESS 0x1e58
-
- #define PDCA_primod_MASK 0xfffffffc /* bits 0-1 */
- #define PDCA_primod_general 0x0 /* val 0, shift 0 */
- #define PDCA_primod_blit 0x1 /* val 1, shift 0 */
- #define PDCA_primod_vector 0x2 /* val 2, shift 0 */
- #define PDCA_primod_vertex 0x3 /* val 3, shift 0 */
- #define PDCA_primaddress_MASK 0x3 /* bits 2-31 */
- #define PDCA_primaddress_SHIFT 2
-
-#define MGAREG_PRIMEND 0x1e5c
-
- #define PDEA_primnostart_MASK 0xfffffffe /* bit 0 */
- #define PDEA_primnostart_disable 0x0
- #define PDEA_primnostart_enable 0x1
- #define PDEA_pagpxfer_MASK 0xfffffffd /* bit 1 */
- #define PDEA_pagpxfer_disable 0x0
- #define PDEA_pagpxfer_enable 0x2
- #define PDEA_primend_MASK 0x3 /* bits 2-31 */
- #define PDEA_primend_SHIFT 2
-
-#define MGAREG_PRIMPTR 0x1e50
-
- #define PLS_primptren0_MASK 0xfffffffe /* bit 0 */
- #define PLS_primptren0_disable 0x0
- #define PLS_primptren0_enable 0x1
- #define PLS_primptren1_MASK 0xfffffffd /* bit 1 */
- #define PLS_primptren1_disable 0x0
- #define PLS_primptren1_enable 0x2
- #define PLS_primptr_MASK 0x7 /* bits 3-31 */
- #define PLS_primptr_SHIFT 3
-
-#define MGAREG_RST 0x1e40
-
- #define R_softreset_MASK 0xfffffffe /* bit 0 */
- #define R_softreset_disable 0x0
- #define R_softreset_enable 0x1
- #define R_softextrst_MASK 0xfffffffd /* bit 1 */
- #define R_softextrst_disable 0x0
- #define R_softextrst_enable 0x2
-
-#define MGAREG_SECADDRESS 0x2c40
-
- #define SDCA_secmod_MASK 0xfffffffc /* bits 0-1 */
- #define SDCA_secmod_general 0x0 /* val 0, shift 0 */
- #define SDCA_secmod_blit 0x1 /* val 1, shift 0 */
- #define SDCA_secmod_vector 0x2 /* val 2, shift 0 */
- #define SDCA_secmod_vertex 0x3 /* val 3, shift 0 */
- #define SDCA_secaddress_MASK 0x3 /* bits 2-31 */
- #define SDCA_secaddress_SHIFT 2
-
-#define MGAREG_SECEND 0x2c44
-
- #define SDEA_sagpxfer_MASK 0xfffffffd /* bit 1 */
- #define SDEA_sagpxfer_disable 0x0
- #define SDEA_sagpxfer_enable 0x2
- #define SDEA_secend_MASK 0x3 /* bits 2-31 */
- #define SDEA_secend_SHIFT 2
-
-#define MGAREG_SETUPADDRESS 0x2cd0
-
- #define SETADD_mode_MASK 0xfffffffc /* bits 0-1 */
- #define SETADD_mode_vertlist 0x0 /* val 0, shift 0 */
- #define SETADD_address_MASK 0x3 /* bits 2-31 */
- #define SETADD_address_SHIFT 2
-
-#define MGAREG_SETUPEND 0x2cd4
-
- #define SETEND_agpxfer_MASK 0xfffffffd /* bit 1 */
- #define SETEND_agpxfer_disable 0x0
- #define SETEND_agpxfer_enable 0x2
- #define SETEND_address_MASK 0x3 /* bits 2-31 */
- #define SETEND_address_SHIFT 2
-
-#define MGAREG_SGN 0x1c58
-
- #define S_sdydxl_MASK 0xfffffffe /* bit 0 */
- #define S_sdydxl_y 0x0
- #define S_sdydxl_x 0x1
- #define S_scanleft_MASK 0xfffffffe /* bit 0 */
- #define S_scanleft_disable 0x0
- #define S_scanleft_enable 0x1
- #define S_sdxl_MASK 0xfffffffd /* bit 1 */
- #define S_sdxl_pos 0x0
- #define S_sdxl_neg 0x2
- #define S_sdy_MASK 0xfffffffb /* bit 2 */
- #define S_sdy_pos 0x0
- #define S_sdy_neg 0x4
- #define S_sdxr_MASK 0xffffffdf /* bit 5 */
- #define S_sdxr_pos 0x0
- #define S_sdxr_neg 0x20
- #define S_brkleft_MASK 0xfffffeff /* bit 8 */
- #define S_brkleft_disable 0x0
- #define S_brkleft_enable 0x100
- #define S_errorinit_MASK 0x7fffffff /* bit 31 */
- #define S_errorinit_disable 0x0
- #define S_errorinit_enable 0x80000000
-
-#define MGAREG_SHIFT 0x1c50
-
- #define FSC_x_off_MASK 0xfffffff0 /* bits 0-3 */
- #define FSC_x_off_SHIFT 0
- #define FSC_funcnt_MASK 0xffffff80 /* bits 0-6 */
- #define FSC_funcnt_SHIFT 0
- #define FSC_y_off_MASK 0xffffff8f /* bits 4-6 */
- #define FSC_y_off_SHIFT 4
- #define FSC_funoff_MASK 0xffc0ffff /* bits 16-21 */
- #define FSC_funoff_SHIFT 16
- #define FSC_stylelen_MASK 0xffc0ffff /* bits 16-21 */
- #define FSC_stylelen_SHIFT 16
-
-#define MGAREG_SOFTRAP 0x2c48
-
- #define STH_softraphand_MASK 0x3 /* bits 2-31 */
- #define STH_softraphand_SHIFT 2
-
-#define MGAREG_SPECBSTART 0x2c98
-#define MGAREG_SPECBXINC 0x2c9c
-#define MGAREG_SPECBYINC 0x2ca0
-#define MGAREG_SPECGSTART 0x2c8c
-#define MGAREG_SPECGXINC 0x2c90
-#define MGAREG_SPECGYINC 0x2c94
-#define MGAREG_SPECRSTART 0x2c80
-#define MGAREG_SPECRXINC 0x2c84
-#define MGAREG_SPECRYINC 0x2c88
-#define MGAREG_SRC0 0x1c30
-#define MGAREG_SRC1 0x1c34
-#define MGAREG_SRC2 0x1c38
-#define MGAREG_SRC3 0x1c3c
-#define MGAREG_SRCORG 0x2cb4
-
- #define SO_srcmap_MASK 0xfffffffe /* bit 0 */
- #define SO_srcmap_fb 0x0
- #define SO_srcmap_sys 0x1
- #define SO_srcacc_MASK 0xfffffffd /* bit 1 */
- #define SO_srcacc_pci 0x0
- #define SO_srcacc_agp 0x2
- #define SO_srcorg_MASK 0x7 /* bits 3-31 */
- #define SO_srcorg_SHIFT 3
-
-#define MGAREG_STATUS 0x1e14
-
- #define STAT_softrapen_MASK 0xfffffffe /* bit 0 */
- #define STAT_softrapen_disable 0x0
- #define STAT_softrapen_enable 0x1
- #define STAT_pickpen_MASK 0xfffffffb /* bit 2 */
- #define STAT_pickpen_disable 0x0
- #define STAT_pickpen_enable 0x4
- #define STAT_vsyncsts_MASK 0xfffffff7 /* bit 3 */
- #define STAT_vsyncsts_disable 0x0
- #define STAT_vsyncsts_enable 0x8
- #define STAT_vsyncpen_MASK 0xffffffef /* bit 4 */
- #define STAT_vsyncpen_disable 0x0
- #define STAT_vsyncpen_enable 0x10
- #define STAT_vlinepen_MASK 0xffffffdf /* bit 5 */
- #define STAT_vlinepen_disable 0x0
- #define STAT_vlinepen_enable 0x20
- #define STAT_extpen_MASK 0xffffffbf /* bit 6 */
- #define STAT_extpen_disable 0x0
- #define STAT_extpen_enable 0x40
- #define STAT_wpen_MASK 0xffffff7f /* bit 7 */
- #define STAT_wpen_disable 0x0
- #define STAT_wpen_enable 0x80
- #define STAT_wcpen_MASK 0xfffffeff /* bit 8 */
- #define STAT_wcpen_disable 0x0
- #define STAT_wcpen_enable 0x100
- #define STAT_dwgengsts_MASK 0xfffeffff /* bit 16 */
- #define STAT_dwgengsts_disable 0x0
- #define STAT_dwgengsts_enable 0x10000
- #define STAT_endprdmasts_MASK 0xfffdffff /* bit 17 */
- #define STAT_endprdmasts_disable 0x0
- #define STAT_endprdmasts_enable 0x20000
- #define STAT_wbusy_MASK 0xfffbffff /* bit 18 */
- #define STAT_wbusy_disable 0x0
- #define STAT_wbusy_enable 0x40000
- #define STAT_swflag_MASK 0xfffffff /* bits 28-31 */
- #define STAT_swflag_SHIFT 28
-
-#define MGAREG_STENCIL 0x2cc8
-
- #define S_sref_MASK 0xffffff00 /* bits 0-7 */
- #define S_sref_SHIFT 0
- #define S_smsk_MASK 0xffff00ff /* bits 8-15 */
- #define S_smsk_SHIFT 8
- #define S_swtmsk_MASK 0xff00ffff /* bits 16-23 */
- #define S_swtmsk_SHIFT 16
-
-#define MGAREG_STENCILCTL 0x2ccc
-
- #define SC_smode_MASK 0xfffffff8 /* bits 0-2 */
- #define SC_smode_salways 0x0 /* val 0, shift 0 */
- #define SC_smode_snever 0x1 /* val 1, shift 0 */
- #define SC_smode_se 0x2 /* val 2, shift 0 */
- #define SC_smode_sne 0x3 /* val 3, shift 0 */
- #define SC_smode_slt 0x4 /* val 4, shift 0 */
- #define SC_smode_slte 0x5 /* val 5, shift 0 */
- #define SC_smode_sgt 0x6 /* val 6, shift 0 */
- #define SC_smode_sgte 0x7 /* val 7, shift 0 */
- #define SC_sfailop_MASK 0xffffffc7 /* bits 3-5 */
- #define SC_sfailop_keep 0x0 /* val 0, shift 3 */
- #define SC_sfailop_zero 0x8 /* val 1, shift 3 */
- #define SC_sfailop_replace 0x10 /* val 2, shift 3 */
- #define SC_sfailop_incrsat 0x18 /* val 3, shift 3 */
- #define SC_sfailop_decrsat 0x20 /* val 4, shift 3 */
- #define SC_sfailop_invert 0x28 /* val 5, shift 3 */
- #define SC_sfailop_incr 0x30 /* val 6, shift 3 */
- #define SC_sfailop_decr 0x38 /* val 7, shift 3 */
- #define SC_szfailop_MASK 0xfffffe3f /* bits 6-8 */
- #define SC_szfailop_keep 0x0 /* val 0, shift 6 */
- #define SC_szfailop_zero 0x40 /* val 1, shift 6 */
- #define SC_szfailop_replace 0x80 /* val 2, shift 6 */
- #define SC_szfailop_incrsat 0xc0 /* val 3, shift 6 */
- #define SC_szfailop_decrsat 0x100 /* val 4, shift 6 */
- #define SC_szfailop_invert 0x140 /* val 5, shift 6 */
- #define SC_szfailop_incr 0x180 /* val 6, shift 6 */
- #define SC_szfailop_decr 0x1c0 /* val 7, shift 6 */
- #define SC_szpassop_MASK 0xfffff1ff /* bits 9-11 */
- #define SC_szpassop_keep 0x0 /* val 0, shift 9 */
- #define SC_szpassop_zero 0x200 /* val 1, shift 9 */
- #define SC_szpassop_replace 0x400 /* val 2, shift 9 */
- #define SC_szpassop_incrsat 0x600 /* val 3, shift 9 */
- #define SC_szpassop_decrsat 0x800 /* val 4, shift 9 */
- #define SC_szpassop_invert 0xa00 /* val 5, shift 9 */
- #define SC_szpassop_incr 0xc00 /* val 6, shift 9 */
- #define SC_szpassop_decr 0xe00 /* val 7, shift 9 */
-
-#define MGAREG_TDUALSTAGE0 0x2cf8
-
- #define TD0_color_arg2_MASK 0xfffffffc /* bits 0-1 */
- #define TD0_color_arg2_diffuse 0x0 /* val 0, shift 0 */
- #define TD0_color_arg2_specular 0x1 /* val 1, shift 0 */
- #define TD0_color_arg2_fcol 0x2 /* val 2, shift 0 */
- #define TD0_color_arg2_prevstage 0x3 /* val 3, shift 0 */
- #define TD0_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
- #define TD0_color_alpha_diffuse 0x0 /* val 0, shift 2 */
- #define TD0_color_alpha_fcol 0x4 /* val 1, shift 2 */
- #define TD0_color_alpha_currtex 0x8 /* val 2, shift 2 */
- #define TD0_color_alpha_prevtex 0xc /* val 3, shift 2 */
- #define TD0_color_alpha_prevstage 0x10 /* val 4, shift 2 */
- #define TD0_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
- #define TD0_color_arg1_replicatealpha_disable 0x0
- #define TD0_color_arg1_replicatealpha_enable 0x20
- #define TD0_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
- #define TD0_color_arg1_inv_disable 0x0
- #define TD0_color_arg1_inv_enable 0x40
- #define TD0_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
- #define TD0_color_arg2_replicatealpha_disable 0x0
- #define TD0_color_arg2_replicatealpha_enable 0x80
- #define TD0_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
- #define TD0_color_arg2_inv_disable 0x0
- #define TD0_color_arg2_inv_enable 0x100
- #define TD0_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
- #define TD0_color_alpha1inv_disable 0x0
- #define TD0_color_alpha1inv_enable 0x200
- #define TD0_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
- #define TD0_color_alpha2inv_disable 0x0
- #define TD0_color_alpha2inv_enable 0x400
- #define TD0_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
- #define TD0_color_arg1mul_arg1 0x0 /* val 0, shift 11 */
- #define TD0_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
- #define TD0_color_arg2mul_MASK 0xffffefff /* bit 12 */
- #define TD0_color_arg2mul_arg2 0x0 /* val 0, shift 12 */
- #define TD0_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
- #define TD0_color_arg1add_MASK 0xffffdfff /* bit 13 */
- #define TD0_color_arg1add_arg1 0x0 /* val 0, shift 13 */
- #define TD0_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
- #define TD0_color_arg2add_MASK 0xffffbfff /* bit 14 */
- #define TD0_color_arg2add_arg2 0x0 /* val 0, shift 14 */
- #define TD0_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
- #define TD0_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
- #define TD0_color_modbright_disable 0x0 /* val 0, shift 15 */
- #define TD0_color_modbright_2x 0x8000 /* val 1, shift 15 */
- #define TD0_color_modbright_4x 0x10000 /* val 2, shift 15 */
- #define TD0_color_add_MASK 0xfffdffff /* bit 17 */
- #define TD0_color_add_sub 0x0 /* val 0, shift 17 */
- #define TD0_color_add_add 0x20000 /* val 1, shift 17 */
- #define TD0_color_add2x_MASK 0xfffbffff /* bit 18 */
- #define TD0_color_add2x_disable 0x0
- #define TD0_color_add2x_enable 0x40000
- #define TD0_color_addbias_MASK 0xfff7ffff /* bit 19 */
- #define TD0_color_addbias_disable 0x0
- #define TD0_color_addbias_enable 0x80000
- #define TD0_color_blend_MASK 0xffefffff /* bit 20 */
- #define TD0_color_blend_disable 0x0
- #define TD0_color_blend_enable 0x100000
- #define TD0_color_sel_MASK 0xff9fffff /* bits 21-22 */
- #define TD0_color_sel_arg1 0x0 /* val 0, shift 21 */
- #define TD0_color_sel_arg2 0x200000 /* val 1, shift 21 */
- #define TD0_color_sel_addout 0x400000 /* val 2, shift 21 */
- #define TD0_color_sel_mulout 0x600000 /* val 3, shift 21 */
- #define TD0_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
- #define TD0_alpha_arg1_inv_disable 0x0
- #define TD0_alpha_arg1_inv_enable 0x800000
- #define TD0_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
- #define TD0_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
- #define TD0_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
- #define TD0_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
- #define TD0_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
- #define TD0_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
- #define TD0_alpha_arg2_inv_disable 0x0
- #define TD0_alpha_arg2_inv_enable 0x4000000
- #define TD0_alpha_add_MASK 0xf7ffffff /* bit 27 */
- #define TD0_alpha_add_disable 0x0
- #define TD0_alpha_add_enable 0x8000000
- #define TD0_alpha_addbias_MASK 0xefffffff /* bit 28 */
- #define TD0_alpha_addbias_disable 0x0
- #define TD0_alpha_addbias_enable 0x10000000
- #define TD0_alpha_add2x_MASK 0xdfffffff /* bit 29 */
- #define TD0_alpha_add2x_disable 0x0
- #define TD0_alpha_add2x_enable 0x20000000
- #define TD0_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
- #define TD0_alpha_modbright_disable 0x0 /* val 0, shift 28 */
- #define TD0_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
- #define TD0_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
- #define TD0_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
- #define TD0_alpha_sel_arg1 0x0 /* val 0, shift 30 */
- #define TD0_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
- #define TD0_alpha_sel_addout 0x80000000 /* val 2, shift 30 */
- #define TD0_alpha_sel_mulout 0xc0000000 /* val 3, shift 30 */
-
-#define MGAREG_TDUALSTAGE1 0x2cfc
-
- #define TD1_color_arg2_MASK 0xfffffffc /* bits 0-1 */
- #define TD1_color_arg2_diffuse 0x0 /* val 0, shift 0 */
- #define TD1_color_arg2_specular 0x1 /* val 1, shift 0 */
- #define TD1_color_arg2_fcol 0x2 /* val 2, shift 0 */
- #define TD1_color_arg2_prevstage 0x3 /* val 3, shift 0 */
- #define TD1_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
- #define TD1_color_alpha_diffuse 0x0 /* val 0, shift 2 */
- #define TD1_color_alpha_fcol 0x4 /* val 1, shift 2 */
- #define TD1_color_alpha_currtex 0x8 /* val 2, shift 2 */
- #define TD1_color_alpha_prevtex 0xc /* val 3, shift 2 */
- #define TD1_color_alpha_prevstage 0x10 /* val 4, shift 2 */
- #define TD1_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
- #define TD1_color_arg1_replicatealpha_disable 0x0
- #define TD1_color_arg1_replicatealpha_enable 0x20
- #define TD1_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
- #define TD1_color_arg1_inv_disable 0x0
- #define TD1_color_arg1_inv_enable 0x40
- #define TD1_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
- #define TD1_color_arg2_replicatealpha_disable 0x0
- #define TD1_color_arg2_replicatealpha_enable 0x80
- #define TD1_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
- #define TD1_color_arg2_inv_disable 0x0
- #define TD1_color_arg2_inv_enable 0x100
- #define TD1_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
- #define TD1_color_alpha1inv_disable 0x0
- #define TD1_color_alpha1inv_enable 0x200
- #define TD1_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
- #define TD1_color_alpha2inv_disable 0x0
- #define TD1_color_alpha2inv_enable 0x400
- #define TD1_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
- #define TD1_color_arg1mul_arg1 0x0 /* val 0, shift 11 */
- #define TD1_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
- #define TD1_color_arg2mul_MASK 0xffffefff /* bit 12 */
- #define TD1_color_arg2mul_arg2 0x0 /* val 0, shift 12 */
- #define TD1_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
- #define TD1_color_arg1add_MASK 0xffffdfff /* bit 13 */
- #define TD1_color_arg1add_arg1 0x0 /* val 0, shift 13 */
- #define TD1_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
- #define TD1_color_arg2add_MASK 0xffffbfff /* bit 14 */
- #define TD1_color_arg2add_arg2 0x0 /* val 0, shift 14 */
- #define TD1_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
- #define TD1_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
- #define TD1_color_modbright_disable 0x0 /* val 0, shift 15 */
- #define TD1_color_modbright_2x 0x8000 /* val 1, shift 15 */
- #define TD1_color_modbright_4x 0x10000 /* val 2, shift 15 */
- #define TD1_color_add_MASK 0xfffdffff /* bit 17 */
- #define TD1_color_add_sub 0x0 /* val 0, shift 17 */
- #define TD1_color_add_add 0x20000 /* val 1, shift 17 */
- #define TD1_color_add2x_MASK 0xfffbffff /* bit 18 */
- #define TD1_color_add2x_disable 0x0
- #define TD1_color_add2x_enable 0x40000
- #define TD1_color_addbias_MASK 0xfff7ffff /* bit 19 */
- #define TD1_color_addbias_disable 0x0
- #define TD1_color_addbias_enable 0x80000
- #define TD1_color_blend_MASK 0xffefffff /* bit 20 */
- #define TD1_color_blend_disable 0x0
- #define TD1_color_blend_enable 0x100000
- #define TD1_color_sel_MASK 0xff9fffff /* bits 21-22 */
- #define TD1_color_sel_arg1 0x0 /* val 0, shift 21 */
- #define TD1_color_sel_arg2 0x200000 /* val 1, shift 21 */
- #define TD1_color_sel_addout 0x400000 /* val 2, shift 21 */
- #define TD1_color_sel_mulout 0x600000 /* val 3, shift 21 */
- #define TD1_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
- #define TD1_alpha_arg1_inv_disable 0x0
- #define TD1_alpha_arg1_inv_enable 0x800000
- #define TD1_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
- #define TD1_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
- #define TD1_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
- #define TD1_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
- #define TD1_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
- #define TD1_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
- #define TD1_alpha_arg2_inv_disable 0x0
- #define TD1_alpha_arg2_inv_enable 0x4000000
- #define TD1_alpha_add_MASK 0xf7ffffff /* bit 27 */
- #define TD1_alpha_add_disable 0x0
- #define TD1_alpha_add_enable 0x8000000
- #define TD1_alpha_addbias_MASK 0xefffffff /* bit 28 */
- #define TD1_alpha_addbias_disable 0x0
- #define TD1_alpha_addbias_enable 0x10000000
- #define TD1_alpha_add2x_MASK 0xdfffffff /* bit 29 */
- #define TD1_alpha_add2x_disable 0x0
- #define TD1_alpha_add2x_enable 0x20000000
- #define TD1_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
- #define TD1_alpha_modbright_disable 0x0 /* val 0, shift 28 */
- #define TD1_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
- #define TD1_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
- #define TD1_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
- #define TD1_alpha_sel_arg1 0x0 /* val 0, shift 30 */
- #define TD1_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
- #define TD1_alpha_sel_addout 0x80000000 /* val 2, shift 30 */
- #define TD1_alpha_sel_mulout 0xc0000000 /* val 3, shift 30 */
-
-#define MGAREG_TEST0 0x1e48
-
- #define TST_ramtsten_MASK 0xfffffffe /* bit 0 */
- #define TST_ramtsten_disable 0x0
- #define TST_ramtsten_enable 0x1
- #define TST_ramtstdone_MASK 0xfffffffd /* bit 1 */
- #define TST_ramtstdone_disable 0x0
- #define TST_ramtstdone_enable 0x2
- #define TST_wramtstpass_MASK 0xfffffffb /* bit 2 */
- #define TST_wramtstpass_disable 0x0
- #define TST_wramtstpass_enable 0x4
- #define TST_tcachetstpass_MASK 0xfffffff7 /* bit 3 */
- #define TST_tcachetstpass_disable 0x0
- #define TST_tcachetstpass_enable 0x8
- #define TST_tluttstpass_MASK 0xffffffef /* bit 4 */
- #define TST_tluttstpass_disable 0x0
- #define TST_tluttstpass_enable 0x10
- #define TST_luttstpass_MASK 0xffffffdf /* bit 5 */
- #define TST_luttstpass_disable 0x0
- #define TST_luttstpass_enable 0x20
- #define TST_besramtstpass_MASK 0xffffffbf /* bit 6 */
- #define TST_besramtstpass_disable 0x0
- #define TST_besramtstpass_enable 0x40
- #define TST_ringen_MASK 0xfffffeff /* bit 8 */
- #define TST_ringen_disable 0x0
- #define TST_ringen_enable 0x100
- #define TST_apllbyp_MASK 0xfffffdff /* bit 9 */
- #define TST_apllbyp_disable 0x0
- #define TST_apllbyp_enable 0x200
- #define TST_hiten_MASK 0xfffffbff /* bit 10 */
- #define TST_hiten_disable 0x0
- #define TST_hiten_enable 0x400
- #define TST_tmode_MASK 0xffffc7ff /* bits 11-13 */
- #define TST_tmode_SHIFT 11
- #define TST_tclksel_MASK 0xfffe3fff /* bits 14-16 */
- #define TST_tclksel_SHIFT 14
- #define TST_ringcnten_MASK 0xfffdffff /* bit 17 */
- #define TST_ringcnten_disable 0x0
- #define TST_ringcnten_enable 0x20000
- #define TST_ringcnt_MASK 0xc003ffff /* bits 18-29 */
- #define TST_ringcnt_SHIFT 18
- #define TST_ringcntclksl_MASK 0xbfffffff /* bit 30 */
- #define TST_ringcntclksl_disable 0x0
- #define TST_ringcntclksl_enable 0x40000000
- #define TST_biosboot_MASK 0x7fffffff /* bit 31 */
- #define TST_biosboot_disable 0x0
- #define TST_biosboot_enable 0x80000000
-
-#define MGAREG_TEXBORDERCOL 0x2c5c
-#define MGAREG_TEXCTL 0x2c30
-
- #define TMC_tformat_MASK 0xfffffff0 /* bits 0-3 */
- #define TMC_tformat_tw4 0x0 /* val 0, shift 0 */
- #define TMC_tformat_tw8 0x1 /* val 1, shift 0 */
- #define TMC_tformat_tw15 0x2 /* val 2, shift 0 */
- #define TMC_tformat_tw16 0x3 /* val 3, shift 0 */
- #define TMC_tformat_tw12 0x4 /* val 4, shift 0 */
- #define TMC_tformat_tw32 0x6 /* val 6, shift 0 */
- #define TMC_tformat_tw8a 0x7 /* val 7, shift 0 */
- #define TMC_tformat_tw8al 0x8 /* val 8, shift 0 */
- #define TMC_tformat_tw422 0xa /* val 10, shift 0 */
- #define TMC_tpitchlin_MASK 0xfffffeff /* bit 8 */
- #define TMC_tpitchlin_disable 0x0
- #define TMC_tpitchlin_enable 0x100
- #define TMC_tpitchext_MASK 0xfff001ff /* bits 9-19 */
- #define TMC_tpitchext_SHIFT 9
- #define TMC_tpitch_MASK 0xfff8ffff /* bits 16-18 */
- #define TMC_tpitch_SHIFT 16
- #define TMC_owalpha_MASK 0xffbfffff /* bit 22 */
- #define TMC_owalpha_disable 0x0
- #define TMC_owalpha_enable 0x400000
- #define TMC_azeroextend_MASK 0xff7fffff /* bit 23 */
- #define TMC_azeroextend_disable 0x0
- #define TMC_azeroextend_enable 0x800000
- #define TMC_decalckey_MASK 0xfeffffff /* bit 24 */
- #define TMC_decalckey_disable 0x0
- #define TMC_decalckey_enable 0x1000000
- #define TMC_takey_MASK 0xfdffffff /* bit 25 */
- #define TMC_takey_0 0x0
- #define TMC_takey_1 0x2000000
- #define TMC_tamask_MASK 0xfbffffff /* bit 26 */
- #define TMC_tamask_0 0x0
- #define TMC_tamask_1 0x4000000
- #define TMC_clampv_MASK 0xf7ffffff /* bit 27 */
- #define TMC_clampv_disable 0x0
- #define TMC_clampv_enable 0x8000000
- #define TMC_clampu_MASK 0xefffffff /* bit 28 */
- #define TMC_clampu_disable 0x0
- #define TMC_clampu_enable 0x10000000
- #define TMC_tmodulate_MASK 0xdfffffff /* bit 29 */
- #define TMC_tmodulate_disable 0x0
- #define TMC_tmodulate_enable 0x20000000
- #define TMC_strans_MASK 0xbfffffff /* bit 30 */
- #define TMC_strans_disable 0x0
- #define TMC_strans_enable 0x40000000
- #define TMC_itrans_MASK 0x7fffffff /* bit 31 */
- #define TMC_itrans_disable 0x0
- #define TMC_itrans_enable 0x80000000
-
-#define MGAREG_TEXCTL2 0x2c3c
-
- #define TMC_decalblend_MASK 0xfffffffe /* bit 0 */
- #define TMC_decalblend_disable 0x0
- #define TMC_decalblend_enable 0x1
- #define TMC_idecal_MASK 0xfffffffd /* bit 1 */
- #define TMC_idecal_disable 0x0
- #define TMC_idecal_enable 0x2
- #define TMC_decaldis_MASK 0xfffffffb /* bit 2 */
- #define TMC_decaldis_disable 0x0
- #define TMC_decaldis_enable 0x4
- #define TMC_ckstransdis_MASK 0xffffffef /* bit 4 */
- #define TMC_ckstransdis_disable 0x0
- #define TMC_ckstransdis_enable 0x10
- #define TMC_borderen_MASK 0xffffffdf /* bit 5 */
- #define TMC_borderen_disable 0x0
- #define TMC_borderen_enable 0x20
- #define TMC_specen_MASK 0xffffffbf /* bit 6 */
- #define TMC_specen_disable 0x0
- #define TMC_specen_enable 0x40
- #define TMC_dualtex_MASK 0xffffff7f /* bit 7 */
- #define TMC_dualtex_disable 0x0
- #define TMC_dualtex_enable 0x80
- #define TMC_tablefog_MASK 0xfffffeff /* bit 8 */
- #define TMC_tablefog_disable 0x0
- #define TMC_tablefog_enable 0x100
- #define TMC_bumpmap_MASK 0xfffffdff /* bit 9 */
- #define TMC_bumpmap_disable 0x0
- #define TMC_bumpmap_enable 0x200
- #define TMC_map1_MASK 0x7fffffff /* bit 31 */
- #define TMC_map1_disable 0x0
- #define TMC_map1_enable 0x80000000
-
-#define MGAREG_TEXFILTER 0x2c58
-
- #define TF_minfilter_MASK 0xfffffff0 /* bits 0-3 */
- #define TF_minfilter_nrst 0x0 /* val 0, shift 0 */
- #define TF_minfilter_bilin 0x2 /* val 2, shift 0 */
- #define TF_minfilter_cnst 0x3 /* val 3, shift 0 */
- #define TF_minfilter_mm1s 0x8 /* val 8, shift 0 */
- #define TF_minfilter_mm2s 0x9 /* val 9, shift 0 */
- #define TF_minfilter_mm4s 0xa /* val 10, shift 0 */
- #define TF_minfilter_mm8s 0xc /* val 12, shift 0 */
- #define TF_magfilter_MASK 0xffffff0f /* bits 4-7 */
- #define TF_magfilter_nrst 0x0 /* val 0, shift 4 */
- #define TF_magfilter_bilin 0x20 /* val 2, shift 4 */
- #define TF_magfilter_cnst 0x30 /* val 3, shift 4 */
- #define TF_avgstride_MASK 0xfff7ffff /* bit 19 */
- #define TF_avgstride_disable 0x0
- #define TF_avgstride_enable 0x80000
- #define TF_filteralpha_MASK 0xffefffff /* bit 20 */
- #define TF_filteralpha_disable 0x0
- #define TF_filteralpha_enable 0x100000
- #define TF_fthres_MASK 0xe01fffff /* bits 21-28 */
- #define TF_fthres_SHIFT 21
- #define TF_mapnb_MASK 0x1fffffff /* bits 29-31 */
- #define TF_mapnb_SHIFT 29
-
-#define MGAREG_TEXHEIGHT 0x2c2c
-
- #define TH_th_MASK 0xffffffc0 /* bits 0-5 */
- #define TH_th_SHIFT 0
- #define TH_rfh_MASK 0xffff81ff /* bits 9-14 */
- #define TH_rfh_SHIFT 9
- #define TH_thmask_MASK 0xe003ffff /* bits 18-28 */
- #define TH_thmask_SHIFT 18
-
-#define MGAREG_TEXORG 0x2c24
-
- #define TO_texorgmap_MASK 0xfffffffe /* bit 0 */
- #define TO_texorgmap_fb 0x0
- #define TO_texorgmap_sys 0x1
- #define TO_texorgacc_MASK 0xfffffffd /* bit 1 */
- #define TO_texorgacc_pci 0x0
- #define TO_texorgacc_agp 0x2
- #define TO_texorgoffsetsel 0x4
- #define TO_texorg_MASK 0x1f /* bits 5-31 */
- #define TO_texorg_SHIFT 5
-
-#define MGAREG_TEXORG1 0x2ca4
-#define MGAREG_TEXORG2 0x2ca8
-#define MGAREG_TEXORG3 0x2cac
-#define MGAREG_TEXORG4 0x2cb0
-#define MGAREG_TEXTRANS 0x2c34
-
- #define TT_tckey_MASK 0xffff0000 /* bits 0-15 */
- #define TT_tckey_SHIFT 0
- #define TT_tkmask_MASK 0xffff /* bits 16-31 */
- #define TT_tkmask_SHIFT 16
-
-#define MGAREG_TEXTRANSHIGH 0x2c38
-
- #define TT_tckeyh_MASK 0xffff0000 /* bits 0-15 */
- #define TT_tckeyh_SHIFT 0
- #define TT_tkmaskh_MASK 0xffff /* bits 16-31 */
- #define TT_tkmaskh_SHIFT 16
-
-#define MGAREG_TEXWIDTH 0x2c28
-
- #define TW_tw_MASK 0xffffffc0 /* bits 0-5 */
- #define TW_tw_SHIFT 0
- #define TW_rfw_MASK 0xffff81ff /* bits 9-14 */
- #define TW_rfw_SHIFT 9
- #define TW_twmask_MASK 0xe003ffff /* bits 18-28 */
- #define TW_twmask_SHIFT 18
-
-#define MGAREG_TMR0 0x2c00
-#define MGAREG_TMR1 0x2c04
-#define MGAREG_TMR2 0x2c08
-#define MGAREG_TMR3 0x2c0c
-#define MGAREG_TMR4 0x2c10
-#define MGAREG_TMR5 0x2c14
-#define MGAREG_TMR6 0x2c18
-#define MGAREG_TMR7 0x2c1c
-#define MGAREG_TMR8 0x2c20
-#define MGAREG_VBIADDR0 0x3e08
-#define MGAREG_VBIADDR1 0x3e0c
-#define MGAREG_VCOUNT 0x1e20
-#define MGAREG_WACCEPTSEQ 0x1dd4
-
- #define WAS_seqdst0_MASK 0xffffffc0 /* bits 0-5 */
- #define WAS_seqdst0_SHIFT 0
- #define WAS_seqdst1_MASK 0xfffff03f /* bits 6-11 */
- #define WAS_seqdst1_SHIFT 6
- #define WAS_seqdst2_MASK 0xfffc0fff /* bits 12-17 */
- #define WAS_seqdst2_SHIFT 12
- #define WAS_seqdst3_MASK 0xff03ffff /* bits 18-23 */
- #define WAS_seqdst3_SHIFT 18
- #define WAS_seqlen_MASK 0xfcffffff /* bits 24-25 */
- #define WAS_wfirsttag_MASK 0xfbffffff /* bit 26 */
- #define WAS_wfirsttag_disable 0x0
- #define WAS_wfirsttag_enable 0x4000000
- #define WAS_wsametag_MASK 0xf7ffffff /* bit 27 */
- #define WAS_wsametag_disable 0x0
- #define WAS_wsametag_enable 0x8000000
- #define WAS_seqoff_MASK 0xefffffff /* bit 28 */
- #define WAS_seqoff_disable 0x0
- #define WAS_seqoff_enable 0x10000000
-
-#define MGAREG_WCODEADDR 0x1e6c
-
- #define WMA_wcodeaddr_MASK 0xff /* bits 8-31 */
- #define WMA_wcodeaddr_SHIFT 8
-
-#define MGAREG_WFLAG 0x1dc4
-
- #define WF_walustsflag_MASK 0xffffff00 /* bits 0-7 */
- #define WF_walustsflag_SHIFT 0
- #define WF_walucfgflag_MASK 0xffff00ff /* bits 8-15 */
- #define WF_walucfgflag_SHIFT 8
- #define WF_wprgflag_MASK 0xffff /* bits 16-31 */
- #define WF_wprgflag_SHIFT 16
-
-#define MGAREG_WFLAG1 0x1de0
-
- #define WF1_walustsflag1_MASK 0xffffff00 /* bits 0-7 */
- #define WF1_walustsflag1_SHIFT 0
- #define WF1_walucfgflag1_MASK 0xffff00ff /* bits 8-15 */
- #define WF1_walucfgflag1_SHIFT 8
- #define WF1_wprgflag1_MASK 0xffff /* bits 16-31 */
- #define WF1_wprgflag1_SHIFT 16
-
-#define MGAREG_WFLAGNB 0x1e64
-#define MGAREG_WFLAGNB1 0x1e08
-#define MGAREG_WGETMSB 0x1dc8
-
- #define WGV_wgetmsbmin_MASK 0xffffffe0 /* bits 0-4 */
- #define WGV_wgetmsbmin_SHIFT 0
- #define WGV_wgetmsbmax_MASK 0xffffe0ff /* bits 8-12 */
- #define WGV_wgetmsbmax_SHIFT 8
- #define WGV_wbrklefttop_MASK 0xfffeffff /* bit 16 */
- #define WGV_wbrklefttop_disable 0x0
- #define WGV_wbrklefttop_enable 0x10000
- #define WGV_wfastcrop_MASK 0xfffdffff /* bit 17 */
- #define WGV_wfastcrop_disable 0x0
- #define WGV_wfastcrop_enable 0x20000
- #define WGV_wcentersnap_MASK 0xfffbffff /* bit 18 */
- #define WGV_wcentersnap_disable 0x0
- #define WGV_wcentersnap_enable 0x40000
- #define WGV_wbrkrighttop_MASK 0xfff7ffff /* bit 19 */
- #define WGV_wbrkrighttop_disable 0x0
- #define WGV_wbrkrighttop_enable 0x80000
-
-#define MGAREG_WIADDR 0x1dc0
-
- #define WIA_wmode_MASK 0xfffffffc /* bits 0-1 */
- #define WIA_wmode_suspend 0x0 /* val 0, shift 0 */
- #define WIA_wmode_resume 0x1 /* val 1, shift 0 */
- #define WIA_wmode_jump 0x2 /* val 2, shift 0 */
- #define WIA_wmode_start 0x3 /* val 3, shift 0 */
- #define WIA_wagp_MASK 0xfffffffb /* bit 2 */
- #define WIA_wagp_pci 0x0
- #define WIA_wagp_agp 0x4
- #define WIA_wiaddr_MASK 0x7 /* bits 3-31 */
- #define WIA_wiaddr_SHIFT 3
-
-#define MGAREG_WIADDR2 0x1dd8
-
- #define WIA2_wmode_MASK 0xfffffffc /* bits 0-1 */
- #define WIA2_wmode_suspend 0x0 /* val 0, shift 0 */
- #define WIA2_wmode_resume 0x1 /* val 1, shift 0 */
- #define WIA2_wmode_jump 0x2 /* val 2, shift 0 */
- #define WIA2_wmode_start 0x3 /* val 3, shift 0 */
- #define WIA2_wagp_MASK 0xfffffffb /* bit 2 */
- #define WIA2_wagp_pci 0x0
- #define WIA2_wagp_agp 0x4
- #define WIA2_wiaddr_MASK 0x7 /* bits 3-31 */
- #define WIA2_wiaddr_SHIFT 3
-
-#define MGAREG_WIADDRNB 0x1e60
-#define MGAREG_WIADDRNB1 0x1e04
-#define MGAREG_WIADDRNB2 0x1e00
-#define MGAREG_WIMEMADDR 0x1e68
-
- #define WIMA_wimemaddr_MASK 0xffffff00 /* bits 0-7 */
- #define WIMA_wimemaddr_SHIFT 0
-
-#define MGAREG_WIMEMDATA 0x2000
-#define MGAREG_WIMEMDATA1 0x2100
-#define MGAREG_WMISC 0x1e70
-
- #define WM_wucodecache_MASK 0xfffffffe /* bit 0 */
- #define WM_wucodecache_disable 0x0
- #define WM_wucodecache_enable 0x1
- #define WM_wmaster_MASK 0xfffffffd /* bit 1 */
- #define WM_wmaster_disable 0x0
- #define WM_wmaster_enable 0x2
- #define WM_wcacheflush_MASK 0xfffffff7 /* bit 3 */
- #define WM_wcacheflush_disable 0x0
- #define WM_wcacheflush_enable 0x8
-
-#define MGAREG_WR 0x2d00
-#define MGAREG_WVRTXSZ 0x1dcc
-
- #define WVS_wvrtxsz_MASK 0xffffffc0 /* bits 0-5 */
- #define WVS_wvrtxsz_SHIFT 0
- #define WVS_primsz_MASK 0xffffc0ff /* bits 8-13 */
- #define WVS_primsz_SHIFT 8
-
-#define MGAREG_XDST 0x1cb0
-#define MGAREG_XYEND 0x1c44
-
- #define XYEA_x_end_MASK 0xffff0000 /* bits 0-15 */
- #define XYEA_x_end_SHIFT 0
- #define XYEA_y_end_MASK 0xffff /* bits 16-31 */
- #define XYEA_y_end_SHIFT 16
-
-#define MGAREG_XYSTRT 0x1c40
-
- #define XYSA_x_start_MASK 0xffff0000 /* bits 0-15 */
- #define XYSA_x_start_SHIFT 0
- #define XYSA_y_start_MASK 0xffff /* bits 16-31 */
- #define XYSA_y_start_SHIFT 16
-
-#define MGAREG_YBOT 0x1c9c
-#define MGAREG_YDST 0x1c90
-
- #define YA_ydst_MASK 0xff800000 /* bits 0-22 */
- #define YA_ydst_SHIFT 0
- #define YA_sellin_MASK 0x1fffffff /* bits 29-31 */
- #define YA_sellin_SHIFT 29
-
-#define MGAREG_YDSTLEN 0x1c88
-
- #define YDL_length_MASK 0xffff0000 /* bits 0-15 */
- #define YDL_length_SHIFT 0
- #define YDL_yval_MASK 0xffff /* bits 16-31 */
- #define YDL_yval_SHIFT 16
-
-#define MGAREG_YDSTORG 0x1c94
-#define MGAREG_YTOP 0x1c98
-#define MGAREG_ZORG 0x1c0c
-
- #define ZO_zorgmap_MASK 0xfffffffe /* bit 0 */
- #define ZO_zorgmap_fb 0x0
- #define ZO_zorgmap_sys 0x1
- #define ZO_zorgacc_MASK 0xfffffffd /* bit 1 */
- #define ZO_zorgacc_pci 0x0
- #define ZO_zorgacc_agp 0x2
- #define ZO_zorg_MASK 0x3 /* bits 2-31 */
- #define ZO_zorg_SHIFT 2
+#define MGAREG_MGA_EXEC 0x0100
+#define MGAREG_AGP_PLL 0x1e4c
+
+ #define AGP_PLL_agp2xpllen_MASK 0xfffffffe /* bit 0 */
+ #define AGP_PLL_agp2xpllen_disable 0x0
+ #define AGP_PLL_agp2xpllen_enable 0x1
+
+#define MGAREG_CFG_OR 0x1e4c
+
+ #define CFG_OR_comp_or_MASK 0xfffffff7 /* bit 3 */
+ #define CFG_OR_comp_or_disable 0x0
+ #define CFG_OR_comp_or_enable 0x8
+ #define CFG_OR_compfreq_MASK 0xffffff0f /* bits 4-7 */
+ #define CFG_OR_compfreq_SHIFT 4
+ #define CFG_OR_comporup_MASK 0xfffff0ff /* bits 8-11 */
+ #define CFG_OR_comporup_SHIFT 8
+ #define CFG_OR_compordn_MASK 0xffff0fff /* bits 12-15 */
+ #define CFG_OR_compordn_SHIFT 12
+ #define CFG_OR_e2pq_MASK 0xfffeffff /* bit 16 */
+ #define CFG_OR_e2pq_disable 0x0
+ #define CFG_OR_e2pq_enable 0x10000
+ #define CFG_OR_e2pqbypcsn_MASK 0xfffdffff /* bit 17 */
+ #define CFG_OR_e2pqbypcsn_disable 0x0
+ #define CFG_OR_e2pqbypcsn_enable 0x20000
+ #define CFG_OR_e2pqbypd_MASK 0xfffbffff /* bit 18 */
+ #define CFG_OR_e2pqbypd_disable 0x0
+ #define CFG_OR_e2pqbypd_enable 0x40000
+ #define CFG_OR_e2pbypclk_MASK 0xfff7ffff /* bit 19 */
+ #define CFG_OR_e2pbypclk_disable 0x0
+ #define CFG_OR_e2pbypclk_enable 0x80000
+ #define CFG_OR_e2pbyp_MASK 0xffefffff /* bit 20 */
+ #define CFG_OR_e2pbyp_disable 0x0
+ #define CFG_OR_e2pbyp_enable 0x100000
+ #define CFG_OR_rate_cap_or_MASK 0xff1fffff /* bits 21-23 */
+ #define CFG_OR_rate_cap_or_SHIFT 21
+ #define CFG_OR_rq_or_MASK 0xe0ffffff /* bits 24-28 */
+ #define CFG_OR_rq_or_SHIFT 24
+
+#define MGAREG_ALPHACTRL 0x2c7c
+
+ #define AC_src_MASK 0xfffffff0 /* bits 0-3 */
+ #define AC_src_zero 0x0 /* val 0, shift 0 */
+ #define AC_src_one 0x1 /* val 1, shift 0 */
+ #define AC_src_dst_color 0x2 /* val 2, shift 0 */
+ #define AC_src_om_dst_color 0x3 /* val 3, shift 0 */
+ #define AC_src_src_alpha 0x4 /* val 4, shift 0 */
+ #define AC_src_om_src_alpha 0x5 /* val 5, shift 0 */
+ #define AC_src_dst_alpha 0x6 /* val 6, shift 0 */
+ #define AC_src_om_dst_alpha 0x7 /* val 7, shift 0 */
+ #define AC_src_src_alpha_sat 0x8 /* val 8, shift 0 */
+ #define AC_dst_MASK 0xffffff0f /* bits 4-7 */
+ #define AC_dst_zero 0x0 /* val 0, shift 4 */
+ #define AC_dst_one 0x10 /* val 1, shift 4 */
+ #define AC_dst_src_color 0x20 /* val 2, shift 4 */
+ #define AC_dst_om_src_color 0x30 /* val 3, shift 4 */
+ #define AC_dst_src_alpha 0x40 /* val 4, shift 4 */
+ #define AC_dst_om_src_alpha 0x50 /* val 5, shift 4 */
+ #define AC_dst_dst_alpha 0x60 /* val 6, shift 4 */
+ #define AC_dst_om_dst_alpha 0x70 /* val 7, shift 4 */
+ #define AC_amode_MASK 0xfffffcff /* bits 8-9 */
+ #define AC_amode_FCOL 0x0 /* val 0, shift 8 */
+ #define AC_amode_alpha_channel 0x100 /* val 1, shift 8 */
+ #define AC_amode_video_alpha 0x200 /* val 2, shift 8 */
+ #define AC_amode_RSVD 0x300 /* val 3, shift 8 */
+ #define AC_astipple_MASK 0xfffff7ff /* bit 11 */
+ #define AC_astipple_disable 0x0
+ #define AC_astipple_enable 0x800
+ #define AC_aten_MASK 0xffffefff /* bit 12 */
+ #define AC_aten_disable 0x0
+ #define AC_aten_enable 0x1000
+ #define AC_atmode_MASK 0xffff1fff /* bits 13-15 */
+ #define AC_atmode_noacmp 0x0 /* val 0, shift 13 */
+ #define AC_atmode_ae 0x4000 /* val 2, shift 13 */
+ #define AC_atmode_ane 0x6000 /* val 3, shift 13 */
+ #define AC_atmode_alt 0x8000 /* val 4, shift 13 */
+ #define AC_atmode_alte 0xa000 /* val 5, shift 13 */
+ #define AC_atmode_agt 0xc000 /* val 6, shift 13 */
+ #define AC_atmode_agte 0xe000 /* val 7, shift 13 */
+ #define AC_atref_MASK 0xff00ffff /* bits 16-23 */
+ #define AC_atref_SHIFT 16
+ #define AC_alphasel_MASK 0xfcffffff /* bits 24-25 */
+ #define AC_alphasel_fromtex 0x0 /* val 0, shift 24 */
+ #define AC_alphasel_diffused 0x1000000 /* val 1, shift 24 */
+ #define AC_alphasel_modulated 0x2000000 /* val 2, shift 24 */
+ #define AC_alphasel_trans 0x3000000 /* val 3, shift 24 */
+
+#define MGAREG_ALPHASTART 0x2c70
+#define MGAREG_ALPHAXINC 0x2c74
+#define MGAREG_ALPHAYINC 0x2c78
+#define MGAREG_AR0 0x1c60
+
+ #define AR0_ar0_MASK 0xfffc0000 /* bits 0-17 */
+ #define AR0_ar0_SHIFT 0
+
+#define MGAREG_AR1 0x1c64
+
+ #define AR1_ar1_MASK 0xff000000 /* bits 0-23 */
+ #define AR1_ar1_SHIFT 0
+
+#define MGAREG_AR2 0x1c68
+
+ #define AR2_ar2_MASK 0xfffc0000 /* bits 0-17 */
+ #define AR2_ar2_SHIFT 0
+
+#define MGAREG_AR3 0x1c6c
+
+ #define AR3_ar3_MASK 0xff000000 /* bits 0-23 */
+ #define AR3_ar3_SHIFT 0
+ #define AR3_spage_MASK 0xf8ffffff /* bits 24-26 */
+ #define AR3_spage_SHIFT 24
+
+#define MGAREG_AR4 0x1c70
+
+ #define AR4_ar4_MASK 0xfffc0000 /* bits 0-17 */
+ #define AR4_ar4_SHIFT 0
+
+#define MGAREG_AR5 0x1c74
+
+ #define AR5_ar5_MASK 0xfffc0000 /* bits 0-17 */
+ #define AR5_ar5_SHIFT 0
+
+#define MGAREG_AR6 0x1c78
+
+ #define AR6_ar6_MASK 0xfffc0000 /* bits 0-17 */
+ #define AR6_ar6_SHIFT 0
+
+#define MGAREG_BCOL 0x1c20
+#define MGAREG_BESA1CORG 0x3d10
+#define MGAREG_BESA1ORG 0x3d00
+#define MGAREG_BESA2CORG 0x3d14
+#define MGAREG_BESA2ORG 0x3d04
+#define MGAREG_BESB1CORG 0x3d18
+#define MGAREG_BESB1ORG 0x3d08
+#define MGAREG_BESB2CORG 0x3d1c
+#define MGAREG_BESB2ORG 0x3d0c
+#define MGAREG_BESCTL 0x3d20
+
+ #define BC_besen_MASK 0xfffffffe /* bit 0 */
+ #define BC_besen_disable 0x0
+ #define BC_besen_enable 0x1
+ #define BC_besv1srcstp_MASK 0xffffffbf /* bit 6 */
+ #define BC_besv1srcstp_even 0x0
+ #define BC_besv1srcstp_odd 0x40
+ #define BC_besv2srcstp_MASK 0xfffffeff /* bit 8 */
+ #define BC_besv2srcstp_disable 0x0
+ #define BC_besv2srcstp_enable 0x100
+ #define BC_beshfen_MASK 0xfffffbff /* bit 10 */
+ #define BC_beshfen_disable 0x0
+ #define BC_beshfen_enable 0x400
+ #define BC_besvfen_MASK 0xfffff7ff /* bit 11 */
+ #define BC_besvfen_disable 0x0
+ #define BC_besvfen_enable 0x800
+ #define BC_beshfixc_MASK 0xffffefff /* bit 12 */
+ #define BC_beshfixc_weight 0x0
+ #define BC_beshfixc_coeff 0x1000
+ #define BC_bescups_MASK 0xfffeffff /* bit 16 */
+ #define BC_bescups_disable 0x0
+ #define BC_bescups_enable 0x10000
+ #define BC_bes420pl_MASK 0xfffdffff /* bit 17 */
+ #define BC_bes420pl_422 0x0
+ #define BC_bes420pl_420 0x20000
+ #define BC_besdith_MASK 0xfffbffff /* bit 18 */
+ #define BC_besdith_disable 0x0
+ #define BC_besdith_enable 0x40000
+ #define BC_beshmir_MASK 0xfff7ffff /* bit 19 */
+ #define BC_beshmir_disable 0x0
+ #define BC_beshmir_enable 0x80000
+ #define BC_besbwen_MASK 0xffefffff /* bit 20 */
+ #define BC_besbwen_color 0x0
+ #define BC_besbwen_bw 0x100000
+ #define BC_besblank_MASK 0xffdfffff /* bit 21 */
+ #define BC_besblank_disable 0x0
+ #define BC_besblank_enable 0x200000
+ #define BC_besfselm_MASK 0xfeffffff /* bit 24 */
+ #define BC_besfselm_soft 0x0
+ #define BC_besfselm_hard 0x1000000
+ #define BC_besfsel_MASK 0xf9ffffff /* bits 25-26 */
+ #define BC_besfsel_a1 0x0 /* val 0, shift 25 */
+ #define BC_besfsel_a2 0x2000000 /* val 1, shift 25 */
+ #define BC_besfsel_b1 0x4000000 /* val 2, shift 25 */
+ #define BC_besfsel_b2 0x6000000 /* val 3, shift 25 */
+
+#define MGAREG_BESGLOBCTL 0x3dc0
+
+ #define BGC_beshzoom_MASK 0xfffffffe /* bit 0 */
+ #define BGC_beshzoom_disable 0x0
+ #define BGC_beshzoom_enable 0x1
+ #define BGC_beshzoomf_MASK 0xfffffffd /* bit 1 */
+ #define BGC_beshzoomf_disable 0x0
+ #define BGC_beshzoomf_enable 0x2
+ #define BGC_bescorder_MASK 0xfffffff7 /* bit 3 */
+ #define BGC_bescorder_even 0x0
+ #define BGC_bescorder_odd 0x8
+ #define BGC_besreghup_MASK 0xffffffef /* bit 4 */
+ #define BGC_besreghup_disable 0x0
+ #define BGC_besreghup_enable 0x10
+ #define BGC_besvcnt_MASK 0xf000ffff /* bits 16-27 */
+ #define BGC_besvcnt_SHIFT 16
+
+#define MGAREG_BESHCOORD 0x3d28
+
+ #define BHC_besright_MASK 0xfffff800 /* bits 0-10 */
+ #define BHC_besright_SHIFT 0
+ #define BHC_besleft_MASK 0xf800ffff /* bits 16-26 */
+ #define BHC_besleft_SHIFT 16
+
+#define MGAREG_BESHISCAL 0x3d30
+
+ #define BHISF_beshiscal_MASK 0xffe00003 /* bits 2-20 */
+ #define BHISF_beshiscal_SHIFT 2
+
+#define MGAREG_BESHSRCEND 0x3d3c
+
+ #define BHSE_beshsrcend_MASK 0xfc000003 /* bits 2-25 */
+ #define BHSE_beshsrcend_SHIFT 2
+
+#define MGAREG_BESHSRCLST 0x3d50
+
+ #define BHSL_beshsrclst_MASK 0xfc00ffff /* bits 16-25 */
+ #define BHSL_beshsrclst_SHIFT 16
+
+#define MGAREG_BESHSRCST 0x3d38
+
+ #define BHSS_beshsrcst_MASK 0xfc000003 /* bits 2-25 */
+ #define BHSS_beshsrcst_SHIFT 2
+
+#define MGAREG_BESPITCH 0x3d24
+
+ #define BP_bespitch_MASK 0xfffff000 /* bits 0-11 */
+ #define BP_bespitch_SHIFT 0
+
+#define MGAREG_BESSTATUS 0x3dc4
+
+ #define BS_besstat_MASK 0xfffffffc /* bits 0-1 */
+ #define BS_besstat_a1 0x0 /* val 0, shift 0 */
+ #define BS_besstat_a2 0x1 /* val 1, shift 0 */
+ #define BS_besstat_b1 0x2 /* val 2, shift 0 */
+ #define BS_besstat_b2 0x3 /* val 3, shift 0 */
+
+#define MGAREG_BESV1SRCLST 0x3d54
+
+ #define BSF_besv1srclast_MASK 0xfffffc00 /* bits 0-9 */
+ #define BSF_besv1srclast_SHIFT 0
+
+#define MGAREG_BESV2SRCLST 0x3d58
+
+ #define BSF_besv2srclst_MASK 0xfffffc00 /* bits 0-9 */
+ #define BSF_besv2srclst_SHIFT 0
+
+#define MGAREG_BESV1WGHT 0x3d48
+
+ #define BSF_besv1wght_MASK 0xffff0003 /* bits 2-15 */
+ #define BSF_besv1wght_SHIFT 2
+ #define BSF_besv1wghts_MASK 0xfffeffff /* bit 16 */
+ #define BSF_besv1wghts_disable 0x0
+ #define BSF_besv1wghts_enable 0x10000
+
+#define MGAREG_BESV2WGHT 0x3d4c
+
+ #define BSF_besv2wght_MASK 0xffff0003 /* bits 2-15 */
+ #define BSF_besv2wght_SHIFT 2
+ #define BSF_besv2wghts_MASK 0xfffeffff /* bit 16 */
+ #define BSF_besv2wghts_disable 0x0
+ #define BSF_besv2wghts_enable 0x10000
+
+#define MGAREG_BESVCOORD 0x3d2c
+
+ #define BVC_besbot_MASK 0xfffff800 /* bits 0-10 */
+ #define BVC_besbot_SHIFT 0
+ #define BVC_bestop_MASK 0xf800ffff /* bits 16-26 */
+ #define BVC_bestop_SHIFT 16
+
+#define MGAREG_BESVISCAL 0x3d34
+
+ #define BVISF_besviscal_MASK 0xffe00003 /* bits 2-20 */
+ #define BVISF_besviscal_SHIFT 2
+
+#define MGAREG_CODECADDR 0x3e44
+#define MGAREG_CODECCTL 0x3e40
+#define MGAREG_CODECHARDPTR 0x3e4c
+#define MGAREG_CODECHOSTPTR 0x3e48
+#define MGAREG_CODECLCODE 0x3e50
+#define MGAREG_CXBNDRY 0x1c80
+
+ #define CXB_cxleft_MASK 0xfffff000 /* bits 0-11 */
+ #define CXB_cxleft_SHIFT 0
+ #define CXB_cxright_MASK 0xf000ffff /* bits 16-27 */
+ #define CXB_cxright_SHIFT 16
+
+#define MGAREG_CXLEFT 0x1ca0
+#define MGAREG_CXRIGHT 0x1ca4
+#define MGAREG_DMAMAP30 0x1e30
+#define MGAREG_DMAMAP74 0x1e34
+#define MGAREG_DMAMAPB8 0x1e38
+#define MGAREG_DMAMAPFC 0x1e3c
+#define MGAREG_DMAPAD 0x1c54
+#define MGAREG_DR0_Z32LSB 0x2c50
+#define MGAREG_DR0_Z32MSB 0x2c54
+#define MGAREG_DR2_Z32LSB 0x2c60
+#define MGAREG_DR2_Z32MSB 0x2c64
+#define MGAREG_DR3_Z32LSB 0x2c68
+#define MGAREG_DR3_Z32MSB 0x2c6c
+#define MGAREG_DR0 0x1cc0
+#define MGAREG_DR2 0x1cc8
+#define MGAREG_DR3 0x1ccc
+#define MGAREG_DR4 0x1cd0
+#define MGAREG_DR6 0x1cd8
+#define MGAREG_DR7 0x1cdc
+#define MGAREG_DR8 0x1ce0
+#define MGAREG_DR10 0x1ce8
+#define MGAREG_DR11 0x1cec
+#define MGAREG_DR12 0x1cf0
+#define MGAREG_DR14 0x1cf8
+#define MGAREG_DR15 0x1cfc
+#define MGAREG_DSTORG 0x2cb8
+
+ #define DO_dstmap_MASK 0xfffffffe /* bit 0 */
+ #define DO_dstmap_fb 0x0
+ #define DO_dstmap_sys 0x1
+ #define DO_dstacc_MASK 0xfffffffd /* bit 1 */
+ #define DO_dstacc_pci 0x0
+ #define DO_dstacc_agp 0x2
+ #define DO_dstorg_MASK 0x7 /* bits 3-31 */
+ #define DO_dstorg_SHIFT 3
+
+#define MGAREG_DWG_INDIR_WT 0x1e80
+#define MGAREG_DWGCTL 0x1c00
+
+ #define DC_opcod_MASK 0xfffffff0 /* bits 0-3 */
+ #define DC_opcod_line_open 0x0 /* val 0, shift 0 */
+ #define DC_opcod_autoline_open 0x1 /* val 1, shift 0 */
+ #define DC_opcod_line_close 0x2 /* val 2, shift 0 */
+ #define DC_opcod_autoline_close 0x3 /* val 3, shift 0 */
+ #define DC_opcod_trap 0x4 /* val 4, shift 0 */
+ #define DC_opcod_texture_trap 0x6 /* val 6, shift 0 */
+ #define DC_opcod_bitblt 0x8 /* val 8, shift 0 */
+ #define DC_opcod_iload 0x9 /* val 9, shift 0 */
+ #define DC_atype_MASK 0xffffff8f /* bits 4-6 */
+ #define DC_atype_rpl 0x0 /* val 0, shift 4 */
+ #define DC_atype_rstr 0x10 /* val 1, shift 4 */
+ #define DC_atype_zi 0x30 /* val 3, shift 4 */
+ #define DC_atype_blk 0x40 /* val 4, shift 4 */
+ #define DC_atype_i 0x70 /* val 7, shift 4 */
+ #define DC_linear_MASK 0xffffff7f /* bit 7 */
+ #define DC_linear_xy 0x0
+ #define DC_linear_linear 0x80
+ #define DC_zmode_MASK 0xfffff8ff /* bits 8-10 */
+ #define DC_zmode_nozcmp 0x0 /* val 0, shift 8 */
+ #define DC_zmode_ze 0x200 /* val 2, shift 8 */
+ #define DC_zmode_zne 0x300 /* val 3, shift 8 */
+ #define DC_zmode_zlt 0x400 /* val 4, shift 8 */
+ #define DC_zmode_zlte 0x500 /* val 5, shift 8 */
+ #define DC_zmode_zgt 0x600 /* val 6, shift 8 */
+ #define DC_zmode_zgte 0x700 /* val 7, shift 8 */
+ #define DC_solid_MASK 0xfffff7ff /* bit 11 */
+ #define DC_solid_disable 0x0
+ #define DC_solid_enable 0x800
+ #define DC_arzero_MASK 0xffffefff /* bit 12 */
+ #define DC_arzero_disable 0x0
+ #define DC_arzero_enable 0x1000
+ #define DC_sgnzero_MASK 0xffffdfff /* bit 13 */
+ #define DC_sgnzero_disable 0x0
+ #define DC_sgnzero_enable 0x2000
+ #define DC_shftzero_MASK 0xffffbfff /* bit 14 */
+ #define DC_shftzero_disable 0x0
+ #define DC_shftzero_enable 0x4000
+ #define DC_bop_MASK 0xfff0ffff /* bits 16-19 */
+ #define DC_bop_SHIFT 16
+ #define DC_trans_MASK 0xff0fffff /* bits 20-23 */
+ #define DC_trans_SHIFT 20
+ #define DC_bltmod_MASK 0xe1ffffff /* bits 25-28 */
+ #define DC_bltmod_bmonolef 0x0 /* val 0, shift 25 */
+ #define DC_bltmod_bmonowf 0x8000000 /* val 4, shift 25 */
+ #define DC_bltmod_bplan 0x2000000 /* val 1, shift 25 */
+ #define DC_bltmod_bfcol 0x4000000 /* val 2, shift 25 */
+ #define DC_bltmod_bu32bgr 0x6000000 /* val 3, shift 25 */
+ #define DC_bltmod_bu32rgb 0xe000000 /* val 7, shift 25 */
+ #define DC_bltmod_bu24bgr 0x16000000 /* val 11, shift 25 */
+ #define DC_bltmod_bu24rgb 0x1e000000 /* val 15, shift 25 */
+ #define DC_pattern_MASK 0xdfffffff /* bit 29 */
+ #define DC_pattern_disable 0x0
+ #define DC_pattern_enable 0x20000000
+ #define DC_transc_MASK 0xbfffffff /* bit 30 */
+ #define DC_transc_disable 0x0
+ #define DC_transc_enable 0x40000000
+ #define DC_clipdis_MASK 0x7fffffff /* bit 31 */
+ #define DC_clipdis_disable 0x0
+ #define DC_clipdis_enable 0x80000000
+
+#define MGAREG_DWGSYNC 0x2c4c
+
+ #define DS_dwgsyncaddr_MASK 0x3 /* bits 2-31 */
+ #define DS_dwgsyncaddr_SHIFT 2
+
+#define MGAREG_FCOL 0x1c24
+#define MGAREG_FIFOSTATUS 0x1e10
+
+ #define FS_fifocount_MASK 0xffffff80 /* bits 0-6 */
+ #define FS_fifocount_SHIFT 0
+ #define FS_bfull_MASK 0xfffffeff /* bit 8 */
+ #define FS_bfull_disable 0x0
+ #define FS_bfull_enable 0x100
+ #define FS_bempty_MASK 0xfffffdff /* bit 9 */
+ #define FS_bempty_disable 0x0
+ #define FS_bempty_enable 0x200
+
+#define MGAREG_FOGCOL 0x1cf4
+#define MGAREG_FOGSTART 0x1cc4
+#define MGAREG_FOGXINC 0x1cd4
+#define MGAREG_FOGYINC 0x1ce4
+#define MGAREG_FXBNDRY 0x1c84
+
+ #define XA_fxleft_MASK 0xffff0000 /* bits 0-15 */
+ #define XA_fxleft_SHIFT 0
+ #define XA_fxright_MASK 0xffff /* bits 16-31 */
+ #define XA_fxright_SHIFT 16
+
+#define MGAREG_FXLEFT 0x1ca8
+#define MGAREG_FXRIGHT 0x1cac
+#define MGAREG_ICLEAR 0x1e18
+
+ #define IC_softrapiclr_MASK 0xfffffffe /* bit 0 */
+ #define IC_softrapiclr_disable 0x0
+ #define IC_softrapiclr_enable 0x1
+ #define IC_pickiclr_MASK 0xfffffffb /* bit 2 */
+ #define IC_pickiclr_disable 0x0
+ #define IC_pickiclr_enable 0x4
+ #define IC_vlineiclr_MASK 0xffffffdf /* bit 5 */
+ #define IC_vlineiclr_disable 0x0
+ #define IC_vlineiclr_enable 0x20
+ #define IC_wiclr_MASK 0xffffff7f /* bit 7 */
+ #define IC_wiclr_disable 0x0
+ #define IC_wiclr_enable 0x80
+ #define IC_wciclr_MASK 0xfffffeff /* bit 8 */
+ #define IC_wciclr_disable 0x0
+ #define IC_wciclr_enable 0x100
+
+#define MGAREG_IEN 0x1e1c
+
+ #define IE_softrapien_MASK 0xfffffffe /* bit 0 */
+ #define IE_softrapien_disable 0x0
+ #define IE_softrapien_enable 0x1
+ #define IE_pickien_MASK 0xfffffffb /* bit 2 */
+ #define IE_pickien_disable 0x0
+ #define IE_pickien_enable 0x4
+ #define IE_vlineien_MASK 0xffffffdf /* bit 5 */
+ #define IE_vlineien_disable 0x0
+ #define IE_vlineien_enable 0x20
+ #define IE_extien_MASK 0xffffffbf /* bit 6 */
+ #define IE_extien_disable 0x0
+ #define IE_extien_enable 0x40
+ #define IE_wien_MASK 0xffffff7f /* bit 7 */
+ #define IE_wien_disable 0x0
+ #define IE_wien_enable 0x80
+ #define IE_wcien_MASK 0xfffffeff /* bit 8 */
+ #define IE_wcien_disable 0x0
+ #define IE_wcien_enable 0x100
+
+#define MGAREG_LEN 0x1c5c
+#define MGAREG_MACCESS 0x1c04
+
+ #define MA_pwidth_MASK 0xfffffffc /* bits 0-1 */
+ #define MA_pwidth_8 0x0 /* val 0, shift 0 */
+ #define MA_pwidth_16 0x1 /* val 1, shift 0 */
+ #define MA_pwidth_32 0x2 /* val 2, shift 0 */
+ #define MA_pwidth_24 0x3 /* val 3, shift 0 */
+ #define MA_zwidth_MASK 0xffffffe7 /* bits 3-4 */
+ #define MA_zwidth_16 0x0 /* val 0, shift 3 */
+ #define MA_zwidth_32 0x8 /* val 1, shift 3 */
+ #define MA_zwidth_15 0x10 /* val 2, shift 3 */
+ #define MA_zwidth_24 0x18 /* val 3, shift 3 */
+ #define MA_memreset_MASK 0xffff7fff /* bit 15 */
+ #define MA_memreset_disable 0x0
+ #define MA_memreset_enable 0x8000
+ #define MA_fogen_MASK 0xfbffffff /* bit 26 */
+ #define MA_fogen_disable 0x0
+ #define MA_fogen_enable 0x4000000
+ #define MA_tlutload_MASK 0xdfffffff /* bit 29 */
+ #define MA_tlutload_disable 0x0
+ #define MA_tlutload_enable 0x20000000
+ #define MA_nodither_MASK 0xbfffffff /* bit 30 */
+ #define MA_nodither_disable 0x0
+ #define MA_nodither_enable 0x40000000
+ #define MA_dit555_MASK 0x7fffffff /* bit 31 */
+ #define MA_dit555_disable 0x0
+ #define MA_dit555_enable 0x80000000
+
+#define MGAREG_MCTLWTST 0x1c08
+
+ #define MCWS_casltncy_MASK 0xfffffff8 /* bits 0-2 */
+ #define MCWS_casltncy_SHIFT 0
+ #define MCWS_rrddelay_MASK 0xffffffcf /* bits 4-5 */
+ #define MCWS_rcddelay_MASK 0xfffffe7f /* bits 7-8 */
+ #define MCWS_rasmin_MASK 0xffffe3ff /* bits 10-12 */
+ #define MCWS_rasmin_SHIFT 10
+ #define MCWS_rpdelay_MASK 0xffff3fff /* bits 14-15 */
+ #define MCWS_wrdelay_MASK 0xfff3ffff /* bits 18-19 */
+ #define MCWS_rddelay_MASK 0xffdfffff /* bit 21 */
+ #define MCWS_rddelay_disable 0x0
+ #define MCWS_rddelay_enable 0x200000
+ #define MCWS_smrdelay_MASK 0xfe7fffff /* bits 23-24 */
+ #define MCWS_bwcdelay_MASK 0xf3ffffff /* bits 26-27 */
+ #define MCWS_bpldelay_MASK 0x1fffffff /* bits 29-31 */
+ #define MCWS_bpldelay_SHIFT 29
+
+#define MGAREG_MEMRDBK 0x1e44
+
+ #define MRB_mclkbrd0_MASK 0xfffffff0 /* bits 0-3 */
+ #define MRB_mclkbrd0_SHIFT 0
+ #define MRB_mclkbrd1_MASK 0xfffffe1f /* bits 5-8 */
+ #define MRB_mclkbrd1_SHIFT 5
+ #define MRB_strmfctl_MASK 0xff3fffff /* bits 22-23 */
+ #define MRB_mrsopcod_MASK 0xe1ffffff /* bits 25-28 */
+ #define MRB_mrsopcod_SHIFT 25
+
+#define MGAREG_OPMODE 0x1e54
+
+ #define OM_dmamod_MASK 0xfffffff3 /* bits 2-3 */
+ #define OM_dmamod_general 0x0 /* val 0, shift 2 */
+ #define OM_dmamod_blit 0x4 /* val 1, shift 2 */
+ #define OM_dmamod_vector 0x8 /* val 2, shift 2 */
+ #define OM_dmamod_vertex 0xc /* val 3, shift 2 */
+ #define OM_dmadatasiz_MASK 0xfffffcff /* bits 8-9 */
+ #define OM_dmadatasiz_8 0x0 /* val 0, shift 8 */
+ #define OM_dmadatasiz_16 0x100 /* val 1, shift 8 */
+ #define OM_dmadatasiz_32 0x200 /* val 2, shift 8 */
+ #define OM_dirdatasiz_MASK 0xfffcffff /* bits 16-17 */
+ #define OM_dirdatasiz_8 0x0 /* val 0, shift 16 */
+ #define OM_dirdatasiz_16 0x10000 /* val 1, shift 16 */
+ #define OM_dirdatasiz_32 0x20000 /* val 2, shift 16 */
+
+#define MGAREG_PAT0 0x1c10
+#define MGAREG_PAT1 0x1c14
+#define MGAREG_PITCH 0x1c8c
+
+ #define P_iy_MASK 0xffffe000 /* bits 0-12 */
+ #define P_iy_SHIFT 0
+ #define P_ylin_MASK 0xffff7fff /* bit 15 */
+ #define P_ylin_disable 0x0
+ #define P_ylin_enable 0x8000
+
+#define MGAREG_PLNWT 0x1c1c
+#define MGAREG_PRIMADDRESS 0x1e58
+
+ #define PDCA_primod_MASK 0xfffffffc /* bits 0-1 */
+ #define PDCA_primod_general 0x0 /* val 0, shift 0 */
+ #define PDCA_primod_blit 0x1 /* val 1, shift 0 */
+ #define PDCA_primod_vector 0x2 /* val 2, shift 0 */
+ #define PDCA_primod_vertex 0x3 /* val 3, shift 0 */
+ #define PDCA_primaddress_MASK 0x3 /* bits 2-31 */
+ #define PDCA_primaddress_SHIFT 2
+
+#define MGAREG_PRIMEND 0x1e5c
+
+ #define PDEA_primnostart_MASK 0xfffffffe /* bit 0 */
+ #define PDEA_primnostart_disable 0x0
+ #define PDEA_primnostart_enable 0x1
+ #define PDEA_pagpxfer_MASK 0xfffffffd /* bit 1 */
+ #define PDEA_pagpxfer_disable 0x0
+ #define PDEA_pagpxfer_enable 0x2
+ #define PDEA_primend_MASK 0x3 /* bits 2-31 */
+ #define PDEA_primend_SHIFT 2
+
+#define MGAREG_PRIMPTR 0x1e50
+
+ #define PLS_primptren0_MASK 0xfffffffe /* bit 0 */
+ #define PLS_primptren0_disable 0x0
+ #define PLS_primptren0_enable 0x1
+ #define PLS_primptren1_MASK 0xfffffffd /* bit 1 */
+ #define PLS_primptren1_disable 0x0
+ #define PLS_primptren1_enable 0x2
+ #define PLS_primptr_MASK 0x7 /* bits 3-31 */
+ #define PLS_primptr_SHIFT 3
+
+#define MGAREG_RST 0x1e40
+
+ #define R_softreset_MASK 0xfffffffe /* bit 0 */
+ #define R_softreset_disable 0x0
+ #define R_softreset_enable 0x1
+ #define R_softextrst_MASK 0xfffffffd /* bit 1 */
+ #define R_softextrst_disable 0x0
+ #define R_softextrst_enable 0x2
+
+#define MGAREG_SECADDRESS 0x2c40
+
+ #define SDCA_secmod_MASK 0xfffffffc /* bits 0-1 */
+ #define SDCA_secmod_general 0x0 /* val 0, shift 0 */
+ #define SDCA_secmod_blit 0x1 /* val 1, shift 0 */
+ #define SDCA_secmod_vector 0x2 /* val 2, shift 0 */
+ #define SDCA_secmod_vertex 0x3 /* val 3, shift 0 */
+ #define SDCA_secaddress_MASK 0x3 /* bits 2-31 */
+ #define SDCA_secaddress_SHIFT 2
+
+#define MGAREG_SECEND 0x2c44
+
+ #define SDEA_sagpxfer_MASK 0xfffffffd /* bit 1 */
+ #define SDEA_sagpxfer_disable 0x0
+ #define SDEA_sagpxfer_enable 0x2
+ #define SDEA_secend_MASK 0x3 /* bits 2-31 */
+ #define SDEA_secend_SHIFT 2
+
+#define MGAREG_SETUPADDRESS 0x2cd0
+
+ #define SETADD_mode_MASK 0xfffffffc /* bits 0-1 */
+ #define SETADD_mode_vertlist 0x0 /* val 0, shift 0 */
+ #define SETADD_address_MASK 0x3 /* bits 2-31 */
+ #define SETADD_address_SHIFT 2
+
+#define MGAREG_SETUPEND 0x2cd4
+
+ #define SETEND_agpxfer_MASK 0xfffffffd /* bit 1 */
+ #define SETEND_agpxfer_disable 0x0
+ #define SETEND_agpxfer_enable 0x2
+ #define SETEND_address_MASK 0x3 /* bits 2-31 */
+ #define SETEND_address_SHIFT 2
+
+#define MGAREG_SGN 0x1c58
+
+ #define S_sdydxl_MASK 0xfffffffe /* bit 0 */
+ #define S_sdydxl_y 0x0
+ #define S_sdydxl_x 0x1
+ #define S_scanleft_MASK 0xfffffffe /* bit 0 */
+ #define S_scanleft_disable 0x0
+ #define S_scanleft_enable 0x1
+ #define S_sdxl_MASK 0xfffffffd /* bit 1 */
+ #define S_sdxl_pos 0x0
+ #define S_sdxl_neg 0x2
+ #define S_sdy_MASK 0xfffffffb /* bit 2 */
+ #define S_sdy_pos 0x0
+ #define S_sdy_neg 0x4
+ #define S_sdxr_MASK 0xffffffdf /* bit 5 */
+ #define S_sdxr_pos 0x0
+ #define S_sdxr_neg 0x20
+ #define S_brkleft_MASK 0xfffffeff /* bit 8 */
+ #define S_brkleft_disable 0x0
+ #define S_brkleft_enable 0x100
+ #define S_errorinit_MASK 0x7fffffff /* bit 31 */
+ #define S_errorinit_disable 0x0
+ #define S_errorinit_enable 0x80000000
+
+#define MGAREG_SHIFT 0x1c50
+
+ #define FSC_x_off_MASK 0xfffffff0 /* bits 0-3 */
+ #define FSC_x_off_SHIFT 0
+ #define FSC_funcnt_MASK 0xffffff80 /* bits 0-6 */
+ #define FSC_funcnt_SHIFT 0
+ #define FSC_y_off_MASK 0xffffff8f /* bits 4-6 */
+ #define FSC_y_off_SHIFT 4
+ #define FSC_funoff_MASK 0xffc0ffff /* bits 16-21 */
+ #define FSC_funoff_SHIFT 16
+ #define FSC_stylelen_MASK 0xffc0ffff /* bits 16-21 */
+ #define FSC_stylelen_SHIFT 16
+
+#define MGAREG_SOFTRAP 0x2c48
+
+ #define STH_softraphand_MASK 0x3 /* bits 2-31 */
+ #define STH_softraphand_SHIFT 2
+
+#define MGAREG_SPECBSTART 0x2c98
+#define MGAREG_SPECBXINC 0x2c9c
+#define MGAREG_SPECBYINC 0x2ca0
+#define MGAREG_SPECGSTART 0x2c8c
+#define MGAREG_SPECGXINC 0x2c90
+#define MGAREG_SPECGYINC 0x2c94
+#define MGAREG_SPECRSTART 0x2c80
+#define MGAREG_SPECRXINC 0x2c84
+#define MGAREG_SPECRYINC 0x2c88
+#define MGAREG_SRC0 0x1c30
+#define MGAREG_SRC1 0x1c34
+#define MGAREG_SRC2 0x1c38
+#define MGAREG_SRC3 0x1c3c
+#define MGAREG_SRCORG 0x2cb4
+
+ #define SO_srcmap_MASK 0xfffffffe /* bit 0 */
+ #define SO_srcmap_fb 0x0
+ #define SO_srcmap_sys 0x1
+ #define SO_srcacc_MASK 0xfffffffd /* bit 1 */
+ #define SO_srcacc_pci 0x0
+ #define SO_srcacc_agp 0x2
+ #define SO_srcorg_MASK 0x7 /* bits 3-31 */
+ #define SO_srcorg_SHIFT 3
+
+#define MGAREG_STATUS 0x1e14
+
+ #define STAT_softrapen_MASK 0xfffffffe /* bit 0 */
+ #define STAT_softrapen_disable 0x0
+ #define STAT_softrapen_enable 0x1
+ #define STAT_pickpen_MASK 0xfffffffb /* bit 2 */
+ #define STAT_pickpen_disable 0x0
+ #define STAT_pickpen_enable 0x4
+ #define STAT_vsyncsts_MASK 0xfffffff7 /* bit 3 */
+ #define STAT_vsyncsts_disable 0x0
+ #define STAT_vsyncsts_enable 0x8
+ #define STAT_vsyncpen_MASK 0xffffffef /* bit 4 */
+ #define STAT_vsyncpen_disable 0x0
+ #define STAT_vsyncpen_enable 0x10
+ #define STAT_vlinepen_MASK 0xffffffdf /* bit 5 */
+ #define STAT_vlinepen_disable 0x0
+ #define STAT_vlinepen_enable 0x20
+ #define STAT_extpen_MASK 0xffffffbf /* bit 6 */
+ #define STAT_extpen_disable 0x0
+ #define STAT_extpen_enable 0x40
+ #define STAT_wpen_MASK 0xffffff7f /* bit 7 */
+ #define STAT_wpen_disable 0x0
+ #define STAT_wpen_enable 0x80
+ #define STAT_wcpen_MASK 0xfffffeff /* bit 8 */
+ #define STAT_wcpen_disable 0x0
+ #define STAT_wcpen_enable 0x100
+ #define STAT_dwgengsts_MASK 0xfffeffff /* bit 16 */
+ #define STAT_dwgengsts_disable 0x0
+ #define STAT_dwgengsts_enable 0x10000
+ #define STAT_endprdmasts_MASK 0xfffdffff /* bit 17 */
+ #define STAT_endprdmasts_disable 0x0
+ #define STAT_endprdmasts_enable 0x20000
+ #define STAT_wbusy_MASK 0xfffbffff /* bit 18 */
+ #define STAT_wbusy_disable 0x0
+ #define STAT_wbusy_enable 0x40000
+ #define STAT_swflag_MASK 0xfffffff /* bits 28-31 */
+ #define STAT_swflag_SHIFT 28
+
+#define MGAREG_STENCIL 0x2cc8
+
+ #define S_sref_MASK 0xffffff00 /* bits 0-7 */
+ #define S_sref_SHIFT 0
+ #define S_smsk_MASK 0xffff00ff /* bits 8-15 */
+ #define S_smsk_SHIFT 8
+ #define S_swtmsk_MASK 0xff00ffff /* bits 16-23 */
+ #define S_swtmsk_SHIFT 16
+
+#define MGAREG_STENCILCTL 0x2ccc
+
+ #define SC_smode_MASK 0xfffffff8 /* bits 0-2 */
+ #define SC_smode_salways 0x0 /* val 0, shift 0 */
+ #define SC_smode_snever 0x1 /* val 1, shift 0 */
+ #define SC_smode_se 0x2 /* val 2, shift 0 */
+ #define SC_smode_sne 0x3 /* val 3, shift 0 */
+ #define SC_smode_slt 0x4 /* val 4, shift 0 */
+ #define SC_smode_slte 0x5 /* val 5, shift 0 */
+ #define SC_smode_sgt 0x6 /* val 6, shift 0 */
+ #define SC_smode_sgte 0x7 /* val 7, shift 0 */
+ #define SC_sfailop_MASK 0xffffffc7 /* bits 3-5 */
+ #define SC_sfailop_keep 0x0 /* val 0, shift 3 */
+ #define SC_sfailop_zero 0x8 /* val 1, shift 3 */
+ #define SC_sfailop_replace 0x10 /* val 2, shift 3 */
+ #define SC_sfailop_incrsat 0x18 /* val 3, shift 3 */
+ #define SC_sfailop_decrsat 0x20 /* val 4, shift 3 */
+ #define SC_sfailop_invert 0x28 /* val 5, shift 3 */
+ #define SC_sfailop_incr 0x30 /* val 6, shift 3 */
+ #define SC_sfailop_decr 0x38 /* val 7, shift 3 */
+ #define SC_szfailop_MASK 0xfffffe3f /* bits 6-8 */
+ #define SC_szfailop_keep 0x0 /* val 0, shift 6 */
+ #define SC_szfailop_zero 0x40 /* val 1, shift 6 */
+ #define SC_szfailop_replace 0x80 /* val 2, shift 6 */
+ #define SC_szfailop_incrsat 0xc0 /* val 3, shift 6 */
+ #define SC_szfailop_decrsat 0x100 /* val 4, shift 6 */
+ #define SC_szfailop_invert 0x140 /* val 5, shift 6 */
+ #define SC_szfailop_incr 0x180 /* val 6, shift 6 */
+ #define SC_szfailop_decr 0x1c0 /* val 7, shift 6 */
+ #define SC_szpassop_MASK 0xfffff1ff /* bits 9-11 */
+ #define SC_szpassop_keep 0x0 /* val 0, shift 9 */
+ #define SC_szpassop_zero 0x200 /* val 1, shift 9 */
+ #define SC_szpassop_replace 0x400 /* val 2, shift 9 */
+ #define SC_szpassop_incrsat 0x600 /* val 3, shift 9 */
+ #define SC_szpassop_decrsat 0x800 /* val 4, shift 9 */
+ #define SC_szpassop_invert 0xa00 /* val 5, shift 9 */
+ #define SC_szpassop_incr 0xc00 /* val 6, shift 9 */
+ #define SC_szpassop_decr 0xe00 /* val 7, shift 9 */
+
+#define MGAREG_TDUALSTAGE0 0x2cf8
+
+ #define TD0_color_arg2_MASK 0xfffffffc /* bits 0-1 */
+ #define TD0_color_arg2_diffuse 0x0 /* val 0, shift 0 */
+ #define TD0_color_arg2_specular 0x1 /* val 1, shift 0 */
+ #define TD0_color_arg2_fcol 0x2 /* val 2, shift 0 */
+ #define TD0_color_arg2_prevstage 0x3 /* val 3, shift 0 */
+ #define TD0_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
+ #define TD0_color_alpha_diffuse 0x0 /* val 0, shift 2 */
+ #define TD0_color_alpha_fcol 0x4 /* val 1, shift 2 */
+ #define TD0_color_alpha_currtex 0x8 /* val 2, shift 2 */
+ #define TD0_color_alpha_prevtex 0xc /* val 3, shift 2 */
+ #define TD0_color_alpha_prevstage 0x10 /* val 4, shift 2 */
+ #define TD0_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
+ #define TD0_color_arg1_replicatealpha_disable 0x0
+ #define TD0_color_arg1_replicatealpha_enable 0x20
+ #define TD0_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
+ #define TD0_color_arg1_inv_disable 0x0
+ #define TD0_color_arg1_inv_enable 0x40
+ #define TD0_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
+ #define TD0_color_arg2_replicatealpha_disable 0x0
+ #define TD0_color_arg2_replicatealpha_enable 0x80
+ #define TD0_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
+ #define TD0_color_arg2_inv_disable 0x0
+ #define TD0_color_arg2_inv_enable 0x100
+ #define TD0_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
+ #define TD0_color_alpha1inv_disable 0x0
+ #define TD0_color_alpha1inv_enable 0x200
+ #define TD0_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
+ #define TD0_color_alpha2inv_disable 0x0
+ #define TD0_color_alpha2inv_enable 0x400
+ #define TD0_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
+ #define TD0_color_arg1mul_disable 0x0 /* val 0, shift 11 */
+ #define TD0_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
+ #define TD0_color_arg2mul_MASK 0xffffefff /* bit 12 */
+ #define TD0_color_arg2mul_disable 0x0 /* val 0, shift 12 */
+ #define TD0_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
+ #define TD0_color_arg1add_MASK 0xffffdfff /* bit 13 */
+ #define TD0_color_arg1add_disable 0x0 /* val 0, shift 13 */
+ #define TD0_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
+ #define TD0_color_arg2add_MASK 0xffffbfff /* bit 14 */
+ #define TD0_color_arg2add_disable 0x0 /* val 0, shift 14 */
+ #define TD0_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
+ #define TD0_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
+ #define TD0_color_modbright_disable 0x0 /* val 0, shift 15 */
+ #define TD0_color_modbright_2x 0x8000 /* val 1, shift 15 */
+ #define TD0_color_modbright_4x 0x10000 /* val 2, shift 15 */
+ #define TD0_color_add_MASK 0xfffdffff /* bit 17 */
+ #define TD0_color_add_sub 0x0 /* val 0, shift 17 */
+ #define TD0_color_add_add 0x20000 /* val 1, shift 17 */
+ #define TD0_color_add2x_MASK 0xfffbffff /* bit 18 */
+ #define TD0_color_add2x_disable 0x0
+ #define TD0_color_add2x_enable 0x40000
+ #define TD0_color_addbias_MASK 0xfff7ffff /* bit 19 */
+ #define TD0_color_addbias_disable 0x0
+ #define TD0_color_addbias_enable 0x80000
+ #define TD0_color_blend_MASK 0xffefffff /* bit 20 */
+ #define TD0_color_blend_disable 0x0
+ #define TD0_color_blend_enable 0x100000
+ #define TD0_color_sel_MASK 0xff9fffff /* bits 21-22 */
+ #define TD0_color_sel_arg1 0x0 /* val 0, shift 21 */
+ #define TD0_color_sel_arg2 0x200000 /* val 1, shift 21 */
+ #define TD0_color_sel_add 0x400000 /* val 2, shift 21 */
+ #define TD0_color_sel_mul 0x600000 /* val 3, shift 21 */
+ #define TD0_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
+ #define TD0_alpha_arg1_inv_disable 0x0
+ #define TD0_alpha_arg1_inv_enable 0x800000
+ #define TD0_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
+ #define TD0_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
+ #define TD0_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
+ #define TD0_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
+ #define TD0_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
+ #define TD0_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
+ #define TD0_alpha_arg2_inv_disable 0x0
+ #define TD0_alpha_arg2_inv_enable 0x4000000
+ #define TD0_alpha_add_MASK 0xf7ffffff /* bit 27 */
+ #define TD0_alpha_add_disable 0x0
+ #define TD0_alpha_add_enable 0x8000000
+ #define TD0_alpha_addbias_MASK 0xefffffff /* bit 28 */
+ #define TD0_alpha_addbias_disable 0x0
+ #define TD0_alpha_addbias_enable 0x10000000
+ #define TD0_alpha_add2x_MASK 0xdfffffff /* bit 29 */
+ #define TD0_alpha_add2x_disable 0x0
+ #define TD0_alpha_add2x_enable 0x20000000
+ #define TD0_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
+ #define TD0_alpha_modbright_disable 0x0 /* val 0, shift 28 */
+ #define TD0_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
+ #define TD0_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
+ #define TD0_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
+ #define TD0_alpha_sel_arg1 0x0 /* val 0, shift 30 */
+ #define TD0_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
+ #define TD0_alpha_sel_add 0x80000000 /* val 2, shift 30 */
+ #define TD0_alpha_sel_mul 0xc0000000 /* val 3, shift 30 */
+
+#define MGAREG_TDUALSTAGE1 0x2cfc
+
+ #define TD1_color_arg2_MASK 0xfffffffc /* bits 0-1 */
+ #define TD1_color_arg2_diffuse 0x0 /* val 0, shift 0 */
+ #define TD1_color_arg2_specular 0x1 /* val 1, shift 0 */
+ #define TD1_color_arg2_fcol 0x2 /* val 2, shift 0 */
+ #define TD1_color_arg2_prevstage 0x3 /* val 3, shift 0 */
+ #define TD1_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
+ #define TD1_color_alpha_diffuse 0x0 /* val 0, shift 2 */
+ #define TD1_color_alpha_fcol 0x4 /* val 1, shift 2 */
+ #define TD1_color_alpha_tex0 0x8 /* val 2, shift 2 */
+ #define TD1_color_alpha_prevtex 0xc /* val 3, shift 2 */
+ #define TD1_color_alpha_prevstage 0x10 /* val 4, shift 2 */
+ #define TD1_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
+ #define TD1_color_arg1_replicatealpha_disable 0x0
+ #define TD1_color_arg1_replicatealpha_enable 0x20
+ #define TD1_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
+ #define TD1_color_arg1_inv_disable 0x0
+ #define TD1_color_arg1_inv_enable 0x40
+ #define TD1_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
+ #define TD1_color_arg2_replicatealpha_disable 0x0
+ #define TD1_color_arg2_replicatealpha_enable 0x80
+ #define TD1_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
+ #define TD1_color_arg2_inv_disable 0x0
+ #define TD1_color_arg2_inv_enable 0x100
+ #define TD1_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
+ #define TD1_color_alpha1inv_disable 0x0
+ #define TD1_color_alpha1inv_enable 0x200
+ #define TD1_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
+ #define TD1_color_alpha2inv_disable 0x0
+ #define TD1_color_alpha2inv_enable 0x400
+ #define TD1_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
+ #define TD1_color_arg1mul_disable 0x0 /* val 0, shift 11 */
+ #define TD1_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
+ #define TD1_color_arg2mul_MASK 0xffffefff /* bit 12 */
+ #define TD1_color_arg2mul_disable 0x0 /* val 0, shift 12 */
+ #define TD1_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
+ #define TD1_color_arg1add_MASK 0xffffdfff /* bit 13 */
+ #define TD1_color_arg1add_disable 0x0 /* val 0, shift 13 */
+ #define TD1_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
+ #define TD1_color_arg2add_MASK 0xffffbfff /* bit 14 */
+ #define TD1_color_arg2add_disable 0x0 /* val 0, shift 14 */
+ #define TD1_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
+ #define TD1_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
+ #define TD1_color_modbright_disable 0x0 /* val 0, shift 15 */
+ #define TD1_color_modbright_2x 0x8000 /* val 1, shift 15 */
+ #define TD1_color_modbright_4x 0x10000 /* val 2, shift 15 */
+ #define TD1_color_add_MASK 0xfffdffff /* bit 17 */
+ #define TD1_color_add_sub 0x0 /* val 0, shift 17 */
+ #define TD1_color_add_add 0x20000 /* val 1, shift 17 */
+ #define TD1_color_add2x_MASK 0xfffbffff /* bit 18 */
+ #define TD1_color_add2x_disable 0x0
+ #define TD1_color_add2x_enable 0x40000
+ #define TD1_color_addbias_MASK 0xfff7ffff /* bit 19 */
+ #define TD1_color_addbias_disable 0x0
+ #define TD1_color_addbias_enable 0x80000
+ #define TD1_color_blend_MASK 0xffefffff /* bit 20 */
+ #define TD1_color_blend_disable 0x0
+ #define TD1_color_blend_enable 0x100000
+ #define TD1_color_sel_MASK 0xff9fffff /* bits 21-22 */
+ #define TD1_color_sel_arg1 0x0 /* val 0, shift 21 */
+ #define TD1_color_sel_arg2 0x200000 /* val 1, shift 21 */
+ #define TD1_color_sel_add 0x400000 /* val 2, shift 21 */
+ #define TD1_color_sel_mul 0x600000 /* val 3, shift 21 */
+ #define TD1_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
+ #define TD1_alpha_arg1_inv_disable 0x0
+ #define TD1_alpha_arg1_inv_enable 0x800000
+ #define TD1_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
+ #define TD1_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
+ #define TD1_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
+ #define TD1_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
+ #define TD1_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
+ #define TD1_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
+ #define TD1_alpha_arg2_inv_disable 0x0
+ #define TD1_alpha_arg2_inv_enable 0x4000000
+ #define TD1_alpha_add_MASK 0xf7ffffff /* bit 27 */
+ #define TD1_alpha_add_disable 0x0
+ #define TD1_alpha_add_enable 0x8000000
+ #define TD1_alpha_addbias_MASK 0xefffffff /* bit 28 */
+ #define TD1_alpha_addbias_disable 0x0
+ #define TD1_alpha_addbias_enable 0x10000000
+ #define TD1_alpha_add2x_MASK 0xdfffffff /* bit 29 */
+ #define TD1_alpha_add2x_disable 0x0
+ #define TD1_alpha_add2x_enable 0x20000000
+ #define TD1_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
+ #define TD1_alpha_modbright_disable 0x0 /* val 0, shift 28 */
+ #define TD1_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
+ #define TD1_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
+ #define TD1_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
+ #define TD1_alpha_sel_arg1 0x0 /* val 0, shift 30 */
+ #define TD1_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
+ #define TD1_alpha_sel_add 0x80000000 /* val 2, shift 30 */
+ #define TD1_alpha_sel_mul 0xc0000000 /* val 3, shift 30 */
+
+#define MGAREG_TEST0 0x1e48
+
+ #define TST_ramtsten_MASK 0xfffffffe /* bit 0 */
+ #define TST_ramtsten_disable 0x0
+ #define TST_ramtsten_enable 0x1
+ #define TST_ramtstdone_MASK 0xfffffffd /* bit 1 */
+ #define TST_ramtstdone_disable 0x0
+ #define TST_ramtstdone_enable 0x2
+ #define TST_wramtstpass_MASK 0xfffffffb /* bit 2 */
+ #define TST_wramtstpass_disable 0x0
+ #define TST_wramtstpass_enable 0x4
+ #define TST_tcachetstpass_MASK 0xfffffff7 /* bit 3 */
+ #define TST_tcachetstpass_disable 0x0
+ #define TST_tcachetstpass_enable 0x8
+ #define TST_tluttstpass_MASK 0xffffffef /* bit 4 */
+ #define TST_tluttstpass_disable 0x0
+ #define TST_tluttstpass_enable 0x10
+ #define TST_luttstpass_MASK 0xffffffdf /* bit 5 */
+ #define TST_luttstpass_disable 0x0
+ #define TST_luttstpass_enable 0x20
+ #define TST_besramtstpass_MASK 0xffffffbf /* bit 6 */
+ #define TST_besramtstpass_disable 0x0
+ #define TST_besramtstpass_enable 0x40
+ #define TST_ringen_MASK 0xfffffeff /* bit 8 */
+ #define TST_ringen_disable 0x0
+ #define TST_ringen_enable 0x100
+ #define TST_apllbyp_MASK 0xfffffdff /* bit 9 */
+ #define TST_apllbyp_disable 0x0
+ #define TST_apllbyp_enable 0x200
+ #define TST_hiten_MASK 0xfffffbff /* bit 10 */
+ #define TST_hiten_disable 0x0
+ #define TST_hiten_enable 0x400
+ #define TST_tmode_MASK 0xffffc7ff /* bits 11-13 */
+ #define TST_tmode_SHIFT 11
+ #define TST_tclksel_MASK 0xfffe3fff /* bits 14-16 */
+ #define TST_tclksel_SHIFT 14
+ #define TST_ringcnten_MASK 0xfffdffff /* bit 17 */
+ #define TST_ringcnten_disable 0x0
+ #define TST_ringcnten_enable 0x20000
+ #define TST_ringcnt_MASK 0xc003ffff /* bits 18-29 */
+ #define TST_ringcnt_SHIFT 18
+ #define TST_ringcntclksl_MASK 0xbfffffff /* bit 30 */
+ #define TST_ringcntclksl_disable 0x0
+ #define TST_ringcntclksl_enable 0x40000000
+ #define TST_biosboot_MASK 0x7fffffff /* bit 31 */
+ #define TST_biosboot_disable 0x0
+ #define TST_biosboot_enable 0x80000000
+
+#define MGAREG_TEXBORDERCOL 0x2c5c
+#define MGAREG_TEXCTL 0x2c30
+
+ #define TMC_tformat_MASK 0xfffffff0 /* bits 0-3 */
+ #define TMC_tformat_tw4 0x0 /* val 0, shift 0 */
+ #define TMC_tformat_tw8 0x1 /* val 1, shift 0 */
+ #define TMC_tformat_tw15 0x2 /* val 2, shift 0 */
+ #define TMC_tformat_tw16 0x3 /* val 3, shift 0 */
+ #define TMC_tformat_tw12 0x4 /* val 4, shift 0 */
+ #define TMC_tformat_tw32 0x6 /* val 6, shift 0 */
+ #define TMC_tformat_tw8a 0x7 /* val 7, shift 0 */
+ #define TMC_tformat_tw8al 0x8 /* val 8, shift 0 */
+ #define TMC_tformat_tw422 0xa /* val 10, shift 0 */
+ #define TMC_tpitchlin_MASK 0xfffffeff /* bit 8 */
+ #define TMC_tpitchlin_disable 0x0
+ #define TMC_tpitchlin_enable 0x100
+ #define TMC_tpitchext_MASK 0xfff001ff /* bits 9-19 */
+ #define TMC_tpitchext_SHIFT 9
+ #define TMC_tpitch_MASK 0xfff8ffff /* bits 16-18 */
+ #define TMC_tpitch_SHIFT 16
+ #define TMC_owalpha_MASK 0xffbfffff /* bit 22 */
+ #define TMC_owalpha_disable 0x0
+ #define TMC_owalpha_enable 0x400000
+ #define TMC_azeroextend_MASK 0xff7fffff /* bit 23 */
+ #define TMC_azeroextend_disable 0x0
+ #define TMC_azeroextend_enable 0x800000
+ #define TMC_decalckey_MASK 0xfeffffff /* bit 24 */
+ #define TMC_decalckey_disable 0x0
+ #define TMC_decalckey_enable 0x1000000
+ #define TMC_takey_MASK 0xfdffffff /* bit 25 */
+ #define TMC_takey_0 0x0
+ #define TMC_takey_1 0x2000000
+ #define TMC_tamask_MASK 0xfbffffff /* bit 26 */
+ #define TMC_tamask_0 0x0
+ #define TMC_tamask_1 0x4000000
+ #define TMC_clampv_MASK 0xf7ffffff /* bit 27 */
+ #define TMC_clampv_disable 0x0
+ #define TMC_clampv_enable 0x8000000
+ #define TMC_clampu_MASK 0xefffffff /* bit 28 */
+ #define TMC_clampu_disable 0x0
+ #define TMC_clampu_enable 0x10000000
+ #define TMC_tmodulate_MASK 0xdfffffff /* bit 29 */
+ #define TMC_tmodulate_disable 0x0
+ #define TMC_tmodulate_enable 0x20000000
+ #define TMC_strans_MASK 0xbfffffff /* bit 30 */
+ #define TMC_strans_disable 0x0
+ #define TMC_strans_enable 0x40000000
+ #define TMC_itrans_MASK 0x7fffffff /* bit 31 */
+ #define TMC_itrans_disable 0x0
+ #define TMC_itrans_enable 0x80000000
+
+#define MGAREG_TEXCTL2 0x2c3c
+
+ #define TMC_decalblend_MASK 0xfffffffe /* bit 0 */
+ #define TMC_decalblend_disable 0x0
+ #define TMC_decalblend_enable 0x1
+ #define TMC_idecal_MASK 0xfffffffd /* bit 1 */
+ #define TMC_idecal_disable 0x0
+ #define TMC_idecal_enable 0x2
+ #define TMC_decaldis_MASK 0xfffffffb /* bit 2 */
+ #define TMC_decaldis_disable 0x0
+ #define TMC_decaldis_enable 0x4
+ #define TMC_ckstransdis_MASK 0xffffffef /* bit 4 */
+ #define TMC_ckstransdis_disable 0x0
+ #define TMC_ckstransdis_enable 0x10
+ #define TMC_borderen_MASK 0xffffffdf /* bit 5 */
+ #define TMC_borderen_disable 0x0
+ #define TMC_borderen_enable 0x20
+ #define TMC_specen_MASK 0xffffffbf /* bit 6 */
+ #define TMC_specen_disable 0x0
+ #define TMC_specen_enable 0x40
+ #define TMC_dualtex_MASK 0xffffff7f /* bit 7 */
+ #define TMC_dualtex_disable 0x0
+ #define TMC_dualtex_enable 0x80
+ #define TMC_tablefog_MASK 0xfffffeff /* bit 8 */
+ #define TMC_tablefog_disable 0x0
+ #define TMC_tablefog_enable 0x100
+ #define TMC_bumpmap_MASK 0xfffffdff /* bit 9 */
+ #define TMC_bumpmap_disable 0x0
+ #define TMC_bumpmap_enable 0x200
+ #define TMC_map1_MASK 0x7fffffff /* bit 31 */
+ #define TMC_map1_disable 0x0
+ #define TMC_map1_enable 0x80000000
+
+#define MGAREG_TEXFILTER 0x2c58
+
+ #define TF_minfilter_MASK 0xfffffff0 /* bits 0-3 */
+ #define TF_minfilter_nrst 0x0 /* val 0, shift 0 */
+ #define TF_minfilter_bilin 0x2 /* val 2, shift 0 */
+ #define TF_minfilter_cnst 0x3 /* val 3, shift 0 */
+ #define TF_minfilter_mm1s 0x8 /* val 8, shift 0 */
+ #define TF_minfilter_mm2s 0x9 /* val 9, shift 0 */
+ #define TF_minfilter_mm4s 0xa /* val 10, shift 0 */
+ #define TF_minfilter_mm8s 0xc /* val 12, shift 0 */
+ #define TF_magfilter_MASK 0xffffff0f /* bits 4-7 */
+ #define TF_magfilter_nrst 0x0 /* val 0, shift 4 */
+ #define TF_magfilter_bilin 0x20 /* val 2, shift 4 */
+ #define TF_magfilter_cnst 0x30 /* val 3, shift 4 */
+ #define TF_avgstride_MASK 0xfff7ffff /* bit 19 */
+ #define TF_avgstride_disable 0x0
+ #define TF_avgstride_enable 0x80000
+ #define TF_filteralpha_MASK 0xffefffff /* bit 20 */
+ #define TF_filteralpha_disable 0x0
+ #define TF_filteralpha_enable 0x100000
+ #define TF_fthres_MASK 0xe01fffff /* bits 21-28 */
+ #define TF_fthres_SHIFT 21
+ #define TF_mapnb_MASK 0x1fffffff /* bits 29-31 */
+ #define TF_mapnb_SHIFT 29
+
+#define MGAREG_TEXHEIGHT 0x2c2c
+
+ #define TH_th_MASK 0xffffffc0 /* bits 0-5 */
+ #define TH_th_SHIFT 0
+ #define TH_rfh_MASK 0xffff81ff /* bits 9-14 */
+ #define TH_rfh_SHIFT 9
+ #define TH_thmask_MASK 0xe003ffff /* bits 18-28 */
+ #define TH_thmask_SHIFT 18
+
+#define MGAREG_TEXORG 0x2c24
+
+ #define TO_texorgmap_MASK 0xfffffffe /* bit 0 */
+ #define TO_texorgmap_fb 0x0
+ #define TO_texorgmap_sys 0x1
+ #define TO_texorgacc_MASK 0xfffffffd /* bit 1 */
+ #define TO_texorgacc_pci 0x0
+ #define TO_texorgacc_agp 0x2
+ #define TO_texorgoffsetsel 0x4
+ #define TO_texorg_MASK 0x1f /* bits 5-31 */
+ #define TO_texorg_SHIFT 5
+
+#define MGAREG_TEXORG1 0x2ca4
+#define MGAREG_TEXORG2 0x2ca8
+#define MGAREG_TEXORG3 0x2cac
+#define MGAREG_TEXORG4 0x2cb0
+#define MGAREG_TEXTRANS 0x2c34
+
+ #define TT_tckey_MASK 0xffff0000 /* bits 0-15 */
+ #define TT_tckey_SHIFT 0
+ #define TT_tkmask_MASK 0xffff /* bits 16-31 */
+ #define TT_tkmask_SHIFT 16
+
+#define MGAREG_TEXTRANSHIGH 0x2c38
+
+ #define TT_tckeyh_MASK 0xffff0000 /* bits 0-15 */
+ #define TT_tckeyh_SHIFT 0
+ #define TT_tkmaskh_MASK 0xffff /* bits 16-31 */
+ #define TT_tkmaskh_SHIFT 16
+
+#define MGAREG_TEXWIDTH 0x2c28
+
+ #define TW_tw_MASK 0xffffffc0 /* bits 0-5 */
+ #define TW_tw_SHIFT 0
+ #define TW_rfw_MASK 0xffff81ff /* bits 9-14 */
+ #define TW_rfw_SHIFT 9
+ #define TW_twmask_MASK 0xe003ffff /* bits 18-28 */
+ #define TW_twmask_SHIFT 18
+
+#define MGAREG_TMR0 0x2c00
+#define MGAREG_TMR1 0x2c04
+#define MGAREG_TMR2 0x2c08
+#define MGAREG_TMR3 0x2c0c
+#define MGAREG_TMR4 0x2c10
+#define MGAREG_TMR5 0x2c14
+#define MGAREG_TMR6 0x2c18
+#define MGAREG_TMR7 0x2c1c
+#define MGAREG_TMR8 0x2c20
+#define MGAREG_VBIADDR0 0x3e08
+#define MGAREG_VBIADDR1 0x3e0c
+#define MGAREG_VCOUNT 0x1e20
+#define MGAREG_WACCEPTSEQ 0x1dd4
+
+ #define WAS_seqdst0_MASK 0xffffffc0 /* bits 0-5 */
+ #define WAS_seqdst0_SHIFT 0
+ #define WAS_seqdst1_MASK 0xfffff03f /* bits 6-11 */
+ #define WAS_seqdst1_SHIFT 6
+ #define WAS_seqdst2_MASK 0xfffc0fff /* bits 12-17 */
+ #define WAS_seqdst2_SHIFT 12
+ #define WAS_seqdst3_MASK 0xff03ffff /* bits 18-23 */
+ #define WAS_seqdst3_SHIFT 18
+ #define WAS_seqlen_MASK 0xfcffffff /* bits 24-25 */
+ #define WAS_wfirsttag_MASK 0xfbffffff /* bit 26 */
+ #define WAS_wfirsttag_disable 0x0
+ #define WAS_wfirsttag_enable 0x4000000
+ #define WAS_wsametag_MASK 0xf7ffffff /* bit 27 */
+ #define WAS_wsametag_disable 0x0
+ #define WAS_wsametag_enable 0x8000000
+ #define WAS_seqoff_MASK 0xefffffff /* bit 28 */
+ #define WAS_seqoff_disable 0x0
+ #define WAS_seqoff_enable 0x10000000
+
+#define MGAREG_WCODEADDR 0x1e6c
+
+ #define WMA_wcodeaddr_MASK 0xff /* bits 8-31 */
+ #define WMA_wcodeaddr_SHIFT 8
+
+#define MGAREG_WFLAG 0x1dc4
+
+ #define WF_walustsflag_MASK 0xffffff00 /* bits 0-7 */
+ #define WF_walustsflag_SHIFT 0
+ #define WF_walucfgflag_MASK 0xffff00ff /* bits 8-15 */
+ #define WF_walucfgflag_SHIFT 8
+ #define WF_wprgflag_MASK 0xffff /* bits 16-31 */
+ #define WF_wprgflag_SHIFT 16
+
+#define MGAREG_WFLAG1 0x1de0
+
+ #define WF1_walustsflag1_MASK 0xffffff00 /* bits 0-7 */
+ #define WF1_walustsflag1_SHIFT 0
+ #define WF1_walucfgflag1_MASK 0xffff00ff /* bits 8-15 */
+ #define WF1_walucfgflag1_SHIFT 8
+ #define WF1_wprgflag1_MASK 0xffff /* bits 16-31 */
+ #define WF1_wprgflag1_SHIFT 16
+
+#define MGAREG_WFLAGNB 0x1e64
+#define MGAREG_WFLAGNB1 0x1e08
+#define MGAREG_WGETMSB 0x1dc8
+
+ #define WGV_wgetmsbmin_MASK 0xffffffe0 /* bits 0-4 */
+ #define WGV_wgetmsbmin_SHIFT 0
+ #define WGV_wgetmsbmax_MASK 0xffffe0ff /* bits 8-12 */
+ #define WGV_wgetmsbmax_SHIFT 8
+ #define WGV_wbrklefttop_MASK 0xfffeffff /* bit 16 */
+ #define WGV_wbrklefttop_disable 0x0
+ #define WGV_wbrklefttop_enable 0x10000
+ #define WGV_wfastcrop_MASK 0xfffdffff /* bit 17 */
+ #define WGV_wfastcrop_disable 0x0
+ #define WGV_wfastcrop_enable 0x20000
+ #define WGV_wcentersnap_MASK 0xfffbffff /* bit 18 */
+ #define WGV_wcentersnap_disable 0x0
+ #define WGV_wcentersnap_enable 0x40000
+ #define WGV_wbrkrighttop_MASK 0xfff7ffff /* bit 19 */
+ #define WGV_wbrkrighttop_disable 0x0
+ #define WGV_wbrkrighttop_enable 0x80000
+
+#define MGAREG_WIADDR 0x1dc0
+
+ #define WIA_wmode_MASK 0xfffffffc /* bits 0-1 */
+ #define WIA_wmode_suspend 0x0 /* val 0, shift 0 */
+ #define WIA_wmode_resume 0x1 /* val 1, shift 0 */
+ #define WIA_wmode_jump 0x2 /* val 2, shift 0 */
+ #define WIA_wmode_start 0x3 /* val 3, shift 0 */
+ #define WIA_wagp_MASK 0xfffffffb /* bit 2 */
+ #define WIA_wagp_pci 0x0
+ #define WIA_wagp_agp 0x4
+ #define WIA_wiaddr_MASK 0x7 /* bits 3-31 */
+ #define WIA_wiaddr_SHIFT 3
+
+#define MGAREG_WIADDR2 0x1dd8
+
+ #define WIA2_wmode_MASK 0xfffffffc /* bits 0-1 */
+ #define WIA2_wmode_suspend 0x0 /* val 0, shift 0 */
+ #define WIA2_wmode_resume 0x1 /* val 1, shift 0 */
+ #define WIA2_wmode_jump 0x2 /* val 2, shift 0 */
+ #define WIA2_wmode_start 0x3 /* val 3, shift 0 */
+ #define WIA2_wagp_MASK 0xfffffffb /* bit 2 */
+ #define WIA2_wagp_pci 0x0
+ #define WIA2_wagp_agp 0x4
+ #define WIA2_wiaddr_MASK 0x7 /* bits 3-31 */
+ #define WIA2_wiaddr_SHIFT 3
+
+#define MGAREG_WIADDRNB 0x1e60
+#define MGAREG_WIADDRNB1 0x1e04
+#define MGAREG_WIADDRNB2 0x1e00
+#define MGAREG_WIMEMADDR 0x1e68
+
+ #define WIMA_wimemaddr_MASK 0xffffff00 /* bits 0-7 */
+ #define WIMA_wimemaddr_SHIFT 0
+
+#define MGAREG_WIMEMDATA 0x2000
+#define MGAREG_WIMEMDATA1 0x2100
+#define MGAREG_WMISC 0x1e70
+
+ #define WM_wucodecache_MASK 0xfffffffe /* bit 0 */
+ #define WM_wucodecache_disable 0x0
+ #define WM_wucodecache_enable 0x1
+ #define WM_wmaster_MASK 0xfffffffd /* bit 1 */
+ #define WM_wmaster_disable 0x0
+ #define WM_wmaster_enable 0x2
+ #define WM_wcacheflush_MASK 0xfffffff7 /* bit 3 */
+ #define WM_wcacheflush_disable 0x0
+ #define WM_wcacheflush_enable 0x8
+
+#define MGAREG_WR 0x2d00
+#define MGAREG_WVRTXSZ 0x1dcc
+
+ #define WVS_wvrtxsz_MASK 0xffffffc0 /* bits 0-5 */
+ #define WVS_wvrtxsz_SHIFT 0
+ #define WVS_primsz_MASK 0xffffc0ff /* bits 8-13 */
+ #define WVS_primsz_SHIFT 8
+
+#define MGAREG_XDST 0x1cb0
+#define MGAREG_XYEND 0x1c44
+
+ #define XYEA_x_end_MASK 0xffff0000 /* bits 0-15 */
+ #define XYEA_x_end_SHIFT 0
+ #define XYEA_y_end_MASK 0xffff /* bits 16-31 */
+ #define XYEA_y_end_SHIFT 16
+
+#define MGAREG_XYSTRT 0x1c40
+
+ #define XYSA_x_start_MASK 0xffff0000 /* bits 0-15 */
+ #define XYSA_x_start_SHIFT 0
+ #define XYSA_y_start_MASK 0xffff /* bits 16-31 */
+ #define XYSA_y_start_SHIFT 16
+
+#define MGAREG_YBOT 0x1c9c
+#define MGAREG_YDST 0x1c90
+
+ #define YA_ydst_MASK 0xff800000 /* bits 0-22 */
+ #define YA_ydst_SHIFT 0
+ #define YA_sellin_MASK 0x1fffffff /* bits 29-31 */
+ #define YA_sellin_SHIFT 29
+
+#define MGAREG_YDSTLEN 0x1c88
+
+ #define YDL_length_MASK 0xffff0000 /* bits 0-15 */
+ #define YDL_length_SHIFT 0
+ #define YDL_yval_MASK 0xffff /* bits 16-31 */
+ #define YDL_yval_SHIFT 16
+
+#define MGAREG_YDSTORG 0x1c94
+#define MGAREG_YTOP 0x1c98
+#define MGAREG_ZORG 0x1c0c
+
+ #define ZO_zorgmap_MASK 0xfffffffe /* bit 0 */
+ #define ZO_zorgmap_fb 0x0
+ #define ZO_zorgmap_sys 0x1
+ #define ZO_zorgacc_MASK 0xfffffffd /* bit 1 */
+ #define ZO_zorgacc_pci 0x0
+ #define ZO_zorgacc_agp 0x2
+ #define ZO_zorg_MASK 0x3 /* bits 2-31 */
+ #define ZO_zorg_SHIFT 2
/**************** (END) AUTOMATICLY GENERATED REGISTER FILE ******************/
-#endif /* _MGAREGS_H_ */
+#endif /* _MGAREGS_H_ */
+
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgarender.c b/xc/lib/GL/mesa/src/drv/mga/mgarender.c
new file mode 100644
index 000000000..d6354b0b9
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/mga/mgarender.c
@@ -0,0 +1,208 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Simulate missing primitives with indexed vertices.
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mem.h"
+#include "mtypes.h"
+#include "mmath.h"
+
+#include "tnl/t_context.h"
+
+#include "mgacontext.h"
+#include "mgatris.h"
+#include "mgastate.h"
+#include "mgaioctl.h"
+#include "mgavb.h"
+
+#define HAVE_POINTS 0
+#define HAVE_LINES 0
+#define HAVE_LINE_STRIPS 0
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 0
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0 /* for now */
+
+static void mgaDmaPrimitive( GLcontext *ctx, GLenum prim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint hwprim;
+
+ switch (prim) {
+ case GL_TRIANGLES:
+ hwprim = MGA_WA_TRIANGLES;
+ break;
+ case GL_TRIANGLE_STRIP:
+ if (mmesa->vertex_size == 8)
+ hwprim = MGA_WA_TRISTRIP_T0;
+ else
+ hwprim = MGA_WA_TRISTRIP_T0T1;
+ break;
+ case GL_TRIANGLE_FAN:
+ if (mmesa->vertex_size == 8)
+ hwprim = MGA_WA_TRIFAN_T0;
+ else
+ hwprim = MGA_WA_TRIFAN_T0T1;
+ break;
+ default:
+ return;
+ }
+
+ mgaRasterPrimitive( ctx, GL_TRIANGLES, hwprim );
+}
+
+static void VERT_FALLBACK( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+ tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
+ tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, count, flags );
+ MGA_CONTEXT(ctx)->SetupNewInputs |= VERT_CLIP;
+}
+
+#define LOCAL_VARS mgaContextPtr mmesa = MGA_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ FLUSH_BATCH(mmesa); \
+ mgaDmaPrimitive( ctx, prim ); \
+} while (0)
+#define NEW_PRIMITIVE() FLUSH_BATCH( mmesa )
+#define NEW_BUFFER() FLUSH_BATCH( mmesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ 0 /* fix me */
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ MGA_BUFFER_SIZE / (mmesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr ) \
+ mga_emit_contiguous_verts(ctx, j, (j)+(nr))
+
+
+#define TAG(x) mga_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean mga_run_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i, length, flags = 0;
+
+ /* Don't handle clipping or indexed vertices or vertex manipulations.
+ */
+ if (VB->ClipOrMask || mmesa->RenderIndex != 0 || VB->Elts) {
+ return GL_TRUE;
+ }
+
+ tnl->Driver.Render.Start( ctx );
+ mmesa->SetupNewInputs = ~0;
+
+ for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length)
+ {
+ flags = VB->Primitive[i];
+ length= VB->PrimitiveLength[i];
+ if (length)
+ mga_render_tab_verts[flags & PRIM_MODE_MASK]( ctx, i, i + length,
+ flags );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+static void mga_check_render( GLcontext *ctx, struct gl_pipeline_stage *stage )
+{
+ GLuint inputs = VERT_CLIP|VERT_RGBA;
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ inputs |= VERT_SPEC_RGB;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled)
+ inputs |= VERT_TEX(0);
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled)
+ inputs |= VERT_TEX(1);
+
+ if (ctx->Fog.Enabled)
+ inputs |= VERT_FOG_COORD;
+ }
+
+ stage->inputs = inputs;
+}
+
+
+static void dtr( struct gl_pipeline_stage *stage )
+{
+ (void)stage;
+}
+
+
+const struct gl_pipeline_stage _mga_render_stage =
+{
+ "mga render",
+ (_DD_NEW_SEPARATE_SPECULAR |
+ _NEW_TEXTURE|
+ _NEW_FOG|
+ _NEW_RENDERMODE), /* re-check (new inputs) */
+ 0, /* re-run (always runs) */
+ GL_TRUE, /* active */
+ 0, 0, /* inputs (set in check_render), outputs */
+ 0, 0, /* changed_inputs, private */
+ dtr, /* destructor */
+ mga_check_render, /* check - initially set to alloc data */
+ mga_run_render /* run */
+};
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
index 2fb01b757..de66b2092 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c
@@ -26,31 +26,33 @@
*/
/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaspan.c,v 1.8 2001/04/10 16:07:51 dawes Exp $ */
-#include "types.h"
+#include "mtypes.h"
#include "mgadd.h"
#include "mgacontext.h"
#include "mgaspan.h"
#include "mgaioctl.h"
+#include "swrast/swrast.h"
#define DBG 0
-#define LOCAL_VARS \
- __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
- mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
- __DRIscreenPrivate *sPriv = mmesa->driScreen; \
- GLuint pitch = mgaScreen->frontPitch; \
- GLuint height = dPriv->h; \
- char *read_buf = (char *)(sPriv->pFB + \
- mmesa->readOffset + \
- dPriv->x * mgaScreen->cpp + \
- dPriv->y * pitch); \
- char *buf = (char *)(sPriv->pFB + \
- mmesa->drawOffset + \
- dPriv->x * mgaScreen->cpp + \
- dPriv->y * pitch); \
- GLuint p = MGA_CONTEXT( ctx )->MonoColor; \
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
+ __DRIscreenPrivate *sPriv = mmesa->driScreen; \
+ GLuint pitch = mgaScreen->frontPitch; \
+ GLuint height = dPriv->h; \
+ char *read_buf = (char *)(sPriv->pFB + \
+ mmesa->readOffset + \
+ dPriv->x * mgaScreen->cpp + \
+ dPriv->y * pitch); \
+ char *buf = (char *)(sPriv->pFB + \
+ mmesa->drawOffset + \
+ dPriv->x * mgaScreen->cpp + \
+ dPriv->y * pitch); \
+ GLuint p; \
(void) read_buf; (void) buf; (void) p
+
#define LOCAL_DEPTH_VARS \
@@ -64,9 +66,7 @@
dPriv->x * mgaScreen->cpp + \
dPriv->y * pitch)
-#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-
-#define INIT_MONO_PIXEL(p)
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \
_y >= miny && _y < maxy)
@@ -113,6 +113,12 @@
/* 16 bit, 565 rgb color spanline and pixel functions
*/
#define Y_FLIP(_y) (height - _y - 1)
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = MGAPACKCOLOR565( color[0], color[1], color[2] )
+
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
@@ -139,6 +145,12 @@ do { \
/* 32 bit, 8888 argb color spanline and pixel functions
*/
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = MGAPACKCOLOR8888( color[0], color[1], color[2], color[3] )
+
+
#define WRITE_RGBA(_x, _y, r, g, b, a) \
*(GLuint *)(buf + _x*4 + _y*pitch) = ((r << 16) | \
(g << 8) | \
@@ -221,51 +233,70 @@ do { \
+static void mgaDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer,
+ GLenum mode )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mode == GL_FRONT_LEFT)
+ {
+ mmesa->readOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->read_buffer = MGA_FRONT;
+ }
+ else
+ {
+ mmesa->readOffset = mmesa->mgaScreen->backOffset;
+ mmesa->read_buffer = MGA_BACK;
+ }
+}
void mgaDDInitSpanFuncs( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetReadBuffer = mgaDDSetReadBuffer;
switch (mmesa->mgaScreen->cpp) {
case 2:
- ctx->Driver.WriteRGBASpan = mgaWriteRGBASpan_565;
- ctx->Driver.WriteRGBSpan = mgaWriteRGBSpan_565;
- ctx->Driver.WriteMonoRGBASpan = mgaWriteMonoRGBASpan_565;
- ctx->Driver.WriteRGBAPixels = mgaWriteRGBAPixels_565;
- ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_565;
- ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_565;
- ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_565;
-
- ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_16;
- ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_16;
- ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_16;
- ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_16;
+ swdd->WriteRGBASpan = mgaWriteRGBASpan_565;
+ swdd->WriteRGBSpan = mgaWriteRGBSpan_565;
+ swdd->WriteMonoRGBASpan = mgaWriteMonoRGBASpan_565;
+ swdd->WriteRGBAPixels = mgaWriteRGBAPixels_565;
+ swdd->WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_565;
+ swdd->ReadRGBASpan = mgaReadRGBASpan_565;
+ swdd->ReadRGBAPixels = mgaReadRGBAPixels_565;
+
+ swdd->ReadDepthSpan = mgaReadDepthSpan_16;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_16;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_16;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_16;
break;
case 4:
- ctx->Driver.WriteRGBASpan = mgaWriteRGBASpan_8888;
- ctx->Driver.WriteRGBSpan = mgaWriteRGBSpan_8888;
- ctx->Driver.WriteMonoRGBASpan = mgaWriteMonoRGBASpan_8888;
- ctx->Driver.WriteRGBAPixels = mgaWriteRGBAPixels_8888;
- ctx->Driver.WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_8888;
- ctx->Driver.ReadRGBASpan = mgaReadRGBASpan_8888;
- ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_8888;
-
+ swdd->WriteRGBASpan = mgaWriteRGBASpan_8888;
+ swdd->WriteRGBSpan = mgaWriteRGBSpan_8888;
+ swdd->WriteMonoRGBASpan = mgaWriteMonoRGBASpan_8888;
+ swdd->WriteRGBAPixels = mgaWriteRGBAPixels_8888;
+ swdd->WriteMonoRGBAPixels = mgaWriteMonoRGBAPixels_8888;
+ swdd->ReadRGBASpan = mgaReadRGBASpan_8888;
+ swdd->ReadRGBAPixels = mgaReadRGBAPixels_8888;
+
if (!mmesa->hw_stencil) {
- ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_32;
- ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_32;
- ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_32;
- ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_32;
+ swdd->ReadDepthSpan = mgaReadDepthSpan_32;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_32;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_32;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_32;
} else {
- ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_24_8;
- ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_24_8;
- ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_24_8;
- ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_24_8;
-
- ctx->Driver.ReadStencilSpan = mgaReadStencilSpan_24_8;
- ctx->Driver.WriteStencilSpan = mgaWriteStencilSpan_24_8;
- ctx->Driver.ReadStencilPixels = mgaReadStencilPixels_24_8;
- ctx->Driver.WriteStencilPixels = mgaWriteStencilPixels_24_8;
+ swdd->ReadDepthSpan = mgaReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_24_8;
+
+ swdd->ReadStencilSpan = mgaReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = mgaWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = mgaReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = mgaWriteStencilPixels_24_8;
}
break;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.c b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
index b954be44b..93e7d5dd3 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.c
@@ -24,12 +24,11 @@
* Authors:
* Keith Whitwell <keithw@valinux.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.11 2001/05/31 08:29:42 alanh Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.9 2001/04/10 16:07:51 dawes Exp $ */
#include <stdio.h>
-#include "types.h"
-#include "pb.h"
+#include "mtypes.h"
#include "dd.h"
#include "mm.h"
@@ -39,9 +38,17 @@
#include "mgatex.h"
#include "mgavb.h"
#include "mgatris.h"
+#include "mgaioctl.h"
#include "mgaregs.h"
#include "mgabuffers.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+
+
/* Some outstanding problems with accelerating logic ops...
*/
#if defined(ACCEL_ROP)
@@ -200,6 +207,7 @@ static void mgaDDClearDepth(GLcontext *ctx, GLclampd d)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ /* KW: should the ~ be there? */
switch (mmesa->setup.maccess & ~MA_zwidth_MASK) {
case MA_zwidth_16: mmesa->ClearDepth = d * 0x0000ffff; break;
case MA_zwidth_24: mmesa->ClearDepth = d * 0xffffff00; break;
@@ -261,7 +269,7 @@ static void mgaUpdateZMode(const GLcontext *ctx)
}
-static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref)
+static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLchan ref)
{
FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
@@ -273,11 +281,12 @@ static void mgaDDBlendEquation(GLcontext *ctx, GLenum mode)
FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_ALPHA;
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- MGA_CONTEXT(ctx)->Fallback |= MGA_FALLBACK_LOGICOP;
- else
- MGA_CONTEXT(ctx)->Fallback &= ~MGA_FALLBACK_LOGICOP;
-
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
}
static void mgaDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
@@ -317,10 +326,6 @@ static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
{
FLUSH_BATCH( MGA_CONTEXT(ctx) );
MGA_CONTEXT(ctx)->new_state |= MGA_NEW_DEPTH;
- if (func == GL_NEVER && ctx->Depth.Test)
- MGA_CONTEXT(ctx)->Fallback |= MGA_FALLBACK_DEPTH;
- else
- MGA_CONTEXT(ctx)->Fallback &= ~MGA_FALLBACK_DEPTH;
}
static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
@@ -338,42 +343,26 @@ static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
#else
static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
{
- if (ctx->Color.ColorLogicOpEnabled) {
- FLUSH_BATCH( MGA_CONTEXT(ctx) );
-
- if (opcode == GL_COPY)
- MGA_CONTEXT(ctx)->Fallback &= ~MGA_FALLBACK_LOGICOP;
- else
- MGA_CONTEXT(ctx)->Fallback |= MGA_FALLBACK_LOGICOP;
- }
- else
- MGA_CONTEXT(ctx)->Fallback &= ~MGA_FALLBACK_LOGICOP;
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
+ FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled && opcode != GL_COPY) );
}
#endif
-static void mgaUpdateFogAttrib( GLcontext *ctx )
+
+static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLuint color = MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F),
- (GLubyte)(ctx->Fog.Color[1]*255.0F),
- (GLubyte)(ctx->Fog.Color[2]*255.0F));
+ if (pname == GL_FOG_COLOR) {
+ GLuint color = MGAPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F),
+ (GLubyte)(ctx->Fog.Color[1]*255.0F),
+ (GLubyte)(ctx->Fog.Color[2]*255.0F));
- if (color != mmesa->setup.fogcolor)
+ MGA_STATECHANGE(mmesa, MGA_UPLOAD_CONTEXT);
mmesa->setup.fogcolor = color;
-
- mmesa->setup.maccess &= ~MA_fogen_enable;
- if (ctx->FogMode == FOG_FRAGMENT)
- mmesa->setup.maccess |= MA_fogen_enable;
-
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
-}
-
-static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
-{
- FLUSH_BATCH( MGA_CONTEXT(ctx) );
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_FOG;
+ }
}
@@ -391,7 +380,7 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
int a = 0;
/* determine source of alpha for blending and testing */
- if ( !ctx->Texture.ReallyEnabled ) {
+ if ( !ctx->Texture._ReallyEnabled ) {
a |= AC_alphasel_diffused;
}
else {
@@ -487,7 +476,7 @@ static void mgaUpdateAlphaMode(GLcontext *ctx)
a |= AC_src_zero;
break;
case GL_SRC_ALPHA_SATURATE:
- if (ctx->Visual->AlphaBits > 0)
+ if (ctx->Visual.alphaBits > 0)
a |= AC_src_src_alpha_sat;
else
a |= AC_src_zero;
@@ -585,34 +574,14 @@ static void mgaDDScissor( GLcontext *ctx, GLint x, GLint y,
}
-/* ======================================================================
- * New stuff for DRI state.
- */
-
-static void mgaDDDither(GLcontext *ctx, GLboolean enable)
-{
-}
-
-
-
-
-static void mgaDDSetColor(GLcontext *ctx,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
+static void mgaDDClearColor(GLcontext *ctx,
+ const GLchan color[4] )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- mmesa->MonoColor = mgaPackColor( mmesa->mgaScreen->cpp, r, g, b, a );
-}
-
-
-static void mgaDDClearColor(GLcontext *ctx,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
- mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp, r, g, b, a );
+ mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp,
+ color[0], color[1],
+ color[2], color[3]);
}
@@ -625,22 +594,22 @@ static void mgaDDClearColor(GLcontext *ctx,
#define _CULL_POSITIVE (1<<11)
-static void mgaUpdateCull( GLcontext *ctx )
+void mgaUpdateCull( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT(ctx);
GLuint mode = _CULL_DISABLE;
- if (ctx->Polygon.CullFlag &&
- ctx->PB->primitive == GL_POLYGON &&
- ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
+ if (ctx->Polygon.CullFlag &&
+ mmesa->raster_primitive == GL_TRIANGLES &&
+ ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
{
mode = _CULL_NEGATIVE;
if (ctx->Polygon.CullFaceMode == GL_FRONT)
mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
if (ctx->Polygon.FrontFace != GL_CCW)
mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
- if (mmesa->warp_pipe & MGA_TEX1_BIT)
- mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* why??? */
+ if (ctx->Texture._ReallyEnabled == (TEXTURE0_2D|TEXTURE1_2D))
+ mode ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* warp bug? */
}
mmesa->setup.wflag = mode;
@@ -661,11 +630,9 @@ static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum mode)
* Color masks
*/
-/* Mesa calls this from the wrong place:
- */
-static GLboolean mgaDDColorMask(GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+static void mgaDDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
@@ -681,13 +648,9 @@ static GLboolean mgaDDColorMask(GLcontext *ctx,
mask = mask | (mask << 16);
if (mmesa->setup.plnwt != mask) {
- FLUSH_BATCH( MGA_CONTEXT(ctx) );
- mmesa->setup.plnwt = mask;
- MGA_CONTEXT(ctx)->new_state |= MGA_NEW_MASK;
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->setup.plnwt = mask;
}
-
- return 0; /* Kind of a hack */
}
/* =============================================================
@@ -724,16 +687,12 @@ static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
const GLubyte *m = mask;
GLubyte p[4];
int i,j,k;
- int active = (ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON);
+ int active = (ctx->Polygon.StippleFlag &&
+ mmesa->raster_primitive == GL_TRIANGLES);
GLuint stipple;
FLUSH_BATCH(mmesa);
-
- /* Turn off flags. We'll turn them on below if this stipple pattern
- * works in h/w.
- */
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- mmesa->canDoStipple = GL_FALSE;
+ mmesa->haveHwStipple = 0;
if (active) {
mmesa->dirty |= MGA_UPLOAD_CONTEXT;
@@ -760,19 +719,13 @@ static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
for (i = 0 ; i < 16 ; i++)
if (mgaStipples[i] == stipple) {
mmesa->poly_stipple = i<<20;
+ mmesa->haveHwStipple = 1;
break;
}
-
- if (i == 16) {
- return;
- }
-
- mmesa->canDoStipple = GL_TRUE;
-
+
if (active) {
mmesa->setup.dwgctl &= ~(0xf<<20);
mmesa->setup.dwgctl |= mmesa->poly_stipple;
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
}
}
@@ -833,8 +786,12 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
mmesa->dirty |= MGA_UPLOAD_TEX1|MGA_UPLOAD_TEX0;
}
- mmesa->sarea->WarpPipe = mmesa->warp_pipe;
- mmesa->sarea->vertsize = mmesa->vertsize;
+ if (mmesa->dirty & MGA_UPLOAD_PIPE) {
+/* mmesa->sarea->wacceptseq = mmesa->hw_primitive; */
+ mmesa->sarea->WarpPipe = mmesa->vertex_format;
+ mmesa->sarea->vertsize = mmesa->vertex_size;
+ }
+
mmesa->sarea->dirty |= mmesa->dirty;
mmesa->dirty &= (MGA_UPLOAD_CLIPRECTS|MGA_WAIT_AGE);
@@ -842,7 +799,7 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
/* This is a bit of a hack but seems to be the best place to ensure
* that separate specular is disabled when not needed.
*/
- if (mmesa->glCtx->Texture.ReallyEnabled == 0 ||
+ if (mmesa->glCtx->Texture._ReallyEnabled == 0 ||
!mmesa->glCtx->Light.Enabled ||
mmesa->glCtx->Light.Model.ColorControl == GL_SINGLE_COLOR) {
sarea->TexState[0].texctl2 &= ~TMC_specen_enable;
@@ -850,11 +807,51 @@ void mgaEmitHwStateLocked( mgaContextPtr mmesa )
}
}
+/* Fallback to swrast for select and feedback.
+ */
+static void mgaRenderMode( GLcontext *ctx, GLenum mode )
+{
+ FALLBACK( ctx, MGA_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
/* =============================================================
*/
+void mgaCalcViewport( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = mmesa->hw_viewport;
+
+ /* See also mga_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * mmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * mmesa->depth_scale;
+
+ mmesa->SetupNewInputs = ~0;
+}
+
+static void mgaViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ mgaCalcViewport( ctx );
+}
+
+static void mgaDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ mgaCalcViewport( ctx );
+}
+
+/* =============================================================
+ */
+
static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
@@ -870,18 +867,15 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
/* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
*/
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- mmesa->Fallback |= MGA_FALLBACK_LOGICOP;
- else
- mmesa->Fallback &= ~MGA_FALLBACK_LOGICOP;
+ FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
break;
case GL_DEPTH_TEST:
FLUSH_BATCH( mmesa );
mmesa->new_state |= MGA_NEW_DEPTH;
- if (ctx->Depth.Func == GL_NEVER && ctx->Depth.Test)
- mmesa->Fallback |= MGA_FALLBACK_DEPTH;
- else
- mmesa->Fallback &= ~MGA_FALLBACK_DEPTH;
+ FALLBACK (ctx, MGA_FALLBACK_DEPTH,
+ ctx->Depth.Func == GL_NEVER && ctx->Depth.Test);
break;
case GL_SCISSOR_TEST:
FLUSH_BATCH( mmesa );
@@ -889,8 +883,11 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
mmesa->new_state |= MGA_NEW_CLIP;
break;
case GL_FOG:
- FLUSH_BATCH( mmesa );
- mmesa->new_state |= MGA_NEW_FOG;
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ if (ctx->Fog.Enabled)
+ mmesa->setup.maccess |= MA_fogen_enable;
+ else
+ mmesa->setup.maccess &= ~MA_fogen_enable;
break;
case GL_CULL_FACE:
FLUSH_BATCH( mmesa );
@@ -903,28 +900,19 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
mmesa->new_state |= (MGA_NEW_TEXTURE|MGA_NEW_ALPHA);
break;
case GL_POLYGON_STIPPLE:
- FLUSH_BATCH(mmesa);
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mmesa->setup.dwgctl &= ~(0xf<<20);
- if (state) {
- if (mmesa->canDoStipple && ctx->PB->primitive == GL_POLYGON) {
+ if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) {
+ FLUSH_BATCH(mmesa);
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ if (state)
mmesa->setup.dwgctl |= mmesa->poly_stipple;
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
- }
- else {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- }
- }
- else {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
}
break;
case GL_COLOR_LOGIC_OP:
FLUSH_BATCH( mmesa );
#if !defined(ACCEL_ROP)
- mmesa->Fallback &= ~MGA_FALLBACK_LOGICOP;
- if (state && ctx->Color.LogicOp != GL_COPY)
- mmesa->Fallback |= MGA_FALLBACK_LOGICOP;
+ FALLBACK( ctx, MGA_FALLBACK_LOGICOP,
+ (state && ctx->Color.LogicOp != GL_COPY));
#else
mmesa->new_state |= MGA_NEW_DEPTH;
#endif
@@ -933,10 +921,8 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
FLUSH_BATCH( mmesa );
if (mmesa->hw_stencil)
mmesa->new_state |= MGA_NEW_STENCIL;
- else if (state)
- mmesa->Fallback |= MGA_FALLBACK_STENCIL;
else
- mmesa->Fallback &= ~MGA_FALLBACK_STENCIL;
+ FALLBACK( ctx, MGA_FALLBACK_STENCIL, state );
default:
break;
}
@@ -946,30 +932,6 @@ static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
/* =============================================================
*/
-/* Just need to note that it has changed - the kernel will do the
- * upload the next time we fire a dma buffer.
- */
-static void mgaWarpUpdateState( GLcontext *ctx )
-{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- int index = mmesa->setupindex;
-
- index &= ~(MGA_WIN_BIT|MGA_TEX0_BIT|MGA_RGBA_BIT);
- index |= (MGA_ALPHA_BIT |
- MGA_SPEC_BIT |
- MGA_FOG_BIT |
-/* MGA_TEX1_BIT | */
- 0);
-
- if (index != mmesa->warp_pipe)
- {
- FLUSH_BATCH(mmesa);
- mmesa->warp_pipe = index;
- mmesa->new_state |= MGA_NEW_WARP;
- mmesa->dirty |= MGA_UPLOAD_PIPE;
- }
-}
-
/* =============================================================
@@ -977,14 +939,12 @@ static void mgaWarpUpdateState( GLcontext *ctx )
static void mgaDDPrintState( const char *msg, GLuint state )
{
- fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s%s\n",
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s\n",
msg,
state,
(state & MGA_NEW_DEPTH) ? "depth, " : "",
(state & MGA_NEW_ALPHA) ? "alpha, " : "",
- (state & MGA_NEW_FOG) ? "fog, " : "",
(state & MGA_NEW_CLIP) ? "clip, " : "",
- (state & MGA_NEW_MASK) ? "colormask, " : "",
(state & MGA_NEW_CULL) ? "cull, " : "",
(state & MGA_NEW_TEXTURE) ? "texture, " : "",
(state & MGA_NEW_CONTEXT) ? "context, " : "");
@@ -1010,9 +970,6 @@ void mgaDDUpdateHwState( GLcontext *ctx )
if (new_state & MGA_NEW_ALPHA)
mgaUpdateAlphaMode(ctx);
- if (new_state & MGA_NEW_FOG)
- mgaUpdateFogAttrib(ctx);
-
if (new_state & MGA_NEW_CLIP)
mgaUpdateClipping(ctx);
@@ -1028,59 +985,13 @@ void mgaDDUpdateHwState( GLcontext *ctx )
}
-void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
-
- FLUSH_BATCH( mmesa );
- mgaUpdateCull(ctx);
-
- if (ctx->Polygon.StippleFlag) {
- mmesa->dirty |= MGA_UPLOAD_CONTEXT;
- mmesa->setup.dwgctl &= ~(0xf<<20);
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- if (ctx->PB->primitive == GL_POLYGON && mmesa->canDoStipple) {
- mmesa->setup.dwgctl |= mmesa->poly_stipple;
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
- }
- }
- else {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- }
-}
-
-
-#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
- NEW_TEXTURE_MATRIX|\
- NEW_USER_CLIP|NEW_CLIENT_STATE))
-
-void mgaDDUpdateState( GLcontext *ctx )
+static void mgaDDInvalidateState( GLcontext *ctx, GLuint new_state )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
-
- if (ctx->NewState & INTERESTED) {
- mgaDDChooseRenderState(ctx);
- mgaChooseRasterSetupFunc(ctx);
- mgaWarpUpdateState(ctx);
- }
-
- /* Have to do this here to detect texture fallbacks in time:
- */
- if (mmesa->new_state & MGA_NEW_TEXTURE)
- mgaDDUpdateHwState( ctx );
-
- if (!mmesa->Fallback) {
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
- ctx->IndirectTriangles |= mmesa->IndirectTriangles;
-
- ctx->Driver.PointsFunc=mmesa->PointsFunc;
- ctx->Driver.LineFunc=mmesa->LineFunc;
- ctx->Driver.TriangleFunc=mmesa->TriangleFunc;
- ctx->Driver.QuadFunc=mmesa->QuadFunc;
- }
- else {
- ctx->IndirectTriangles |= mmesa->IndirectTriangles;
- }
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ MGA_CONTEXT(ctx)->new_gl_state |= new_state;
}
@@ -1123,7 +1034,7 @@ void mgaInitState( mgaContextPtr mmesa )
exit( 1 );
}
- switch (mmesa->glCtx->Visual->DepthBits) {
+ switch (mmesa->glCtx->Visual.depthBits) {
case 16:
mmesa->setup.maccess |= MA_zwidth_16;
break;
@@ -1175,7 +1086,7 @@ void mgaInitState( mgaContextPtr mmesa )
void mgaDDInitStateFuncs( GLcontext *ctx )
{
- ctx->Driver.UpdateState = mgaDDUpdateState;
+ ctx->Driver.UpdateState = mgaDDInvalidateState;
ctx->Driver.Enable = mgaDDEnable;
ctx->Driver.LightModelfv = mgaDDLightModelfv;
ctx->Driver.AlphaFunc = mgaDDAlphaFunc;
@@ -1190,16 +1101,10 @@ void mgaDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.CullFace = mgaDDCullFaceFrontFace;
ctx->Driver.FrontFace = mgaDDCullFaceFrontFace;
ctx->Driver.ColorMask = mgaDDColorMask;
- ctx->Driver.ReducedPrimitiveChange = mgaDDReducedPrimitiveChange;
- ctx->Driver.RenderStart = mgaDDUpdateHwState;
- ctx->Driver.RenderFinish = 0;
ctx->Driver.SetDrawBuffer = mgaDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = mgaDDSetReadBuffer;
- ctx->Driver.Color = mgaDDSetColor;
ctx->Driver.ClearColor = mgaDDClearColor;
ctx->Driver.ClearDepth = mgaDDClearDepth;
- ctx->Driver.Dither = mgaDDDither;
ctx->Driver.LogicOpcode = mgaDDLogicOp;
ctx->Driver.PolygonStipple = mgaDDPolygonStipple;
@@ -1208,7 +1113,17 @@ void mgaDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.StencilMask = mgaDDStencilMask;
ctx->Driver.StencilOp = mgaDDStencilOp;
- ctx->Driver.Index = 0;
+ ctx->Driver.DepthRange = mgaDepthRange;
+ ctx->Driver.Viewport = mgaViewport;
+ ctx->Driver.RenderMode = mgaRenderMode;
+
ctx->Driver.ClearIndex = 0;
ctx->Driver.IndexMask = 0;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgastate.h b/xc/lib/GL/mesa/src/drv/mga/mgastate.h
index 50ba3c363..e4ab65770 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgastate.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgastate.h
@@ -30,14 +30,12 @@
#define _MGA_STATE_H
+extern void mgaInitState( mgaContextPtr mmesa );
extern void mgaDDInitStateFuncs(GLcontext *ctx);
extern void mgaDDUpdateHwState( GLcontext *ctx );
-extern void mgaDDUpdateState( GLcontext *ctx );
-extern void mgaDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim );
-
-extern void mgaInitState( mgaContextPtr mmesa );
-
extern void mgaUpdateClipping(const GLcontext *ctx);
+extern void mgaUpdateCull( GLcontext *ctx );
+extern void mgaCalcViewport( GLcontext *ctx );
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatex.c b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
index 93b3b9fd7..119bac66b 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatex.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatex.c
@@ -24,7 +24,7 @@
* Authors:
* Keith Whitwell <keithw@valinux.com>
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.12 2001/08/18 02:51:05 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.10 2001/04/10 16:07:51 dawes Exp $ */
#include <stdlib.h>
#include <stdio.h>
@@ -34,13 +34,17 @@
#include "mgacontext.h"
#include "mgatex.h"
#include "mgaregs.h"
+#include "mgatris.h"
#include "mgaioctl.h"
-#include "context.h"
#include "enums.h"
#include "simple_list.h"
#include "mem.h"
-#include "texutil.h"
+#include "macros.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#include "swrast/swrast.h"
#define TEX_0 1
#define TEX_1 2
@@ -60,7 +64,7 @@ mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t )
mmFreeMem( t->MemBlock );
t->MemBlock = 0;
- if (t->age > mmesa->dirtyAge)
+ if (mmesa && t->age > mmesa->dirtyAge)
mmesa->dirtyAge = t->age;
}
@@ -69,9 +73,11 @@ mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t )
t->tObj->DriverData = NULL;
/* see if it was the driver's current object */
- if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0;
- if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0;
-
+ if (mmesa) {
+ if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0;
+ if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0;
+ }
+
remove_from_list(t);
FREE( t );
}
@@ -157,9 +163,9 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
fprintf( stderr, "internal=%s format=%s type=%s\n",
texImage->IntFormat == 3 ? "GL_RGB (3)" :
texImage->IntFormat == 4 ? "GL_RGBA (4)" :
- gl_lookup_enum_by_nr( texImage->IntFormat ),
- gl_lookup_enum_by_nr( format ),
- gl_lookup_enum_by_nr( type ) );
+ _mesa_lookup_enum_by_nr( texImage->IntFormat ),
+ _mesa_lookup_enum_by_nr( format ),
+ _mesa_lookup_enum_by_nr( type ) );
#define SET_FORMAT( r, gl ) \
do { \
@@ -179,6 +185,10 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
} while (0)
switch ( texImage->IntFormat ) {
+ /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
+ * got to be better than sticking them way down the end of this
+ * huge list.
+ */
case GL_RGBA:
case 4:
if ( format == GL_BGRA ) {
@@ -207,6 +217,9 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
TMC_tformat_tw16, _mesa_texformat_rgb565 );
break;
+ /* GH: Okay, keep checking as normal. Still test for GL_RGB,
+ * GL_RGBA formats first.
+ */
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
@@ -217,17 +230,12 @@ static GLint mgaChooseTexFormat( mgaContextPtr mmesa,
case GL_RGBA4:
case GL_RGBA2:
- case GL_RGB5_A1:
SET_FORMAT( TMC_tformat_tw12, _mesa_texformat_argb4444 );
break;
-#if 0
case GL_RGB5_A1:
- /* GH: Leave this until we use the new texture conversion code.
- */
SET_FORMAT( TMC_tformat_tw15, _mesa_texformat_argb1555 );
break;
-#endif
case GL_RGB8:
case GL_RGB10:
@@ -417,7 +425,7 @@ static void mgaCreateTexObj(mgaContextPtr mmesa,
static void mgaUpdateTextureEnvG200( GLcontext *ctx )
{
- struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
mgaTextureObjectPtr t;
if (!tObj || !tObj->DriverData)
@@ -439,7 +447,7 @@ static void mgaUpdateTextureEnvG200( GLcontext *ctx )
t->setup.texctl2 |= TMC_decalblend_enable;
break;
case GL_BLEND:
- t->ctx->Fallback |= MGA_FALLBACK_TEXTURE;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
break;
default:
break;
@@ -451,13 +459,10 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
GLuint source = mmesa->tmu_source[unit];
- struct gl_texture_object *tObj = ctx->Texture.Unit[source].Current;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[source]._Current;
GLenum format;
- if ( tObj != ctx->Texture.Unit[source].CurrentD[2] ||
- !tObj ||
- !tObj->Complete ||
- ((ctx->Enabled>>(source*4))&TEXTURE0_ANY) != TEXTURE0_2D )
+ if ( tObj != ctx->Texture.Unit[source].Current2D || !tObj )
return;
format = tObj->Image[tObj->BaseLevel]->Format;
@@ -483,16 +488,16 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
case GL_MODULATE:
if (unit == 0) {
*reg = ( TD0_color_arg2_diffuse |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
else {
*reg = ( TD0_color_arg2_prevstage |
TD0_color_alpha_prevstage |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
break;
case GL_DECAL:
@@ -509,55 +514,36 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
}
}
else if ( format == GL_RGBA ) {
-#if 1
- if(unit == 0)
- {
- if(mmesa->tmu_source[0] == 0)
- {
- *reg = ( TD0_color_arg2_diffuse |
- TD0_color_alpha_currtex |
- TD0_color_alpha1inv_enable |
- TD0_color_arg1mul_alpha1 |
- TD0_color_blend_enable |
- TD0_color_add_add |
- TD0_color_arg1add_mulout |
- TD0_color_arg2add_mulout |
- TD0_color_sel_addout |
- TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg2 );
- }else {
- *reg = ( TD0_color_arg2_diffuse |
- TD0_color_sel_arg2 |
- TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_arg2 );
- }
- }
- else {
- if(mmesa->tmu_source[1] == 1)
- {
- *reg = ( TD0_color_arg2_prevstage |
- TD0_color_alpha_currtex |
- TD0_color_alpha1inv_enable |
- TD0_color_arg2mul_alpha2 |
- TD0_color_blend_enable |
- TD0_color_add_add |
- TD0_color_arg1add_mulout |
- TD0_color_arg2add_mulout |
- TD0_color_sel_addout |
- TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg2 );
- }else {
- *reg = ( TD0_color_arg2_prevstage |
- TD0_color_sel_arg2 |
- TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_arg2 );
- }
- }
-
-
+#if 0
+ if (unit == 0) {
+ /* this doesn't work */
+ *reg = (TD0_color_arg2_diffuse |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha2inv_enable |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2 );
+ }
+ else {
+ *reg = (TD0_color_arg2_prevstage |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha2inv_enable |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2 );
+ }
#else
/* s/w fallback, pretty sure we can't do in h/w */
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
fprintf( stderr, "FALLBACK: GL_DECAL RGBA texture, unit=%d\n",
unit );
@@ -584,44 +570,44 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
if (format == GL_INTENSITY)
*reg = ( TD0_color_arg2_diffuse |
TD0_color_add_add |
- TD0_color_sel_addout |
+ TD0_color_sel_add |
TD0_alpha_arg2_diffuse |
TD0_alpha_add_enable |
- TD0_alpha_sel_addout);
+ TD0_alpha_sel_add);
else if (format == GL_ALPHA)
*reg = ( TD0_color_arg2_diffuse |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
else
*reg = ( TD0_color_arg2_diffuse |
TD0_color_add_add |
- TD0_color_sel_addout |
+ TD0_color_sel_add |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
else {
if (format == GL_INTENSITY) {
*reg = ( TD0_color_arg2_prevstage |
TD0_color_add_add |
- TD0_color_sel_addout |
+ TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
TD0_alpha_add_enable |
- TD0_alpha_sel_addout);
+ TD0_alpha_sel_add);
}
else if (format == GL_ALPHA) {
*reg = ( TD0_color_arg2_prevstage |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
else {
*reg = ( TD0_color_arg2_prevstage |
TD0_color_alpha_prevstage |
TD0_color_add_add |
- TD0_color_sel_addout |
+ TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
}
break;
@@ -629,12 +615,12 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
case GL_BLEND:
if (format == GL_ALPHA) {
*reg = ( TD0_color_arg2_diffuse |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
- TD0_alpha_sel_mulout);
+ TD0_alpha_sel_mul);
}
else {
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
fprintf( stderr, "FALLBACK: GL_BLEND envcolor=0x%08x\n",
mmesa->envcolor );
@@ -649,7 +635,7 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
*/
*reg = ( TD0_color_arg2_diffuse |
TD0_color_arg1_inv_enable |
- TD0_color_sel_mulout |
+ TD0_color_sel_mul |
TD0_alpha_arg2_diffuse |
TD0_alpha_sel_arg1);
} else {
@@ -658,7 +644,7 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
*/
*reg = ( TD0_color_arg2_prevstage |
TD0_color_add_add |
- TD0_color_sel_addout |
+ TD0_color_sel_add |
TD0_alpha_arg2_prevstage |
TD0_alpha_sel_arg2);
}
@@ -671,67 +657,52 @@ static void mgaUpdateTextureEnvG400( GLcontext *ctx, int unit )
-static void mgaUpdateTextureObject( GLcontext *ctx, int unit )
+static void mgaUpdateTextureObject( GLcontext *ctx, int hw_unit )
{
mgaTextureObjectPtr t;
struct gl_texture_object *tObj;
GLuint enabled;
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- GLuint source = mmesa->tmu_source[unit];
+ GLuint gl_unit = mmesa->tmu_source[hw_unit];
- enabled = (ctx->Texture.ReallyEnabled>>(source*4))&TEXTURE0_ANY;
- tObj = ctx->Texture.Unit[source].Current;
+ enabled = ctx->Texture.Unit[gl_unit]._ReallyEnabled;
+ tObj = ctx->Texture.Unit[gl_unit]._Current;
if (enabled != TEXTURE0_2D) {
- if (enabled) {
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
- if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
- fprintf( stderr, "FALLBACK: tex enable != 2D\n" );
- }
- return;
- }
-
- if ( !tObj || tObj != ctx->Texture.Unit[source].CurrentD[2] ) {
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
- if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
- fprintf( stderr, "FALLBACK: tObj != 2D texture\n" );
+ if (enabled)
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
return;
}
if (tObj->Image[tObj->BaseLevel]->Border > 0) {
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
fprintf( stderr, "FALLBACK: texture border\n" );
return;
}
-/* if (!tObj) tObj = ctx->Texture.Unit[0].Current; */
-/* if (!tObj) return; */
-
if ( !tObj->DriverData ) {
mgaCreateTexObj( mmesa, tObj );
if ( !tObj->DriverData ) {
- mmesa->Fallback |= MGA_FALLBACK_TEXTURE;
- if ( MGA_DEBUG & DEBUG_VERBOSE_FALLBACK )
- fprintf( stderr, "FALLBACK: could not create texture object\n" );
- return;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_TRUE );
+ return;
}
}
t = (mgaTextureObjectPtr)tObj->DriverData;
if (t->dirty_images)
- mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << unit);
+ mmesa->dirty |= (MGA_UPLOAD_TEX0IMAGE << hw_unit);
- mmesa->CurrentTexObj[unit] = t;
- t->bound |= unit+1;
+ mmesa->CurrentTexObj[hw_unit] = t;
+ t->bound |= hw_unit+1;
/* if (t->MemBlock) */
/* mgaUpdateTexLRU( mmesa, t ); */
t->setup.texctl2 &= ~TMC_dualtex_enable;
- if (mmesa->multitex)
+ if (ctx->Texture._ReallyEnabled == (TEXTURE0_2D|TEXTURE1_2D))
t->setup.texctl2 |= TMC_dualtex_enable;
t->setup.texctl2 &= ~TMC_specen_enable;
@@ -749,7 +720,7 @@ static void mgaUpdateTextureObject( GLcontext *ctx, int unit )
void mgaUpdateTextureState( GLcontext *ctx )
{
mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mmesa->Fallback &= ~MGA_FALLBACK_TEXTURE;
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, GL_FALSE );
if (mmesa->CurrentTexObj[0]) {
mmesa->CurrentTexObj[0]->bound = 0;
@@ -761,24 +732,23 @@ void mgaUpdateTextureState( GLcontext *ctx )
mmesa->CurrentTexObj[1] = 0;
}
+ if (ctx->Texture._ReallyEnabled == TEXTURE1_2D) {
+ mmesa->tmu_source[0] = 1;
+ } else {
+ mmesa->tmu_source[0] = 0;
+ }
+
if (MGA_IS_G400(mmesa)) {
mgaUpdateTextureObject( ctx, 0 );
mgaUpdateTextureEnvG400( ctx, 0 );
mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
-
- if (mmesa->multitex || 1) {
- mgaUpdateTextureObject( ctx, 1 );
+
+ if (ctx->Texture._ReallyEnabled == (TEXTURE0_2D|TEXTURE1_2D)) {
+ mgaUpdateTextureObject( ctx, 1 );
mgaUpdateTextureEnvG400( ctx, 1 );
+ mmesa->dirty |= MGA_UPLOAD_TEX1;
}
-/* else */
-/* mmesa->Setup[MGA_CTXREG_TDUAL1] = ( TD0_color_arg2_prevstage | */
-/* TD0_color_sel_arg2 | */
-/* TD0_alpha_arg2_prevstage | */
-/* TD0_alpha_sel_arg2); */
-
-
- mmesa->dirty |= MGA_UPLOAD_TEX1;
} else {
mgaUpdateTextureObject( ctx, 0 );
mgaUpdateTextureEnvG200( ctx );
@@ -787,7 +757,7 @@ void mgaUpdateTextureState( GLcontext *ctx )
mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0;
mmesa->setup.dwgctl &= DC_opcod_MASK;
- mmesa->setup.dwgctl |= (ctx->Texture.ReallyEnabled
+ mmesa->setup.dwgctl |= (ctx->Texture._ReallyEnabled
? DC_opcod_texture_trap
: DC_opcod_trap);
}
@@ -839,69 +809,49 @@ static void mgaDDTexEnv( GLcontext *ctx, GLenum target,
}
-static void mgaDDTexImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint internalFormat,
- const struct gl_texture_image *image )
+static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaTextureObjectPtr t;
- GLint tformat;
- /* hack: cast-away const */
- struct gl_texture_image *img = (struct gl_texture_image *) image;
-
- /* just free the mga texture if it exists, it will be recreated at
- mgaUpdateTextureState time. */
- t = (mgaTextureObjectPtr) tObj->DriverData;
- if ( t ) {
- if (t->bound) FLUSH_BATCH(mmesa);
- /* if this is the current object, it will force an update */
- mgaDestroyTexObj( mmesa, t );
- mmesa->new_state |= MGA_NEW_TEXTURE;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ mgaDestroyTexObj( MGA_CONTEXT(ctx), t );
+ texObj->DriverData = 0;
}
-
- tformat = mgaChooseTexFormat( mmesa, img, img->Format,
- GL_UNSIGNED_BYTE );
-
- if (0)
- fprintf(stderr, "mgaDDTexImage tObj %p, level %d, image %p\n",
- tObj, level, image);
-
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
}
-static void mgaDDTexSubImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLint internalFormat,
- const struct gl_texture_image *image )
+static void mgaTexSubImage2D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaTextureObjectPtr t;
-
- t = (mgaTextureObjectPtr) tObj->DriverData;
-
-
- /* just free the mga texture if it exists, it will be recreated at
- mgaUpdateTextureState time. */
- t = (mgaTextureObjectPtr) tObj->DriverData;
- if ( t ) {
- if (t->bound) FLUSH_BATCH(mmesa);
- /* if this is the current object, it will force an update */
- mgaDestroyTexObj( mmesa, t );
- mmesa->new_state |= MGA_NEW_TEXTURE;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ mgaDestroyTexObj( MGA_CONTEXT(ctx), t );
+ texObj->DriverData = 0;
}
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
-
-
-#if 0
- /* the texture currently exists, so directly update it */
- mgaUploadSubImage( t, level, xoffset, yoffset, width, height );
-#endif
}
+
/*
* mgaTexParameter
* This just changes variables and flags for a state update, which
@@ -977,15 +927,16 @@ mgaDDDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
mgaTextureObjectPtr t = (mgaTextureObjectPtr)tObj->DriverData;
if ( t ) {
- if (t->bound) {
- FLUSH_BATCH(mmesa);
- if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0;
- if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0;
- mmesa->new_state |= MGA_NEW_TEXTURE;
+ if (mmesa) {
+ if (t->bound) {
+ FLUSH_BATCH(mmesa);
+ if (t->bound & TEX_0) mmesa->CurrentTexObj[0] = 0;
+ if (t->bound & TEX_1) mmesa->CurrentTexObj[1] = 0;
+ }
+ mmesa->new_state |= MGA_NEW_TEXTURE;
}
mgaDestroyTexObj( mmesa, t );
- mmesa->new_state |= MGA_NEW_TEXTURE;
}
}
@@ -1002,8 +953,21 @@ void
mgaDDInitTextureFuncs( GLcontext *ctx )
{
ctx->Driver.TexEnv = mgaDDTexEnv;
- ctx->Driver.TexImage = mgaDDTexImage;
- ctx->Driver.TexSubImage = mgaDDTexSubImage;
+
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = mgaTexImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = mgaTexSubImage2D;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
ctx->Driver.BindTexture = mgaDDBindTexture;
ctx->Driver.DeleteTexture = mgaDDDeleteTexture;
ctx->Driver.TexParameter = mgaDDTexParameter;
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.c b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
index cd9da5a0e..c2c2a25fa 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatris.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.c
@@ -29,153 +29,887 @@
#include <stdio.h>
#include <math.h>
-#include "types.h"
-#include "vb.h"
-#include "pipeline.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
#include "mm.h"
#include "mgacontext.h"
+#include "mgaioctl.h"
#include "mgatris.h"
#include "mgavb.h"
+#include "mgastate.h"
-#define MGA_COLOR(to, from) { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
- (to)[3] = (from)[3]; \
+static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+
+#if defined (USE_X86_ASM)
+#define EMIT_VERT( j, vb, vertex_size, v ) \
+do { int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertex_size), \
+ "D" ((long)vb), \
+ "S" ((long)v)); \
+} while (0)
+#else
+#define EMIT_VERT( j, vb, vertex_size, v ) \
+do { \
+ for ( j = 0 ; j < vertex_size ; j++ ) \
+ vb[j] = (v)->ui[j]; \
+ vb += vertex_size; \
+} while (0)
+#endif
+
+static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1,
+ mgaVertexPtr v2 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 3 * 4 * vertex_size );
+ int j;
+
+ EMIT_VERT( j, vb, vertex_size, v0 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v2 );
}
-#define MGA_COLOR3(to, from) { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
+
+static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1,
+ mgaVertexPtr v2,
+ mgaVertexPtr v3 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ int j;
+
+ EMIT_VERT( j, vb, vertex_size, v0 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v3 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v2 );
+ EMIT_VERT( j, vb, vertex_size, v3 );
}
+static __inline__ void mga_draw_point( mgaContextPtr mmesa,
+ mgaVertexPtr tmp )
+{
+ GLfloat sz = mmesa->glCtx->Point._Size * .5;
+ int vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ int j;
+
+#if 0
+ v0->v.x += PNT_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
+#endif
-static triangle_func tri_tab[0x10];
-static quad_func quad_tab[0x10];
-static line_func line_tab[0x10];
-static points_func points_tab[0x10];
+ /* Draw a point as two triangles.
+ */
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
-#define IND (0)
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+
+#if 0
+ v0->v.x -= PNT_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+}
+
+
+static __inline__ void mga_draw_line( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ GLfloat dx, dy, ix, iy;
+ GLfloat width = mmesa->glCtx->Line._Width;
+ GLint j;
+
+#if 0
+ v0->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ v1->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ v1->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+
+ dx = v0->v.x - v1->v.x;
+ dy = v0->v.y - v1->v.y;
+
+ ix = width * .5; iy = 0;
+ if (dx * dx > dy * dy) {
+ iy = ix; ix = 0;
+ }
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v0->v.x + ix;
+ *(float *)&vb[1] = v0->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x - ix;
+ *(float *)&vb[1] = v1->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+#if 0
+ v0->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ v1->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ v1->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+}
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_tri( mmesa, a, b, c ); \
+ else \
+ mga_draw_triangle( mmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ mmesa->draw_tri( mmesa, a, b, d ); \
+ mmesa->draw_tri( mmesa, b, c, d ); \
+ } else { \
+ mga_draw_quad( mmesa, a, b, c, d ); \
+ } \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_line( mmesa, v0, v1 ); \
+ else { \
+ mga_draw_line( mmesa, v0, v1 ); \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_point( mmesa, v0 ); \
+ else { \
+ mga_draw_point( mmesa, v0 ); \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+
+static void
+mga_fallback_tri( mgaContextPtr mmesa,
+ mgaVertex *v0,
+ mgaVertex *v1,
+ mgaVertex *v2 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[3];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ mga_translate_vertex( ctx, v1, &v[1] );
+ mga_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+mga_fallback_line( mgaContextPtr mmesa,
+ mgaVertex *v0,
+ mgaVertex *v1 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[2];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ mga_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+mga_fallback_point( mgaContextPtr mmesa,
+ mgaVertex *v0 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[1];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+
+#define MGA_UNFILLED_BIT 0x1
+#define MGA_OFFSET_BIT 0x2
+#define MGA_TWOSIDE_BIT 0x4
+#define MGA_FLAT_BIT 0x8 /* mga can't flatshade? */
+#define MGA_FALLBACK_BIT 0x10
+#define MGA_MAX_TRIFUNC 0x20
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[MGA_MAX_TRIFUNC];
+
+#define DO_FALLBACK (IND & MGA_FALLBACK_BIT)
+#define DO_OFFSET (IND & MGA_OFFSET_BIT)
+#define DO_UNFILLED (IND & MGA_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & MGA_TWOSIDE_BIT)
+#define DO_FLAT (IND & MGA_FLAT_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_SPEC 1
+#define HAVE_HW_FLATSHADE 0
+#define VERTEX mgaVertex
+#define TAB rast_tab
+
+#define MGA_COLOR( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+} while (0)
+
+#define MGA_SPEC( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+} while (0)
+
+#define DEPTH_SCALE mmesa->depth_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (mmesa->verts + (e<<mmesa->vertex_stride_shift))
+
+#define VERT_SET_RGBA( v, c ) MGA_COLOR( v->ub4[4], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) MGA_SPEC( v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ (void) color; (void) spec;
+
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (mmesa->raster_primitive != x) \
+ mgaRasterPrimitive( ctx, x, MGA_WA_TRIANGLES )
+#define RENDER_PRIMITIVE mmesa->render_primitive
+#define IND MGA_FALLBACK_BIT
#define TAG(x) x
-#include "mgatritmp.h"
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
-#define IND (MGA_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "mgatritmp.h"
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (MGA_OFFSET_BIT)
#define TAG(x) x##_offset
-#include "mgatritmp.h"
-
-#define IND (MGA_OFFSET_BIT|MGA_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "mgatritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (MGA_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "mgatritmp.h"
-
-#define IND (MGA_TWOSIDE_BIT|MGA_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "mgatritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT)
#define TAG(x) x##_twoside_offset
-#include "mgatritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT| \
+ MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Mga doesn't support provoking-vertex flat-shading?
+ */
+#define IND (MGA_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FLAT_BIT)
#define TAG(x) x##_twoside_offset_flat
-#include "mgatritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-void mgaDDTrifuncInit()
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT| \
+ MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
{
init();
- init_flat();
init_offset();
- init_offset_flat();
init_twoside();
- init_twoside_flat();
init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
+}
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+#define VERT(x) (mgaVertex *)(vertptr + ((x)<<vertshift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ mga_draw_point( mmesa, VERT(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) \
+ mga_draw_line( mmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ mga_draw_triangle( mmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ mga_draw_quad( mmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) mgaRenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)mmesa->verts; \
+ const GLuint vertshift = mmesa->vertex_stride_shift; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) mga_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) mga_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void mgaRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = mmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void mgaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void mgaFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, (n-2) * 3 * 4 * vertex_size );
+ GLubyte *vertptr = (GLubyte *)mmesa->verts;
+ const GLuint vertshift = mmesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) start );
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i-1]) );
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i]) );
+ }
}
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
-#define ALL_FALLBACK (DD_SELECT | DD_FEEDBACK)
-#define POINT_FALLBACK (ALL_FALLBACK | DD_POINT_SMOOTH)
-#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_SMOOTH | DD_LINE_STIPPLE)
-#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_UNFILLED)
-#define ANY_FALLBACK (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
-#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET)
-
-/* Setup the Point, Line, Triangle and Quad functions based on the
- current rendering state. Wherever possible, use the hardware to
- render the primitive. Otherwise, fallback to software rendering. */
-void mgaDDChooseRenderState(GLcontext *ctx)
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
- GLuint index = 0;
-
- if (mmesa->Fallback) {
- mmesa->renderindex = MGA_FALLBACK_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE) {
- mmesa->IndirectTriangles = DD_TRI_LIGHT_TWOSIDE;
- }
- return;
- }
-
- if (flags & ANY_RASTER_FLAGS) {
- if (flags & DD_FLATSHADE) index |= MGA_FLAT_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MGA_TWOSIDE_BIT;
- if (flags & DD_TRI_OFFSET) index |= MGA_OFFSET_BIT;
- }
-
- mmesa->PointsFunc = points_tab[index];
- mmesa->LineFunc = line_tab[index];
- mmesa->TriangleFunc = tri_tab[index];
- mmesa->QuadFunc = quad_tab[index];
-
- mmesa->renderindex = index;
- mmesa->IndirectTriangles = 0;
-
- if (flags & ANY_FALLBACK) {
- if (flags & POINT_FALLBACK) {
- mmesa->renderindex |= MGA_FALLBACK_BIT;
- mmesa->PointsFunc = 0;
- mmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- }
-
- if (flags & LINE_FALLBACK) {
- mmesa->renderindex |= MGA_FALLBACK_BIT;
- mmesa->LineFunc = 0;
- mmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- }
-
- if (flags & TRI_FALLBACK) {
- mmesa->renderindex |= MGA_FALLBACK_BIT;
- mmesa->TriangleFunc = 0;
- mmesa->QuadFunc = 0;
- mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- }
- /* Special cases:
- */
- if ((flags & DD_TRI_STIPPLE) &&
- (ctx->IndirectTriangles & DD_TRI_STIPPLE)) {
- mmesa->renderindex |= MGA_FALLBACK_BIT;
- mmesa->TriangleFunc = 0;
- mmesa->QuadFunc = 0;
- mmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- if (flags & DD_TRI_LIGHT_TWOSIDE) {
- mmesa->IndirectTriangles |= DD_TRI_LIGHT_TWOSIDE;
- }
- }
- }
+
+#define _MGA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_SMOOTH | DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_UNFILLED)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK| \
+ DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
+ DD_TRI_UNFILLED)
+
+static void mgaChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MGA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= MGA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= MGA_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= MGA_FLAT_BIT;
+ }
+
+ mmesa->draw_point = mga_draw_point;
+ mmesa->draw_line = mga_draw_line;
+ mmesa->draw_tri = mga_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ mmesa->draw_point = mga_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ mmesa->draw_line = mga_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ mmesa->draw_tri = mga_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !mmesa->haveHwStipple)
+ mmesa->draw_tri = mga_fallback_tri;
+
+ index |= MGA_FALLBACK_BIT;
+ }
+ }
+
+ if (mmesa->RenderIndex != index) {
+ mmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = mga_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = mga_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = mgaFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = mgaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = mgaRenderClippedPoly;
+ }
+ }
+}
+
+/**********************************************************************/
+/* Runtime render state and callbacks */
+/**********************************************************************/
+
+
+static void mgaRunPipeline( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mmesa->new_state) {
+ mgaDDUpdateHwState( ctx );
+ }
+
+ if (!mmesa->Fallback && mmesa->new_gl_state) {
+ if (mmesa->new_gl_state & _MGA_NEW_RASTERSETUP)
+ mgaChooseVertexState( ctx );
+
+ if (mmesa->new_gl_state & _MGA_NEW_RENDERSTATE)
+ mgaChooseRenderState( ctx );
+
+ mmesa->new_gl_state = 0;
+
+ /* Circularity: mgaDDUpdateHwState can affect mmesa->Fallback,
+ * but mgaChooseVertexState can affect mmesa->new_state. Hence
+ * the second check. (Fix this...)
+ */
+ if (mmesa->new_state) {
+ mgaDDUpdateHwState( ctx );
+ }
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ FLUSH_BATCH( mmesa );
+ mmesa->raster_primitive = prim;
+/* mmesa->hw_primitive = hwprim; */
+ mmesa->hw_primitive = MGA_WA_TRIANGLES; /* disable mgarender.c for now */
+ mgaUpdateCull(ctx);
+
+ if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple)
+ {
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ if (mmesa->raster_primitive == GL_TRIANGLES)
+ mmesa->setup.dwgctl |= mmesa->poly_stipple;
+ else
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ }
+}
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in mgarender.c.
+ */
+static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ mmesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (mmesa->raster_primitive != rprim) {
+ mgaRasterPrimitive( ctx, rprim, MGA_WA_TRIANGLES );
+ }
+}
+
+static void mgaRenderFinish( GLcontext *ctx )
+{
+ if (MGA_CONTEXT(ctx)->RenderIndex & MGA_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
+
+void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint oldfallback = mmesa->Fallback;
+
+ if (mode) {
+ mmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ FLUSH_BATCH(mmesa);
+ _swsetup_Wakeup( ctx );
+ mmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ mmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = mgaCheckTexSizes;
+ tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive;
+ tnl->Driver.Render.Finish = mgaRenderFinish;
+ tnl->Driver.Render.BuildVertices = mgaBuildVertices;
+ mmesa->new_gl_state |= (_MGA_NEW_RENDERSTATE |
+ _MGA_NEW_RASTERSETUP);
+ }
+ }
+}
+
+
+void mgaDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ static int firsttime = 1;
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ mmesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = mgaRunPipeline;
+ tnl->Driver.Render.Start = mgaCheckTexSizes;
+ tnl->Driver.Render.Finish = mgaRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = mgaBuildVertices;
+ tnl->Driver.Render.Multipass = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatris.h b/xc/lib/GL/mesa/src/drv/mga/mgatris.h
index 5a16490e6..48d48f195 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgatris.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgatris.h
@@ -29,191 +29,14 @@
#ifndef MGATRIS_INC
#define MGATRIS_INC
-#include "types.h"
-#include "mgaioctl.h"
+#include "mtypes.h"
-extern void mgaDDChooseRenderState(GLcontext *ctx);
-extern void mgaDDTrifuncInit( void );
+extern void mgaDDInitTriFuncs( GLcontext *ctx );
+extern void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim );
-#define MGA_FLAT_BIT 0x1
-#define MGA_OFFSET_BIT 0x2
-#define MGA_TWOSIDE_BIT 0x4
-#define MGA_FALLBACK_BIT 0x8
-
-static __inline void mga_draw_triangle( mgaContextPtr mmesa,
- mgaVertex *v0,
- mgaVertex *v1,
- mgaVertex *v2 )
-{
- GLuint vertsize = mmesa->vertsize;
- GLuint *wv = mgaAllocVertexDwordsInline( mmesa, 3 * vertsize );
- int j;
-
-#if defined (USE_X86_ASM)
- /* GTH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)wv), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
-#else
- {
- for (j = 0 ; j < vertsize ; j++)
- wv[j] = v0->ui[j];
-
- wv += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- wv[j] = v1->ui[j];
-
- wv += vertsize;
- for (j = 0 ; j < vertsize ; j++)
- wv[j] = v2->ui[j];
- }
-#endif
-}
-
-
-static __inline void mga_draw_point( mgaContextPtr mmesa,
- mgaVertex *tmp, float sz )
-{
- GLuint vertsize = mmesa->vertsize;
- GLuint *wv = mgaAllocVertexDwords( mmesa, 6*vertsize);
- GLuint j;
- const GLfloat x = tmp->v.x + 0.125;
- const GLfloat y = tmp->v.y - 0.125;
-
- *(float *)&wv[0] = x - sz;
- *(float *)&wv[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x + sz;
- *(float *)&wv[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x + sz;
- *(float *)&wv[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x + sz;
- *(float *)&wv[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x - sz;
- *(float *)&wv[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x - sz;
- *(float *)&wv[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp->ui[j];
-}
-
-
-static __inline void mga_draw_line( mgaContextPtr mmesa,
- const mgaVertex *tmp0,
- const mgaVertex *tmp1,
- float width )
-{
- const GLuint vertsize = mmesa->vertsize;
- GLuint *wv = mgaAllocVertexDwords( mmesa, 6 * vertsize );
- GLuint j;
- GLfloat x0 = tmp0->v.x;
- GLfloat y0 = tmp0->v.y;
- GLfloat x1 = tmp1->v.x;
- GLfloat y1 = tmp1->v.y;
- GLfloat dx, dy, ix, iy;
- GLfloat hw;
-
- hw = 0.5F * width;
- if (hw > 0.1F && hw < 0.5F) {
- hw = 0.5F;
- }
-
- /* adjust vertices depending on line direction */
- dx = tmp0->v.x - tmp1->v.x;
- dy = tmp0->v.y - tmp1->v.y;
- if (dx * dx > dy * dy) {
- /* X-major line */
- ix = 0.0F;
- iy = hw;
- if (x1 < x0) {
- x0 += 0.5F;
- x1 += 0.5F;
- }
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- else {
- /* Y-major line */
- ix = hw;
- iy = 0.0F;
- if (y1 > y0) {
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- x0 += 0.5F;
- x1 += 0.5F;
- }
-
- *(float *)&wv[0] = x0 - ix;
- *(float *)&wv[1] = y0 - iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp0->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x1 + ix;
- *(float *)&wv[1] = y1 + iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp1->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x0 + ix;
- *(float *)&wv[1] = y0 + iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp0->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x0 - ix;
- *(float *)&wv[1] = y0 - iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp0->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x1 - ix;
- *(float *)&wv[1] = y1 - iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp1->ui[j];
- wv += vertsize;
-
- *(float *)&wv[0] = x1 + ix;
- *(float *)&wv[1] = y1 + iy;
- for (j = 2 ; j < vertsize ; j++)
- wv[j] = tmp1->ui[j];
- wv += vertsize;
-}
-
+extern void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode )
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h b/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
deleted file mode 100644
index 50c9f4852..000000000
--- a/xc/lib/GL/mesa/src/drv/mga/mgatritmp.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatritmp.h,v 1.6 2001/03/21 16:14:22 dawes Exp $ */
-
-static __inline void TAG(triangle)(GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv)
-{
- mgaContextPtr mmesa = MGA_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- mgaVertexPtr mgaverts = MGA_DRIVER_DATA(VB)->verts;
- mgaVertex *v[3];
-
-#if (IND & MGA_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[3];
-#endif
-
-#if (IND & (MGA_TWOSIDE_BIT | MGA_FLAT_BIT))
- GLuint c[3];
- GLuint s[3];
-#endif
-
- v[0] = &mgaverts[e0];
- v[1] = &mgaverts[e1];
- v[2] = &mgaverts[e2];
-
-#if (IND & (MGA_TWOSIDE_BIT | MGA_FLAT_BIT))
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
- s[0] = v[0]->ui[5];
- s[1] = v[1]->ui[5];
- s[2] = v[2]->ui[5];
-#endif
-
-
-#if (IND & (MGA_TWOSIDE_BIT | MGA_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & MGA_TWOSIDE_BIT)
- {
- GLuint facing = (cc > 0.0) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- GLubyte (*vbspec)[4] = VB->Spec[facing];
- if (IND & MGA_FLAT_BIT) {
- MGA_COLOR((char *)&v[0]->ui[4], vbcolor[pv]);
- v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- MGA_COLOR3((char *)&v[0]->ui[5], vbspec[pv]);
- v[2]->ui[5] = v[1]->ui[5] = v[0]->ui[5];
- } else {
- MGA_COLOR((char *)&v[0]->ui[4], vbcolor[e0]);
- MGA_COLOR((char *)&v[1]->ui[4], vbcolor[e1]);
- MGA_COLOR((char *)&v[2]->ui[4], vbcolor[e2]);
- MGA_COLOR3((char *)&v[0]->ui[5], vbspec[e0]);
- MGA_COLOR3((char *)&v[1]->ui[5], vbspec[e1]);
- MGA_COLOR3((char *)&v[2]->ui[5], vbspec[e2]);
- }
- }
-#endif
-
-#if (IND & MGA_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * mmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- if (cc * cc > 1e-16) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if (ac < 0.0f) ac = -ac;
- if (bc < 0.0f) bc = -bc;
- offset += MAX2(ac, bc) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- }
-#endif
- }
-#elif (IND & MGA_FLAT_BIT)
- {
- GLuint color = mgaverts[pv].ui[4];
- GLuint spec = mgaverts[pv].ui[5];
- v[0]->ui[4] = color;
- v[1]->ui[4] = color;
- v[2]->ui[4] = color;
- v[0]->ui[5] = spec;
- v[1]->ui[5] = spec;
- v[2]->ui[5] = spec;
- }
-#endif
-
- mga_draw_triangle( mmesa, v[0], v[1], v[2] );
-
-#if (IND & MGA_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
-#endif
-
-#if (IND & (MGA_FLAT_BIT | MGA_TWOSIDE_BIT))
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
- v[0]->ui[5] = s[0];
- v[1]->ui[5] = s[1];
- v[2]->ui[5] = s[2];
-#endif
-
-}
-
-
-
-
-static void TAG(quad)( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3,
- GLuint pv )
-{
- TAG(triangle)( ctx, v0, v1, v3, pv );
- TAG(triangle)( ctx, v1, v2, v3, pv );
-}
-
-
-static void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv )
-{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- mgaVertexPtr mgaVB = MGA_DRIVER_DATA(ctx->VB)->verts;
- float width = ctx->Line.Width;
- GLfloat z0, z1;
- GLuint c0, c1;
- GLuint s0, s1;
- mgaVertex *vert0 = &mgaVB[v0];
- mgaVertex *vert1 = &mgaVB[v1];
-
- if (IND & MGA_TWOSIDE_BIT) {
- GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
- GLubyte (*vbspec)[4] = ctx->VB->Specular;
-
- if (IND & MGA_FLAT_BIT) {
- MGA_COLOR((char *)&vert0->v.color,vbcolor[pv]);
- *(int *)&vert1->v.color = *(int *)&vert0->v.color;
- MGA_COLOR3((char *)&vert0->v.specular, vbspec[pv]);
- *(int *)&vert1->v.specular = *(int *)&vert0->v.specular;
- } else {
- MGA_COLOR((char *)&vert0->v.color,vbcolor[v0]);
- MGA_COLOR((char *)&vert1->v.color,vbcolor[v1]);
- MGA_COLOR3((char *)&vert0->v.specular, vbspec[v0]);
- MGA_COLOR3((char *)&vert1->v.specular, vbspec[v1]);
- }
- } else if (IND & MGA_FLAT_BIT) {
- c0 = *(GLuint *) &(vert0->v.color);
- c1 = *(GLuint *) &(vert1->v.color);
- *(int *)&vert0->v.color =
- *(int *)&vert1->v.color = *(int *)&mgaVB[pv].v.color;
- s0 = *(GLuint *) &(vert0->v.specular);
- s1 = *(GLuint *) &(vert1->v.specular);
- *(int *)&vert0->v.specular =
- *(int *)&vert1->v.specular = *(int *)&mgaVB[pv].v.specular;
- }
-
- if (IND & MGA_OFFSET_BIT) {
- GLfloat offset = ctx->LineZoffset * mmesa->depth_scale;
- z0 = vert0->v.z;
- z1 = vert1->v.z;
- vert0->v.z += offset;
- vert1->v.z += offset;
- }
-
- mga_draw_line( mmesa, &mgaVB[v0], &mgaVB[v1], width );
-
- if (IND & MGA_OFFSET_BIT) {
- vert0->v.z = z0;
- vert1->v.z = z1;
- }
-
- if ((IND & MGA_FLAT_BIT) && !(IND & MGA_TWOSIDE_BIT)) {
- *(GLuint *) &(vert0->v.color) = c0;
- *(GLuint *) &(vert1->v.color) = c1;
- *(GLuint *) &(vert0->v.specular) = s0;
- *(GLuint *) &(vert1->v.specular) = s1;
- }
-}
-
-
-static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
-{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- struct vertex_buffer *VB = ctx->VB;
- mgaVertexPtr mgaVB = MGA_DRIVER_DATA(VB)->verts;
- GLfloat sz = ctx->Point.Size * .5;
- int i;
-
- for(i=first;i<last;i++)
- if(VB->ClipMask[i]==0) {
- if (IND & (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT)) {
- mgaVertex tmp0 = mgaVB[i];
- if (IND & MGA_TWOSIDE_BIT) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
- MGA_COLOR((char *)&tmp0.v.color, vbcolor[i]);
- }
- if (IND & MGA_OFFSET_BIT) {
- GLfloat offset = ctx->PointZoffset * mmesa->depth_scale;
- tmp0.v.z += offset;
- }
- mga_draw_point( mmesa, &tmp0, sz );
- } else
- mga_draw_point( mmesa, &mgaVB[i], sz );
- }
-}
-
-
-
-
-static void TAG(init)( void )
-{
- tri_tab[IND] = TAG(triangle);
- quad_tab[IND] = TAG(quad);
- line_tab[IND] = TAG(line);
- points_tab[IND] = TAG(points);
-}
-
-
-#undef IND
-#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
index d5ae1b5f2..05bd1db50 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c
@@ -28,484 +28,469 @@
#include "mgacontext.h"
#include "mgavb.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
#include "mga_xmesa.h"
-#include "stages.h"
+#include "glheader.h"
+#include "mtypes.h"
#include "mem.h"
+#include "macros.h"
+#include "colormac.h"
+#include "mmath.h"
+
+#include "tnl/t_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast/swrast.h"
#include <stdio.h>
#include <stdlib.h>
-#define TEX0 { \
- v->v.tu0 = tc0[i][0]; \
- v->v.tv0 = tc0[i][1]; \
-}
-#define TEX1 { \
- v->v.tu1 = tc1[i][0]; \
- v->v.tv1 = tc1[i][1]; \
-}
+#define MGA_TEX1_BIT 0x1
+#define MGA_TEX0_BIT 0x2
+#define MGA_RGBA_BIT 0x4
+#define MGA_SPEC_BIT 0x8
+#define MGA_FOG_BIT 0x10
+#define MGA_XYZW_BIT 0x20
+#define MGA_PTEX_BIT 0x40
+#define MGA_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[MGA_MAX_SETUP];
+
+
+#define TINY_VERTEX_FORMAT 0
+#define NOTEX_VERTEX_FORMAT 0
+#define TEX0_VERTEX_FORMAT (MGA_A|MGA_S|MGA_F)
+#define TEX1_VERTEX_FORMAT (MGA_A|MGA_S|MGA_F|MGA_T2)
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & MGA_XYZW_BIT)
+#define DO_RGBA (IND & MGA_RGBA_BIT)
+#define DO_SPEC (IND & MGA_SPEC_BIT)
+#define DO_FOG (IND & MGA_FOG_BIT)
+#define DO_TEX0 (IND & MGA_TEX0_BIT)
+#define DO_TEX1 (IND & MGA_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & MGA_PTEX_BIT)
+
+
+#define VERTEX mgaVertex
+#define LOCALVARS mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+#define GET_VIEWPORT_MAT() mmesa->hw_viewport
+#define GET_TEXSOURCE(n) mmesa->tmu_source[n]
+#define GET_VERTEX_FORMAT() mmesa->vertex_format
+#define GET_VERTEX_STORE() mmesa->verts
+#define GET_VERTEX_STRIDE_SHIFT() mmesa->vertex_stride_shift
+#define GET_UBYTE_COLOR_STORE() &mmesa->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &mmesa->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 0
+#define HAVE_NOTEX_VERTICES 0
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS \
+ const GLfloat dx = - mmesa->drawX - SUBPIXEL_X; \
+ const GLfloat dy = (mmesa->driDrawable->h + \
+ mmesa->drawY + SUBPIXEL_Y); \
+ const GLfloat sz = 1.0 / mmesa->depth_scale
+
+#define UNVIEWPORT_X(x) x + dx;
+#define UNVIEWPORT_Y(y) - y + dy;
+#define UNVIEWPORT_Z(z) z * sz;
+
+#define PTEX_FALLBACK() FALLBACK(ctx, MGA_FALLBACK_TEXTURE, 1)
+
+
+#define IMPORT_FLOAT_COLORS mga_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS mga_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[MGA_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[MGA_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) mga_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
-#define SPC { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.red = spec[0]; \
- v->v.specular.green = spec[1]; \
- v->v.specular.blue = spec[2]; \
-}
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
-#define FOG { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.alpha = spec[3]; \
-}
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
-#define COL { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->v.color.blue = col[2]; \
- v->v.color.green = col[1]; \
- v->v.color.red = col[0]; \
- v->v.color.alpha = col[3]; \
-}
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-/* The v code we have doesn't seem to support projective texturing
- * in the multitexture case. (Would require another 1/w value for the
- * second set of texcoords). This may be a problem for the g400.
- */
-#define TEX0_4 \
- if (VB->TexCoordPtr[0]->size == 4) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
- v = &(MGA_DRIVER_DATA(VB)->verts[start]); \
- mmesa->setupdone &= ~MGA_WIN_BIT; \
- for (i = start; i < end; i++, v++) { \
- GLfloat oow = 1.0 / tc[i][3]; \
- v->v.rhw *= tc[i][3]; \
- v->v.tu0 *= oow; \
- v->v.tv0 *= oow; \
- } \
- }
-
-
-#define COORD \
- GLfloat *win = VB->Win.data[i]; \
- v->v.rhw = win[3]; \
- v->v.z = depth_scale * win[2]; \
- v->v.x = win[0] + xoffset; \
- v->v.y = - win[1] + yoffset;
-
-
-#define NOP
-
-
-
-
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,spec,fog) \
-static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \
-{ \
- mgaContextPtr mmesa = MGA_CONTEXT( VB->ctx ); \
- mgaVertexPtr v; \
- GLfloat (*tc0)[4]; \
- GLfloat (*tc1)[4]; \
- const GLfloat depth_scale = mmesa->depth_scale; \
- const GLfloat xoffset = mmesa->drawX + SUBPIXEL_X; \
- const GLfloat yoffset = mmesa->driDrawable->h + mmesa->drawY + \
- SUBPIXEL_Y; \
- int i; \
- (void) xoffset; (void) yoffset; (void) depth_scale; \
- gl_import_client_data( VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE|VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE)); \
- \
- tc0 = VB->TexCoordPtr[mmesa->tmu_source[0]]->data; \
- tc1 = VB->TexCoordPtr[mmesa->tmu_source[1]]->data; \
- \
- v = &(MGA_DRIVER_DATA(VB)->verts[start]); \
- \
- if (VB->ClipOrMask == 0) \
- for (i=start; i < end; i++, v++) { \
- win; \
- col; \
- tex0; \
- tex1; \
- spec; \
- fog; \
- } \
- else \
- for (i=start; i < end; i++, v++) { \
- if (VB->ClipMask[i] == 0) { \
- win; \
- tex0; \
- tex1; \
- spec; \
- fog; \
- } \
- col; \
- } \
- tex0_4; \
-}
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-SETUPFUNC(rs_wt0, COORD,NOP,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wt0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wft0, COORD,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wft0t1, COORD,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wg, COORD,COL,NOP,NOP,NOP,NOP,NOP)
-SETUPFUNC(rs_wgs, COORD,COL,NOP,NOP,NOP,SPC,NOP)
-SETUPFUNC(rs_wgt0, COORD,COL,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wgt0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_wgst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_wgst0t1, COORD,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_wgf, COORD,COL,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_wgfs, COORD,COL,NOP,NOP,NOP,SPC,FOG)
-SETUPFUNC(rs_wgft0, COORD,COL,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wgft0t1, COORD,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_wgfst0, COORD,COL,TEX0,NOP,TEX0_4,SPC,FOG)
-SETUPFUNC(rs_wgfst0t1, COORD,COL,TEX0,TEX1,TEX0_4,SPC,FOG)
-
-SETUPFUNC(rs_t0, NOP,NOP,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_t0t1, NOP,NOP,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_f, NOP,NOP,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_ft0, NOP,NOP,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_ft0t1, NOP,NOP,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_g, NOP,COL,NOP,NOP,NOP,NOP,NOP)
-SETUPFUNC(rs_gs, NOP,COL,NOP,NOP,NOP,SPC,NOP)
-SETUPFUNC(rs_gt0, NOP,COL,TEX0,NOP,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_gt0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,NOP)
-SETUPFUNC(rs_gst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_gst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,NOP)
-SETUPFUNC(rs_gf, NOP,COL,NOP,NOP,NOP,NOP,FOG)
-SETUPFUNC(rs_gfs, NOP,COL,NOP,NOP,NOP,SPC,FOG)
-SETUPFUNC(rs_gft0, NOP,COL,TEX0,NOP,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_gft0t1, NOP,COL,TEX0,TEX1,TEX0_4,NOP,FOG)
-SETUPFUNC(rs_gfst0, NOP,COL,TEX0,NOP,TEX0_4,SPC,FOG)
-SETUPFUNC(rs_gfst0t1, NOP,COL,TEX0,TEX1,TEX0_4,SPC,FOG)
-
-
-static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end)
-{
- fprintf(stderr, "mgaRasterSetup(): invalid combination\n");
-}
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
-typedef void (*setupFunc)(struct vertex_buffer *,GLuint,GLuint);
+#define IND (MGA_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
-static setupFunc setup_func[0x80];
+#define IND (MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-void mgaDDSetupInit( void )
-{
- int i;
-
- for (i = 0 ; i < 0x80 ; i++)
- setup_func[i] = rs_invalid;
-
- /* Functions to build vert's from scratch */
- setup_func[MGA_WIN_BIT|MGA_TEX0_BIT] = rs_wt0;
- setup_func[MGA_WIN_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wt0t1;
- setup_func[MGA_WIN_BIT|MGA_FOG_BIT|MGA_TEX0_BIT] = rs_wft0;
- setup_func[MGA_WIN_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wft0t1;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT] = rs_wg;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT] = rs_wgs;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT] = rs_wgt0;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wgt0t1;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT] = rs_wgst0;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wgst0t1;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT] = rs_wgf;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT] = rs_wgfs;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT] = rs_wgft0;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wgft0t1;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT] = rs_wgfst0;
- setup_func[MGA_WIN_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_wgfst0t1;
-
- /* Repair functions */
- setup_func[MGA_TEX0_BIT] = rs_t0;
- setup_func[MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_t0t1;
- setup_func[MGA_FOG_BIT] = rs_f;
- setup_func[MGA_FOG_BIT|MGA_TEX0_BIT] = rs_ft0;
- setup_func[MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_ft0t1;
- setup_func[MGA_RGBA_BIT] = rs_g;
- setup_func[MGA_RGBA_BIT|MGA_SPEC_BIT] = rs_gs;
- setup_func[MGA_RGBA_BIT|MGA_TEX0_BIT] = rs_gt0;
- setup_func[MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_gt0t1;
- setup_func[MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT] = rs_gst0;
- setup_func[MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_gst0t1;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT] = rs_gf;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT] = rs_gfs;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT] = rs_gft0;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_gft0t1;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT] = rs_gfst0;
- setup_func[MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT] = rs_gfst0t1;
+#define IND (MGA_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
-}
+#define IND (MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-void mgaPrintSetupFlags(char *msg, GLuint flags )
-{
- fprintf(stderr, "%s: %d %s%s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & MGA_WIN_BIT) ? " xyzw," : "",
- (flags & MGA_RGBA_BIT) ? " rgba," : "",
- (flags & MGA_SPEC_BIT) ? " spec," : "",
- (flags & MGA_FOG_BIT) ? " fog," : "",
- (flags & MGA_TEX0_BIT) ? " tex-0," : "",
- (flags & MGA_TEX1_BIT) ? " tex-1," : "",
- (flags & MGA_ALPHA_BIT) ? " alpha," : "");
-}
+#define IND (MGA_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_RGBA_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
-void mgaChooseRasterSetupFunc(GLcontext *ctx)
-{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- int funcindex = (MGA_WIN_BIT | MGA_RGBA_BIT);
- int multi = mmesa->multitex;
-
- mmesa->vertsize = 8;
- mmesa->tmu_source[0] = 0;
- mmesa->tmu_source[1] = 1;
- mmesa->tex_dest[0] = MGA_TEX0_BIT;
- mmesa->tex_dest[1] = MGA_TEX1_BIT;
- mmesa->multitex = 0;
- mmesa->blend_flags &= ~MGA_BLEND_MULTITEX;
-
- if (ctx->Texture.ReallyEnabled & 0xf) {
- /* This doesn't work for non-RGBA textures
- if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE)
- funcindex &= ~MGA_RGBA_BIT;
- */
- if ((ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
- mmesa->envcolor) || ctx->Texture.Unit[0].EnvMode == GL_DECAL)
- {
- mmesa->multitex = 1;
- mmesa->vertsize = 10;
- mmesa->tmu_source[1] = 0;
- funcindex |= MGA_TEX1_BIT;
- }
-
- funcindex |= MGA_TEX0_BIT;
- }
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
- if (ctx->Texture.ReallyEnabled & 0xf0) {
- if (ctx->Texture.ReallyEnabled & 0xf) {
- mmesa->multitex = 1;
- mmesa->vertsize = 10;
- mmesa->tmu_source[1] = 1;
- mmesa->blend_flags |= MGA_BLEND_MULTITEX;
- funcindex |= MGA_TEX1_BIT;
- } else {
- /* Just a funny way of doing single texturing
- */
- mmesa->tmu_source[0] = 1;
- mmesa->tex_dest[1] = MGA_TEX0_BIT;
-
- if ((ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
- mmesa->envcolor) || ctx->Texture.Unit[0].EnvMode == GL_DECAL)
- {
- mmesa->multitex = 1;
- mmesa->vertsize = 10;
- mmesa->tmu_source[1] = 1;
- funcindex |= MGA_TEX1_BIT;
- }
-
- funcindex |= MGA_TEX0_BIT;
- }
- }
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
- if (multi != mmesa->multitex)
- mmesa->new_state |= MGA_NEW_WARP;
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
- /* Not really a good place to do this - need to make the mga state
- * management code more event-driven so this can be calculated for
- * free.
- */
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
- if (ctx->Color.BlendEnabled)
- funcindex |= MGA_ALPHA_BIT;
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- funcindex |= MGA_SPEC_BIT;
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
- if (ctx->Fog.Enabled)
- funcindex |= MGA_FOG_BIT;
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
- if (0)
- mgaPrintSetupFlags("xsmesa: full setup function", funcindex);
- mmesa->dirty |= MGA_UPLOAD_PIPE;
- mmesa->setupindex = funcindex;
-
- /* Called by mesa's clip functons:
- */
- ctx->Driver.RasterSetup = setup_func[funcindex & ~MGA_ALPHA_BIT];
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
}
-void mgaDDCheckPartialRasterSetup( GLcontext *ctx, struct gl_pipeline_stage *d )
+void mgaPrintSetupFlags(char *msg, GLuint flags )
{
- mgaContextPtr mmesa = MGA_CONTEXT( ctx );
- GLuint tmp = mmesa->setupdone;
+ fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & MGA_XYZW_BIT) ? " xyzw," : "",
+ (flags & MGA_RGBA_BIT) ? " rgba," : "",
+ (flags & MGA_SPEC_BIT) ? " spec," : "",
+ (flags & MGA_FOG_BIT) ? " fog," : "",
+ (flags & MGA_TEX0_BIT) ? " tex-0," : "",
+ (flags & MGA_TEX1_BIT) ? " tex-1," : "");
+}
- d->type = 0;
- mmesa->setupdone = 0; /* cleared if we return */
- if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0)
- return;
+void mgaCheckTexSizes( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
- if (ctx->IndirectTriangles)
- return;
+ /*fprintf(stderr, "%s\n", __FUNCTION__);*/
- mmesa->setupdone = tmp;
+ if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) {
+ mmesa->SetupIndex |= MGA_PTEX_BIT;
+ mmesa->SetupNewInputs = ~0;
- /* disabled until we have a merge&render op */
- /* d->inputs = available; */
- /* d->outputs = VERT_RAST_SETUP_PART; */
- /* d->type = PIPE_PRECALC; */
+ if (!mmesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[mmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[mmesa->SetupIndex].copy_pv;
+ }
+ }
}
-/* Repair existing precalculated vertices with new data.
- */
-void mgaDDPartialRasterSetup( struct vertex_buffer *VB )
+void mgaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
{
- mgaContextPtr mmesa = MGA_CONTEXT( VB->ctx );
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
- GLuint ind = 0;
-
- if (new & VERT_WIN) {
- new = available;
- ind |= MGA_WIN_BIT | MGA_FOG_BIT;
- }
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ GLubyte *v = ((GLubyte *)mmesa->verts + (start<<mmesa->vertex_stride_shift));
+ GLuint stride = 1<<mmesa->vertex_stride_shift;
- if (new & VERT_RGBA)
- ind |= MGA_RGBA_BIT | MGA_SPEC_BIT;
+ newinputs |= mmesa->SetupNewInputs;
+ mmesa->SetupNewInputs = 0;
- if (new & VERT_TEX0_ANY)
- ind |= MGA_TEX0_BIT;
+ if (!newinputs)
+ return;
- if (new & VERT_TEX1_ANY)
- ind |= mmesa->tex_dest[1];
+ if (newinputs & VERT_CLIP) {
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
- if (new & VERT_FOG_COORD)
- ind |= MGA_FOG_BIT;
+ if (newinputs & VERT_RGBA)
+ ind |= MGA_RGBA_BIT;
+
+ if (newinputs & VERT_SPEC_RGB)
+ ind |= MGA_SPEC_BIT;
- mmesa->setupdone &= ~ind;
- ind &= mmesa->setupindex;
- mmesa->setupdone |= ind;
+ if (newinputs & VERT_TEX0)
+ ind |= MGA_TEX0_BIT;
- if (0)
- mgaPrintSetupFlags("xsmesa: partial setup function", ind);
-
- if (ind)
- setup_func[ind&~MGA_ALPHA_BIT]( VB, VB->Start, VB->Count );
-}
+ if (newinputs & VERT_TEX1)
+ ind |= MGA_TEX0_BIT|MGA_TEX1_BIT;
+ if (newinputs & VERT_FOG_COORD)
+ ind |= MGA_FOG_BIT;
-void mgaDDDoRasterSetup( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
-/* mgaContextPtr mmesa = MGA_CONTEXT( ctx ); */
+ if (mmesa->SetupIndex & MGA_PTEX_BIT)
+ ind = ~0;
- /* Can't lock, won't lock
- */
-/* REFRESH_DRAWABLE_INFO( mmesa ); */
+ ind &= mmesa->SetupIndex;
- if (VB->Type == VB_CVA_PRECALC)
- mgaDDPartialRasterSetup( VB );
- else if (ctx->Driver.RasterSetup)
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
}
-static void FatalError( char *s )
+
+void mgaChooseVertexState( GLcontext *ctx )
{
- fprintf(stderr, s);
- exit(1);
-}
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = MGA_XYZW_BIT|MGA_RGBA_BIT;
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= MGA_SPEC_BIT;
-void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size )
-{
- mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB);
-
- while (mvb->size < size)
- mvb->size *= 2;
-
- FREE( mvb->vert_store );
- mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31);
- if (!mvb->vert_store)
- FatalError("mga-glx: out of memory !\n");
-
- mvb->verts = (mgaVertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
-
- gl_vector1ui_free( &mvb->clipped_elements );
- gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start)
- FatalError("mga-glx: out of memory !\n");
-
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32);
- if (!VB->ClipMask)
- FatalError("mga-glx: out of memory !\n");
-
- if (VB->Type == VB_IMMEDIATE) {
- FREE( mvb->primitive );
- FREE( mvb->next_primitive );
- mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
- mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive)
- FatalError("mga-glx: out of memory!");
+ if (ctx->Fog.Enabled)
+ ind |= MGA_FOG_BIT;
+
+ if (ctx->Texture._ReallyEnabled & 0xf0) {
+ if (ctx->Texture._ReallyEnabled & 0xf) {
+ ind |= MGA_TEX1_BIT|MGA_TEX0_BIT;
+ }
+ else {
+ ind |= MGA_TEX0_BIT;
+ }
+ }
+ else if (ctx->Texture._ReallyEnabled & 0xf) {
+ ind |= MGA_TEX0_BIT;
+ }
+
+ mmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = mga_interp_extras;
+ tnl->Driver.Render.CopyPV = mga_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}
-}
+ if (setup_tab[ind].vertex_format != mmesa->vertex_format) {
+ FLUSH_BATCH(mmesa);
+ mmesa->new_state |= MGA_NEW_WARP;
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
+ mmesa->vertex_format = setup_tab[ind].vertex_format;
+ mmesa->vertex_size = setup_tab[ind].vertex_size;
+ mmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
+ }
+}
-void mgaDDRegisterVB( struct vertex_buffer *VB )
-{
- mgaVertexBufferPtr mvb;
- mvb = (mgaVertexBufferPtr)MALLOC( sizeof(*mvb) );
- /* This looks like it allocates a lot of memory, but it basically
- * just sets an upper limit on how much can be used - nothing like
- * this amount will ever be turned into 'real' memory.
- */
- mvb->size = VB->Size * 5;
- mvb->vert_store = MALLOC( sizeof(mgaVertex) * mvb->size + 31);
- if (!mvb->vert_store)
- FatalError("mga-glx: out of memory !\n");
+void mga_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint vertex_size = mmesa->vertex_size * 4;
+ GLuint *dest = mgaAllocDmaLow( mmesa, (count-start) * vertex_size);
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
+}
+
- mvb->verts = (mgaVertexPtr)(((unsigned long)mvb->vert_store + 31) & ~31);
- gl_vector1ui_alloc( &mvb->clipped_elements, VEC_WRITABLE, mvb->size, 32 );
- if (!mvb->clipped_elements.start)
- FatalError("mga-glx: out of memory !\n");
+void mgaInitVB( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC(sizeof(GLubyte) * mvb->size, 32);
- if (!VB->ClipMask)
- FatalError("mga-glx: out of memory !\n");
+ mmesa->verts = (char *)ALIGN_MALLOC(size * sizeof(mgaVertex), 32);
- mvb->primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
- mvb->next_primitive = (GLuint *)MALLOC( sizeof(GLuint) * mvb->size );
- if (!mvb->primitive || !mvb->next_primitive)
- FatalError("mga-glx: out of memory!");
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
- VB->driver_data = mvb;
+ mmesa->new_state |= MGA_NEW_WARP;
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
+ mmesa->vertex_format = setup_tab[0].vertex_format;
+ mmesa->vertex_size = setup_tab[0].vertex_size;
+ mmesa->vertex_stride_shift = setup_tab[0].vertex_stride_shift;
}
-void mgaDDUnregisterVB( struct vertex_buffer *VB )
+void mgaFreeVB( GLcontext *ctx )
{
- mgaVertexBufferPtr mvb = MGA_DRIVER_DATA(VB);
-
- if (mvb) {
- if (mvb->vert_store) FREE(mvb->vert_store);
- if (mvb->primitive) FREE(mvb->primitive);
- if (mvb->next_primitive) FREE(mvb->next_primitive);
- gl_vector1ui_free( &mvb->clipped_elements );
- FREE(mvb);
- VB->driver_data = 0;
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ if (mmesa->verts) {
+ ALIGN_FREE(mmesa->verts);
+ mmesa->verts = 0;
+ }
+
+ if (mmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE(mmesa->UbyteSecondaryColor.Ptr);
+ mmesa->UbyteSecondaryColor.Ptr = 0;
+ }
+
+ if (mmesa->UbyteColor.Ptr) {
+ ALIGN_FREE(mmesa->UbyteColor.Ptr);
+ mmesa->UbyteColor.Ptr = 0;
}
}
+
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.h b/xc/lib/GL/mesa/src/drv/mga/mgavb.h
index 399d946ec..2fd72ee70 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgavb.h
+++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.h
@@ -29,93 +29,37 @@
#ifndef MGAVB_INC
#define MGAVB_INC
-#include "types.h"
-#include "vb.h"
+#include "mtypes.h"
+#include "mgacontext.h"
+#include "swrast/swrast.h"
+#define _MGA_NEW_RASTERSETUP (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
-/* common datatypes for the mga warp engines */
-/*
- * color type for the vertex data
- * we probably want to use an internal datatype here?
- */
-typedef struct mga_warp_color_t {
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
-} mga_warp_color;
-
-
-
-/*
- * The vertex structure. The final tu1/tv1 values only used in multitexture
- * modes.
- */
-typedef struct mga_warp_vertex_t {
- GLfloat x,y,z; /* coordinates in screen space*/
- GLfloat rhw; /* reciprocal homogeneous w */
- mga_warp_color color; /* vertex color */
- mga_warp_color specular; /* specular color, alpha is fog */
- GLfloat tu0,tv0; /* texture coordinates */
- GLfloat tu1,tv1; /* same for second stage */
-} mga_warp_vertex;
-
-
-/* The fastpath code still expects a 16-float stride vertex.
- */
-union mga_vertex_t {
- mga_warp_vertex v;
- float f[16];
- GLuint ui[16];
-};
-
-typedef union mga_vertex_t mgaVertex;
-typedef union mga_vertex_t *mgaVertexPtr;
-
-struct mga_vertex_buffer_t {
- GLvector1ui clipped_elements;
- mgaVertexPtr verts;
- int last_vert;
- GLuint *primitive;
- GLuint *next_primitive;
- void *vert_store;
- GLuint size;
-
- GLuint *vert_buf;
- GLuint *elt_buf;
- GLuint vert_phys_start;
-};
-
-typedef struct mga_vertex_buffer_t *mgaVertexBufferPtr;
-
-#define MGA_CONTEXT(ctx) ((mgaContextPtr)((ctx)->DriverCtx))
-#define MGA_DRIVER_DATA(vb) ((mgaVertexBufferPtr)((vb)->driver_data))
-
-
-#define MGA_FOG_BIT MGA_F
-#define MGA_ALPHA_BIT MGA_A
-#define MGA_SPEC_BIT MGA_S
-#define MGA_TEX1_BIT MGA_T2
-#define MGA_TEX0_BIT 0x10 /* non-warp parameters */
-#define MGA_RGBA_BIT 0x20
-#define MGA_WIN_BIT 0x40
-
-struct gl_pipeline_stage;
+extern void mgaChooseVertexState( GLcontext *ctx );
+extern void mgaCheckTexSizes( GLcontext *ctx );
+extern void mgaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
-extern void mgaChooseRasterSetupFunc(GLcontext *ctx);
extern void mgaPrintSetupFlags(char *msg, GLuint flags );
-extern void mgaDDDoRasterSetup( struct vertex_buffer *VB );
-extern void mgaDDPartialRasterSetup( struct vertex_buffer *VB );
-extern void mgaDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d );
+extern void mgaInitVB( GLcontext *ctx );
+extern void mgaFreeVB( GLcontext *ctx );
-extern void mgaDDUnregisterVB( struct vertex_buffer *VB );
-extern void mgaDDRegisterVB( struct vertex_buffer *VB );
-extern void mgaDDResizeVB( struct vertex_buffer *VB, GLuint size );
+extern void mga_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
-extern void mgaDDSetupInit( void );
+extern void mga_translate_vertex(GLcontext *ctx,
+ const mgaVertex *src,
+ SWvertex *dst);
+extern void mga_print_vertex( GLcontext *ctx, const mgaVertex *v );
#endif
diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile b/xc/lib/GL/mesa/src/drv/r128/Imakefile
index e85916629..68243040e 100644
--- a/xc/lib/GL/mesa/src/drv/r128/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile
@@ -22,12 +22,14 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/r128/Imakefile,v 1.17 2001/05/10 16:56:11
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
@@ -63,7 +65,7 @@ InstallDynamicModule($(LIBNAME),$(MODULEDIR),dri)
#ifdef GlxSoProf
SOPROF_LIBNAME = _r128_dri_p
-NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(ALL_OBJS))
+NormalDepLibraryTarget($(SOPROF_LIBNAME),DONE $(OBJS),$(OBJS))
InstallLibrary($(SOPROF_LIBNAME),$(MODULEDIR)/dri)
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/r128/Imakefile.inc b/xc/lib/GL/mesa/src/drv/r128/Imakefile.inc
index daa6a4c09..e4e768aa2 100644
--- a/xc/lib/GL/mesa/src/drv/r128/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/r128/Imakefile.inc
@@ -17,109 +17,99 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#if BuildXF86DRI
DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
- DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \
- -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(GLXLIBSRC)/glx \
+ -I$(INCLUDESRC) \
+ -I$(INCLUDESRC)/GL \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/ati \
-I$(XF86COMSRC) \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
-MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESADRVSRCDIR)/common \
-I$(MESADRVSRCDIR)/r128
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
R128SRCS = $(MESADRVR128BUILDDIR)r128_context.c \
$(MESADRVR128BUILDDIR)r128_dd.c \
- $(MESADRVR128BUILDDIR)r128_fastpath.c \
- $(MESADRVR128BUILDDIR)r128_eltpath.c \
$(MESADRVR128BUILDDIR)r128_ioctl.c \
$(MESADRVR128BUILDDIR)r128_lock.c \
- $(MESADRVR128BUILDDIR)r128_pipeline.c \
$(MESADRVR128BUILDDIR)r128_screen.c \
$(MESADRVR128BUILDDIR)r128_span.c \
$(MESADRVR128BUILDDIR)r128_state.c \
$(MESADRVR128BUILDDIR)r128_tex.c \
+ $(MESADRVR128BUILDDIR)r128_texmem.c \
+ $(MESADRVR128BUILDDIR)r128_texstate.c \
$(MESADRVR128BUILDDIR)r128_tris.c \
- $(MESADRVR128BUILDDIR)r128_vb.c \
- $(MESADRVR128BUILDDIR)r128_xmesa.c
+ $(MESADRVR128BUILDDIR)r128_vb.c
R128OBJS = $(MESADRVR128BUILDDIR)r128_context.o \
$(MESADRVR128BUILDDIR)r128_dd.o \
- $(MESADRVR128BUILDDIR)r128_fastpath.o \
- $(MESADRVR128BUILDDIR)r128_eltpath.o \
$(MESADRVR128BUILDDIR)r128_ioctl.o \
$(MESADRVR128BUILDDIR)r128_lock.o \
- $(MESADRVR128BUILDDIR)r128_pipeline.o \
$(MESADRVR128BUILDDIR)r128_screen.o \
$(MESADRVR128BUILDDIR)r128_span.o \
$(MESADRVR128BUILDDIR)r128_state.o \
$(MESADRVR128BUILDDIR)r128_tex.o \
+ $(MESADRVR128BUILDDIR)r128_texmem.o \
+ $(MESADRVR128BUILDDIR)r128_texstate.o \
$(MESADRVR128BUILDDIR)r128_tris.o \
- $(MESADRVR128BUILDDIR)r128_vb.o \
- $(MESADRVR128BUILDDIR)r128_xmesa.o
+ $(MESADRVR128BUILDDIR)r128_vb.o
R128UOBJS = $(MESADRVR128BUILDDIR)unshared/r128_context.o \
$(MESADRVR128BUILDDIR)unshared/r128_dd.o \
- $(MESADRVR128BUILDDIR)unshared/r128_fastpath.o \
- $(MESADRVR128BUILDDIR)unshared/r128_eltpath.o \
$(MESADRVR128BUILDDIR)unshared/r128_ioctl.o \
$(MESADRVR128BUILDDIR)unshared/r128_lock.o \
- $(MESADRVR128BUILDDIR)unshared/r128_pipeline.o \
$(MESADRVR128BUILDDIR)unshared/r128_screen.o \
$(MESADRVR128BUILDDIR)unshared/r128_span.o \
$(MESADRVR128BUILDDIR)unshared/r128_state.o \
$(MESADRVR128BUILDDIR)unshared/r128_tex.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)unshared/r128_texstate.o \
$(MESADRVR128BUILDDIR)unshared/r128_tris.o \
- $(MESADRVR128BUILDDIR)unshared/r128_vb.o \
- $(MESADRVR128BUILDDIR)unshared/r128_xmesa.o
+ $(MESADRVR128BUILDDIR)unshared/r128_vb.o
R128DOBJS = $(MESADRVR128BUILDDIR)debugger/r128_context.o \
$(MESADRVR128BUILDDIR)debugger/r128_dd.o \
- $(MESADRVR128BUILDDIR)debugger/r128_fastpath.o \
- $(MESADRVR128BUILDDIR)debugger/r128_eltpath.o \
$(MESADRVR128BUILDDIR)debugger/r128_ioctl.o \
$(MESADRVR128BUILDDIR)debugger/r128_lock.o \
- $(MESADRVR128BUILDDIR)debugger/r128_pipeline.o \
$(MESADRVR128BUILDDIR)debugger/r128_screen.o \
$(MESADRVR128BUILDDIR)debugger/r128_span.o \
$(MESADRVR128BUILDDIR)debugger/r128_state.o \
$(MESADRVR128BUILDDIR)debugger/r128_tex.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)debugger/r128_texstate.o \
$(MESADRVR128BUILDDIR)debugger/r128_tris.o \
- $(MESADRVR128BUILDDIR)debugger/r128_vb.o \
- $(MESADRVR128BUILDDIR)debugger/r128_xmesa.o
+ $(MESADRVR128BUILDDIR)debugger/r128_vb.o
R128POBJS = $(MESADRVR128BUILDDIR)profiled/r128_context.o \
$(MESADRVR128BUILDDIR)profiled/r128_dd.o \
- $(MESADRVR128BUILDDIR)profiled/r128_fastpath.o \
- $(MESADRVR128BUILDDIR)profiled/r128_eltpath.o \
$(MESADRVR128BUILDDIR)profiled/r128_ioctl.o \
$(MESADRVR128BUILDDIR)profiled/r128_lock.o \
- $(MESADRVR128BUILDDIR)profiled/r128_pipeline.o \
$(MESADRVR128BUILDDIR)profiled/r128_screen.o \
$(MESADRVR128BUILDDIR)profiled/r128_span.o \
$(MESADRVR128BUILDDIR)profiled/r128_state.o \
$(MESADRVR128BUILDDIR)profiled/r128_tex.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_texmem.o \
+ $(MESADRVR128BUILDDIR)profiled/r128_texstate.o \
$(MESADRVR128BUILDDIR)profiled/r128_tris.o \
- $(MESADRVR128BUILDDIR)profiled/r128_vb.o \
- $(MESADRVR128BUILDDIR)profiled/r128_xmesa.o
+ $(MESADRVR128BUILDDIR)profiled/r128_vb.o
#ifdef NeedToLinkMesaSrc
LinkSourceFile(r128_context.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_dd.c, $(MESADRVSRCDIR)/r128)
-LinkSourceFile(r128_fastpath.c, $(MESADRVSRCDIR)/r128)
-LinkSourceFile(r128_eltpath.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_ioctl.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_lock.c, $(MESADRVSRCDIR)/r128)
-LinkSourceFile(r128_pipeline.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_screen.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_span.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_state.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_tex.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_texmem.c, $(MESADRVSRCDIR)/r128)
+LinkSourceFile(r128_texstate.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_tris.c, $(MESADRVSRCDIR)/r128)
LinkSourceFile(r128_vb.c, $(MESADRVSRCDIR)/r128)
-LinkSourceFile(r128_xmesa.c, $(MESADRVSRCDIR)/r128)
#endif
-
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.c b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
index 4e6c13e60..d637cd60a 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.c,v 1.6 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.c,v 1.5 2001/01/08 01:07:20 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -41,12 +41,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_state.h"
#include "r128_span.h"
#include "r128_tex.h"
+#include "r128_tris.h"
#include "r128_vb.h"
-#include "r128_pipeline.h"
+
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
#include "context.h"
#include "simple_list.h"
#include "mem.h"
+#include "matrix.h"
#ifndef R128_DEBUG
int R128_DEBUG = (0
@@ -62,25 +71,38 @@ int R128_DEBUG = (0
/* Create the device specific context.
*/
-GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
- __DRIcontextPrivate *driContextPriv )
+GLboolean r128CreateContext( Display *dpy, const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
{
- GLcontext *ctx = driContextPriv->mesaContext;
+ GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
r128ContextPtr rmesa;
r128ScreenPtr r128scrn;
int i;
+ /* Allocate the r128 context */
rmesa = (r128ContextPtr) CALLOC( sizeof(*rmesa) );
- if ( !rmesa ) return GL_FALSE;
+ if ( !rmesa )
+ return GL_FALSE;
- rmesa->glCtx = ctx;
- rmesa->display = dpy;
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, rmesa, GL_TRUE);
+ if (!rmesa->glCtx) {
+ FREE(rmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = rmesa;
+ ctx = rmesa->glCtx;
+ rmesa->display = dpy;
rmesa->driContext = driContextPriv;
rmesa->driScreen = sPriv;
- rmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
-
+ rmesa->driDrawable = NULL;
rmesa->hHWContext = driContextPriv->hHWContext;
rmesa->driHwLock = &sPriv->pSAREA->lock;
rmesa->driFd = sPriv->fd;
@@ -90,12 +112,6 @@ GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
rmesa->sarea = (R128SAREAPrivPtr)((char *)sPriv->pSAREA +
r128scrn->sarea_priv_offset);
- rmesa->tmp_matrix = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
- if ( !rmesa->tmp_matrix ) {
- FREE( rmesa );
- return GL_FALSE;
- }
-
rmesa->CurrentTexObj[0] = NULL;
rmesa->CurrentTexObj[1] = NULL;
@@ -109,15 +125,9 @@ GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
rmesa->lastTexHeap = r128scrn->numTexHeaps;
rmesa->RenderIndex = -1; /* Impossible value */
- rmesa->OnFastPath = 0;
-
rmesa->vert_buf = NULL;
rmesa->num_verts = 0;
- rmesa->elt_buf = NULL;
- rmesa->retained_buf = NULL;
- rmesa->vert_heap = r128scrn->buffers->list->address;
-
/* KW: Set the maximum texture size small enough that we can
* guarentee that both texture units can bind a maximal texture
* and have them both in on-card memory at once. (Kevin or
@@ -125,17 +135,29 @@ GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
*/
if ( r128scrn->texSize[0] < 2*1024*1024 ) {
ctx->Const.MaxTextureLevels = 9;
- ctx->Const.MaxTextureSize = (1 << 8);
} else if ( r128scrn->texSize[0] < 8*1024*1024 ) {
ctx->Const.MaxTextureLevels = 10;
- ctx->Const.MaxTextureSize = (1 << 9);
} else {
ctx->Const.MaxTextureLevels = 11;
- ctx->Const.MaxTextureSize = (1 << 10);
}
ctx->Const.MaxTextureUnits = 2;
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ /* No wide lines.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
#if ENABLE_PERF_BOXES
if ( getenv( "LIBGL_PERFORMANCE_BOXES" ) ) {
rmesa->boxes = 1;
@@ -144,35 +166,31 @@ GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
}
#endif
- ctx->DriverCtx = (void *)rmesa;
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
- r128DDInitExtensions( ctx );
+ /* Install the customized pipeline:
+ */
+/* _tnl_destroy_pipeline( ctx ); */
+/* _tnl_install_pipeline( ctx, r128_pipeline ); */
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ r128InitVB( ctx );
+ r128InitTriFuncs( ctx );
+ r128DDInitExtensions( ctx );
r128DDInitDriverFuncs( ctx );
r128DDInitIoctlFuncs( ctx );
r128DDInitStateFuncs( ctx );
r128DDInitSpanFuncs( ctx );
r128DDInitTextureFuncs( ctx );
-
- ctx->Driver.TriangleCaps = (DD_TRI_CULL |
- DD_TRI_LIGHT_TWOSIDE |
- DD_TRI_STIPPLE |
- DD_TRI_OFFSET);
-
- /* Ask Mesa to clip fog coordinates for us.
- */
- ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
-
- if ( ctx->VB )
- r128DDRegisterVB( ctx->VB );
-
- if ( ctx->NrPipelineStages ) {
- ctx->NrPipelineStages =
- r128DDRegisterPipelineStages( ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages );
- }
-
r128DDInitState( rmesa );
driContextPriv->driverPrivate = (void *)rmesa;
@@ -182,24 +200,42 @@ GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
/* Destroy the device specific context.
*/
-void r128DestroyContext( r128ContextPtr rmesa )
+void r128DestroyContext( __DRIcontextPrivate *driContextPriv )
{
+ r128ContextPtr rmesa = (r128ContextPtr) driContextPriv->driverPrivate;
+
+ assert(rmesa); /* should never be null */
if ( rmesa ) {
- r128TexObjPtr t, next_t;
- int i;
-
- for ( i = 0 ; i < rmesa->r128Screen->numTexHeaps ; i++ ) {
- foreach_s ( t, next_t, &rmesa->TexObjList[i] ) {
- r128DestroyTexObj( rmesa, t );
- }
- mmDestroy( rmesa->texHeap[i] );
+ if (rmesa->glCtx->Shared->RefCount == 1) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ r128TexObjPtr t, next_t;
+ int i;
+
+ for ( i = 0 ; i < rmesa->r128Screen->numTexHeaps ; i++ ) {
+ foreach_s ( t, next_t, &rmesa->TexObjList[i] ) {
+ r128DestroyTexObj( rmesa, t );
+ }
+ mmDestroy( rmesa->texHeap[i] );
+ }
+
+ foreach_s ( t, next_t, &rmesa->SwappedOut ) {
+ r128DestroyTexObj( rmesa, t );
+ }
}
- foreach_s ( t, next_t, &rmesa->SwappedOut ) {
- r128DestroyTexObj( rmesa, t );
- }
+ _swsetup_DestroyContext( rmesa->glCtx );
+ _tnl_DestroyContext( rmesa->glCtx );
+ _ac_DestroyContext( rmesa->glCtx );
+ _swrast_DestroyContext( rmesa->glCtx );
+
+ r128FreeVB( rmesa->glCtx );
+
+ /* free the Mesa context */
+ rmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(rmesa->glCtx);
- ALIGN_FREE( rmesa->tmp_matrix );
FREE( rmesa );
}
@@ -209,27 +245,50 @@ void r128DestroyContext( r128ContextPtr rmesa )
#endif
}
-/* Load the device specific context into the hardware. The actual
- * setting of the hardware state is done in the r128UpdateHWState().
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
*/
-r128ContextPtr r128MakeCurrent( r128ContextPtr oldCtx,
- r128ContextPtr newCtx,
- __DRIdrawablePrivate *dPriv )
+GLboolean
+r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
{
- if ( oldCtx ) {
- if ( oldCtx != newCtx ) {
- newCtx->new_state |= R128_NEW_CONTEXT;
- newCtx->dirty = R128_UPLOAD_ALL;
+ if ( driContextPriv ) {
+ GET_CURRENT_CONTEXT(ctx);
+ r128ContextPtr oldR128Ctx = ctx ? R128_CONTEXT(ctx) : NULL;
+ r128ContextPtr newR128Ctx = (r128ContextPtr) driContextPriv->driverPrivate;
+
+ if ( newR128Ctx != oldR128Ctx ) {
+ newR128Ctx->new_state |= R128_NEW_CONTEXT;
+ newR128Ctx->dirty = R128_UPLOAD_ALL;
}
- if ( oldCtx->driDrawable != dPriv ) {
- newCtx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
+
+ newR128Ctx->driDrawable = driDrawPriv;
+
+ _mesa_make_current2( newR128Ctx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+
+ newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
+
+ if ( !newR128Ctx->glCtx->Viewport.Width ) {
+ _mesa_set_viewport(newR128Ctx->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
}
} else {
- newCtx->new_state |= R128_NEW_CONTEXT;
- newCtx->dirty = R128_UPLOAD_ALL;
+ _mesa_make_current( 0, 0 );
}
- newCtx->driDrawable = dPriv;
+ return GL_TRUE;
+}
+
- return newCtx;
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean
+r128UnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
index c23b5848b..7f3a90ec9 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -40,13 +40,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xlibint.h>
-#include "dri_mesaint.h"
-#include "dri_tmm.h"
+#include "dri_util.h"
#include "xf86drm.h"
#include "xf86drmR128.h"
-#include "types.h"
+#include "mtypes.h"
#include "r128_sarea.h"
#include "r128_reg.h"
@@ -82,6 +81,16 @@ typedef struct r128_context *r128ContextPtr;
#define R128_FALLBACK_RENDER_MODE 0x0010
#define R128_FALLBACK_MULTIDRAW 0x0020
#define R128_FALLBACK_LOGICOP 0x0040
+#define R128_FALLBACK_SEP_SPECULAR 0x0080
+#define R128_FALLBACK_BLEND_EQ 0x0100
+#define R128_FALLBACK_BLEND_FUNC 0x0200
+
+
+/* Use the templated vertex format:
+ */
+#define TAG(x) r128##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
/* Reasons why the GL_BLEND fallback mightn't work:
*/
@@ -93,32 +102,19 @@ typedef struct r128_context *r128ContextPtr;
#define SUBPIXEL_X (0.0F)
#define SUBPIXEL_Y (0.125F)
-/* Offset for points:
- */
-#define PNT_X_OFFSET ( 0.125F)
-#define PNT_Y_OFFSET (-0.125F)
+typedef void (*r128_tri_func)( r128ContextPtr,
+ r128Vertex *,
+ r128Vertex *,
+ r128Vertex * );
-typedef void (*r128_interp_func)( GLfloat t,
- GLfloat *result,
- const GLfloat *in,
- const GLfloat *out );
+typedef void (*r128_line_func)( r128ContextPtr,
+ r128Vertex *,
+ r128Vertex * );
-struct r128_elt_tab {
- void (*emit_unclipped_verts)( struct vertex_buffer *VB );
+typedef void (*r128_point_func)( r128ContextPtr,
+ r128Vertex * );
- void (*build_tri_verts)( r128ContextPtr rmesa,
- struct vertex_buffer *VB,
- GLfloat *O, GLuint *elt );
-
- void (*interp)( GLfloat t, GLfloat *O,
- const GLfloat *I, const GLfloat *J );
-
- void (*project_and_emit_verts)( r128ContextPtr rmesa,
- const GLfloat *verts,
- GLuint *elts,
- GLuint nr );
-};
struct r128_context {
GLcontext *glCtx; /* Mesa context */
@@ -129,22 +125,32 @@ struct r128_context {
GLuint dirty; /* Hardware state to be updated */
r128_context_regs_t setup;
- GLuint vertsize;
- GLuint vc_format;
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
+
+ GLuint NewGLState;
+ GLuint Fallback;
+ GLuint SetupIndex;
+ GLuint SetupNewInputs;
+ GLuint RenderIndex;
+ GLfloat hw_viewport[16];
GLfloat depth_scale;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+ GLuint num_verts;
+ char *verts;
- GLuint Color; /* Current draw color */
- GLuint ClearColor; /* Color used to clear color buffer */
- GLuint ClearDepth; /* Value used to clear depth buffer */
- GLuint ClearStencil; /* Value used to clear stencil */
- GLuint DepthMask;
- GLuint StencilMask;
+ CARD32 ClearColor; /* Color used to clear color buffer */
+ CARD32 ClearDepth; /* Value used to clear depth buffer */
+ CARD32 ClearStencil; /* Value used to clear stencil */
/* Map GL texture units onto hardware
*/
GLint multitex;
GLint tmu_source[2];
- GLint tex_dest[2];
GLuint tex_combine[2];
GLuint blend_flags;
GLuint env_color;
@@ -157,41 +163,19 @@ struct r128_context {
memHeap_t *texHeap[R128_NR_TEX_HEAPS];
GLint lastTexAge[R128_NR_TEX_HEAPS];
GLint lastTexHeap;
-
- /* Current rendering state, fallbacks
+
+ /* Fallback rasterization functions
*/
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
-
- GLuint IndirectTriangles;
- GLuint Fallback;
-
- /* Fast path
- */
- GLuint SetupIndex;
- GLuint SetupDone;
- GLuint RenderIndex;
- GLuint OnFastPath;
- r128_interp_func interp;
- GLfloat *tmp_matrix;
+ r128_point_func draw_point;
+ r128_line_func draw_line;
+ r128_tri_func draw_tri;
/* Vertex buffers
*/
drmBufPtr vert_buf;
- GLuint num_verts;
- /* Elt path
- */
- drmBufPtr elt_buf, retained_buf;
- GLushort *first_elt, *next_elt;
- GLfloat *next_vert, *vert_heap;
- GLushort next_vert_index;
- GLushort first_vert_index;
- GLuint elt_vertsize;
- struct r128_elt_tab *elt_tab;
- GLfloat device_matrix[16];
+ GLuint hw_primitive;
+ GLenum render_primitive;
/* Page flipping
*/
@@ -248,26 +232,18 @@ struct r128_context {
(rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
-extern GLboolean r128CreateContext( Display *dpy, GLvisual *glVisual,
- __DRIcontextPrivate *driContextPriv );
-extern void r128DestroyContext( r128ContextPtr rmesa );
-extern r128ContextPtr r128MakeCurrent( r128ContextPtr oldCtx,
- r128ContextPtr newCtx,
- __DRIdrawablePrivate *dPriv );
+extern GLboolean r128CreateContext( Display *dpy,
+ const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
-/* ================================================================
- * Byte ordering
- */
-#include "X11/Xarch.h"
+extern void r128DestroyContext( __DRIcontextPrivate * );
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-#define LE32_OUT( x, y ) do { x = y; } while (0)
-#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)&(x) = y; } while (0)
-#else
-#include <byteswap.h>
-#define LE32_OUT( x, y ) do { x = bswap_32( y ); } while (0)
-#define LE32_OUT_FLOAT( x, y ) do { x = bswap_32( *(unsigned int *)&y ); } while (0)
-#endif
+extern GLboolean r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean r128UnbindContext( __DRIcontextPrivate *driContextPriv );
/* ================================================================
* Debugging:
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
index fd6223ff5..07899b74b 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.c,v 1.12 2001/04/10 16:07:52 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.c,v 1.9 2001/01/11 03:36:54 tsi Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -37,15 +37,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_ioctl.h"
#include "r128_state.h"
#include "r128_vb.h"
-#include "r128_pipeline.h"
#include "r128_dd.h"
#include "extensions.h"
-#if defined(USE_X86_ASM) || defined(USE_3DNOW_ASM) || defined(USE_KATMAI_ASM)
+#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#endif
-#define R128_DATE "20010405"
+#define R128_DATE "20010624"
/* Return the width and height of the current color buffer.
@@ -84,7 +83,7 @@ static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
strncat( buffer, " M3", 3 );
}
- /* Append any AGP/PCI-specific information.
+ /* Append any AGP-specific information.
*/
switch ( rmesa->r128Screen->AGPMode ) {
case 1:
@@ -101,10 +100,9 @@ static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
/* Append any CPU-specific information.
*/
#ifdef USE_X86_ASM
- if ( gl_x86_cpu_features ) {
+ if ( _mesa_x86_cpu_features ) {
strncat( buffer, " x86", 4 );
}
-#endif
#ifdef USE_MMX_ASM
if ( cpu_has_mmx ) {
strncat( buffer, "/MMX", 4 );
@@ -115,11 +113,12 @@ static const GLubyte *r128DDGetString( GLcontext *ctx, GLenum name )
strncat( buffer, "/3DNow!", 7 );
}
#endif
-#ifdef USE_KATMAI_ASM
+#ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
strncat( buffer, "/SSE", 4 );
}
#endif
+#endif
return (GLubyte *)buffer;
default:
@@ -166,62 +165,24 @@ static void r128DDFinish( GLcontext *ctx )
r128WaitForIdle( rmesa );
}
-/* Return various parameters requested by Mesa (this is deprecated).
- */
-static GLint r128DDGetParameteri( const GLcontext *ctx, GLint param )
-{
- switch ( param ) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- return 0;
- }
-}
/* Initialize the extensions supported by this driver.
*/
void r128DDInitExtensions( GLcontext *ctx )
{
- gl_extensions_disable( ctx, "GL_ARB_imaging" );
- gl_extensions_disable( ctx, "GL_ARB_texture_compression" );
- gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );
-
- gl_extensions_disable( ctx, "GL_EXT_blend_color" );
- gl_extensions_disable( ctx, "GL_EXT_blend_func_separate" );
- gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
- gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
- gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
- gl_extensions_disable( ctx, "GL_EXT_convolution" );
- gl_extensions_disable( ctx, "GL_EXT_paletted_texture" );
- gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
- gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
- gl_extensions_disable( ctx, "GL_EXT_texture_env_combine" );
-
- gl_extensions_disable( ctx, "GL_HP_occlusion_test" );
-
- gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
-
- gl_extensions_disable( ctx, "GL_SGI_color_matrix" );
- gl_extensions_disable( ctx, "GL_SGI_color_table" );
- gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
+ _mesa_enable_extension( ctx, "GL_ARB_texture_env_add" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
+ _mesa_enable_imaging_extensions( ctx );
}
/* Initialize the driver's misc functions.
*/
void r128DDInitDriverFuncs( GLcontext *ctx )
{
- ctx->Driver.GetBufferSize = r128DDGetBufferSize;
- ctx->Driver.GetString = r128DDGetString;
- ctx->Driver.Finish = r128DDFinish;
- ctx->Driver.Flush = r128DDFlush;
-
- ctx->Driver.Error = NULL;
- ctx->Driver.GetParameteri = r128DDGetParameteri;
-
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.Bitmap = NULL;
-
- ctx->Driver.RegisterVB = r128DDRegisterVB;
- ctx->Driver.UnregisterVB = r128DDUnregisterVB;
- ctx->Driver.BuildPrecalcPipeline = r128DDBuildPrecalcPipeline;
+ ctx->Driver.GetBufferSize = r128DDGetBufferSize;
+ ctx->Driver.GetString = r128DDGetString;
+ ctx->Driver.Finish = r128DDFinish;
+ ctx->Driver.Flush = r128DDFlush;
+ ctx->Driver.Error = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c b/xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c
deleted file mode 100644
index b3b592222..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c
+++ /dev/null
@@ -1,499 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_eltpath.c,v 1.4 2001/04/01 14:00:00 tsi Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-#include <stdio.h>
-
-#include "r128_context.h"
-#include "r128_pipeline.h"
-#include "r128_ioctl.h"
-#include "r128_tris.h"
-#include "r128_state.h"
-#include "r128_vb.h"
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-#include "mmath.h"
-#include "xform.h"
-
-
-/* Always use a full-sized stride for vertices. [FIXME]
- * Stride in the buffers must be a quadword multiple.
- */
-#define CLIP_STRIDE 10
-
-static void fire_elts( r128ContextPtr rmesa )
-{
- GLuint vertsize = rmesa->vertsize;
-
- LOCK_HARDWARE( rmesa );
-
- /* Fire queued elements and discard that buffer if its contents
- * won't be referenced by future elements.
- */
- if ( rmesa->elt_buf )
- {
- GLuint retain = (rmesa->elt_buf == rmesa->retained_buf);
-
- if ( rmesa->first_elt != rmesa->next_elt ) {
- r128FireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- !retain );
- } else if ( !retain ) {
- r128ReleaseBufLocked( rmesa, rmesa->elt_buf );
- }
-
- rmesa->elt_buf = 0;
- }
- else if ( rmesa->vert_buf )
- {
- r128FlushVerticesLocked( rmesa );
- }
-
- r128GetEltBufLocked( rmesa );
-
- UNLOCK_HARDWARE( rmesa );
-
- /* Give the compiler a chance to optimize the divisions.
- */
- switch ( vertsize ) {
- case 8:
- rmesa->next_vert_index = (GLushort)
- (((rmesa->elt_buf->idx + 1) *
- R128_BUFFER_SIZE / (8 * sizeof(GLuint))) - 1);
- rmesa->next_vert = (GLfloat *)
- ((char *)rmesa->vert_heap +
- rmesa->next_vert_index * 8 * sizeof(GLfloat));
- break;
-
- case 10:
- rmesa->next_vert_index = (GLushort)
- (((rmesa->elt_buf->idx + 1) *
- R128_BUFFER_SIZE / (10 * sizeof(GLuint))) - 1);
- rmesa->next_vert = (GLfloat *)
- ((char *)rmesa->vert_heap +
- rmesa->next_vert_index * 10 * sizeof(GLfloat));
- break;
- }
-
- rmesa->first_elt = rmesa->next_elt = (GLushort *)
- ((GLubyte *)rmesa->elt_buf->address + R128_INDEX_PRIM_OFFSET);
-
- rmesa->elt_vertsize = vertsize;
-}
-
-
-static void release_bufs( r128ContextPtr rmesa )
-{
- if ( rmesa->retained_buf && rmesa->retained_buf != rmesa->elt_buf )
- {
- LOCK_HARDWARE( rmesa );
- if ( rmesa->first_elt != rmesa->next_elt ) {
- r128FireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- 0 );
-
- ALIGN_NEXT_ELT( rmesa );
- rmesa->first_elt = rmesa->next_elt;
- }
-
- r128ReleaseBufLocked( rmesa, rmesa->retained_buf );
- UNLOCK_HARDWARE( rmesa );
- }
-
- rmesa->retained_buf = 0;
-}
-
-
-
-
-#define NEGATIVE( f ) (f < 0)
-#define DIFFERENT_SIGNS( a, b ) ((a * b) < 0)
-#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
-
-
-#define INTERP_RGBA( t, out, a, b ) { \
- GLuint i; \
- for ( i = 0 ; i < 4 ; i++ ) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR( a[i] ); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR( b[i] ); \
- GLfloat fo = LINTERP( t, fa, fb ); \
- FLOAT_COLOR_TO_UBYTE_COLOR( out[i], fo ); \
- } \
-}
-
-
-#define CLIP( SGN, V, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]]; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- for ( i = n = 0 ; i < nr ; i++ ) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i]; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert]; \
- outdata[n++] = next_vert++; \
- \
- if ( NEGATIVE( dpI ) ) { \
- GLfloat t = dpI / (dpI - dpJ); \
- interp( t, O, I, J ); \
- } \
- else \
- { \
- GLfloat t = dpJ / (dpJ - dpI); \
- interp( t, O, J, I ); \
- } \
- } \
- \
- if ( !NEGATIVE( dpI ) ) \
- outdata[n++] = elt_i; \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if ( n < 3 ) return; \
- } \
-} while (0)
-
-
-static void r128_tri_clip( r128ContextPtr rmesa,
- struct vertex_buffer *VB,
- GLuint *elt,
- GLubyte mask )
-{
- struct r128_elt_tab *tab = rmesa->elt_tab;
- r128_interp_func interp = tab->interp;
- GLuint vertsize = rmesa->vertsize;
- GLuint inlist[2][VB_MAX_CLIPPED_VERTS];
- GLuint in = 0;
- GLuint n = 3, next_vert = 3;
- GLuint i;
- GLfloat verts[VB_MAX_CLIPPED_VERTS][CLIP_STRIDE];
-
- /* Build temporary vertices in clipspace. This is the potential
- * downside to this path.
- */
- tab->build_tri_verts( rmesa, VB, (GLfloat *)verts, elt );
-
- inlist[0][0] = 0;
- inlist[0][1] = 1;
- inlist[0][2] = 2;
-
- CLIP( -, 0, CLIP_RIGHT_BIT );
- CLIP( +, 0, CLIP_LEFT_BIT );
- CLIP( -, 1, CLIP_TOP_BIT );
- CLIP( +, 1, CLIP_BOTTOM_BIT );
- CLIP( -, 2, CLIP_FAR_BIT );
- CLIP( +, 2, CLIP_NEAR_BIT );
-
-
- {
- GLuint *out = inlist[in];
- GLint space = (GLint)((char *)rmesa->next_vert -
- (char *)rmesa->next_elt);
-
- if ( space < (GLint)(n * (vertsize + 2) * sizeof(GLuint)) ) {
- fire_elts( rmesa );
- }
-
- /* Project the new vertices and emit to dma buffers. Translate
- * out values to physical addresses for setup dma.
- */
- tab->project_and_emit_verts( rmesa, (GLfloat *)verts, out, n );
-
- /* Convert the planar polygon to a list of triangles and emit to
- * elt buffers.
- */
- for ( i = 2 ; i < n ; i++ ) {
- rmesa->next_elt[0] = (GLushort) out[0];
- rmesa->next_elt[1] = (GLushort) out[i-1];
- rmesa->next_elt[2] = (GLushort) out[i];
- rmesa->next_elt += 3;
- }
- }
-}
-
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-
-#define INIT( x )
-
-#define TRI_THRESHOLD (GLint)(2 * sizeof(GLuint))
-
-#define UNCLIPPED_VERT( x ) (GLushort)(rmesa->first_vert_index - x)
-
-#define TRIANGLE( e2, e1, e0 ) \
-do { \
- if ( (GLint)((char *)rmesa->next_vert - \
- (char *)rmesa->next_elt) < TRI_THRESHOLD ) { \
- fire_elts( rmesa ); \
- } \
- rmesa->next_elt[0] = UNCLIPPED_VERT( e2 ); \
- rmesa->next_elt[1] = UNCLIPPED_VERT( e1 ); \
- rmesa->next_elt[2] = UNCLIPPED_VERT( e0 ); \
- rmesa->next_elt += 3; \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask = mask[e2] | mask[e1] | mask[e0]; \
- if ( ormask == 0 ) { \
- TRIANGLE( e2, e1, e0 ); \
- } else if ( (mask[e2] & mask[e1] & mask[e0]) == 0 ) { \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- r128_tri_clip( rmesa, VB, out, ormask ); \
- } \
-} while (0)
-
-#define LOCAL_VARS \
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx); \
- GLuint *elt = VB->EltPtr->data; \
- GLuint out[VB_MAX_CLIPPED_VERTS]; \
- GLubyte *mask = VB->ClipMask; \
- (void) mask; (void) out; (void) elt; (void) rmesa;
-
-
-
-#define RENDER_POINTS( start, count )
-#define RENDER_LINE( i1, i0 )
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
- CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] )
-
-#define TAG(x) r128_##x##_elt
-#include "render_tmp.h"
-
-
-
-#define LOCAL_VARS \
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx); \
- GLuint *elt = VB->EltPtr->data; \
- (void) elt; (void) rmesa;
-
-#define RENDER_POINTS( start, count )
-#define RENDER_LINE( i1, i0 )
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
- TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- TRIANGLE( elt[i2], elt[i1], elt[i0] )
-
-#define TAG(x) r128_##x##_elt_unclipped
-#include "render_tmp.h"
-
-
-
-
-static void refresh_projection_matrix( GLcontext *ctx )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat *m = rmesa->device_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY] + rmesa->driDrawable->h;
- m[MAT_SZ] = mat->m[MAT_SZ] * rmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * rmesa->depth_scale;
-}
-
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-
-
-#define TYPE (0)
-#define TAG(x) x
-#include "r128_elttmp.h"
-
-#define TYPE (R128_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "r128_elttmp.h"
-
-#define TYPE (R128_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "r128_elttmp.h"
-
-#define TYPE (R128_RGBA_BIT|R128_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "r128_elttmp.h"
-
-#define TYPE (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "r128_elttmp.h"
-
-#define TYPE (R128_TEX0_BIT|R128_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "r128_elttmp.h"
-
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct r128_elt_tab r128EltTab[R128_MAX_SETUPFUNC];
-
-void r128DDEltPathInit( void )
-{
- r128_render_init_elt();
- r128_render_init_elt_unclipped();
-
- r128_init_eltpath( &r128EltTab[0] );
- r128_init_eltpath_RGBA( &r128EltTab[R128_RGBA_BIT] );
- r128_init_eltpath_TEX0( &r128EltTab[R128_TEX0_BIT] );
- r128_init_eltpath_RGBA_TEX0( &r128EltTab[R128_RGBA_BIT|R128_TEX0_BIT] );
- r128_init_eltpath_TEX0_TEX1( &r128EltTab[R128_TEX0_BIT|R128_TEX1_BIT] );
- r128_init_eltpath_RGBA_TEX0_TEX1( &r128EltTab[(R128_RGBA_BIT |
- R128_TEX0_BIT |
- R128_TEX1_BIT)] );
-}
-
-#define VALID_SETUP (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
-
-
-
-/* Use a temporary array for device coordinates, so that we can easily
- * tap into existing mesa assembly. Otherwise consider emitting
- * device coordinates to dma buffers directly from the project/cliptest
- * routine. (requires output stride, potential loss of writecombining
- * efficiency?)
- *
- * This path is a lot closer to the standard vertex path in the
- * initial stages than the original fastpath. A slightly more optimal
- * path could be constructed, but would require us to write new
- * assembly.
- */
-void r128DDEltPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct r128_elt_tab *tab = &r128EltTab[rmesa->SetupIndex & VALID_SETUP];
- GLuint vertsize = rmesa->vertsize;
- GLint space;
-
- VB->ClipPtr = TransformRaw( &VB->Clip,
- &ctx->ModelProjectMatrix,
- VB->ObjPtr );
-
- refresh_projection_matrix( ctx );
-
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- VB->Projected = gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &VB->Win,
- VB->ClipMask,
- &VB->ClipOrMask,
- &VB->ClipAndMask );
-
- if ( VB->ClipAndMask )
- return;
-
- if ( rmesa->vert_buf )
- r128FlushVertices( rmesa );
-
- if ( rmesa->new_state )
- r128DDUpdateHWState( ctx );
-
- space = (GLint)((char *)rmesa->next_vert -
- (char *)rmesa->next_elt);
-
- /* Allocate a single buffer to hold unclipped vertices. All
- * unclipped vertices must be contiguous.
- */
- if ( space < (GLint)(VB->Count * vertsize * sizeof(GLuint)) ||
- rmesa->vertsize != rmesa->elt_vertsize ) {
- fire_elts( rmesa );
- }
-
- rmesa->retained_buf = rmesa->elt_buf;
-
- /* Emit unclipped vertices to the buffer.
- */
- tab->emit_unclipped_verts( VB );
-
- /* Emit indices and clipped vertices to one or more buffers.
- */
- if ( VB->ClipOrMask ) {
- rmesa->elt_tab = tab;
- r128_render_tab_elt[prim]( VB, 0, VB->EltPtr->count, 0 );
- } else {
- r128_render_tab_elt_unclipped[prim]( VB, 0, VB->EltPtr->count, 0 );
- }
-
- /* Send to hardware and release the elt buffer.
- */
- release_bufs( rmesa );
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h
deleted file mode 100644
index 11e30fbfe..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_elttmp.h,v 1.2 2001/01/08 01:07:20 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-/* Buffers fill from high addresses down with vertices and from low
- * addresses up with elements.
- */
-
-
-/* Emit the bulk of the vertices to the first dma buffer. Leave
- * empty slots for clipped vertices so that we can still address
- * vertices by index.
- */
-static void TAG(emit_unclipped_verts)( struct vertex_buffer *VB )
-{
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx);
- GLfloat *dev = VB->Projected->start;
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
- GLuint buffer_stride = rmesa->vertsize;
-
- GLfloat *f = rmesa->next_vert;
- GLuint count = VB->Count;
- GLubyte *clipmask = VB->ClipMask;
-
- const GLfloat *m = rmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
- GLuint i;
-
- rmesa->retained_buf = rmesa->elt_buf;
- rmesa->first_vert_index = rmesa->next_vert_index;
-
- for ( i = 0 ; i < count ; f -= buffer_stride, i++ )
- {
- if ( !clipmask[i] )
- {
- f[0] = sx * dev[0] + tx;
- f[1] = sy * dev[1] + ty;
- f[2] = sz * dev[2] + tz;
- f[3] = dev[3];
-
- if ( TYPE & R128_RGBA_BIT ) {
-#if 0 /*defined(USE_X86_ASM)*/
- __asm__ ( "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (f)
- : "%eax" );
-#else
- GLubyte *b = (GLubyte *)&f[4];
- b[CLIP_UBYTE_B] = color[2];
- b[CLIP_UBYTE_G] = color[1];
- b[CLIP_UBYTE_R] = color[0];
- b[CLIP_UBYTE_A] = color[3];
-#endif
- }
-
- if ( TYPE & R128_TEX0_BIT ) {
- *(GLuint *)&f[6] = *(GLuint *)&tex0_data[0];
- *(GLuint *)&f[7] = *(GLuint *)&tex0_data[1];
- }
-
- if ( TYPE & R128_TEX1_BIT ) {
- *(GLuint *)&f[8] = *(GLuint *)&tex1_data[0];
- *(GLuint *)&f[9] = *(GLuint *)&tex1_data[1];
- }
- }
-
- STRIDE_F( dev, 16 );
- if ( TYPE & R128_RGBA_BIT ) color += color_stride;
- if ( TYPE & R128_TEX0_BIT ) STRIDE_F( tex0_data, tex0_stride );
- if ( TYPE & R128_TEX1_BIT ) STRIDE_F( tex1_data, tex1_stride );
- }
-
- rmesa->next_vert = f;
- rmesa->next_vert_index -= count;
-}
-
-
-/* Build three temporary clipspace vertex for clipping a triangle.
- * Recreate from the VB data rather than trying to read back from
- * uncached memory.
- */
-static void TAG(build_tri_verts)( r128ContextPtr rmesa,
- struct vertex_buffer *VB,
- GLfloat *O,
- GLuint *elt )
-{
- GLint i;
-
- for ( i = 0 ; i < 3 ; i++, O += CLIP_STRIDE ) {
- GLfloat *clip = VB->Clip.start + elt[i]*4;
-
- O[0] = clip[0];
- O[1] = clip[1];
- O[2] = clip[2];
- O[3] = clip[3];
-
- if ( TYPE & R128_RGBA_BIT ) {
- GLubyte *col = VEC_ELT( VB->ColorPtr, GLubyte, elt[i] );
- GLubyte *b = (GLubyte *)&O[4];
- b[CLIP_UBYTE_R] = col[0];
- b[CLIP_UBYTE_G] = col[1];
- b[CLIP_UBYTE_B] = col[2];
- b[CLIP_UBYTE_A] = col[3];
- }
-
- *(GLuint *)&O[5] = UNCLIPPED_VERT(elt[i]);
-
- if ( TYPE & R128_TEX0_BIT ) {
- GLfloat *tex0_data = VEC_ELT( VB->TexCoordPtr[0], GLfloat, elt[i] );
- *(int*)&O[6] = *(int*)&tex0_data[0];
- *(int*)&O[7] = *(int*)&tex0_data[1];
- }
-
- if ( TYPE & R128_TEX1_BIT ) {
- GLfloat *tex1_data = VEC_ELT( VB->TexCoordPtr[1], GLfloat, elt[i] );
- *(int*)&O[8] = *(int*)&tex1_data[0];
- *(int*)&O[9] = *(int*)&tex1_data[1];
- }
- }
-}
-
-
-/* Interpolate between two of the vertices constructed above.
- */
-static void TAG(interp)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP( t, I[0], J[0] );
- O[1] = LINTERP( t, I[1], J[1] );
- O[2] = LINTERP( t, I[2], J[2] );
- O[3] = LINTERP( t, I[3], J[3] );
-
- if ( TYPE & R128_RGBA_BIT ) {
- INTERP_RGBA( t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])) );
- }
-
- *(GLuint *)&O[5] = ~0; /* note that this is a new vertex */
-
- if ( TYPE & R128_TEX0_BIT ) {
- O[6] = LINTERP( t, I[6], J[6] );
- O[7] = LINTERP( t, I[7], J[7] );
- }
-
- if ( TYPE & R128_TEX1_BIT ) {
- O[8] = LINTERP( t, I[8], J[8] );
- O[9] = LINTERP( t, I[9], J[9] );
- }
-}
-
-
-
-/* When clipping is complete, scan the final vertex list and emit any
- * new ones to dma buffers. Update the element list to a format
- * suitable for sending to hardware.
- */
-static void TAG(project_and_emit_verts)( r128ContextPtr rmesa,
- const GLfloat *verts,
- GLuint *elt,
- GLuint nr)
-{
- GLfloat *O = rmesa->next_vert;
- GLushort index = rmesa->next_vert_index;
- GLuint buffer_stride = rmesa->vertsize;
-
- const GLfloat *m = rmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
- GLuint i;
-
- for ( i = 0 ; i < nr ; i++ ) {
- const GLfloat *I = &verts[elt[i] * CLIP_STRIDE];
- GLuint tmp = *(GLuint *)&I[5];
-
- if ( (elt[i] = tmp) == ~0 ) {
- GLfloat oow = 1.0 / I[3];
-
- elt[i] = index--;
-
- O[0] = sx * I[0] * oow + tx;
- O[1] = sy * I[1] * oow + ty;
- O[2] = sz * I[2] * oow + tz;
- O[3] = oow;
-
- if ( TYPE & R128_RGBA_BIT ) {
- *(GLuint *)&O[4] = *(GLuint *)&I[4];
- }
-
- if ( TYPE & R128_TEX0_BIT ) {
- *(GLuint *)&O[6] = *(GLuint *)&I[6];
- *(GLuint *)&O[7] = *(GLuint *)&I[7];
- }
-
- if ( TYPE & R128_TEX1_BIT ) {
- *(GLuint *)&O[8] = *(GLuint *)&I[8];
- *(GLuint *)&O[9] = *(GLuint *)&I[9];
- }
-
- O -= buffer_stride;
- }
- }
-
- rmesa->next_vert = O;
- rmesa->next_vert_index = index;
-}
-
-
-
-static void TAG(r128_init_eltpath)( struct r128_elt_tab *tab )
-{
- tab->emit_unclipped_verts = TAG(emit_unclipped_verts);
- tab->build_tri_verts = TAG(build_tri_verts);
- tab->interp = TAG(interp);
- tab->project_and_emit_verts = TAG(project_and_emit_verts);
-}
-
-#undef TYPE
-#undef TAG
-#undef STRIDE
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c
deleted file mode 100644
index 44c996125..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c,v 1.5 2001/01/08 01:07:20 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- *
- */
-
-#include "r128_state.h"
-#include "r128_vb.h"
-#include "r128_pipeline.h"
-#include "r128_ioctl.h"
-#include "r128_tris.h"
-
-#include "mmath.h"
-#include "cva.h"
-#include "vertices.h"
-
-
-struct r128_fast_tab {
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
- void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
-};
-
-#define POINT(x) r128_draw_point( rmesa, &vert[x], psize )
-#define LINE(x,y) r128_draw_line( rmesa, &vert[x], &vert[y], lwidth )
-#define TRI(x,y,z) r128_draw_triangle( rmesa, &vert[x], &vert[y], &vert[z] )
-
-
-/* Direct, and no clipping required. The clip funcs have not been
- * written yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for ( e = start ; e < count ; e++ ) \
- POINT( elt[e] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if ( parity ) { \
- GLuint tmp = e2; \
- e2 = e1; \
- e1 = tmp; \
- } \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI( e3, e2, e ); \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define LOCAL_VARS \
- r128VertexPtr vert = R128_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- r128ContextPtr rmesa = R128_CONTEXT(ctx); \
- const GLfloat lwidth = ctx->Line.Width; \
- const GLfloat psize = ctx->Point.Size; \
- (void) lwidth; (void) psize; (void) vert;
-
-#define TAG(x) r128_##x##_smooth_indirect
-#include "render_tmp.h"
-
-
-
-#define NEGATIVE( f ) (f < 0)
-#define DIFFERENT_SIGNS( a, b ) ((a * b) < 0)
-#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
-
-
-#define INTERP_RGBA( t, out, a, b ) \
-do { \
- int i; \
- for (i = 0; i < 4; i++) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
- GLfloat fo = LINTERP(t, fa, fb); \
- FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
- } \
-} while (0)
-
-
-#define CLIP( SGN, V, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- inlist[0] = vlist1; \
- for ( i = n = 0 ; i < nr ; i++ ) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t, *in, *out; \
- \
- if ( NEGATIVE( dpI ) ) { \
- t = dpI / (dpI - dpJ); \
- in = I; \
- out = J; \
- } else { \
- t = dpJ / (dpJ - dpI); \
- in = J; \
- out = I; \
- } \
- \
- interp( t, O, in, out ); \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if ( !NEGATIVE( dpI ) ) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if ( n < 3 ) return; \
- } \
-} while (0)
-
-#define LINE_CLIP( x, y, z, w, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLfloat dpI = DOT4V( I, x, y, z, w ); \
- GLfloat dpJ = DOT4V( J, x, y, z, w ); \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- \
- interp( t, O, I, J ); \
- \
- clipmask[next_vert] = 0; \
- \
- if ( NEGATIVE( dpI ) ) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; \
- elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; \
- elts[1] = next_vert++; \
- } \
- } else if ( NEGATIVE( dpI ) ) return; \
- } \
-} while (0)
-
-
-static __inline void r128_tri_clip( GLuint **p_elts,
- r128VertexPtr verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- r128_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint in = 0;
- GLuint n = 3;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP( -, 0, CLIP_RIGHT_BIT );
- CLIP( +, 0, CLIP_LEFT_BIT );
- CLIP( -, 1, CLIP_TOP_BIT );
- CLIP( +, 1, CLIP_BOTTOM_BIT );
- CLIP( -, 2, CLIP_FAR_BIT );
- CLIP( +, 2, CLIP_NEAR_BIT );
-
- /* Convert the planar polygon to a list of triangles */
- out = inlist[in];
-
- for ( i = 2 ; i < n ; i++ ) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static __inline void r128_line_clip( GLuint **p_elts,
- r128VertexPtr verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- r128_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP( 1, 0, 0, -1, CLIP_LEFT_BIT );
- LINE_CLIP( -1, 0, 0, 1, CLIP_RIGHT_BIT );
- LINE_CLIP( 0, 1, 0, -1, CLIP_TOP_BIT );
- LINE_CLIP( 0, -1, 0, 1, CLIP_BOTTOM_BIT );
- LINE_CLIP( 0, 0, 1, -1, CLIP_FAR_BIT );
- LINE_CLIP( 0, 0, -1, 1, CLIP_NEAR_BIT );
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-
-#define CLIP_POINT( e ) \
-do { \
- if (mask[e]) *out++ = e; \
-} while (0)
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out += 2; \
- if ( ormask ) { \
- out-=2; \
- if ( !(mask[e0] & mask[e1]) ) { \
- r128_line_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if ( ormask ) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0]) ) { \
- r128_tri_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-#define LOCAL_VARS \
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx); \
- r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB); \
- GLuint *elt = VB->EltPtr->data; \
- r128VertexPtr verts = r128VB->verts; \
- GLuint next_vert = r128VB->last_vert; \
- GLuint *out = r128VB->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
- r128_interp_func interp = rmesa->interp; \
- (void) interp; (void) verts;
-
-#define POSTFIX \
- r128VB->clipped_elements.count = out - r128VB->clipped_elements.data;\
- r128VB->last_vert = next_vert;
-
-
-#define INIT( x )
-
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint i; \
- for ( i = start ; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i0 ) \
-do { \
- CLIP_LINE( elt[i1], elt[i0] ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
-do { \
- CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] ); \
-} while (0)
-
-#define TAG(x) r128_##x##_clip_elt
-#include "render_tmp.h"
-
-
-
-/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_UBYTE_COLOR 4
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define TYPE (0)
-#define TAG(x) x
-#include "r128_fasttmp.h"
-
-#define TYPE (R128_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "r128_fasttmp.h"
-
-#define TYPE (R128_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "r128_fasttmp.h"
-
-#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "r128_fasttmp.h"
-
-#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "r128_fasttmp.h"
-
-/* This one *could* get away with sneaking TEX1 into the color and
- * specular slots, thus fitting inside a cache line. Would be even
- * better to switch to a smaller vertex.
- */
-#define TYPE (R128_TEX0_BIT | R128_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "r128_fasttmp.h"
-
-
-
-static void r128_render_elements_direct( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = r128_render_tab_smooth_indirect[prim];
- GLuint p = 0;
-
- if ( rmesa->new_state )
- r128DDUpdateHWState( ctx );
-
- do {
- func( VB, 0, nr, 0 );
- } while ( ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ) );
-}
-
-static void r128_project_vertices( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB);
- GLfloat *m = rmesa->tmp_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY] + rmesa->driDrawable->h;
- m[MAT_SZ] = mat->m[MAT_SZ] * rmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * rmesa->depth_scale;
-
- gl_project_v16( r128VB->verts[VB->CopyStart].f,
- r128VB->verts[r128VB->last_vert].f,
- m,
- 16 * 4 );
-}
-
-static void r128_project_clipped_vertices( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB);
- GLfloat *m = rmesa->tmp_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY] + rmesa->driDrawable->h;
- m[MAT_SZ] = mat->m[MAT_SZ] * rmesa->depth_scale;
- m[MAT_TZ] = mat->m[MAT_TZ] * rmesa->depth_scale;
-
- gl_project_clipped_v16( r128VB->verts[VB->CopyStart].f,
- r128VB->verts[r128VB->last_vert].f,
- m,
- 16 * 4,
- VB->ClipMask + VB->CopyStart );
-}
-
-static struct r128_fast_tab r128FastTab[R128_MAX_SETUPFUNC];
-
-void r128DDFastPathInit( void )
-{
- r128_render_init_clip_elt();
- r128_render_init_smooth_indirect();
-
- r128_init_fastpath( &r128FastTab[0] );
- r128_init_fastpath_RGBA( &r128FastTab[R128_RGBA_BIT] );
- r128_init_fastpath_TEX0( &r128FastTab[R128_TEX0_BIT] );
- r128_init_fastpath_RGBA_TEX0( &r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT] );
- r128_init_fastpath_TEX0_TEX1( &r128FastTab[R128_TEX0_BIT|R128_TEX1_BIT] );
- r128_init_fastpath_RGBA_TEX0_TEX1( &r128FastTab[(R128_RGBA_BIT |
- R128_TEX0_BIT |
- R128_TEX1_BIT)] );
-}
-
-#define VALID_SETUP (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT)
-
-void r128DDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct r128_fast_tab *tab = &r128FastTab[rmesa->SetupIndex & VALID_SETUP];
- GLuint do_cliptest = 1;
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- if ( ( gl_reduce_prim[prim] == GL_TRIANGLES ) &&
- ( VB->Count < (R128_BUFFER_SIZE / (10 * sizeof(GLuint))) ) &&
- ( ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL |
- MAT_FLAG_PERSPECTIVE) ) )
- {
- r128DDEltPath( VB );
- return;
- }
-
- /* Reserve enough space for the pathological case */
- if ( VB->EltPtr->count * 12 > R128_DRIVER_DATA(VB)->size ) {
- r128DDResizeVB( VB, VB->EltPtr->count * 12 );
- do_cliptest = 1;
- }
-
- tab->build_vertices( VB, do_cliptest ); /* object->clip space */
-
- if ( rmesa->new_state )
- r128DDUpdateHWState( ctx );
-
- if ( VB->ClipOrMask ) {
- if ( !VB->ClipAndMask ) {
- render_func *clip = r128_render_tab_clip_elt;
-
- rmesa->interp = tab->interp;
-
- clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(R128_DRIVER_DATA(VB)->clipped_elements);
-
- r128_project_clipped_vertices( VB ); /* clip->device space */
- r128_render_elements_direct( VB ); /* render using new list */
- }
- } else {
- r128_project_vertices( VB ); /* clip->device space */
- r128_render_elements_direct( VB ); /* render using orig list */
- }
-
- /* This indicates that there is no cached data to reuse */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h
deleted file mode 100644
index 4370a553c..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_fasttmp.h,v 1.3 2001/01/08 01:07:20 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-/* The first part of setup is applied to all vertices, clipped or
- * unclipped. This data will be used for clipping, and then all
- * vertices with a zero clipmask will be projected to device space.
- *
- * This could be split into several loops, but - it seems that the
- * large stride of the fxVertices makes cache issues the big
- * performance factor, and that multiple loops mean multiple cache
- * misses....
- */
-static void TAG(r128_setup_full)( struct vertex_buffer *VB,
- GLuint do_cliptest )
-{
- GLcontext *ctx = VB->ctx;
- r128VertexBufferPtr rvb = R128_DRIVER_DATA(VB);
- const GLfloat *m = ctx->ModelProjectMatrix.m;
- GLuint start = VB->CopyStart;
- GLuint count = VB->Count;
-
- gl_xform_points3_v16_general( rvb->verts[start].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count - start );
-
- if ( do_cliptest ) {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16( rvb->verts[start].f,
- rvb->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask + start );
- }
-
- /* These branches are all resolved at compile time. Hopefully all
- * the pointers are valid addresses even when not enabled.
- */
- if ( TYPE ) {
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
-
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
-
- GLfloat *f = rvb->verts[start].f;
- GLfloat *end = f + (16 * (count - start));
-
- while ( f != end ) {
- if ( TYPE & R128_RGBA_BIT ) {
-#if defined(USE_X86_ASM)
- /* GH: I'd like to get some accurate timing data on the
- * bswap instruction, but it gives a nice speedup anyway.
- */
- __asm__ ( "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (f)
- : "%eax" );
-#else
- GLubyte *col = color;
- GLubyte *b = (GLubyte *)&f[CLIP_UBYTE_COLOR];
- b[CLIP_UBYTE_B] = col[2];
- b[CLIP_UBYTE_G] = col[1];
- b[CLIP_UBYTE_R] = col[0];
- b[CLIP_UBYTE_A] = col[3];
-#endif
- }
- if ( TYPE & R128_TEX0_BIT ) {
-#if defined (USE_X86_ASM)
- __asm__ ( "movl (%%ecx), %%eax \n"
- "movl %%eax, 24(%%edi) \n"
- "movl 4(%%ecx), %%eax \n"
- "movl %%eax, 28(%%edi)"
- :
- : "c" (tex0_data), "D" (f)
- : "%eax" );
-#else
- *(GLuint *)(f+CLIP_S0) = *(GLuint *)tex0_data;
- *(GLuint *)(f+CLIP_T0) = *(GLuint *)(tex0_data+1);
-#endif
- }
- if ( TYPE & R128_TEX1_BIT ) {
- /* Hits a second cache line.
- */
-#if defined (USE_X86_ASM)
- __asm__ ( "movl (%%esi), %%eax \n"
- "movl %%eax, 32(%%edi) \n"
- "movl 4(%%esi), %%eax \n"
- "movl %%eax, 36(%%edi)"
- :
- : "S" (tex1_data), "D" (f)
- : "%eax" );
-#else
- *(GLuint *)(f+CLIP_S1) = *(GLuint *)tex1_data;
- *(GLuint *)(f+CLIP_T1) = *(GLuint *)(tex1_data+1);
-#endif
- }
- if ( TYPE & R128_RGBA_BIT ) color += color_stride;
- if ( TYPE & R128_TEX0_BIT ) STRIDE_F( tex0_data, tex0_stride );
- if ( TYPE & R128_TEX1_BIT ) STRIDE_F( tex1_data, tex1_stride );
- f += 16;
- }
- }
-
- rvb->clipped_elements.count = start;
- rvb->last_vert = count;
-}
-
-
-/* Changed to just put the interp func instead of the whole clip
- * routine into the header. Less code and better chance of doing some
- * of this stuff in assembly.
- */
-static void TAG(r128_interp_vert)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP( t, I[0], J[0] );
- O[1] = LINTERP( t, I[1], J[1] );
- O[2] = LINTERP( t, I[2], J[2] );
- O[3] = LINTERP( t, I[3], J[3] );
-
- if ( TYPE & R128_RGBA_BIT ) {
- INTERP_RGBA( t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])) );
- }
-
- if ( TYPE & R128_TEX0_BIT ) {
- O[6] = LINTERP( t, I[6], J[6] );
- O[7] = LINTERP( t, I[7], J[7] );
- }
-
- if ( TYPE & R128_TEX1_BIT ) {
- O[8] = LINTERP( t, I[8], J[8] );
- O[9] = LINTERP( t, I[9], J[9] );
- }
-}
-
-
-static void TAG(r128_init_fastpath)(struct r128_fast_tab *tab)
-{
- tab->build_vertices = TAG(r128_setup_full);
- tab->interp = TAG(r128_interp_vert);
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
index a82cfe8c2..996106141 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
@@ -37,6 +37,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_ioctl.h"
#include "mem.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
#define R128_TIMEOUT 2048
@@ -98,7 +101,7 @@ void r128FlushVerticesLocked( r128ContextPtr rmesa )
int nbox = rmesa->numClipRects;
drmBufPtr buffer = rmesa->vert_buf;
int count = rmesa->num_verts;
- int prim = R128_TRIANGLES;
+ int prim = rmesa->hw_primitive;
int fd = rmesa->driScreen->fd;
int i;
@@ -155,111 +158,6 @@ void r128FlushVerticesLocked( r128ContextPtr rmesa )
-/* ================================================================
- * Indexed vertex buffer handling
- */
-
-void r128GetEltBufLocked( r128ContextPtr rmesa )
-{
- rmesa->elt_buf = r128GetBufferLocked( rmesa );
-}
-
-void r128FireEltsLocked( r128ContextPtr rmesa,
- GLuint start, GLuint end,
- GLuint discard )
-{
- XF86DRIClipRectPtr pbox = rmesa->pClipRects;
- int nbox = rmesa->numClipRects;
- drmBufPtr buffer = rmesa->elt_buf;
- int prim = R128_TRIANGLES;
- int fd = rmesa->driScreen->fd;
- int i;
-
- if ( !buffer )
- return;
-
- if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS )
- r128EmitHwStateLocked( rmesa );
-
- if ( !nbox )
- end = start;
-
- if ( nbox >= R128_NR_SAREA_CLIPRECTS )
- rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
-
- if ( start == end || !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
- {
- if ( nbox < 3 ) {
- rmesa->sarea->nbox = 0;
- } else {
- rmesa->sarea->nbox = nbox;
- }
-
- drmR128FlushIndices( fd, prim, buffer->idx, start, end, discard );
- }
- else
- {
- for ( i = 0 ; i < nbox ; ) {
- int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
- XF86DRIClipRectPtr b = rmesa->sarea->boxes;
- int d = 0;
-
- rmesa->sarea->nbox = nr - i;
- for ( ; i < nr ; i++ ) {
- *b++ = pbox[i];
- }
-
- /* Finished with the buffer?
- */
- if ( nr == nbox ) {
- d = discard;
- }
-
- rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
- drmR128FlushIndices( fd, prim, buffer->idx, start, end, d );
- }
- }
-
- if ( R128_DEBUG & DEBUG_ALWAYS_SYNC ) {
- drmR128WaitForIdleCCE( rmesa->driFd );
- }
-
- rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
-}
-
-void r128FlushEltsLocked( r128ContextPtr rmesa )
-{
- if ( rmesa->first_elt != rmesa->next_elt ) {
- r128FireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- 0 );
-
- ALIGN_NEXT_ELT( rmesa );
- rmesa->first_elt = rmesa->next_elt;
- }
-}
-
-void r128ReleaseBufLocked( r128ContextPtr rmesa, drmBufPtr buffer )
-{
- int fd = rmesa->driScreen->fd;
-
- if ( !buffer )
- return;
-
- drmR128FlushVertexBuffer( fd, R128_TRIANGLES, buffer->idx, 0, 1 );
-}
-
-
-/* Allocate some space in the current vertex buffer. If the current
- * buffer is full, flush it and grab another one.
- */
-CARD32 *r128AllocVertices( r128ContextPtr rmesa, int count )
-{
- return r128AllocVerticesInline( rmesa, count );
-}
/* ================================================================
@@ -308,19 +206,7 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
int wait = 0;
while ( 1 ) {
-#if defined(__alpha__)
- /* necessary to preserve the Alpha paradigm */
- /* NOTE: this will not work on SPARSE machines */
- mem_barrier();
- frame = *(volatile CARD32 *)(void *)(R128MMIO + R128_LAST_FRAME_REG);
-#else
frame = INREG( R128_LAST_FRAME_REG );
-#endif
-
- if ( 0 )
- fprintf( stderr, " last=0x%08x frame=0x%08lx\n",
- rmesa->sarea->last_frame, (long)frame );
-
if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) {
break;
}
@@ -337,11 +223,16 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
/* Copy the back color buffer to the front color buffer.
*/
-void r128SwapBuffers( r128ContextPtr rmesa )
+void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
{
- GLint nbox;
- GLint i;
- GLint ret;
+ r128ContextPtr rmesa;
+ GLint nbox, i, ret;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "\n********************************\n" );
@@ -365,6 +256,8 @@ void r128SwapBuffers( r128ContextPtr rmesa )
rmesa->hardwareWentIdle = 0;
}
+ nbox = dPriv->numClipRects;
+
for ( i = 0 ; i < nbox ; ) {
GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , nbox );
XF86DRIClipRectPtr box = rmesa->pClipRects;
@@ -403,10 +296,17 @@ void r128SwapBuffers( r128ContextPtr rmesa )
#endif
}
-void r128PageFlip( r128ContextPtr rmesa )
+void r128PageFlip( const __DRIdrawablePrivate *dPriv )
{
+ r128ContextPtr rmesa;
GLint ret;
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
+
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "\n%s( %p ): page=%d\n\n",
__FUNCTION__, rmesa->glCtx, rmesa->currentPage );
@@ -468,14 +368,12 @@ void r128PageFlip( r128ContextPtr rmesa )
* Buffer clear
*/
-static GLbitfield r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch )
+static void r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
__DRIdrawablePrivate *dPriv = rmesa->driDrawable;
GLuint flags = 0;
- GLuint color_mask = 0;
- GLuint depth_mask = 0;
GLint i;
GLint ret;
@@ -485,109 +383,124 @@ static GLbitfield r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
FLUSH_BATCH( rmesa );
- /* Update and emit any new state. We need to do this here to catch
- * changes to the masks.
- * FIXME: Just update the masks?
+ /* The only state change we care about here is the RGBA colormask
+ * We'll just update that state, if needed. If we do more then
+ * there's some strange side-effects that the conformance tests find.
*/
- if ( rmesa->new_state )
+ if ( rmesa->new_state & R128_NEW_MASKS) {
+ const GLuint save_state = rmesa->new_state;
+ rmesa->new_state = R128_NEW_MASKS;
r128DDUpdateHWState( ctx );
+ rmesa->new_state = save_state & ~R128_NEW_MASKS;
+ }
if ( mask & DD_FRONT_LEFT_BIT ) {
flags |= DRM_R128_FRONT;
- color_mask = rmesa->setup.plane_3d_mask_c;
mask &= ~DD_FRONT_LEFT_BIT;
}
if ( mask & DD_BACK_LEFT_BIT ) {
flags |= DRM_R128_BACK;
- color_mask = rmesa->setup.plane_3d_mask_c;
mask &= ~DD_BACK_LEFT_BIT;
}
if ( ( mask & DD_DEPTH_BIT ) && ctx->Depth.Mask ) {
flags |= DRM_R128_DEPTH;
- depth_mask |= rmesa->DepthMask;
mask &= ~DD_DEPTH_BIT;
}
#if 0
/* FIXME: Add stencil support */
if ( mask & DD_STENCIL_BIT ) {
flags |= DRM_R128_DEPTH;
- depth_mask |= rmesa->StencilMask;
mask &= ~DD_STENCIL_BIT;
}
#endif
- if ( !flags )
- return mask;
+ if ( flags ) {
- /* Flip top to bottom */
- cx += dPriv->x;
- cy = dPriv->y + dPriv->h - cy - ch;
+ /* Flip top to bottom */
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
- LOCK_HARDWARE( rmesa );
-
- for ( i = 0 ; i < rmesa->numClipRects ; ) {
- GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects );
- XF86DRIClipRectPtr box = rmesa->pClipRects;
- XF86DRIClipRectPtr b = rmesa->sarea->boxes;
- GLint n = 0;
+ LOCK_HARDWARE( rmesa );
- if ( !all ) {
- for ( ; i < nr ; i++ ) {
- GLint x = box[i].x1;
- GLint y = box[i].y1;
- GLint w = box[i].x2 - x;
- GLint h = box[i].y2 - y;
-
- if ( x < cx ) w -= cx - x, x = cx;
- if ( y < cy ) h -= cy - y, y = cy;
- if ( x + w > cx + cw ) w = cx + cw - x;
- if ( y + h > cy + ch ) h = cy + ch - y;
- if ( w <= 0 ) continue;
- if ( h <= 0 ) continue;
-
- b->x1 = x;
- b->y1 = y;
- b->x2 = x + w;
- b->y2 = y + h;
- b++;
- n++;
- }
- } else {
- for ( ; i < nr ; i++ ) {
- *b++ = *(XF86DRIClipRectRec *)&box[i];
- n++;
- }
+ /* FIXME: Do we actually need this?
+ */
+ if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) {
+ r128EmitHwStateLocked( rmesa );
}
- rmesa->sarea->nbox = n;
+ for ( i = 0 ; i < rmesa->numClipRects ; ) {
+ GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects );
+ XF86DRIClipRectPtr box = rmesa->pClipRects;
+ XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ if ( x < cx ) w -= cx - x, x = cx;
+ if ( y < cy ) h -= cy - y, y = cy;
+ if ( x + w > cx + cw ) w = cx + cw - x;
+ if ( y + h > cy + ch ) h = cy + ch - y;
+ if ( w <= 0 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = *(XF86DRIClipRectPtr)&box[i];
+ n++;
+ }
+ }
- if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) {
- fprintf( stderr,
- "drmR128Clear: flag 0x%x color %x depth %x nbox %d\n",
- flags,
- (GLuint)rmesa->ClearColor,
- (GLuint)rmesa->ClearDepth,
- rmesa->sarea->nbox );
- }
+ rmesa->sarea->nbox = n;
- ret = drmR128Clear( rmesa->driFd, flags,
- rmesa->ClearColor, rmesa->ClearDepth,
- color_mask, depth_mask );
+ if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) {
+ fprintf( stderr,
+ "drmR128Clear: flag 0x%x color %x depth %x nbox %d\n",
+ flags,
+ (GLuint)rmesa->ClearColor,
+ (GLuint)rmesa->ClearDepth,
+ rmesa->sarea->nbox );
+ }
- if ( ret ) {
- UNLOCK_HARDWARE( rmesa );
- fprintf( stderr, "drmR128Clear: return = %d\n", ret );
- exit( 1 );
+/* ret = drmR128Clear( rmesa->driFd, */
+/* flags, */
+/* rmesa->ClearColor, */
+/* rmesa->setup.plane_3d_mask_c, */
+/* rmesa->ClearDepth ); */
+
+ ret = drmR128Clear( rmesa->driFd, flags,
+ rmesa->ClearColor,
+ rmesa->ClearDepth,
+ rmesa->setup.plane_3d_mask_c,
+ ~0 ); /* depthmask */
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "drmR128Clear: return = %d\n", ret );
+ exit( 1 );
+ }
}
- }
- UNLOCK_HARDWARE( rmesa );
+ UNLOCK_HARDWARE( rmesa );
- rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
- return mask;
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
index 23f002175..a0c72000b 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h,v 1.3 2001/04/01 14:00:00 tsi Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h,v 1.2 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -50,46 +50,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
extern void r128FlushVerticesLocked( r128ContextPtr rmesa );
-extern void r128GetEltBufLocked( r128ContextPtr rmesa );
-extern void r128FlushEltsLocked( r128ContextPtr rmesa );
-extern void r128FireEltsLocked( r128ContextPtr rmesa,
- GLuint start, GLuint end,
- GLuint discard );
-extern void r128ReleaseBufLocked( r128ContextPtr rmesa, drmBufPtr buffer );
-
-/* Make this available as both a regular and an inline function.
- */
-extern CARD32 *r128AllocVertices( r128ContextPtr rmesa, int count );
-
-static __inline CARD32 *r128AllocVerticesInline( r128ContextPtr rmesa,
- int count )
+static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int bytes )
{
- int bytes = count * rmesa->vertsize * sizeof(CARD32);
CARD32 *head;
if ( !rmesa->vert_buf ) {
LOCK_HARDWARE( rmesa );
-
- if ( rmesa->first_elt != rmesa->next_elt ) {
- r128FlushEltsLocked( rmesa );
- }
-
rmesa->vert_buf = r128GetBufferLocked( rmesa );
-
UNLOCK_HARDWARE( rmesa );
} else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
LOCK_HARDWARE( rmesa );
-
r128FlushVerticesLocked( rmesa );
rmesa->vert_buf = r128GetBufferLocked( rmesa );
-
UNLOCK_HARDWARE( rmesa );
}
- head = (CARD32 *)((char *)rmesa->vert_buf->address +
- rmesa->vert_buf->used);
-
- rmesa->num_verts += count;
+ head = (CARD32 *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used);
rmesa->vert_buf->used += bytes;
return head;
}
@@ -111,8 +87,8 @@ extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
const GLint x[], const GLint y[] );
-extern void r128SwapBuffers( r128ContextPtr rmesa );
-extern void r128PageFlip( r128ContextPtr rmesa );
+extern void r128CopyBuffer( const __DRIdrawablePrivate *dPriv );
+extern void r128PageFlip( const __DRIdrawablePrivate *dPriv );
extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
@@ -130,8 +106,6 @@ do { \
fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
if ( rmesa->vert_buf ) { \
r128FlushVertices( rmesa ); \
- } else if ( rmesa->next_elt != rmesa->first_elt ) { \
- r128FlushElts( rmesa ); \
} \
} while (0)
@@ -141,7 +115,7 @@ do { \
#define ALIGN_NEXT_ELT( rmesa ) \
do { \
rmesa->next_elt = (GLushort *) \
- (((unsigned long)rmesa->next_elt + 7) & ~0x7); \
+ (((GLuint)rmesa->next_elt + 7) & ~0x7); \
rmesa->next_elt = (GLushort *) \
((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET); \
} while (0)
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.c b/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
index 5b50fc2e8..38ad89fde 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.c,v 1.3 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.c,v 1.2 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -67,12 +67,12 @@ void r128GetLock( r128ContextPtr rmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- XMESA_VALIDATE_DRAWABLE_INFO( rmesa->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( rmesa->display, sPriv, dPriv );
if ( rmesa->lastStamp != dPriv->lastStamp ) {
rmesa->lastStamp = dPriv->lastStamp;
rmesa->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
- rmesa->SetupDone = 0;
+ rmesa->SetupNewInputs = ~0;
}
rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c
deleted file mode 100644
index 7c85141be..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c,v 1.4 2001/01/08 01:07:21 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "r128_context.h"
-#include "r128_vb.h"
-#include "r128_pipeline.h"
-
-#include "types.h"
-#include "fog.h"
-
-static struct gl_pipeline_stage r128_fast_stage = {
- "r128 Fast Path",
- (PIPE_OP_VERT_XFORM |
- PIPE_OP_RAST_SETUP_0 |
- PIPE_OP_RAST_SETUP_1 |
- PIPE_OP_RENDER),
- PIPE_PRECALC,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- r128DDFastPath
-};
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D | \
- TEXTURE1_3D | \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-/* Build the PRECALC pipeline with our stage, if possible. Otherwise,
- * return GL_FALSE.
- */
-GLboolean r128DDBuildPrecalcPipeline( GLcontext *ctx )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct gl_pipeline *pipe = &ctx->CVA.pre;
-
- if ( rmesa->RenderIndex == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Flags & (VERT_OBJ_234 |
- VERT_TEX0_4 |
- VERT_TEX1_4 |
- VERT_ELT)) == (VERT_OBJ_23 | VERT_ELT) )
- {
- pipe->stages[0] = &r128_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
-
- rmesa->OnFastPath = GL_TRUE;
- return GL_TRUE;
- }
-
- if ( rmesa->OnFastPath ) {
- rmesa->OnFastPath = GL_FALSE;
-
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
- ctx->Array.NewArrayState |= ctx->Array.Summary;
- }
-
- return GL_FALSE;
-}
-
-
-/* Still do the normal fixup and copy-to-current, so this isn't so
- * bad.
- */
-#define ILLEGAL_INPUTS_IMM (VERT_OBJ_4 | \
- VERT_TEX0_4 | \
- VERT_TEX1_4 | \
- VERT_MATERIAL)
-
-static void r128DDCheckRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d )
-{
- d->type = PIPE_IMMEDIATE | PIPE_PRECALC;
- d->inputs = ctx->RenderFlags;
-
- /* r128 requires an extra input:
- */
- if ( ctx->FogMode == FOG_FRAGMENT )
- d->inputs |= VERT_FOG_COORD;
-
- d->outputs = VERT_SETUP_FULL;
-
- if ( ctx->IndirectTriangles & DD_SW_SETUP )
- d->type = PIPE_IMMEDIATE;
-}
-
-
-GLuint r128DDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- int i, o;
-
- for ( i = o = 0 ; i < nr ; i++ ) {
- switch ( in[i].ops ) {
- /* Completely replace Mesa's fog processing to generate fog
- * coordinates instead of messing with colors.
- */
- case PIPE_OP_FOG:
- out[o] = gl_fog_coord_stage;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = (NEW_LIGHTING |
- NEW_TEXTURING |
- NEW_RASTER_OPS);
- out[o].state_change = ~0;
- out[o].check = r128DDCheckPartialRasterSetup;
- out[o].run = r128DDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].check = r128DDCheckRasterSetup;
- out[o].run = r128DDDoRasterSetup;
- o++;
- break;
-
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h
deleted file mode 100644
index 1cfb27d44..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_pipeline.h,v 1.4 2001/01/08 01:07:21 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- *
- */
-
-#ifndef __R128_PIPELINE_H__
-#define __R128_PIPELINE_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern GLboolean r128DDBuildPrecalcPipeline( GLcontext *ctx );
-extern GLuint r128DDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
-
-extern void r128DDFastPathInit( void );
-extern void r128DDFastPath( struct vertex_buffer *VB );
-
-extern void r128DDEltPathInit( void );
-extern void r128DDEltPath( struct vertex_buffer *VB );
-
-#endif
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
index 57d5c4f63..8af724493 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.5 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.4 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -39,8 +39,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_ioctl.h"
#include "r128_tris.h"
#include "r128_vb.h"
-#include "r128_pipeline.h"
+#include "context.h"
#include "mem.h"
#if 1
@@ -59,7 +59,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Create the device specific screen private data struct.
*/
-r128ScreenPtr r128CreateScreen( __DRIscreenPrivate *sPriv )
+static r128ScreenPtr
+r128CreateScreen( __DRIscreenPrivate *sPriv )
{
r128ScreenPtr r128Screen;
R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
@@ -155,17 +156,13 @@ r128ScreenPtr r128CreateScreen( __DRIscreenPrivate *sPriv )
r128Screen->driScreen = sPriv;
- r128DDSetupInit();
- r128DDTriangleFuncsInit();
- r128DDFastPathInit();
- r128DDEltPathInit();
-
return r128Screen;
}
/* Destroy the device specific screen private data struct.
*/
-void r128DestroyScreen( __DRIscreenPrivate *sPriv )
+static void
+r128DestroyScreen( __DRIscreenPrivate *sPriv )
{
r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
@@ -179,3 +176,197 @@ void r128DestroyScreen( __DRIscreenPrivate *sPriv )
FREE( r128Screen );
sPriv->private = NULL;
}
+
+
+/* Initialize the fullscreen mode.
+ */
+static GLboolean
+r128OpenFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+#if 0
+ r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
+ GLint ret;
+
+ /* FIXME: Do we need to check this?
+ */
+ if ( !r128Ctx->glCtx->Visual.doubleBufferMode )
+ return GL_TRUE;
+
+ LOCK_HARDWARE( rmesa );
+ r128WaitForIdleLocked( rmesa );
+
+ /* Ignore errors. If this fails, we simply don't do page flipping.
+ */
+ ret = drmR128FullScreen( rmesa->driFd, GL_TRUE );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->doPageFlip = ( ret == 0 );
+#endif
+
+ return GL_TRUE;
+}
+
+/* Shut down the fullscreen mode.
+ */
+static GLboolean
+r128CloseFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+#if 0
+ r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
+ LOCK_HARDWARE( rmesa );
+ r128WaitForIdleLocked( rmesa );
+
+ /* Don't care if this fails, we're not page flipping anymore.
+ */
+ drmR128FullScreen( rmesa->driFd, GL_FALSE );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->doPageFlip = GL_FALSE;
+ rmesa->currentPage = 0;
+#endif
+
+ return GL_TRUE;
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+r128CreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+/* Copy the back color buffer to the front color buffer */
+static void
+r128SwapBuffers(Display *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ (void) dpy;
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ r128ContextPtr rmesa;
+ GLcontext *ctx;
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = rmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_swapbuffers( ctx ); /* flush pending rendering comands */
+ if ( rmesa->doPageFlip ) {
+ r128PageFlip( dPriv );
+ }
+ else {
+ r128CopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "r128SwapBuffers: drawable has no context!\n");
+ }
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+r128InitDriver( __DRIscreenPrivate *sPriv )
+{
+ sPriv->private = (void *) r128CreateScreen( sPriv );
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
+ if ( major != 4 || minor < 0 ) {
+ __driUtilMessage( "R128 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch );
+ return GL_FALSE;
+ }
+ }
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( sPriv->ddxMajor != 4 ||
+ sPriv->ddxMinor < 0 ) {
+ __driUtilMessage( "R128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( sPriv->drmMajor != 2 ||
+ sPriv->drmMinor < 2 ) {
+ __driUtilMessage( "R128 DRI driver expected DRM driver version 2.2.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
+ return GL_FALSE;
+ }
+
+ if ( !sPriv->private ) {
+ r128DestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+
+/* This function is called by libGL.so as soon as libGL.so is loaded.
+ * This is where we'd register new extension functions with the
+ * dispatcher.
+ */
+void __driRegisterExtensions( void )
+{
+}
+
+
+static struct __DriverAPIRec r128API = {
+ r128InitDriver,
+ r128DestroyScreen,
+ r128CreateContext,
+ r128DestroyContext,
+ r128CreateBuffer,
+ r128DestroyBuffer,
+ r128SwapBuffers,
+ r128MakeCurrent,
+ r128UnbindContext,
+ r128OpenFullScreen,
+ r128CloseFullScreen
+};
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &r128API);
+ return (void *) psp;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.h b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
index 7dea050ac..808f87b34 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.h,v 1.5 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.h,v 1.4 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -79,8 +79,5 @@ typedef struct {
} r128ScreenRec, *r128ScreenPtr;
-extern r128ScreenPtr r128CreateScreen( __DRIscreenPrivate *sPriv );
-extern void r128DestroyScreen( __DRIscreenPrivate *sPriv );
-
#endif
#endif /* __R128_SCREEN_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.c b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
index 521ffcf24..cc3be9cbf 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_span.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.6 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.5 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -38,8 +38,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_ioctl.h"
#include "r128_state.h"
#include "r128_span.h"
+#include "r128_tex.h"
-#include "pb.h"
+#include "swrast/s_pb.h" /* for PB_SIZE */
#define DBG 0
@@ -74,7 +75,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-#define INIT_MONO_PIXEL( p ) p = rmesa->Color
#define CLIPPIXEL( _x, _y ) \
((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
@@ -125,6 +125,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 16 bit, RGB565 color spanline and pixel functions
*/
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = R128PACKCOLOR565( color[0], color[1], color[2] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
@@ -153,6 +157,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 32 bit, ARGB8888 color spanline and pixel functions
*/
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = R128PACKCOLOR8888( color[0], color[1], color[2], color[3] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
(g << 8) | \
@@ -168,7 +176,7 @@ do { \
rgba[0] = (p >> 16) & 0xff; \
rgba[1] = (p >> 8) & 0xff; \
rgba[2] = (p >> 0) & 0xff; \
- rgba[3] = (p >> 24) & 0xff; \
+ rgba[3] = 0xff;/*(p >> 24) & 0xff;*/ \
} while (0)
#define TAG(x) r128##x##_ARGB8888
@@ -176,6 +184,10 @@ do { \
/* 24 bit, RGB888 color spanline and pixel functions */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = R128PACKCOLOR888( color[0], color[1], color[2] )
+
#define WRITE_RGBA(_x, _y, r, g, b, a) \
*(GLuint *)(buf + _x*3 + _y*pitch) = ((r << 16) | \
(g << 8) | \
@@ -364,59 +376,85 @@ do { \
#define WRITE_DEPTH(_x, _y, d) \
*(GLuint *)(buf + _x*4 + _y*pitch) = d
+
+
+static void r128DDSetReadBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ rmesa->readOffset = rmesa->r128Screen->frontOffset;
+ rmesa->readPitch = rmesa->r128Screen->frontPitch;
+ break;
+ case GL_BACK_LEFT:
+ rmesa->readOffset = rmesa->r128Screen->backOffset;
+ rmesa->readPitch = rmesa->r128Screen->backPitch;
+ break;
+ default:
+ break;
+ }
+}
+
+
void r128DDInitSpanFuncs( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetReadBuffer = r128DDSetReadBuffer;
switch ( rmesa->r128Screen->cpp ) {
case 2:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB565;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB565;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB565;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB565;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB565;
+ swdd->WriteRGBASpan = r128WriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = r128WriteRGBSpan_RGB565;
+ swdd->WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565;
+ swdd->WriteRGBAPixels = r128WriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = r128ReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = r128ReadRGBAPixels_RGB565;
break;
case 4:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB8888;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB8888;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888;
+ swdd->WriteRGBASpan = r128WriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = r128WriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
+ swdd->ReadRGBASpan = r128ReadRGBASpan_ARGB8888;
+ swdd->ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888;
break;
default:
break;
}
- switch ( rmesa->glCtx->Visual->DepthBits ) {
+ switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
- ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16;
- ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16;
- ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16;
- ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16;
+ swdd->ReadDepthSpan = r128ReadDepthSpan_16;
+ swdd->WriteDepthSpan = r128WriteDepthSpan_16;
+ swdd->ReadDepthPixels = r128ReadDepthPixels_16;
+ swdd->WriteDepthPixels = r128WriteDepthPixels_16;
break;
case 24:
- ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_24_8;
- ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_24_8;
- ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_24_8;
- ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_24_8;
+ swdd->ReadDepthSpan = r128ReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = r128WriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = r128ReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = r128WriteDepthPixels_24_8;
break;
default:
break;
}
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.c b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
index 8244696aa..f62e516bc 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_state.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.8 2001/03/21 16:14:23 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -43,9 +43,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "context.h"
#include "mmath.h"
-#include "pb.h"
#include "enums.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
/* =============================================================
* Alpha blending
@@ -95,6 +101,8 @@ static void r128UpdateAlphaMode( GLcontext *ctx )
t &= ~R128_ALPHA_TEST_ENABLE;
}
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_FALSE );
+
if ( ctx->Color.BlendEnabled ) {
a &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK);
@@ -126,6 +134,8 @@ static void r128UpdateAlphaMode( GLcontext *ctx )
case GL_SRC_ALPHA_SATURATE:
a |= R128_ALPHA_BLEND_SRC_SRCALPHASAT;
break;
+ default:
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE );
}
switch ( ctx->Color.BlendDstRGB ) {
@@ -153,6 +163,8 @@ static void r128UpdateAlphaMode( GLcontext *ctx )
case GL_ONE_MINUS_DST_ALPHA:
a |= R128_ALPHA_BLEND_DST_INVDESTALPHA;
break;
+ default:
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE );
}
t |= R128_ALPHA_ENABLE;
@@ -170,7 +182,7 @@ static void r128UpdateAlphaMode( GLcontext *ctx )
}
}
-static void r128DDAlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
+static void r128DDAlphaFunc( GLcontext *ctx, GLenum func, GLchan ref )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
@@ -183,13 +195,19 @@ static void r128DDBlendEquation( GLcontext *ctx, GLenum mode )
r128ContextPtr rmesa = R128_CONTEXT(ctx);
FLUSH_BATCH( rmesa );
- rmesa->new_state |= R128_NEW_ALPHA;
- if ( ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY ) {
- rmesa->Fallback |= R128_FALLBACK_LOGICOP;
- } else {
- rmesa->Fallback &= ~R128_FALLBACK_LOGICOP;
- }
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+
+ /* Can only do blend addition, not min, max, subtract, etc. */
+ FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_BLEND_EQ,
+ mode != GL_FUNC_ADD_EXT);
+
+ rmesa->new_state |= R128_NEW_ALPHA;
}
static void r128DDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
@@ -317,13 +335,16 @@ static void r128UpdateFogAttrib( GLcontext *ctx )
GLubyte c[4];
GLuint col;
- if ( ctx->FogMode == FOG_FRAGMENT ) {
+ if ( ctx->Fog.Enabled ) {
t |= R128_FOG_ENABLE;
} else {
t &= ~R128_FOG_ENABLE;
}
- FLOAT_RGB_TO_UBYTE_RGB( c, ctx->Fog.Color );
+ c[0] = FLOAT_TO_UBYTE( ctx->Fog.Color[0] );
+ c[1] = FLOAT_TO_UBYTE( ctx->Fog.Color[1] );
+ c[2] = FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
+
col = r128PackColor( 4, c[0], c[1], c[2], 0 );
if ( rmesa->setup.fog_color_c != col ) {
@@ -419,7 +440,7 @@ static void r128UpdateCull( GLcontext *ctx )
f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
- if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
+ if ( ctx->Polygon.CullFlag ) {
switch ( ctx->Polygon.CullFaceMode ) {
case GL_FRONT:
f &= ~R128_FRONTFACE_SOLID;
@@ -434,7 +455,7 @@ static void r128UpdateCull( GLcontext *ctx )
}
}
- if ( rmesa->setup.pm4_vc_fpu_setup != f ) {
+ if ( 1 || rmesa->setup.pm4_vc_fpu_setup != f ) {
rmesa->setup.pm4_vc_fpu_setup = f;
rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_SETUP;
}
@@ -477,17 +498,14 @@ static void r128UpdateMasks( GLcontext *ctx )
}
}
-static GLboolean r128DDColorMask( GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+static void r128DDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
FLUSH_BATCH( rmesa );
rmesa->new_state |= R128_NEW_MASKS;
-
- return GL_FALSE; /* This forces the software paths to do colormasking. */
- /* This function will return void when we use Mesa 3.5 */
}
@@ -499,26 +517,58 @@ static GLboolean r128DDColorMask( GLcontext *ctx,
* sense to break them out of the core texture state update routines.
*/
+static void updateSpecularLighting( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint t = rmesa->setup.tex_cntl_c;
+
+ if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled) {
+ /* XXX separate specular color just doesn't seem to work as it should.
+ * For now, we fall back to s/w rendering whenever separate specular
+ * is enabled.
+ */
+#if 0
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* R128 can't do flat-shaded separate specular */
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
+ /*printf("%s fallback sep spec\n", __FUNCTION__);*/
+ }
+ else {
+ t |= R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
+ /*printf("%s enable sep spec\n", __FUNCTION__);*/
+ }
+#else
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
+ /*printf("%s fallback sep spec\n", __FUNCTION__);*/
+#endif
+ }
+ else {
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
+ /*printf("%s disable sep spec\n", __FUNCTION__);*/
+ }
+
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_SETUP;
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ }
+}
+
+
static void r128DDLightModelfv( GLcontext *ctx, GLenum pname,
const GLfloat *param )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
- GLuint t = rmesa->setup.tex_cntl_c;
-
FLUSH_BATCH( rmesa );
-
- if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) {
- t |= R128_SPEC_LIGHT_ENABLE;
- } else {
- t &= ~R128_SPEC_LIGHT_ENABLE;
- }
-
- if ( rmesa->setup.tex_cntl_c != t ) {
- rmesa->setup.tex_cntl_c = t;
- rmesa->dirty |= R128_UPLOAD_CONTEXT;
- }
+ updateSpecularLighting(ctx);
}
}
@@ -540,6 +590,8 @@ static void r128DDShadeModel( GLcontext *ctx, GLenum mode )
return;
}
+ updateSpecularLighting(ctx);
+
if ( rmesa->setup.pm4_vc_fpu_setup != s ) {
FLUSH_BATCH( rmesa );
rmesa->setup.pm4_vc_fpu_setup = s;
@@ -566,27 +618,53 @@ void r128UpdateWindow( GLcontext *ctx )
rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW;
}
-
/* =============================================================
- * Miscellaneous
+ * Viewport
*/
-static void r128DDClearColor( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+
+static void r128CalcViewport( GLcontext *ctx )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = rmesa->hw_viewport;
- rmesa->ClearColor = r128PackColor( rmesa->r128Screen->cpp,
- r, g, b, a );
+ /* See also r128_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + rmesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * rmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * rmesa->depth_scale;
}
-static void r128DDColor( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+static void r128Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ r128CalcViewport( ctx );
+}
+
+static void r128DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ r128CalcViewport( ctx );
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void r128DDClearColor( GLcontext *ctx,
+ const GLchan color[4] )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- rmesa->Color = r128PackColor( rmesa->r128Screen->cpp,
- r, g, b, a );
+ rmesa->ClearColor = r128PackColor( rmesa->r128Screen->cpp,
+ color[0], color[1],
+ color[2], color[3] );
}
static void r128DDLogicOpCode( GLcontext *ctx, GLenum opcode )
@@ -596,13 +674,7 @@ static void r128DDLogicOpCode( GLcontext *ctx, GLenum opcode )
if ( ctx->Color.ColorLogicOpEnabled ) {
FLUSH_BATCH( rmesa );
- if ( opcode == GL_COPY ) {
- rmesa->Fallback &= ~R128_FALLBACK_LOGICOP;
- } else {
- rmesa->Fallback |= R128_FALLBACK_LOGICOP;
- }
- } else {
- rmesa->Fallback &= ~R128_FALLBACK_LOGICOP;
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP, opcode != GL_COPY );
}
}
@@ -615,19 +687,20 @@ static GLboolean r128DDSetDrawBuffer( GLcontext *ctx, GLenum mode )
if ( rmesa->DrawBuffer != mode ) {
rmesa->DrawBuffer = mode;
- rmesa->Fallback &= ~R128_FALLBACK_DRAW_BUFFER;
switch ( mode ) {
case GL_FRONT_LEFT:
rmesa->drawOffset = rmesa->r128Screen->frontOffset;
rmesa->drawPitch = rmesa->r128Screen->frontPitch;
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
case GL_BACK_LEFT:
rmesa->drawOffset = rmesa->r128Screen->backOffset;
rmesa->drawPitch = rmesa->r128Screen->backPitch;
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
break;
default:
- rmesa->Fallback |= R128_FALLBACK_DRAW_BUFFER;
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE );
found = GL_FALSE;
break;
}
@@ -640,29 +713,6 @@ static GLboolean r128DDSetDrawBuffer( GLcontext *ctx, GLenum mode )
return found;
}
-static void r128DDSetReadBuffer( GLcontext *ctx,
- GLframebuffer *colorBuffer,
- GLenum mode )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
-
- rmesa->Fallback &= ~R128_FALLBACK_READ_BUFFER;
-
- switch ( mode ) {
- case GL_FRONT_LEFT:
- rmesa->readOffset = rmesa->r128Screen->frontOffset;
- rmesa->readPitch = rmesa->r128Screen->frontPitch;
- break;
- case GL_BACK_LEFT:
- rmesa->readOffset = rmesa->r128Screen->backOffset;
- rmesa->readPitch = rmesa->r128Screen->backPitch;
- break;
- default:
- rmesa->Fallback |= R128_FALLBACK_READ_BUFFER;
- break;
- }
-}
-
/* =============================================================
* Polygon stipple
@@ -671,22 +721,18 @@ static void r128DDSetReadBuffer( GLcontext *ctx,
static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLuint *stipple = (GLuint *)mask;
-
- FLUSH_BATCH( rmesa );
-
- rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+ GLuint stipple[32], i;
- if ( ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON ) {
- rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_32x32_MONO_FG_LA;
- } else {
- rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_SOLID_COLOR;
+ for (i = 0; i < 32; i++) {
+ stipple[31 - i] = ((mask[i*4+0] << 24) |
+ (mask[i*4+1] << 16) |
+ (mask[i*4+2] << 8) |
+ (mask[i*4+3]));
}
+ FLUSH_BATCH( rmesa );
LOCK_HARDWARE( rmesa );
-
drmR128PolygonStipple( rmesa->driFd, stipple );
-
UNLOCK_HARDWARE( rmesa );
rmesa->new_state |= R128_NEW_CONTEXT;
@@ -695,6 +741,18 @@ static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
/* =============================================================
+ * Render mode
+ */
+
+static void r128DDRenderMode( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ FALLBACK( rmesa, R128_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+
+
+/* =============================================================
* State enable/disable
*/
@@ -704,7 +762,7 @@ static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s( %s = %s )\n",
- __FUNCTION__, gl_lookup_enum_by_nr( cap ),
+ __FUNCTION__, _mesa_lookup_enum_by_nr( cap ),
state ? "GL_TRUE" : "GL_FALSE" );
}
@@ -718,11 +776,11 @@ static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
FLUSH_BATCH( rmesa );
rmesa->new_state |= R128_NEW_ALPHA;
- if ( ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY ) {
- rmesa->Fallback |= R128_FALLBACK_LOGICOP;
- } else {
- rmesa->Fallback &= ~R128_FALLBACK_LOGICOP;
- }
+ /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
break;
case GL_CULL_FACE:
@@ -760,11 +818,12 @@ static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_COLOR_LOGIC_OP:
FLUSH_BATCH( rmesa );
- if ( state && ctx->Color.LogicOp != GL_COPY ) {
- rmesa->Fallback |= R128_FALLBACK_LOGICOP;
- } else {
- rmesa->Fallback &= ~R128_FALLBACK_LOGICOP;
- }
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
+ state && ctx->Color.LogicOp != GL_COPY );
+ break;
+
+ case GL_LIGHTING:
+ updateSpecularLighting(ctx);
break;
case GL_SCISSOR_TEST:
@@ -773,6 +832,11 @@ static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
rmesa->new_state |= R128_NEW_CLIP;
break;
+ case GL_STENCIL_TEST:
+ FLUSH_BATCH( rmesa );
+ FALLBACK( rmesa, R128_FALLBACK_STENCIL, state );
+ break;
+
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
@@ -781,9 +845,7 @@ static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_POLYGON_STIPPLE:
- if ( (ctx->Driver.TriangleCaps & DD_TRI_STIPPLE) &&
- ctx->PB->primitive == GL_POLYGON )
- {
+ if ( rmesa->render_primitive == GL_TRIANGLES ) {
FLUSH_BATCH( rmesa );
rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
if ( state ) {
@@ -842,8 +904,8 @@ void r128EmitHwStateLocked( r128ContextPtr rmesa )
{
R128SAREAPrivPtr sarea = rmesa->sarea;
r128_context_regs_t *regs = &(rmesa->setup);
- r128TexObjPtr t0 = rmesa->CurrentTexObj[0];
- r128TexObjPtr t1 = rmesa->CurrentTexObj[1];
+ const r128TexObjPtr t0 = rmesa->CurrentTexObj[0];
+ const r128TexObjPtr t1 = rmesa->CurrentTexObj[1];
if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
r128DDPrintDirty( "r128EmitHwStateLocked", rmesa->dirty );
@@ -889,8 +951,8 @@ void r128EmitHwStateLocked( r128ContextPtr rmesa )
tex->tex_border_color = t1->setup.tex_border_color;
}
- sarea->vertsize = rmesa->vertsize;
- sarea->vc_format = rmesa->vc_format;
+ sarea->vertsize = rmesa->vertex_size;
+ sarea->vc_format = rmesa->vertex_format;
/* Turn off the texture cache flushing */
rmesa->setup.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH;
@@ -958,82 +1020,18 @@ void r128DDUpdateHWState( GLcontext *ctx )
}
}
-/* This is called when Mesa switches between rendering triangle
- * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc),
- * and lines, points and bitmaps.
- *
- * As the r128 uses triangles to render lines and points, it is
- * necessary to turn off hardware culling when rendering these
- * primitives.
- */
-static void r128DDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLuint f = rmesa->setup.pm4_vc_fpu_setup;
-
- f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
-
- if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
- switch ( ctx->Polygon.CullFaceMode ) {
- case GL_FRONT:
- f &= ~R128_FRONTFACE_SOLID;
- break;
- case GL_BACK:
- f &= ~R128_BACKFACE_SOLID;
- break;
- case GL_FRONT_AND_BACK:
- f &= ~(R128_BACKFACE_SOLID |
- R128_FRONTFACE_SOLID);
- break;
- }
- }
-
- if ( rmesa->setup.pm4_vc_fpu_setup != f ) {
- FLUSH_BATCH( rmesa );
- rmesa->setup.pm4_vc_fpu_setup = f;
-
- /* NOTE: Only upload the setup state, everything else has been
- * uploaded by the usual means already.
- */
- rmesa->dirty |= R128_UPLOAD_SETUP;
- }
-}
-
-
-#define INTERESTED (~(NEW_MODELVIEW | \
- NEW_PROJECTION | \
- NEW_TEXTURE_MATRIX | \
- NEW_USER_CLIP | \
- NEW_CLIENT_STATE))
-void r128DDUpdateState( GLcontext *ctx )
+static void r128DDInvalidateState( GLcontext *ctx, GLuint new_state )
{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
-
- if ( ctx->NewState & INTERESTED ) {
- r128DDChooseRenderState( ctx );
- r128DDChooseRasterSetupFunc( ctx );
- }
-
- /* Need to do this here to detect texture fallbacks before
- * setting triangle functions.
- */
- if ( rmesa->new_state & R128_NEW_TEXTURE ) {
- r128DDUpdateHWState( ctx );
- }
-
- if ( !rmesa->Fallback ) {
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
- ctx->IndirectTriangles |= rmesa->IndirectTriangles;
-
- ctx->Driver.PointsFunc = rmesa->PointsFunc;
- ctx->Driver.LineFunc = rmesa->LineFunc;
- ctx->Driver.TriangleFunc = rmesa->TriangleFunc;
- ctx->Driver.QuadFunc = rmesa->QuadFunc;
- }
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ R128_CONTEXT(ctx)->NewGLState |= new_state;
}
+
/* Initialize the context's hardware state.
*/
void r128DDInitState( r128ContextPtr rmesa )
@@ -1054,35 +1052,26 @@ void r128DDInitState( r128ContextPtr rmesa )
rmesa->ClearColor = 0x00000000;
- switch ( rmesa->glCtx->Visual->DepthBits ) {
+ switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
rmesa->ClearDepth = 0x0000ffff;
- rmesa->DepthMask = 0xffffffff;
depth_bpp = R128_Z_PIX_WIDTH_16;
rmesa->depth_scale = 1.0 / (GLfloat)0xffff;
break;
case 24:
rmesa->ClearDepth = 0x00ffffff;
- rmesa->DepthMask = 0x00ffffff;
depth_bpp = R128_Z_PIX_WIDTH_24;
rmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
break;
default:
fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
- rmesa->glCtx->Visual->DepthBits );
+ rmesa->glCtx->Visual.depthBits );
exit( -1 );
}
- rmesa->RenderIndex = R128_FALLBACK_BIT;
- rmesa->PointsFunc = NULL;
- rmesa->LineFunc = NULL;
- rmesa->TriangleFunc = NULL;
- rmesa->QuadFunc = NULL;
-
- rmesa->IndirectTriangles = 0;
rmesa->Fallback = 0;
- if ( rmesa->glCtx->Visual->DBflag ) {
+ if ( rmesa->glCtx->Visual.doubleBufferMode ) {
rmesa->DrawBuffer = GL_BACK_LEFT;
rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
@@ -1198,33 +1187,14 @@ void r128DDInitState( r128ContextPtr rmesa )
*/
void r128DDInitStateFuncs( GLcontext *ctx )
{
- ctx->Driver.UpdateState = r128DDUpdateState;
+ ctx->Driver.UpdateState = r128DDInvalidateState;
ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = r128DDClearColor;
- ctx->Driver.Index = NULL;
- ctx->Driver.Color = r128DDColor;
ctx->Driver.SetDrawBuffer = r128DDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = r128DDSetReadBuffer;
ctx->Driver.IndexMask = NULL;
ctx->Driver.ColorMask = r128DDColorMask;
- ctx->Driver.LogicOp = NULL;
- ctx->Driver.Dither = NULL;
-
- ctx->Driver.NearFar = NULL;
-
- ctx->Driver.RenderStart = r128DDUpdateHWState;
- ctx->Driver.RenderFinish = NULL;
- ctx->Driver.RasterSetup = NULL;
-
- ctx->Driver.RenderVBClippedTab = NULL;
- ctx->Driver.RenderVBCulledTab = NULL;
- ctx->Driver.RenderVBRawTab = NULL;
-
- ctx->Driver.ReducedPrimitiveChange = r128DDReducedPrimitiveChange;
- ctx->Driver.MultipassFunc = NULL;
-
ctx->Driver.AlphaFunc = r128DDAlphaFunc;
ctx->Driver.BlendEquation = r128DDBlendEquation;
ctx->Driver.BlendFunc = r128DDBlendFunc;
@@ -1234,7 +1204,6 @@ void r128DDInitStateFuncs( GLcontext *ctx )
ctx->Driver.FrontFace = r128DDFrontFace;
ctx->Driver.DepthFunc = r128DDDepthFunc;
ctx->Driver.DepthMask = r128DDDepthMask;
- ctx->Driver.DepthRange = NULL;
ctx->Driver.Enable = r128DDEnable;
ctx->Driver.Fogfv = r128DDFogfv;
ctx->Driver.Hint = NULL;
@@ -1243,11 +1212,30 @@ void r128DDInitStateFuncs( GLcontext *ctx )
ctx->Driver.LogicOpcode = r128DDLogicOpCode;
ctx->Driver.PolygonMode = NULL;
ctx->Driver.PolygonStipple = r128DDPolygonStipple;
+ ctx->Driver.RenderMode = r128DDRenderMode;
ctx->Driver.Scissor = r128DDScissor;
ctx->Driver.ShadeModel = r128DDShadeModel;
ctx->Driver.ClearStencil = NULL;
ctx->Driver.StencilFunc = NULL;
ctx->Driver.StencilMask = NULL;
ctx->Driver.StencilOp = NULL;
- ctx->Driver.Viewport = NULL;
+
+ ctx->Driver.DepthRange = r128DepthRange;
+ ctx->Driver.Viewport = r128Viewport;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
index d6d42c5cc..05d533184 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.10 2001/08/18 02:51:05 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -30,19 +30,24 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Kevin E. Martin <martin@valinux.com>
- * Michel Dänzer <michdaen@iiic.ethz.ch>
- *
+ * Brian Paul <brianp@valinux.com>
*/
#include "r128_context.h"
#include "r128_state.h"
#include "r128_ioctl.h"
#include "r128_vb.h"
+#include "r128_tris.h"
#include "r128_tex.h"
+#include "r128_texobj.h"
+#include "context.h"
+#include "macros.h"
#include "mmath.h"
#include "simple_list.h"
#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
#include "mem.h"
#define TEX_0 1
@@ -55,6 +60,9 @@ static void r128SetTexWrap( r128TexObjPtr t, GLenum swrap, GLenum twrap )
switch ( swrap ) {
case GL_CLAMP:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_S_BORDER_COLOR;
+ break;
+ case GL_CLAMP_TO_EDGE:
t->setup.tex_cntl |= R128_TEX_CLAMP_S_CLAMP;
break;
case GL_REPEAT:
@@ -64,6 +72,9 @@ static void r128SetTexWrap( r128TexObjPtr t, GLenum swrap, GLenum twrap )
switch ( twrap ) {
case GL_CLAMP:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_T_BORDER_COLOR;
+ break;
+ case GL_CLAMP_TO_EDGE:
t->setup.tex_cntl |= R128_TEX_CLAMP_T_CLAMP;
break;
case GL_REPEAT:
@@ -87,10 +98,10 @@ static void r128SetTexFilter( r128TexObjPtr t, GLenum minf, GLenum magf )
t->setup.tex_cntl |= R128_MIN_BLEND_MIPNEAREST;
break;
case GL_LINEAR_MIPMAP_NEAREST:
- t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
+ t->setup.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
break;
case GL_NEAREST_MIPMAP_LINEAR:
- t->setup.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
+ t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
break;
case GL_LINEAR_MIPMAP_LINEAR:
t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR;
@@ -113,1323 +124,262 @@ static void r128SetTexBorderColor( r128TexObjPtr t, GLubyte c[4] )
}
-/* Allocate and initialize hardware state associated with texture `t'.
- */
-static r128TexObjPtr r128CreateTexObj( r128ContextPtr rmesa,
- struct gl_texture_object *tObj )
+static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj )
{
r128TexObjPtr t;
- struct gl_texture_image *image;
- int log2Pitch, log2Height, log2Size, log2MinSize;
- int totalSize;
- int i;
-
- image = tObj->Image[0];
- if ( !image )
- return NULL;
-
- t = (r128TexObjPtr) CALLOC( sizeof(*t) );
- if ( !t )
- return NULL;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API )
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj );
-
- switch ( image->Format ) {
- case GL_RGBA:
- case GL_ALPHA:
- case GL_LUMINANCE_ALPHA:
- if ( rmesa->r128Screen->cpp == 4 ) {
- t->texelBytes = 4;
- t->textureFormat = R128_DATATYPE_ARGB8888;
- } else {
- t->texelBytes = 2;
- t->textureFormat = R128_DATATYPE_ARGB4444;
- }
- break;
-
- case GL_RGB:
- if ( rmesa->r128Screen->cpp == 4 ) {
- t->texelBytes = 4;
- t->textureFormat = R128_DATATYPE_ARGB8888;
- } else {
- t->texelBytes = 2;
- t->textureFormat = R128_DATATYPE_RGB565;
- }
- break;
-
- case GL_LUMINANCE:
- case GL_INTENSITY:
- t->texelBytes = 1;
- t->textureFormat = R128_DATATYPE_RGB8;
- break;
- case GL_COLOR_INDEX:
- t->texelBytes = 1;
- t->textureFormat = R128_DATATYPE_CI8;
- break;
-
- default:
- fprintf( stderr, "%s: bad image->Format\n", __FUNCTION__ );
- FREE( t );
- return NULL;
- }
-
- /* Calculate dimensions in log domain */
- for ( i = 1, log2Height = 0 ; i < image->Height ; i *= 2 ) {
- log2Height++;
- }
- for ( i = 1, log2Pitch = 0 ; i < image->Width ; i *= 2 ) {
- log2Pitch++;
- }
- if ( image->Width > image->Height ) {
- log2Size = log2Pitch;
- } else {
- log2Size = log2Height;
- }
-
- t->dirty_images = 0;
-
- /* Calculate mipmap offsets and dimensions */
- totalSize = 0;
- for ( i = 0 ; i <= log2Size && tObj->Image[i] ; i++ ) {
- t->image[i].offset = totalSize;
- t->image[i].width = tObj->Image[i]->Width;
- t->image[i].height = tObj->Image[i]->Height;
-
- t->dirty_images |= (1 << i);
-
- totalSize += (tObj->Image[i]->Height *
- tObj->Image[i]->Width *
- t->texelBytes);
-
- /* Offsets must be 32-byte aligned for host data blits and tiling */
- totalSize = (totalSize + 31) & ~31;
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, __FUNCTION__"( %p, %p )\n", texObj, t );
}
- log2MinSize = log2Size - i + 1;
-
- t->totalSize = totalSize;
- t->internFormat = image->IntFormat;
- t->age = 0;
- t->bound = 0;
- t->heap = 0;
- t->tObj = tObj;
-
- t->memBlock = NULL;
- t->bufAddr = 0;
+ t = (r128TexObjPtr) CALLOC_STRUCT( r128_tex_obj );
+ if (!t)
+ return NULL;
- /* Hardware state:
+ /* Initialize non-image-dependent parts of the state:
*/
- t->setup.tex_cntl = (R128_MIN_BLEND_NEAREST |
- R128_MAG_BLEND_NEAREST |
- R128_TEX_CLAMP_S_WRAP |
- R128_TEX_CLAMP_T_WRAP |
- t->textureFormat);
-
- t->setup.tex_combine_cntl = 0x00000000;
-
- t->setup.tex_size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) |
- (log2Size << R128_TEX_SIZE_SHIFT) |
- (log2Height << R128_TEX_HEIGHT_SHIFT) |
- (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
-
- for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
- t->setup.tex_offset[i] = 0x00000000;
- }
- t->setup.tex_border_color = 0x00000000;
-
- if ( ( log2MinSize == log2Size ) || ( log2MinSize != 0 ) ) {
- t->setup.tex_cntl |= R128_MIP_MAP_DISABLE;
- }
-
- r128SetTexWrap( t, tObj->WrapS, tObj->WrapT );
- r128SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
- r128SetTexBorderColor( t, tObj->BorderColor );
-
- tObj->DriverData = t;
-
- make_empty_list( t );
-
- return t;
-}
-
-/* Destroy hardware state associated with texture `t'.
- */
-void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t )
-{
-#if ENABLE_PERF_BOXES
- /* Bump the performace counter */
- rmesa->c_textureSwaps++;
-#endif
- if ( !t ) return;
-
- if ( t->memBlock ) {
- mmFreeMem( t->memBlock );
- t->memBlock = NULL;
- }
-
- if ( t->tObj )
- t->tObj->DriverData = NULL;
-
- if ( t->bound & TEX_0 ) rmesa->CurrentTexObj[0] = NULL;
- if ( t->bound & TEX_1 ) rmesa->CurrentTexObj[1] = NULL;
-
- remove_from_list( t );
- FREE( t );
-}
-
-/* Keep track of swapped out texture objects.
- */
-static void r128SwapOutTexObj( r128ContextPtr rmesa, r128TexObjPtr t )
-{
-#if ENABLE_PERF_BOXES
- /* Bump the performace counter */
- rmesa->c_textureSwaps++;
-#endif
- if ( t->memBlock ) {
- mmFreeMem( t->memBlock );
- t->memBlock = NULL;
- }
-
+ t->tObj = texObj;
t->dirty_images = ~0;
- move_to_tail( &rmesa->SwappedOut, t );
-}
-
-/* Print out debugging information about texture LRU.
- */
-void r128PrintLocalLRU( r128ContextPtr rmesa, int heap )
-{
- r128TexObjPtr t;
- int sz = 1 << (rmesa->r128Screen->logTexGranularity[heap]);
-
- fprintf( stderr, "\nLocal LRU, heap %d:\n", heap );
-
- foreach ( t, &rmesa->TexObjList[heap] ) {
- if ( !t->tObj ) {
- fprintf( stderr, "Placeholder %d at 0x%x sz 0x%x\n",
- t->memBlock->ofs / sz,
- t->memBlock->ofs,
- t->memBlock->size );
- } else {
- fprintf( stderr, "Texture (bound %d) at 0x%x sz 0x%x\n",
- t->bound,
- t->memBlock->ofs,
- t->memBlock->size );
- }
- }
-
- fprintf( stderr, "\n" );
-}
-
-void r128PrintGlobalLRU( r128ContextPtr rmesa, int heap )
-{
- r128_tex_region_t *list = rmesa->sarea->texList[heap];
- int i, j;
-
- fprintf( stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list );
-
- for ( i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++ ) {
- fprintf( stderr, "list[%d] age %d next %d prev %d\n",
- j, list[j].age, list[j].next, list[j].prev );
- j = list[j].next;
- if ( j == R128_NR_TEX_REGIONS ) break;
- }
-
- if ( j != R128_NR_TEX_REGIONS ) {
- fprintf( stderr, "Loop detected in global LRU\n" );
- for ( i = 0 ; i < R128_NR_TEX_REGIONS ; i++ ) {
- fprintf( stderr, "list[%d] age %d next %d prev %d\n",
- i, list[i].age, list[i].next, list[i].prev );
- }
- }
-
- fprintf( stderr, "\n" );
-}
-
-/* Reset the global texture LRU.
- */
-static void r128ResetGlobalLRU( r128ContextPtr rmesa, int heap )
-{
- r128_tex_region_t *list = rmesa->sarea->texList[heap];
- int sz = 1 << rmesa->r128Screen->logTexGranularity[heap];
- int i;
-
- /* (Re)initialize the global circular LRU list. The last element in
- * the array (R128_NR_TEX_REGIONS) is the sentinal. Keeping it at
- * the end of the array allows it to be addressed rationally when
- * looking up objects at a particular location in texture memory.
- */
- for ( i = 0 ; (i+1) * sz <= rmesa->r128Screen->texSize[heap] ; i++ ) {
- list[i].prev = i-1;
- list[i].next = i+1;
- list[i].age = 0;
- }
-
- i--;
- list[0].prev = R128_NR_TEX_REGIONS;
- list[i].prev = i-1;
- list[i].next = R128_NR_TEX_REGIONS;
- list[R128_NR_TEX_REGIONS].prev = i;
- list[R128_NR_TEX_REGIONS].next = 0;
- rmesa->sarea->texAge[heap] = 0;
-}
-
-/* Update the local and glock texture LRUs.
- */
-static void r128UpdateTexLRU( r128ContextPtr rmesa, r128TexObjPtr t )
-{
- int heap = t->heap;
- r128_tex_region_t *list = rmesa->sarea->texList[heap];
- int log2sz = rmesa->r128Screen->logTexGranularity[heap];
- int start = t->memBlock->ofs >> log2sz;
- int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
- int i;
-
- rmesa->lastTexAge[heap] = ++rmesa->sarea->texAge[heap];
-
- if ( !t->memBlock ) {
- fprintf( stderr, "no memblock\n\n" );
- return;
- }
- /* Update our local LRU */
- move_to_head( &rmesa->TexObjList[heap], t );
-
- /* Update the global LRU */
- for ( i = start ; i <= end ; i++ ) {
- list[i].in_use = 1;
- list[i].age = rmesa->lastTexAge[heap];
-
- /* remove_from_list(i) */
- list[(CARD32)list[i].next].prev = list[i].prev;
- list[(CARD32)list[i].prev].next = list[i].next;
-
- /* insert_at_head(list, i) */
- list[i].prev = R128_NR_TEX_REGIONS;
- list[i].next = list[R128_NR_TEX_REGIONS].next;
- list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i;
- list[R128_NR_TEX_REGIONS].next = i;
- }
-
- if ( 0 ) {
- r128PrintGlobalLRU( rmesa, t->heap );
- r128PrintLocalLRU( rmesa, t->heap );
- }
-}
-
-/* Update our notion of what textures have been changed since we last
- * held the lock. This pertains to both our local textures and the
- * textures belonging to other clients. Keep track of other client's
- * textures by pushing a placeholder texture onto the LRU list -- these
- * are denoted by (tObj == NULL).
- */
-static void r128TexturesGone( r128ContextPtr rmesa, int heap,
- int offset, int size, int in_use )
-{
- r128TexObjPtr t, tmp;
-
- foreach_s ( t, tmp, &rmesa->TexObjList[heap] ) {
- if ( t->memBlock->ofs >= offset + size ||
- t->memBlock->ofs + t->memBlock->size <= offset )
- continue;
-
- /* It overlaps - kick it out. Need to hold onto the currently
- * bound objects, however.
- */
- if ( t->bound ) {
- r128SwapOutTexObj( rmesa, t );
- } else {
- r128DestroyTexObj( rmesa, t );
- }
- }
-
- if ( in_use ) {
- t = (r128TexObjPtr) CALLOC( sizeof(*t) );
- if ( !t ) return;
-
- t->memBlock = mmAllocMem( rmesa->texHeap[heap], size, 0, offset );
- if ( !t->memBlock ) {
- fprintf( stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
- (int)size, (int)offset );
- mmDumpMemInfo( rmesa->texHeap[heap] );
- return;
- }
- insert_at_head( &rmesa->TexObjList[heap], t );
- }
-}
-
-/* Update our client's shared texture state. If another client has
- * modified a region in which we have textures, then we need to figure
- * out which of our textures has been removed, and update our global
- * LRU.
- */
-void r128AgeTextures( r128ContextPtr rmesa, int heap )
-{
- R128SAREAPrivPtr sarea = rmesa->sarea;
-
- if ( sarea->texAge[heap] != rmesa->lastTexAge[heap] ) {
- int sz = 1 << rmesa->r128Screen->logTexGranularity[heap];
- int nr = 0;
- int idx;
-
- /* Have to go right round from the back to ensure stuff ends up
- * LRU in our local list... Fix with a cursor pointer.
- */
- for ( idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev ;
- idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS ;
- idx = sarea->texList[heap][idx].prev, nr++ )
- {
- /* If switching texturing schemes, then the SAREA might not
- * have been properly cleared, so we need to reset the
- * global texture LRU.
- */
- if ( idx * sz > rmesa->r128Screen->texSize[heap] ) {
- nr = R128_NR_TEX_REGIONS;
- break;
- }
-
- if ( sarea->texList[heap][idx].age > rmesa->lastTexAge[heap] ) {
- r128TexturesGone( rmesa, heap, idx * sz, sz,
- sarea->texList[heap][idx].in_use );
- }
- }
-
- /* If switching texturing schemes, then the SAREA might not
- * have been properly cleared, so we need to reset the
- * global texture LRU.
- */
- if ( nr == R128_NR_TEX_REGIONS ) {
- r128TexturesGone( rmesa, heap, 0,
- rmesa->r128Screen->texSize[heap], 0 );
- r128ResetGlobalLRU( rmesa, heap );
- }
+ make_empty_list( t );
- if ( 0 ) {
- r128PrintGlobalLRU( rmesa, heap );
- r128PrintLocalLRU( rmesa, heap );
- }
+ r128SetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ /*r128SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );*/
+ r128SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ r128SetTexBorderColor( t, texObj->BorderColor );
- rmesa->dirty |= (R128_UPLOAD_CONTEXT |
- R128_UPLOAD_TEX0IMAGES |
- R128_UPLOAD_TEX1IMAGES);
- rmesa->lastTexAge[heap] = sarea->texAge[heap];
- }
+ return t;
}
-/* ================================================================
- * Texture image conversions
- */
-
-/* Convert a block of Mesa-formatted texture to an 8bpp hardware format.
- */
-static void r128ConvertTexture8bpp( CARD32 *dst,
- struct gl_texture_image *image,
- int x, int y, int width, int height,
- int pitch )
-{
- CARD8 *src;
- int i, j;
-
- switch ( image->Format ) {
- case GL_LUMINANCE:
- case GL_INTENSITY:
- case GL_COLOR_INDEX:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x);
- for ( j = width >> 2 ; j ; j-- ) {
- *dst++ = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
- src += 4;
- }
- }
- break;
-
- default:
- fprintf( stderr, "%s: unsupported format 0x%x\n",
- __FUNCTION__, image->Format );
- break;
- }
-}
-
-/* Convert a block of Mesa-formatted texture to a 16bpp hardware format.
- */
-static void r128ConvertTexture16bpp( CARD32 *dst,
- struct gl_texture_image *image,
- int x, int y, int width, int height,
- int pitch )
+/* Called by the _mesa_store_teximage[123]d() functions. */
+static const struct gl_texture_format *
+r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
{
- CARD8 *src;
- int i, j;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s: %d,%d at %d,%d\n",
- __FUNCTION__, width, height, x, y );
- }
-
-
- switch ( image->Format ) {
- case GL_RGBA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
- for ( j = width >> 1 ; j ; j-- ) {
- *dst++ = R128PACKCOLORS4444( src[0], src[1], src[2], src[3],
- src[4], src[5], src[6], src[7] );
- src += 8;
- }
- }
- break;
-
- case GL_RGB:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
- for ( j = width >> 1 ; j ; j-- ) {
- *dst++ = R128PACKCOLORS565( src[0], src[1], src[2],
- src[3], src[4], src[5] );
- src += 6;
- }
- }
- break;
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ (void) format;
+ (void) type;
+ switch ( internalFormat ) {
case GL_ALPHA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x);
- for ( j = width >> 1 ; j ; j-- ) {
- *dst++ = R128PACKCOLORS4444( 0xff, 0xff, 0xff, src[0],
- 0xff, 0xff, 0xff, src[1] );
- src += 2;
- }
- }
- break;
-
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case 2:
case GL_LUMINANCE_ALPHA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
- for ( j = width >> 1 ; j ; j-- ) {
- *dst++ = R128PACKCOLORS4444( src[0], src[0], src[0], src[1],
- src[2], src[2], src[2], src[3] );
- src += 4;
- }
- }
- break;
-
- default:
- fprintf( stderr, "%s: unsupported format 0x%x\n",
- __FUNCTION__, image->Format );
- break;
- }
-}
-
-/* Convert a block of Mesa-formatted texture to a 32bpp hardware format.
- */
-static void r128ConvertTexture32bpp( CARD32 *dst,
- struct gl_texture_image *image,
- int x, int y, int width, int height,
- int pitch )
-{
- CARD8 *src;
- int i, j;
-
- switch ( image->Format ) {
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case 4:
case GL_RGBA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4;
- for ( j = width ; j ; j-- ) {
- *dst++ = R128PACKCOLOR8888( src[0], src[1], src[2], src[3] );
- src += 4;
- }
- }
- break;
-
+ case GL_RGBA2:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ if (rmesa->r128Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_argb4444;
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+
+ case 3:
case GL_RGB:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3;
- for ( j = width ; j ; j-- ) {
- *dst++ = R128PACKCOLOR8888( src[0], src[1], src[2], 0xff );
- src += 3;
- }
- }
- break;
-
- case GL_ALPHA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x);
- for ( j = width ; j ; j-- ) {
- *dst++ = R128PACKCOLOR8888( 0xff, 0xff, 0xff, src[0] );
- src += 1;
- }
- }
- break;
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ if (rmesa->r128Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_rgb565;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ if (rmesa->r128Screen->cpp == 4)
+ return &_mesa_texformat_argb8888; /* inefficient but accurate */
+ else
+ return &_mesa_texformat_rgb565;
+
+ case GL_INTENSITY4:
+ return &_mesa_texformat_argb4444;
+ case GL_INTENSITY:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ if (rmesa->r128Screen->cpp == 4)
+ return &_mesa_texformat_argb8888; /* inefficient but accurate */
+ else
+ return &_mesa_texformat_argb4444;
- case GL_LUMINANCE_ALPHA:
- for ( i = 0 ; i < height ; i++ ) {
- src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2;
- for ( j = width ; j ; j-- ) {
- *dst++ = R128PACKCOLOR8888( src[0], src[0], src[0], src[1] );
- src += 2;
- }
- }
- break;
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ return &_mesa_texformat_ci8;
default:
- fprintf( stderr, "%s: unsupported format 0x%x\n",
- __FUNCTION__, image->Format );
- break;
+ _mesa_problem( ctx, "unexpected format in r128ChooseTextureFormat" );
+ return NULL;
}
}
-/* Upload the texture image associated with texture `t' at level `level'
- * at the address relative to `start'.
- */
-static void r128UploadSubImage( r128ContextPtr rmesa,
- r128TexObjPtr t, int level,
- int x, int y, int width, int height )
-{
- struct gl_texture_image *image;
- int texelsPerDword = 0;
- int imageWidth, imageHeight;
- int remaining, rows;
- int format, dwords;
- CARD32 pitch, offset;
- drmBufPtr buffer;
- CARD32 *dst;
- int i;
-
- /* Ensure we have a valid texture to upload */
- if ( ( level < 0 ) || ( level > R128_MAX_TEXTURE_LEVELS ) )
- return;
-
- image = t->tObj->Image[level];
- if ( !image || !image->Data )
- return;
-
- switch ( t->texelBytes ) {
- case 1: texelsPerDword = 4; break;
- case 2: texelsPerDword = 2; break;
- case 4: texelsPerDword = 1; break;
- }
-
-#if 1
- /* FIXME: The subimage index calcs are wrong... */
- x = 0;
- y = 0;
- width = image->Width;
- height = image->Height;
-#endif
-
- imageWidth = image->Width;
- imageHeight = image->Height;
-
- format = t->textureFormat >> 16;
-
- /* The texel upload routines have a minimum width, so force the size
- * if needed.
- */
- if ( imageWidth < texelsPerDword ) {
- int factor;
-
- factor = texelsPerDword / imageWidth;
- imageWidth = texelsPerDword;
- imageHeight /= factor;
- if ( imageHeight == 0 ) {
- /* In this case, the texel converter will actually walk a
- * texel or two off the end of the image, but normal malloc
- * alignment should prevent it from ever causing a fault.
- */
- imageHeight = 1;
- }
- }
-
- /* We can't upload to a pitch less than 8 texels so we will need to
- * linearly upload all modified rows for textures smaller than this.
- * This makes the x/y/width/height different for the blitter and the
- * texture walker.
- */
- if ( imageWidth >= 8 ) {
- /* The texture walker and the blitter look identical */
- pitch = imageWidth >> 3;
- } else {
- int factor;
- int y2;
- int start, end;
-
- start = (y * imageWidth) & ~7;
- end = (y + height) * imageWidth;
-
- if ( end - start < 8 ) {
- /* Handle the case where the total number of texels
- * uploaded is < 8.
- */
- x = 0;
- y = start / 8;
- width = end - start;
- height = 1;
- } else {
- /* Upload some number of full 8 texel blit rows */
- factor = 8 / imageWidth;
-
- y2 = y + height - 1;
- y /= factor;
- y2 /= factor;
-
- x = 0;
- width = 8;
- height = y2 - y + 1;
- }
-
- /* Fixed pitch of 8 */
- pitch = 1;
- }
-
- dwords = width * height / texelsPerDword;
- offset = t->bufAddr + t->image[level].offset;
-
-#if ENABLE_PERF_BOXES
- /* Bump the performace counter */
- rmesa->c_textureBytes += (dwords << 2);
-#endif
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n",
- width, height, image->Width, image->Height, x, y );
- fprintf( stderr, " blit ofs: 0x%07x pitch: 0x%x dwords: %d "
- "level: %d format: %x\n",
- (GLuint)offset, (GLuint)pitch, dwords, level, format );
- }
-
- /* Subdivide the texture if required */
- if ( dwords <= R128_BUFFER_MAX_DWORDS / 2 ) {
- rows = height;
- } else {
- rows = (R128_BUFFER_MAX_DWORDS * texelsPerDword) / (2 * width);
- }
-
- for ( i = 0, remaining = height ;
- remaining > 0 ;
- remaining -= rows, y += rows, i++ )
- {
- height = (remaining >= rows) ? rows : remaining;
- dwords = width * height / texelsPerDword;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, " blitting: %d,%d at %d,%d - %d dwords\n",
- width, height, x, y, dwords );
- }
-
- /* Grab the indirect buffer for the texture blit */
- buffer = r128GetBufferLocked( rmesa );
-
- dst = (CARD32 *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
-
- /* Actually do the texture conversion */
- switch ( t->texelBytes ) {
- case 1:
- r128ConvertTexture8bpp( dst, image,
- x, y, width, height, width );
- break;
- case 2:
- r128ConvertTexture16bpp( dst, image,
- x, y, width, height, width );
- break;
- case 4:
- r128ConvertTexture32bpp( dst, image,
- x, y, width, height, width );
- break;
- }
-
- r128FireBlitLocked( rmesa, buffer,
- offset, pitch, format,
- x, y, width, height );
- }
-
- rmesa->new_state |= R128_NEW_CONTEXT;
- rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
-}
-/* Upload the texture images associated with texture `t'. This might
- * require removing our own and/or other client's texture objects to
- * make room for these images.
- */
-/* NOTE: This function is only called while holding the hardware lock */
-int r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t )
+static void r128TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- int i;
- int minLevel;
- int maxLevel;
- int heap;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %p )\n",
- __FUNCTION__, rmesa->glCtx, t );
- }
-
- if ( !t ) return 0;
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ r128TexObjPtr t = (r128TexObjPtr) texObj->DriverData;
- /* Choose the heap appropriately */
- heap = t->heap = R128_CARD_HEAP;
- if ( !rmesa->r128Screen->IsPCI &&
- t->totalSize > rmesa->r128Screen->texSize[heap] ) {
- heap = t->heap = R128_AGP_HEAP;
+ if ( t ) {
+ r128SwapOutTexObj( R128_CONTEXT(ctx), t );
}
-
- /* Do we need to eject LRU texture objects? */
- if ( !t->memBlock ) {
- /* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
- t->memBlock = mmAllocMem( rmesa->texHeap[heap], t->totalSize, 12, 0 );
-
- /* Try AGP before kicking anything out of local mem */
- if ( !rmesa->r128Screen->IsPCI &&
- !t->memBlock && heap == R128_CARD_HEAP ) {
- t->memBlock = mmAllocMem( rmesa->texHeap[R128_AGP_HEAP],
- t->totalSize, 12, 0 );
-
- if ( t->memBlock )
- heap = t->heap = R128_AGP_HEAP;
- }
-
- /* Kick out textures until the requested texture fits */
- while ( !t->memBlock ) {
- if ( rmesa->TexObjList[heap].prev->bound ) {
- fprintf( stderr,
- "r128UploadTexImages: ran into bound texture\n" );
- return -1;
- }
- if ( rmesa->TexObjList[heap].prev == &rmesa->TexObjList[heap] ) {
- if ( rmesa->r128Screen->IsPCI ) {
- fprintf( stderr, "r128UploadTexImages: upload texture "
- "failure on local texture heaps, sz=%d\n",
- t->totalSize );
- return -1;
- } else if ( heap == R128_CARD_HEAP ) {
- heap = t->heap = R128_AGP_HEAP;
- continue;
- } else {
- fprintf( stderr, "r128UploadTexImages: upload texture "
- "failure on both local and AGP texture heaps, "
- "sz=%d\n",
- t->totalSize );
- return -1;
- }
- }
-
- r128DestroyTexObj( rmesa, rmesa->TexObjList[heap].prev );
-
- t->memBlock = mmAllocMem( rmesa->texHeap[heap],
- t->totalSize, 12, 0 );
- }
-
- /* Set the base offset of the texture image */
- t->bufAddr = rmesa->r128Screen->texOffset[heap] + t->memBlock->ofs;
-
- maxLevel = ((t->setup.tex_size_pitch & R128_TEX_SIZE_MASK) >>
- R128_TEX_SIZE_SHIFT);
- minLevel = ((t->setup.tex_size_pitch & R128_TEX_MIN_SIZE_MASK) >>
- R128_TEX_MIN_SIZE_SHIFT);
-
- /* Set texture offsets */
- if ( t->setup.tex_cntl & R128_MIP_MAP_DISABLE ) {
- for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
- t->setup.tex_offset[i] = t->bufAddr;
- }
- } else {
- for ( i = maxLevel ; i >= minLevel ; i-- ) {
- t->setup.tex_offset[i] =
- (t->image[maxLevel-i].offset + t->bufAddr);
- }
- }
-
- /* Force loading the new state into the hardware */
- switch ( t->bound ) {
- case 1:
- rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX0;
- break;
-
- case 2:
- rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX1;
- break;
-
- default:
- return -1;
+ else {
+ t = r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
}
+ texObj->DriverData = t;
}
- /* Let the world know we've used this memory recently */
- r128UpdateTexLRU( rmesa, t );
+ /* Note, this will call r128ChooseTextureFormat */
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
- /* Upload any images that are new */
- if ( t->dirty_images ) {
- int num_levels = (((t->setup.tex_size_pitch & R128_TEX_SIZE_MASK) >>
- R128_TEX_SIZE_SHIFT) -
- ((t->setup.tex_size_pitch & R128_TEX_MIN_SIZE_MASK) >>
- R128_TEX_MIN_SIZE_SHIFT));
-
- for ( i = 0 ; i <= num_levels ; i++ ) {
- if ( t->dirty_images & (1 << i) ) {
- r128UploadSubImage( rmesa, t, i, 0, 0,
- t->image[i].width, t->image[i].height );
- }
- }
-
- rmesa->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
-
- rmesa->dirty |= R128_UPLOAD_CONTEXT;
- }
-
- t->dirty_images = 0;
- return 0;
+ t->dirty_images |= (1 << level);
+ rmesa->new_state |= R128_NEW_TEXTURE;
}
-/* ================================================================
- * Texture combine functions
- */
-
-#define COLOR_COMB_DISABLE (R128_COMB_DIS | \
- R128_COLOR_FACTOR_TEX)
-#define COLOR_COMB_COPY_INPUT (R128_COMB_COPY_INP | \
- R128_COLOR_FACTOR_TEX)
-#define COLOR_COMB_MODULATE (R128_COMB_MODULATE | \
- R128_COLOR_FACTOR_TEX)
-#define COLOR_COMB_MODULATE_NTEX (R128_COMB_MODULATE | \
- R128_COLOR_FACTOR_NTEX)
-#define COLOR_COMB_ADD (R128_COMB_ADD | \
- R128_COLOR_FACTOR_TEX)
-#define COLOR_COMB_BLEND_TEX (R128_COMB_BLEND_TEXTURE | \
- R128_COLOR_FACTOR_TEX)
-/* Rage 128 Pro/M3 only! */
-#define COLOR_COMB_BLEND_COLOR (R128_COMB_MODULATE2X | \
- R128_COMB_FCN_MSB | \
- R128_COLOR_FACTOR_CONST_COLOR)
-
-#define ALPHA_COMB_DISABLE (R128_COMB_ALPHA_DIS | \
- R128_ALPHA_FACTOR_TEX_ALPHA)
-#define ALPHA_COMB_COPY_INPUT (R128_COMB_ALPHA_COPY_INP | \
- R128_ALPHA_FACTOR_TEX_ALPHA)
-#define ALPHA_COMB_MODULATE (R128_COMB_ALPHA_MODULATE | \
- R128_ALPHA_FACTOR_TEX_ALPHA)
-#define ALPHA_COMB_MODULATE_NTEX (R128_COMB_ALPHA_MODULATE | \
- R128_ALPHA_FACTOR_NTEX_ALPHA)
-#define ALPHA_COMB_ADD (R128_COMB_ALPHA_ADD | \
- R128_ALPHA_FACTOR_TEX_ALPHA)
-
-#define INPUT_INTERP (R128_INPUT_FACTOR_INT_COLOR | \
- R128_INP_FACTOR_A_INT_ALPHA)
-#define INPUT_PREVIOUS (R128_INPUT_FACTOR_PREV_COLOR | \
- R128_INP_FACTOR_A_PREV_ALPHA)
-
-static void r128UpdateTextureEnv( GLcontext *ctx, int unit )
+static void r128TexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLint source = rmesa->tmu_source[unit];
- struct gl_texture_object *tObj;
- GLuint enabled;
- GLuint combine;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %d )\n",
- __FUNCTION__, ctx, unit );
- }
+ r128TexObjPtr t = (r128TexObjPtr) texObj->DriverData;
- enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
- if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D )
- return;
-
- /* Only update the hardware texture state if the texture is current,
- * complete and enabled.
- */
- tObj = ctx->Texture.Unit[source].Current;
- if ( !tObj || !tObj->Complete )
- return;
-
- if ( ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) &&
- ( tObj != ctx->Texture.Unit[source].CurrentD[1] ) )
- return;
-
- if ( unit == 0 ) {
- combine = INPUT_INTERP;
- } else {
- combine = INPUT_PREVIOUS;
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ r128SwapOutTexObj( R128_CONTEXT(ctx), t );
+ t->dirty_images |= (1 << level);
}
-
- /* Set the texture environment state */
- switch ( ctx->Texture.Unit[source].EnvMode ) {
- case GL_REPLACE:
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- combine |= (COLOR_COMB_DISABLE | /* C = Ct */
- ALPHA_COMB_DISABLE); /* A = At */
- break;
- case GL_RGB:
- case GL_LUMINANCE:
- combine |= (COLOR_COMB_DISABLE | /* C = Ct */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case GL_ALPHA:
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_DISABLE); /* A = At */
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_MODULATE:
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
- case GL_RGB:
- case GL_LUMINANCE:
- combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case GL_ALPHA:
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_DECAL:
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- combine |= (COLOR_COMB_BLEND_TEX | /* C = Cf(1-At)+CtAt */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case GL_RGB:
- combine |= (COLOR_COMB_DISABLE | /* C = Ct */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- case GL_INTENSITY:
- /* Undefined behaviour - just copy the incoming fragment */
- combine |= (COLOR_COMB_COPY_INPUT | /* C = undefined */
- ALPHA_COMB_COPY_INPUT); /* A = undefined */
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_BLEND:
- /* Rage 128 Pro and M3 can handle GL_BLEND texturing.
- */
- if ( !R128_IS_PLAIN( rmesa ) ) {
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
-
- case GL_RGB:
- case GL_LUMINANCE:
- combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
-
- case GL_ALPHA:
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
-
- case GL_INTENSITY:
- /* GH: We could be smarter about this... */
- switch ( rmesa->env_color & 0xff000000 ) {
- case 0x00000000:
- combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-It)+CcIt */
- ALPHA_COMB_MODULATE_NTEX); /* A = Af(1-It) */
- default:
- combine |= (COLOR_COMB_MODULATE | /* C = fallback */
- ALPHA_COMB_MODULATE); /* A = fallback */
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- break;
- }
- break;
-
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
- }
-
- /* Rage 128 has to fake some cases of GL_BLEND, otherwise fallback
- * to software rendering.
- */
- if ( rmesa->blend_flags ) {
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
+ else {
+ t = r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
}
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- switch ( rmesa->env_color & 0x00ffffff ) {
- case 0x00000000:
- combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
- case 0x00ffffff:
- if ( unit == 0 ) {
- combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- } else {
- combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- }
- break;
- default:
- combine |= (COLOR_COMB_MODULATE | /* C = fallback */
- ALPHA_COMB_MODULATE); /* A = fallback */
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- break;
- }
- break;
- case GL_RGB:
- case GL_LUMINANCE:
- switch ( rmesa->env_color & 0x00ffffff ) {
- case 0x00000000:
- combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case 0x00ffffff:
- if ( unit == 0 ) {
- combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- } else {
- combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- }
- break;
- default:
- combine |= (COLOR_COMB_MODULATE | /* C = fallback */
- ALPHA_COMB_COPY_INPUT); /* A = fallback */
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- break;
- }
- break;
- case GL_ALPHA:
- if ( unit == 0 ) {
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- } else {
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- }
- break;
- case GL_INTENSITY:
- switch ( rmesa->env_color & 0x00ffffff ) {
- case 0x00000000:
- combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
- break;
- case 0x00ffffff:
- if ( unit == 0 ) {
- combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
- } else {
- combine |= COLOR_COMB_ADD; /* C = Cf+It */
- }
- break;
- default:
- combine |= (COLOR_COMB_MODULATE | /* C = fallback */
- ALPHA_COMB_MODULATE); /* A = fallback */
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- break;
- }
- switch ( rmesa->env_color & 0xff000000 ) {
- case 0x00000000:
- combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
- break;
- case 0xff000000:
- if ( unit == 0 ) {
- combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
- } else {
- combine |= ALPHA_COMB_ADD; /* A = Af+It */
- }
- break;
- default:
- combine |= (COLOR_COMB_MODULATE | /* C = fallback */
- ALPHA_COMB_MODULATE); /* A = fallback */
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- break;
- }
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- case GL_ADD:
- switch ( tObj->Image[0]->Format ) {
- case GL_RGBA:
- case GL_LUMINANCE_ALPHA:
- combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
- case GL_RGB:
- case GL_LUMINANCE:
- combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
- ALPHA_COMB_COPY_INPUT); /* A = Af */
- break;
- case GL_ALPHA:
- combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
- ALPHA_COMB_MODULATE); /* A = AfAt */
- break;
- case GL_INTENSITY:
- combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
- ALPHA_COMB_ADD); /* A = Af+At */
- break;
- case GL_COLOR_INDEX:
- default:
- return;
- }
- break;
-
- default:
- return;
+ texObj->DriverData = t;
}
- rmesa->tex_combine[unit] = combine;
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images |= (1 << level);
+ rmesa->new_state |= R128_NEW_TEXTURE;
}
-static void r128UpdateTextureObject( GLcontext *ctx, int unit )
+
+static void r128TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- int source = rmesa->tmu_source[unit];
- struct gl_texture_object *tObj;
- r128TexObjPtr t;
- GLuint enabled;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %d ) really=0x%x\n",
- __FUNCTION__, ctx, unit, ctx->Texture.ReallyEnabled );
- }
-
- enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
- if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D ) {
- if ( enabled )
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- return;
- }
+ r128TexObjPtr t = (r128TexObjPtr) texObj->DriverData;
- /* Only update the hardware texture state if the texture is current,
- * complete and enabled.
- */
- tObj = ctx->Texture.Unit[source].Current;
- if ( !tObj || !tObj->Complete ) {
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- return;
- }
-
- if ( ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) &&
- ( tObj != ctx->Texture.Unit[source].CurrentD[1] ) ) {
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- return;
+ if ( t ) {
+ r128SwapOutTexObj( R128_CONTEXT(ctx), t );
}
-
- if ( !tObj->DriverData ) {
- /* If this is the first time the texture has been used, then create
- * a new texture object for it.
- */
- r128CreateTexObj( rmesa, tObj );
-
- if ( !tObj->DriverData ) {
- /* Can't create a texture object... */
- fprintf( stderr, "%s: texture object creation failed!\n",
- __FUNCTION__ );
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
- return;
+ else {
+ t = r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
}
+ texObj->DriverData = t;
}
- /* We definately have a valid texture now */
- t = tObj->DriverData;
-
- /* Force the texture unit state to be loaded into the hardware */
- rmesa->dirty |= R128_UPLOAD_CONTEXT | (R128_UPLOAD_TEX0 << unit);
-
- /* Force any texture images to be loaded into the hardware */
- if ( t->dirty_images )
- rmesa->dirty |= (R128_UPLOAD_TEX0IMAGES << unit);
-
- /* Bind to the given texture unit */
- rmesa->CurrentTexObj[unit] = t;
- t->bound |= unit + 1;
-
- if ( t->memBlock )
- r128UpdateTexLRU( rmesa, t );
-
- if ( unit == 0 ) {
- rmesa->setup.tex_cntl_c |= R128_TEXMAP_ENABLE;
- rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 0;
- rmesa->setup.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT;
+ /* Note, this will call r128ChooseTextureFormat */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
- t->setup.tex_cntl &= ~R128_SEC_SELECT_SEC_ST;
- } else {
- t->setup.tex_cntl |= R128_SEC_SELECT_SEC_ST;
-
- rmesa->setup.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE;
- rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 16;
- rmesa->setup.scale_3d_cntl |= R128_TEX_CACHE_SPLIT;
- }
+ t->dirty_images |= (1 << level);
+ rmesa->new_state |= R128_NEW_TEXTURE;
}
-void r128UpdateTextureState( GLcontext *ctx )
+
+static void r128TexSubImage2D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ r128TexObjPtr t = (r128TexObjPtr) texObj->DriverData;
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p ) en=0x%x\n",
- __FUNCTION__, ctx, ctx->Texture.ReallyEnabled );
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ r128SwapOutTexObj( R128_CONTEXT(ctx), t );
}
-
- /* Clear any texturing fallbacks */
- rmesa->Fallback &= ~R128_FALLBACK_TEXTURE;
-
- /* Unbind any currently bound textures */
- if ( rmesa->CurrentTexObj[0] ) rmesa->CurrentTexObj[0]->bound = 0;
- if ( rmesa->CurrentTexObj[1] ) rmesa->CurrentTexObj[1]->bound = 0;
- rmesa->CurrentTexObj[0] = NULL;
- rmesa->CurrentTexObj[1] = NULL;
-
- if ( ctx->Enabled & (TEXTURE0_3D|TEXTURE1_3D) )
- rmesa->Fallback |= R128_FALLBACK_TEXTURE;
-
- /* Disable all texturing until it is known to be good */
- rmesa->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE |
- R128_SEC_TEXMAP_ENABLE);
- rmesa->setup.tex_size_pitch_c = 0x00000000;
-
- r128UpdateTextureObject( ctx, 0 );
- r128UpdateTextureEnv( ctx, 0 );
-
- if ( rmesa->multitex ) {
- r128UpdateTextureObject( ctx, 1 );
- r128UpdateTextureEnv( ctx, 1 );
+ else {
+ t = r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ texObj->DriverData = t;
}
- rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+ t->dirty_images |= (1 << level);
+ rmesa->new_state |= R128_NEW_TEXTURE;
}
-/* ================================================================
- * DD interface texturing functions
- *
- * FIXME: Many of these are deprecated -- we should move to the new
- * single-copy texture interface.
- */
-
static void r128DDTexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
@@ -1439,7 +389,7 @@ static void r128DDTexEnv( GLcontext *ctx, GLenum target,
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s( %s )\n",
- __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
}
switch ( pname ) {
@@ -1450,7 +400,10 @@ static void r128DDTexEnv( GLcontext *ctx, GLenum target,
case GL_TEXTURE_ENV_COLOR:
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- FLOAT_RGBA_TO_UBYTE_RGBA( c, texUnit->EnvColor );
+ CLAMPED_FLOAT_TO_UBYTE( c[0], texUnit->EnvColor[0] );
+ CLAMPED_FLOAT_TO_UBYTE( c[1], texUnit->EnvColor[1] );
+ CLAMPED_FLOAT_TO_UBYTE( c[2], texUnit->EnvColor[2] );
+ CLAMPED_FLOAT_TO_UBYTE( c[3], texUnit->EnvColor[3] );
rmesa->env_color = r128PackColor( 4, c[0], c[1], c[2], c[3] );
if ( rmesa->setup.constant_color_c != rmesa->env_color ) {
FLUSH_BATCH( rmesa );
@@ -1516,81 +469,6 @@ static void r128DDTexEnv( GLcontext *ctx, GLenum target,
}
}
-static void r128DDTexImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint internalFormat,
- const struct gl_texture_image *image )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- r128TexObjPtr t;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API )
- fprintf( stderr, "%s( %p, level %d )\n", __FUNCTION__, tObj, level );
-
- if ( ( target != GL_TEXTURE_2D ) &&
- ( target != GL_TEXTURE_1D ) )
- return;
-
- if ( level >= R128_MAX_TEXTURE_LEVELS )
- return;
-
- t = (r128TexObjPtr)tObj->DriverData;
- if ( t ) {
- if ( t->bound ) FLUSH_BATCH( rmesa );
-
- /* Destroy the old texture, and upload a new one. The actual
- * uploading of the texture image occurs in the UploadSubImage
- * function.
- */
- r128DestroyTexObj( rmesa, t );
- rmesa->new_state |= R128_NEW_TEXTURE;
- }
-}
-
-static void r128DDTexSubImage( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLint internalFormat,
- const struct gl_texture_image *image )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- r128TexObjPtr t;
-
- if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, level %d ) size: %d,%d of %d,%d\n",
- __FUNCTION__, tObj, level, width, height,
- image->Width, image->Height );
- }
-
- if ( ( target != GL_TEXTURE_2D ) &&
- ( target != GL_TEXTURE_1D ) )
- return;
-
- if ( level >= R128_MAX_TEXTURE_LEVELS )
- return;
-
- t = (r128TexObjPtr)tObj->DriverData;
- if ( t ) {
- if ( t->bound ) FLUSH_BATCH( rmesa );
-
-#if 0
- /* FIXME: Only upload textures if we already have space in the heap.
- */
- LOCK_HARDWARE( rmesa );
- r128UploadSubImage( rmesa, t, level,
- xoffset, yoffset, width, height );
- UNLOCK_HARDWARE( rmesa );
-
- /* Update the context state */
- rmesa->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
-#else
- r128DestroyTexObj( rmesa, t );
-#endif
-
- rmesa->new_state |= R128_NEW_TEXTURE;
- }
-}
static void r128DDTexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
@@ -1601,19 +479,20 @@ static void r128DDTexParameter( GLcontext *ctx, GLenum target,
if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s( %s )\n",
- __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
}
- /* If we don't have a hardware texture, it will be automatically
- * created with current state before it is used, so we don't have
- * to do anything now.
- */
- if ( !t || !t->bound )
+ if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) )
return;
- if ( ( target != GL_TEXTURE_2D ) &&
- ( target != GL_TEXTURE_1D ) )
- return;
+ if (!t) {
+ t = r128AllocTexObj(tObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexParameter");
+ return;
+ }
+ tObj->DriverData = t;
+ }
switch ( pname ) {
case GL_TEXTURE_MIN_FILTER:
@@ -1633,6 +512,19 @@ static void r128DDTexParameter( GLcontext *ctx, GLenum target,
r128SetTexBorderColor( t, tObj->BorderColor );
break;
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for R128. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ if ( t->bound ) FLUSH_BATCH( rmesa );
+ r128SwapOutTexObj( rmesa, t );
+ break;
+
default:
return;
}
@@ -1654,7 +546,7 @@ static void r128DDBindTexture( GLcontext *ctx, GLenum target,
FLUSH_BATCH( rmesa );
if ( rmesa->CurrentTexObj[unit] ) {
- rmesa->CurrentTexObj[unit]->bound &= ~(unit+1);
+ rmesa->CurrentTexObj[unit]->bound &= ~(1 << unit);
rmesa->CurrentTexObj[unit] = NULL;
}
@@ -1694,8 +586,19 @@ static GLboolean r128DDIsTextureResident( GLcontext *ctx,
void r128DDInitTextureFuncs( GLcontext *ctx )
{
ctx->Driver.TexEnv = r128DDTexEnv;
- ctx->Driver.TexImage = r128DDTexImage;
- ctx->Driver.TexSubImage = r128DDTexSubImage;
+ ctx->Driver.ChooseTextureFormat = r128ChooseTextureFormat;
+ ctx->Driver.TexImage1D = r128TexImage1D;
+ ctx->Driver.TexSubImage1D = r128TexSubImage1D;
+ ctx->Driver.TexImage2D = r128TexImage2D;
+ ctx->Driver.TexSubImage2D = r128TexSubImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
ctx->Driver.TexParameter = r128DDTexParameter;
ctx->Driver.BindTexture = r128DDBindTexture;
ctx->Driver.DeleteTexture = r128DDDeleteTexture;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.h b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
index 4e8822947..7a983ea19 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.6 2001/04/10 17:53:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.4 2001/01/08 01:07:23 martin Exp $ */
/**************************************************************************
Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
@@ -40,11 +40,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
extern void r128UpdateTextureState( GLcontext *ctx );
-extern int r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t );
+extern void r128SwapOutTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
+
+extern void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t );
extern void r128AgeTextures( r128ContextPtr rmesa, int heap );
extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
+extern void r128UpdateTexLRU( r128ContextPtr rmesa, r128TexObjPtr t );
+
extern void r128PrintLocalLRU( r128ContextPtr rmesa, int heap );
extern void r128PrintGlobalLRU( r128ContextPtr rmesa, int heap );
@@ -74,24 +78,6 @@ extern void r128DDInitTextureFuncs( GLcontext *ctx );
#define R128PACKCOLOR4444( r, g, b, a ) \
((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-#include "X11/Xarch.h"
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-#define R128PACKCOLORS565( r0, g0, b0, r1, g1, b1 ) \
- ((R128PACKCOLOR565( r0, g0, b0 )) | \
- (R128PACKCOLOR565( r1, g1, b1 ) << 16))
-#define R128PACKCOLORS4444( r0, g0, b0, a0, r1, g1, b1, a1 ) \
- ((R128PACKCOLOR4444( r0, g0, b0, a0 )) | \
- (R128PACKCOLOR4444( r1, g1, b1, a1 ) << 16))
-#else
-#define R128PACKCOLORS565( r0, g0, b0, r1, g1, b1 ) \
- ((R128PACKCOLOR565( r1, g1, b1 )) | \
- (R128PACKCOLOR565( r0, g0, b0 ) << 16))
-#define R128PACKCOLORS4444( r0, g0, b0, a0, r1, g1, b1, a1 ) \
- ((R128PACKCOLOR4444( r1, g1, b1, a1 )) | \
- (R128PACKCOLOR4444( r0, g0, b0, a0 ) << 16))
-
-#endif
-
static __inline__ CARD32 r128PackColor( GLuint cpp,
GLubyte r, GLubyte g,
GLubyte b, GLubyte a )
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_texmem.c b/xc/lib/GL/mesa/src/drv/r128/r128_texmem.c
new file mode 100644
index 000000000..3f40c4a45
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_texmem.c
@@ -0,0 +1,592 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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, PRECISION INSIGHT 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_vb.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+
+#include "context.h"
+#include "macros.h"
+#include "mmath.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "mem.h"
+
+#define TEX_0 1
+#define TEX_1 2
+
+
+/* Destroy hardware state associated with texture `t'.
+ */
+void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ rmesa->c_textureSwaps++;
+#endif
+ if ( !t ) return;
+
+ if ( t->memBlock ) {
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+ }
+
+ if ( t->tObj )
+ t->tObj->DriverData = NULL;
+
+ if ( t->bound & TEX_0 ) rmesa->CurrentTexObj[0] = NULL;
+ if ( t->bound & TEX_1 ) rmesa->CurrentTexObj[1] = NULL;
+
+ remove_from_list( t );
+ FREE( t );
+}
+
+/* Keep track of swapped out texture objects.
+ */
+void r128SwapOutTexObj( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ rmesa->c_textureSwaps++;
+#endif
+ if ( t->memBlock ) {
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail( &rmesa->SwappedOut, t );
+}
+
+/* Print out debugging information about texture LRU.
+ */
+void r128PrintLocalLRU( r128ContextPtr rmesa, int heap )
+{
+ r128TexObjPtr t;
+ int sz = 1 << (rmesa->r128Screen->logTexGranularity[heap]);
+
+ fprintf( stderr, "\nLocal LRU, heap %d:\n", heap );
+
+ foreach ( t, &rmesa->TexObjList[heap] ) {
+ if ( !t->tObj ) {
+ fprintf( stderr, "Placeholder %d at 0x%x sz 0x%x\n",
+ t->memBlock->ofs / sz,
+ t->memBlock->ofs,
+ t->memBlock->size );
+ } else {
+ fprintf( stderr, "Texture (bound %d) at 0x%x sz 0x%x\n",
+ t->bound,
+ t->memBlock->ofs,
+ t->memBlock->size );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+void r128PrintGlobalLRU( r128ContextPtr rmesa, int heap )
+{
+ r128_tex_region_t *list = rmesa->sarea->texList[heap];
+ int i, j;
+
+ fprintf( stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list );
+
+ for ( i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++ ) {
+ fprintf( stderr, "list[%d] age %d next %d prev %d\n",
+ j, list[j].age, list[j].next, list[j].prev );
+ j = list[j].next;
+ if ( j == R128_NR_TEX_REGIONS ) break;
+ }
+
+ if ( j != R128_NR_TEX_REGIONS ) {
+ fprintf( stderr, "Loop detected in global LRU\n" );
+ for ( i = 0 ; i < R128_NR_TEX_REGIONS ; i++ ) {
+ fprintf( stderr, "list[%d] age %d next %d prev %d\n",
+ i, list[i].age, list[i].next, list[i].prev );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+/* Reset the global texture LRU.
+ */
+static void r128ResetGlobalLRU( r128ContextPtr rmesa, int heap )
+{
+ r128_tex_region_t *list = rmesa->sarea->texList[heap];
+ int sz = 1 << rmesa->r128Screen->logTexGranularity[heap];
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element in
+ * the array (R128_NR_TEX_REGIONS) is the sentinal. Keeping it at
+ * the end of the array allows it to be addressed rationally when
+ * looking up objects at a particular location in texture memory.
+ */
+ for ( i = 0 ; (i+1) * sz <= rmesa->r128Screen->texSize[heap] ; i++ ) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = R128_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = R128_NR_TEX_REGIONS;
+ list[R128_NR_TEX_REGIONS].prev = i;
+ list[R128_NR_TEX_REGIONS].next = 0;
+ rmesa->sarea->texAge[heap] = 0;
+}
+
+/* Update the local and glock texture LRUs.
+ */
+void r128UpdateTexLRU( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+ int heap = t->heap;
+ r128_tex_region_t *list = rmesa->sarea->texList[heap];
+ int log2sz = rmesa->r128Screen->logTexGranularity[heap];
+ int start = t->memBlock->ofs >> log2sz;
+ int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
+ int i;
+
+ rmesa->lastTexAge[heap] = ++rmesa->sarea->texAge[heap];
+
+ if ( !t->memBlock ) {
+ fprintf( stderr, "no memblock\n\n" );
+ return;
+ }
+
+ /* Update our local LRU */
+ move_to_head( &rmesa->TexObjList[heap], t );
+
+ /* Update the global LRU */
+ for ( i = start ; i <= end ; i++ ) {
+ list[i].in_use = 1;
+ list[i].age = rmesa->lastTexAge[heap];
+
+ /* remove_from_list(i) */
+ list[(CARD32)list[i].next].prev = list[i].prev;
+ list[(CARD32)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i) */
+ list[i].prev = R128_NR_TEX_REGIONS;
+ list[i].next = list[R128_NR_TEX_REGIONS].next;
+ list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i;
+ list[R128_NR_TEX_REGIONS].next = i;
+ }
+
+ if ( 0 ) {
+ r128PrintGlobalLRU( rmesa, t->heap );
+ r128PrintLocalLRU( rmesa, t->heap );
+ }
+}
+
+/* Update our notion of what textures have been changed since we last
+ * held the lock. This pertains to both our local textures and the
+ * textures belonging to other clients. Keep track of other client's
+ * textures by pushing a placeholder texture onto the LRU list -- these
+ * are denoted by (tObj == NULL).
+ */
+static void r128TexturesGone( r128ContextPtr rmesa, int heap,
+ int offset, int size, int in_use )
+{
+ r128TexObjPtr t, tmp;
+
+ foreach_s ( t, tmp, &rmesa->TexObjList[heap] ) {
+ if ( t->memBlock->ofs >= offset + size ||
+ t->memBlock->ofs + t->memBlock->size <= offset )
+ continue;
+
+ /* It overlaps - kick it out. Need to hold onto the currently
+ * bound objects, however.
+ */
+ if ( t->bound ) {
+ r128SwapOutTexObj( rmesa, t );
+ } else {
+ r128DestroyTexObj( rmesa, t );
+ }
+ }
+
+ if ( in_use ) {
+ t = (r128TexObjPtr) CALLOC( sizeof(*t) );
+ if ( !t ) return;
+
+ t->memBlock = mmAllocMem( rmesa->texHeap[heap], size, 0, offset );
+ if ( !t->memBlock ) {
+ fprintf( stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
+ (int)size, (int)offset );
+ mmDumpMemInfo( rmesa->texHeap[heap] );
+ return;
+ }
+ insert_at_head( &rmesa->TexObjList[heap], t );
+ }
+}
+
+/* Update our client's shared texture state. If another client has
+ * modified a region in which we have textures, then we need to figure
+ * out which of our textures has been removed, and update our global
+ * LRU.
+ */
+void r128AgeTextures( r128ContextPtr rmesa, int heap )
+{
+ R128SAREAPrivPtr sarea = rmesa->sarea;
+
+ if ( sarea->texAge[heap] != rmesa->lastTexAge[heap] ) {
+ int sz = 1 << rmesa->r128Screen->logTexGranularity[heap];
+ int nr = 0;
+ int idx;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in our local list... Fix with a cursor pointer.
+ */
+ for ( idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev ;
+ idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS ;
+ idx = sarea->texList[heap][idx].prev, nr++ )
+ {
+ /* If switching texturing schemes, then the SAREA might not
+ * have been properly cleared, so we need to reset the
+ * global texture LRU.
+ */
+ if ( idx * sz > rmesa->r128Screen->texSize[heap] ) {
+ nr = R128_NR_TEX_REGIONS;
+ break;
+ }
+
+ if ( sarea->texList[heap][idx].age > rmesa->lastTexAge[heap] ) {
+ r128TexturesGone( rmesa, heap, idx * sz, sz,
+ sarea->texList[heap][idx].in_use );
+ }
+ }
+
+ /* If switching texturing schemes, then the SAREA might not
+ * have been properly cleared, so we need to reset the
+ * global texture LRU.
+ */
+ if ( nr == R128_NR_TEX_REGIONS ) {
+ r128TexturesGone( rmesa, heap, 0,
+ rmesa->r128Screen->texSize[heap], 0 );
+ r128ResetGlobalLRU( rmesa, heap );
+ }
+
+ if ( 0 ) {
+ r128PrintGlobalLRU( rmesa, heap );
+ r128PrintLocalLRU( rmesa, heap );
+ }
+
+ rmesa->dirty |= (R128_UPLOAD_CONTEXT |
+ R128_UPLOAD_TEX0IMAGES |
+ R128_UPLOAD_TEX1IMAGES);
+ rmesa->lastTexAge[heap] = sarea->texAge[heap];
+ }
+}
+
+
+/* Upload the texture image associated with texture `t' at level `level'
+ * at the address relative to `start'.
+ */
+static void r128UploadSubImage( r128ContextPtr rmesa,
+ r128TexObjPtr t, int level,
+ int x, int y, int width, int height )
+{
+ struct gl_texture_image *image;
+ int texelsPerDword = 0;
+ int imageWidth, imageHeight;
+ int remaining, rows;
+ int format, dwords;
+ CARD32 pitch, offset;
+ int i;
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( level < 0 ) || ( level > R128_MAX_TEXTURE_LEVELS ) )
+ return;
+
+ image = t->tObj->Image[level];
+ if ( !image )
+ return;
+
+ switch ( image->TexFormat->TexelBytes ) {
+ case 1: texelsPerDword = 4; break;
+ case 2: texelsPerDword = 2; break;
+ case 4: texelsPerDword = 1; break;
+ }
+
+#if 1
+ /* FIXME: The subimage index calcs are wrong... */
+ x = 0;
+ y = 0;
+ width = image->Width;
+ height = image->Height;
+#endif
+
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+
+ format = t->textureFormat >> 16;
+
+ /* The texel upload routines have a minimum width, so force the size
+ * if needed.
+ */
+ if ( imageWidth < texelsPerDword ) {
+ int factor;
+
+ factor = texelsPerDword / imageWidth;
+ imageWidth = texelsPerDword;
+ imageHeight /= factor;
+ if ( imageHeight == 0 ) {
+ /* In this case, the texel converter will actually walk a
+ * texel or two off the end of the image, but normal malloc
+ * alignment should prevent it from ever causing a fault.
+ */
+ imageHeight = 1;
+ }
+ }
+
+ /* We can't upload to a pitch less than 8 texels so we will need to
+ * linearly upload all modified rows for textures smaller than this.
+ * This makes the x/y/width/height different for the blitter and the
+ * texture walker.
+ */
+ if ( imageWidth >= 8 ) {
+ /* The texture walker and the blitter look identical */
+ pitch = imageWidth >> 3;
+ } else {
+ int factor;
+ int y2;
+ int start, end;
+
+ start = (y * imageWidth) & ~7;
+ end = (y + height) * imageWidth;
+
+ if ( end - start < 8 ) {
+ /* Handle the case where the total number of texels
+ * uploaded is < 8.
+ */
+ x = 0;
+ y = start / 8;
+ width = end - start;
+ height = 1;
+ } else {
+ /* Upload some number of full 8 texel blit rows */
+ factor = 8 / imageWidth;
+
+ y2 = y + height - 1;
+ y /= factor;
+ y2 /= factor;
+
+ x = 0;
+ width = 8;
+ height = y2 - y + 1;
+ }
+
+ /* Fixed pitch of 8 */
+ pitch = 1;
+ }
+
+ dwords = width * height / texelsPerDword;
+ offset = t->bufAddr + t->image[level - t->firstLevel].offset;
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ rmesa->c_textureBytes += (dwords << 2);
+#endif
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n",
+ width, height, image->Width, image->Height, x, y );
+ fprintf( stderr, " blit ofs: 0x%07x pitch: 0x%x dwords: %d "
+ "level: %d format: %x\n",
+ (GLuint)offset, (GLuint)pitch, dwords, level, format );
+ }
+
+ /* Subdivide the texture if required */
+ if ( dwords <= R128_BUFFER_MAX_DWORDS / 2 ) {
+ rows = height;
+ } else {
+ rows = (R128_BUFFER_MAX_DWORDS * texelsPerDword) / (2 * width);
+ }
+
+ for ( i = 0, remaining = height ;
+ remaining > 0 ;
+ remaining -= rows, y += rows, i++ )
+ {
+ CARD32 *dst;
+ drmBufPtr buffer;
+
+ height = MIN2(remaining, rows);
+
+ /* Grab the indirect buffer for the texture blit */
+ buffer = r128GetBufferLocked( rmesa );
+
+ dst = (CARD32 *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
+
+ assert(image->Data);
+
+ /* Copy the next chunck of the texture image into the blit buffer */
+ {
+ const GLubyte *src = (const GLubyte *) image->Data +
+ (y * image->Width + x) * image->TexFormat->TexelBytes;
+ const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ memcpy(dst, src, bytes);
+ }
+
+ r128FireBlitLocked( rmesa, buffer,
+ offset, pitch, format,
+ x, y, width, height );
+ }
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+}
+
+
+/* Upload the texture images associated with texture `t'. This might
+ * require removing our own and/or other client's texture objects to
+ * make room for these images.
+ */
+/* NOTE: This function is only called while holding the hardware lock */
+void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+ const GLint numLevels = t->lastLevel - t->firstLevel + 1;
+ GLint i, heap;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %p )\n",
+ __FUNCTION__, rmesa->glCtx, t );
+ }
+
+ assert(t);
+
+ /* Choose the heap appropriately */
+ heap = t->heap = R128_CARD_HEAP;
+ if ( !rmesa->r128Screen->IsPCI &&
+ t->totalSize > rmesa->r128Screen->texSize[heap] ) {
+ heap = t->heap = R128_AGP_HEAP;
+ }
+
+ /* Do we need to eject LRU texture objects? */
+ if ( !t->memBlock ) {
+ /* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
+ t->memBlock = mmAllocMem( rmesa->texHeap[heap], t->totalSize, 12, 0 );
+
+ /* Try AGP before kicking anything out of local mem */
+ if ( !t->memBlock && heap == R128_CARD_HEAP ) {
+ t->memBlock = mmAllocMem( rmesa->texHeap[R128_AGP_HEAP],
+ t->totalSize, 12, 0 );
+
+ if ( t->memBlock )
+ heap = t->heap = R128_AGP_HEAP;
+ }
+
+ /* Kick out textures until the requested texture fits */
+ while ( !t->memBlock ) {
+ if ( rmesa->TexObjList[heap].prev->bound ) {
+ fprintf( stderr,
+ "r128UploadTexImages: ran into bound texture\n" );
+ return;
+ }
+ if ( rmesa->TexObjList[heap].prev == &rmesa->TexObjList[heap] ) {
+ if ( rmesa->r128Screen->IsPCI ) {
+ fprintf( stderr, "r128UploadTexImages: upload texture "
+ "failure on local texture heaps, sz=%d\n",
+ t->totalSize );
+ return;
+ } else if ( heap == R128_CARD_HEAP ) {
+ heap = t->heap = R128_AGP_HEAP;
+ continue;
+ } else {
+ fprintf( stderr, "r128UploadTexImages: upload texture "
+ "failure on both local and AGP texture heaps, "
+ "sz=%d\n",
+ t->totalSize );
+ return;
+ }
+ }
+
+ r128DestroyTexObj( rmesa, rmesa->TexObjList[heap].prev );
+
+ t->memBlock = mmAllocMem( rmesa->texHeap[heap],
+ t->totalSize, 12, 0 );
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = rmesa->r128Screen->texOffset[heap] + t->memBlock->ofs;
+
+ /* Set texture offsets for each mipmap level */
+ if ( t->setup.tex_cntl & R128_MIP_MAP_DISABLE ) {
+ for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
+ t->setup.tex_offset[i] = t->bufAddr;
+ }
+ } else {
+ for ( i = 0; i < numLevels; i++ ) {
+ const int j = numLevels - i - 1;
+ t->setup.tex_offset[j] = t->bufAddr + t->image[i].offset;
+ }
+ }
+
+ /* Force loading the new state into the hardware */
+ switch ( t->bound ) {
+ case 1:
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX0;
+ break;
+
+ case 2:
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_TEX1;
+ break;
+
+ default:
+ return;
+ }
+ }
+
+ /* Let the world know we've used this memory recently */
+ r128UpdateTexLRU( rmesa, t );
+
+ /* Upload any images that are new */
+ if ( t->dirty_images ) {
+ for ( i = 0 ; i < numLevels; i++ ) {
+ const GLint j = t->firstLevel + i; /* the texObj's level */
+ if ( t->dirty_images & (1 << j) ) {
+ r128UploadSubImage( rmesa, t, j, 0, 0,
+ t->image[i].width, t->image[i].height );
+ }
+ }
+
+ rmesa->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ t->dirty_images = 0;
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h b/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
index 9939c219b..c1f1e8bd4 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_texobj.h
@@ -72,12 +72,14 @@ struct r128_tex_obj {
GLint totalSize; /* Total size of the texture
including all mipmap levels */
- GLuint internFormat; /* Internal GL format used to store
- texture on card */
CARD32 textureFormat; /* Actual hardware format */
- GLint texelBytes; /* Number of bytes per texel */
r128_texture_regs_t setup; /* Setup regs for texture */
+
+ /* texObj->Image[firstLevel] through texObj->Image[lastLevel] are the
+ * images to upload.
+ */
+ GLint firstLevel, lastLevel;
};
#endif /* _R128_TEXOBJ_H_ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_texstate.c b/xc/lib/GL/mesa/src/drv/r128/r128_texstate.c
new file mode 100644
index 000000000..0a8aae9c7
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_texstate.c
@@ -0,0 +1,597 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.7 2001/01/08 01:07:21 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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, PRECISION INSIGHT 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_vb.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+
+#include "context.h"
+#include "macros.h"
+#include "mem.h"
+#include "texformat.h"
+
+
+static void r128SetTexImages( r128ContextPtr rmesa,
+ const struct gl_texture_object *tObj )
+{
+ r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData;
+ struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
+ int log2Pitch, log2Height, log2Size, log2MinSize;
+ int totalSize;
+ int i;
+ GLint firstLevel, lastLevel;
+
+ assert(t);
+ assert(baseImage);
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj );
+
+ switch (baseImage->TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB8888:
+ t->textureFormat = R128_DATATYPE_ARGB8888;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ t->textureFormat = R128_DATATYPE_ARGB4444;
+ break;
+ case MESA_FORMAT_RGB565:
+ t->textureFormat = R128_DATATYPE_RGB565;
+ break;
+ case MESA_FORMAT_RGB332:
+ t->textureFormat = R128_DATATYPE_RGB8;
+ break;
+ case MESA_FORMAT_CI8:
+ t->textureFormat = R128_DATATYPE_CI8;
+ break;
+ default:
+ _mesa_problem(rmesa->glCtx, "Bad texture format in r128SetTexImages");
+ };
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+
+ log2Pitch = tObj->Image[firstLevel]->WidthLog2;
+ log2Height = tObj->Image[firstLevel]->HeightLog2;
+ log2Size = MAX2(log2Pitch, log2Height);
+ log2MinSize = log2Size;
+
+ t->dirty_images = 0;
+ totalSize = 0;
+ for ( i = firstLevel; i <= lastLevel; i++ ) {
+ const struct gl_texture_image *texImage;
+
+ texImage = tObj->Image[i];
+ if ( !texImage || !texImage->Data ) {
+ lastLevel = i - 1;
+ break;
+ }
+
+ log2MinSize = texImage->MaxLog2;
+
+ t->image[i - firstLevel].offset = totalSize;
+ t->image[i - firstLevel].width = tObj->Image[i]->Width;
+ t->image[i - firstLevel].height = tObj->Image[i]->Height;
+
+ t->dirty_images |= (1 << i);
+
+ totalSize += (tObj->Image[i]->Height *
+ tObj->Image[i]->Width *
+ tObj->Image[i]->TexFormat->TexelBytes);
+
+ /* Offsets must be 32-byte aligned for host data blits and tiling */
+ totalSize = (totalSize + 31) & ~31;
+ }
+
+ t->totalSize = totalSize;
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ /* Set the texture format */
+ t->setup.tex_cntl &= ~(0xf << 16);
+ t->setup.tex_cntl |= t->textureFormat;
+
+ t->setup.tex_combine_cntl = 0x00000000; /* XXX is this right? */
+
+ t->setup.tex_size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) |
+ (log2Size << R128_TEX_SIZE_SHIFT) |
+ (log2Height << R128_TEX_HEIGHT_SHIFT) |
+ (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
+
+ for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
+ t->setup.tex_offset[i] = 0x00000000;
+ }
+
+ if (firstLevel == lastLevel)
+ t->setup.tex_cntl |= R128_MIP_MAP_DISABLE;
+ else
+ t->setup.tex_cntl &= ~R128_MIP_MAP_DISABLE;
+
+ /* XXX this is done in r128EmitHwStateLocked():
+ r128UploadTexImages( rmesa, t );
+ */
+}
+
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+#define COLOR_COMB_DISABLE (R128_COMB_DIS | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_COPY_INPUT (R128_COMB_COPY_INP | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE (R128_COMB_MODULATE | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE_NTEX (R128_COMB_MODULATE | \
+ R128_COLOR_FACTOR_NTEX)
+#define COLOR_COMB_ADD (R128_COMB_ADD | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_BLEND_TEX (R128_COMB_BLEND_TEXTURE | \
+ R128_COLOR_FACTOR_TEX)
+/* Rage 128 Pro/M3 only! */
+#define COLOR_COMB_BLEND_COLOR (R128_COMB_MODULATE2X | \
+ R128_COMB_FCN_MSB | \
+ R128_COLOR_FACTOR_CONST_COLOR)
+
+#define ALPHA_COMB_DISABLE (R128_COMB_ALPHA_DIS | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_COPY_INPUT (R128_COMB_ALPHA_COPY_INP | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE (R128_COMB_ALPHA_MODULATE | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE_NTEX (R128_COMB_ALPHA_MODULATE | \
+ R128_ALPHA_FACTOR_NTEX_ALPHA)
+#define ALPHA_COMB_ADD (R128_COMB_ALPHA_ADD | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+
+#define INPUT_INTERP (R128_INPUT_FACTOR_INT_COLOR | \
+ R128_INP_FACTOR_A_INT_ALPHA)
+#define INPUT_PREVIOUS (R128_INPUT_FACTOR_PREV_COLOR | \
+ R128_INP_FACTOR_A_PREV_ALPHA)
+
+static void r128UpdateTextureEnv( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLint source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLenum format = tObj->Image[tObj->BaseLevel]->Format;
+ GLuint combine;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %d )\n",
+ __FUNCTION__, ctx, unit );
+ }
+
+ if ( unit == 0 ) {
+ combine = INPUT_INTERP;
+ } else {
+ combine = INPUT_PREVIOUS;
+ }
+
+ /* Set the texture environment state */
+ switch ( texUnit->EnvMode ) {
+ case GL_REPLACE:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_DISABLE); /* A = At */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_DISABLE); /* A = At */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_DECAL:
+ switch ( format ) {
+ case GL_RGBA:
+ combine |= (COLOR_COMB_BLEND_TEX | /* C = Cf(1-At)+CtAt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_RGB:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* Undefined behaviour - just copy the incoming fragment */
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = undefined */
+ ALPHA_COMB_COPY_INPUT); /* A = undefined */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ /* Rage 128 Pro and M3 can handle GL_BLEND texturing.
+ */
+ if ( !R128_IS_PLAIN( rmesa ) ) {
+ /* XXX this hasn't been fully tested, I don't have a Pro card. -BP */
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+
+ case GL_INTENSITY:
+ /* GH: We could be smarter about this... */
+ switch ( rmesa->env_color & 0xff000000 ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-It)+CcIt */
+ ALPHA_COMB_MODULATE_NTEX); /* A = Af(1-It) */
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ break;
+ }
+ break;
+
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+ }
+
+ /* Rage 128 has to fake some cases of GL_BLEND, otherwise fallback
+ * to software rendering.
+ */
+ if ( rmesa->blend_flags ) {
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ } else {
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ break;
+ }
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ } else {
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_COPY_INPUT); /* A = fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ break;
+ }
+ break;
+ case GL_ALPHA:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ } else {
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+ case GL_INTENSITY:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
+ } else {
+ combine |= COLOR_COMB_ADD; /* C = Cf+It */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ break;
+ }
+ switch ( rmesa->env_color & 0xff000000 ) {
+ case 0x00000000:
+ combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0xff000000:
+ if ( unit == 0 ) {
+ combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
+ } else {
+ combine |= ALPHA_COMB_ADD; /* A = Af+It */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ break;
+ }
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_ADD:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_ADD); /* A = Af+At */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ rmesa->tex_combine[unit] = combine;
+}
+
+static void r128UpdateTextureUnit( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const int source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = ctx->Texture.Unit[source]._Current;
+ r128TexObjPtr t = tObj->DriverData;
+
+ assert(unit == 0 || unit == 1); /* only two tex units */
+
+ if (texUnit->_ReallyEnabled & (TEXTURE0_1D | TEXTURE0_2D)) {
+
+ assert(t); /* should have driver tex data by now */
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[tObj->BaseLevel]->Border > 0 ) {
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+
+ /* Upload teximages */
+ if (t->dirty_images) {
+ r128SetTexImages( rmesa, tObj );
+ }
+
+ /* Bind to the given texture unit */
+ rmesa->CurrentTexObj[unit] = t;
+ t->bound |= (1 << unit);
+
+ if ( t->memBlock )
+ r128UpdateTexLRU( rmesa, t );
+
+ /* register setup */
+ if ( unit == 0 ) {
+ rmesa->setup.tex_cntl_c |= R128_TEXMAP_ENABLE;
+ rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 0;
+ rmesa->setup.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT;
+ t->setup.tex_cntl &= ~R128_SEC_SELECT_SEC_ST;
+ }
+ else {
+ rmesa->setup.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE;
+ rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 16;
+ rmesa->setup.scale_3d_cntl |= R128_TEX_CACHE_SPLIT;
+ t->setup.tex_cntl |= R128_SEC_SELECT_SEC_ST;
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ /* 3D or cube map texture enabled - fallback */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else {
+ /* texture unit disabled */
+ }
+}
+
+
+void r128UpdateTextureState( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p ) enabled=0x%x\n",
+ __FUNCTION__, ctx, ctx->Texture._ReallyEnabled );
+ }
+
+ /* Clear any texturing fallbacks */
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, GL_FALSE );
+
+ /* Unbind any currently bound textures */
+ if ( rmesa->CurrentTexObj[0] ) rmesa->CurrentTexObj[0]->bound = 0;
+ if ( rmesa->CurrentTexObj[1] ) rmesa->CurrentTexObj[1]->bound = 0;
+ rmesa->CurrentTexObj[0] = NULL;
+ rmesa->CurrentTexObj[1] = NULL;
+
+ /* Disable all texturing until it is known to be good */
+ rmesa->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE |
+ R128_SEC_TEXMAP_ENABLE);
+ rmesa->setup.tex_size_pitch_c = 0x00000000;
+
+ /*
+ * Now examine texture enable state to do rest of setup.
+ */
+ rmesa->tmu_source[0] = 0;
+ rmesa->tmu_source[1] = 1;
+ rmesa->blend_flags &= ~R128_BLEND_MULTITEX;
+
+ if (ctx->Texture._ReallyEnabled & TEXTURE1_ANY) {
+ if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
+ /* both texture 0 and 1 enabled */
+ if ( R128_IS_PLAIN( rmesa ) )
+ rmesa->blend_flags |= R128_BLEND_MULTITEX;
+ r128UpdateTextureUnit( ctx, 0 );
+ r128UpdateTextureEnv( ctx, 0 );
+ r128UpdateTextureUnit( ctx, 1 );
+ r128UpdateTextureEnv( ctx, 1 );
+ rmesa->dirty |= (R128_UPLOAD_TEX0IMAGES | R128_UPLOAD_TEX0 |
+ R128_UPLOAD_TEX1IMAGES | R128_UPLOAD_TEX1);
+ }
+ else {
+ /* only texture 1 enabled */
+ rmesa->tmu_source[0] = 1;
+ rmesa->tmu_source[1] = 0;
+ r128UpdateTextureUnit( ctx, 0 );
+ r128UpdateTextureEnv( ctx, 0 );
+ rmesa->dirty |= (R128_UPLOAD_TEX0IMAGES | R128_UPLOAD_TEX0);
+ }
+ }
+ else if (ctx->Texture._ReallyEnabled & TEXTURE0_ANY) {
+ /* only texture 0 enabled */
+ r128UpdateTextureUnit( ctx, 0 );
+ r128UpdateTextureEnv( ctx, 0 );
+ rmesa->dirty |= (R128_UPLOAD_TEX0IMAGES | R128_UPLOAD_TEX0);
+ }
+
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
index 261142d75..bd6248261 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c
@@ -1,8 +1,9 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.6 2001/04/10 17:53:07 dawes Exp $ */ /* -*- c-basic-offset: 3 -*- */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.4 2001/01/08 01:07:24 martin Exp $ */ /* -*- c-basic-offset: 3 -*- */
/**************************************************************************
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,7 +20,7 @@ Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+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.
@@ -28,194 +29,695 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- * Michel Dänzer <michdaen@iiic.ethz.ch>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
-#include "r128_context.h"
-#include "r128_ioctl.h"
-#include "r128_vb.h"
-#include "r128_tris.h"
-#include "r128_state.h"
+#include <stdio.h>
+#include <math.h>
-#include "pipeline.h"
-#include "vbindirect.h"
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "macros.h"
-static struct {
- points_func points;
- line_func line;
- triangle_func triangle;
- quad_func quad;
-} rast_tab[R128_MAX_TRIFUNC];
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-#define R128_COLOR( to, from ) \
+#include "r128_tris.h"
+#include "r128_state.h"
+#include "r128_tex.h"
+#include "r128_vb.h"
+#include "r128_ioctl.h"
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ R128_CCE_VC_CNTL_PRIM_TYPE_POINT,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+};
+
+static void r128RasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void r128RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
do { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
- (to)[3] = (from)[3]; \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
} while (0)
#else
-#define R128_COLOR( to, from ) \
+#define COPY_DWORDS( j, vb, vertsize, v ) \
do { \
- (to)[0] = (from)[3]; \
- (to)[1] = (from)[0]; \
- (to)[2] = (from)[1]; \
- (to)[3] = (from)[2]; \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
} while (0)
#endif
-
-static void r128_null_quad( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3, GLuint pv )
+static __inline void r128_draw_quad( r128ContextPtr rmesa,
+ r128VertexPtr v0,
+ r128VertexPtr v1,
+ r128VertexPtr v2,
+ r128VertexPtr v3 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 6 * vertsize * 4 );
+ GLuint j;
+
+ rmesa->num_verts += 6;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
}
-static void r128_null_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
-}
-static void r128_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
+
+
+static __inline void r128_draw_triangle( r128ContextPtr rmesa,
+ r128VertexPtr v0,
+ r128VertexPtr v1,
+ r128VertexPtr v2 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 3 * vertsize * 4 );
+ GLuint j;
+
+ rmesa->num_verts += 3;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
}
-static void r128_null_points( GLcontext *ctx, GLuint first, GLuint last )
+
+static __inline void r128_draw_line( r128ContextPtr rmesa,
+ r128VertexPtr v0,
+ r128VertexPtr v1 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, 2 * vertsize * 4 );
+ GLuint j;
+
+ rmesa->num_verts += 2;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
}
-static void r128PrintRenderState( const char *msg, GLuint state )
+static __inline void r128_draw_point( r128ContextPtr rmesa,
+ r128VertexPtr v0 )
{
- fprintf( stderr, "%s: (0x%x) %s%s%s%s%s\n",
- msg, state,
- (state & R128_FLAT_BIT) ? "flat, " : "",
- (state & R128_OFFSET_BIT) ? "offset, " : "",
- (state & R128_TWOSIDE_BIT) ? "twoside, " : "",
- (state & R128_NODRAW_BIT) ? "no-draw, " : "",
- (state & R128_FALLBACK_BIT) ? "fallback" : "" );
+ int vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)r128AllocDmaLow( rmesa, vertsize * 4 );
+ int j;
+
+ rmesa->num_verts += 1;
+ COPY_DWORDS( j, vb, vertsize, v0 );
}
-#define IND (0)
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_tri( rmesa, a, b, c ); \
+ else \
+ r128_draw_triangle( rmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ rmesa->draw_tri( rmesa, a, b, d ); \
+ rmesa->draw_tri( rmesa, b, c, d ); \
+ } else \
+ r128_draw_quad( rmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_line( rmesa, v0, v1 ); \
+ else \
+ r128_draw_line( rmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_point( rmesa, v0 ); \
+ else \
+ r128_draw_point( rmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define R128_OFFSET_BIT 0x01
+#define R128_TWOSIDE_BIT 0x02
+#define R128_UNFILLED_BIT 0x04
+#define R128_FALLBACK_BIT 0x08
+#define R128_MAX_TRIFUNC 0x10
+
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[R128_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & R128_FALLBACK_BIT)
+#define DO_OFFSET (IND & R128_OFFSET_BIT)
+#define DO_UNFILLED (IND & R128_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & R128_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX r128Vertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (rmesa->verts + (e<<rmesa->vertex_stride_shift))
+
+#define R128_COLOR( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+} while (0)
+
+#define R128_SPEC( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+} while (0)
+
+#define VERT_SET_RGBA( v, c ) R128_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) R128_SPEC( v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (rmesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (rmesa->vertex_size == 4 ? 0 : 1); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (rmesa->hw_primitive != hw_prim[x]) \
+ r128RasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE rmesa->render_primitive
+#define IND R128_FALLBACK_BIT
#define TAG(x) x
-#include "r128_tritmp.h"
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
-#define IND (R128_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "r128_tritmp.h"
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (R128_OFFSET_BIT)
#define TAG(x) x##_offset
-#include "r128_tritmp.h"
-
-#define IND (R128_OFFSET_BIT | R128_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "r128_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (R128_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "r128_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (R128_TWOSIDE_BIT | R128_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "r128_tritmp.h"
-
-#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT)
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT)
#define TAG(x) x##_twoside_offset
-#include "r128_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT | R128_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "r128_tritmp.h"
+#define IND (R128_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (R128_OFFSET_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
-void r128DDTriangleFuncsInit( void )
-{
- GLint i;
+#define IND (R128_TWOSIDE_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT|R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_UNFILLED_BIT| \
+ R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
init();
- init_flat();
init_offset();
- init_offset_flat();
init_twoside();
- init_twoside_flat();
init_twoside_offset();
- init_twoside_offset_flat();
-
- for ( i = 0 ; i < R128_MAX_TRIFUNC ; i++ ) {
- if ( i & R128_NODRAW_BIT ) {
- rast_tab[i].points = r128_null_points;
- rast_tab[i].line = r128_null_line;
- rast_tab[i].triangle = r128_null_triangle;
- rast_tab[i].quad = r128_null_quad;
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+r128_fallback_tri( r128ContextPtr rmesa,
+ r128Vertex *v0,
+ r128Vertex *v1,
+ r128Vertex *v2 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[3];
+ r128_translate_vertex( ctx, v0, &v[0] );
+ r128_translate_vertex( ctx, v1, &v[1] );
+ r128_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+r128_fallback_line( r128ContextPtr rmesa,
+ r128Vertex *v0,
+ r128Vertex *v1 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[2];
+ r128_translate_vertex( ctx, v0, &v[0] );
+ r128_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+r128_fallback_point( r128ContextPtr rmesa,
+ r128Vertex *v0 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[1];
+ r128_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (r128Vertex *)(r128verts + (x << shift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ r128_draw_point( rmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ r128_draw_line( rmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ r128_draw_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ r128_draw_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ r128RenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ const GLuint shift = rmesa->vertex_stride_shift; \
+ const char *r128verts = (char *)rmesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) r128_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) r128_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void r128RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+}
+
+static void r128RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void r128FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ r128ContextPtr rmesa = R128_CONTEXT( ctx );
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize );
+ GLubyte *r128verts = (GLubyte *)rmesa->verts;
+ const GLuint shift = rmesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i,j;
+
+ rmesa->num_verts += (n-2) * 3;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start );
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i]) );
+ }
+}
+
+
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define _R128_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET) \
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+
+static void r128ChooseRenderState(GLcontext *ctx)
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+ rmesa->draw_point = r128_draw_point;
+ rmesa->draw_line = r128_draw_line;
+ rmesa->draw_tri = r128_draw_triangle;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R128_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= R128_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= R128_UNFILLED_BIT;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
+ if (flags & POINT_FALLBACK) rmesa->draw_point = r128_fallback_point;
+ if (flags & LINE_FALLBACK) rmesa->draw_line = r128_fallback_line;
+ if (flags & TRI_FALLBACK) rmesa->draw_tri = r128_fallback_tri;
+ index |= R128_FALLBACK_BIT;
+ }
+ }
+
+ if (index != rmesa->RenderIndex) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = r128_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = r128_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.ClippedPolygon = r128FastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = r128RenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = r128RenderClippedPoly;
}
+
+ rmesa->RenderIndex = index;
}
}
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
-/* FIXME: Only enable software fallback for stencil in 16 bpp mode after
- * we have hardware stencil support.
- */
-#define ALL_FALLBACK (DD_MULTIDRAW | DD_SELECT | DD_FEEDBACK | DD_STENCIL)
-#define POINT_FALLBACK (ALL_FALLBACK | DD_POINT_SMOOTH | DD_POINT_ATTEN)
-#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_SMOOTH | DD_LINE_STIPPLE)
-#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_STIPPLE | DD_TRI_UNFILLED)
-#define ANY_FALLBACK (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
-#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_Z_NEVER)
-
-/* Setup the Point, Line, Triangle and Quad functions based on the
- * current rendering state. Wherever possible, use the hardware to
- * render the primitive. Otherwise, fallback to software rendering.
+static void r128RunPipeline( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if (rmesa->new_state)
+ r128DDUpdateHWState( ctx );
+
+ if (!rmesa->Fallback && rmesa->NewGLState) {
+ if (rmesa->NewGLState & _R128_NEW_VERTEX_STATE)
+ r128ChooseVertexState( ctx );
+
+ if (rmesa->NewGLState & _R128_NEW_RENDER_STATE)
+ r128ChooseRenderState( ctx );
+
+ rmesa->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+/* This is called when Mesa switches between rendering triangle
+ * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc),
+ * and lines, points and bitmaps.
+ *
+ * As the r128 uses triangles to render lines and points, it is
+ * necessary to turn off hardware culling when rendering these
+ * primitives.
*/
-void r128DDChooseRenderState( GLcontext *ctx )
+
+static void r128RasterPrimitive( GLcontext *ctx, GLuint hwprim )
{
r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
- GLuint index = 0;
- if ( rmesa->Fallback ) {
- rmesa->RenderIndex = R128_FALLBACK_BIT;
- return;
+ rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+
+ if ( ctx->Polygon.StippleFlag && hwprim == GL_TRIANGLES ) {
+ rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_32x32_MONO_FG_LA;
+ }
+ else {
+ rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_SOLID_COLOR;
}
- if ( flags & ANY_RASTER_FLAGS ) {
- if ( flags & DD_FLATSHADE ) index |= R128_FLAT_BIT;
- if ( flags & DD_TRI_LIGHT_TWOSIDE ) index |= R128_TWOSIDE_BIT;
- if ( flags & DD_TRI_OFFSET ) index |= R128_OFFSET_BIT;
- if ( flags & DD_Z_NEVER ) index |= R128_NODRAW_BIT;
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+
+ if (rmesa->hw_primitive != hwprim) {
+ FLUSH_BATCH( rmesa );
+ rmesa->hw_primitive = hwprim;
}
+}
+
+static void r128RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint hw = hw_prim[prim];
+ rmesa->render_primitive = prim;
+ if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+ r128RasterPrimitive( ctx, hw );
+}
- rmesa->PointsFunc = rast_tab[index].points;
- rmesa->LineFunc = rast_tab[index].line;
- rmesa->TriangleFunc = rast_tab[index].triangle;
- rmesa->QuadFunc = rast_tab[index].quad;
- rmesa->RenderIndex = index;
- rmesa->IndirectTriangles = 0;
+static void r128RenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ r128CheckTexSizes( ctx );
+}
- if ( flags & ANY_FALLBACK ) {
- if ( flags & POINT_FALLBACK ) {
- rmesa->RenderIndex |= R128_FALLBACK_BIT;
- rmesa->PointsFunc = 0;
- rmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- }
+static void r128RenderFinish( GLcontext *ctx )
+{
+ if (R128_CONTEXT(ctx)->RenderIndex & R128_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
- if ( flags & LINE_FALLBACK ) {
- rmesa->RenderIndex |= R128_FALLBACK_BIT;
- rmesa->LineFunc = 0;
- rmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- }
- if ( flags & TRI_FALLBACK ) {
- rmesa->RenderIndex |= R128_FALLBACK_BIT;
- rmesa->TriangleFunc = 0;
- rmesa->QuadFunc = 0;
- rmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->Fallback;
+
+ if (mode) {
+ rmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ FLUSH_BATCH( rmesa );
+ _swsetup_Wakeup( ctx );
+ rmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ rmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = r128RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive;
+ tnl->Driver.Render.Finish = r128RenderFinish;
+ tnl->Driver.Render.BuildVertices = r128BuildVertices;
+ rmesa->NewGLState |= (_R128_NEW_RENDER_STATE|
+ _R128_NEW_VERTEX_STATE);
}
}
+}
+
- if ( 0 ) {
- gl_print_tri_caps( "tricaps", ctx->TriangleCaps );
- r128PrintRenderState( "r128 render state", rmesa->RenderIndex );
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void r128InitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
}
+
+ tnl->Driver.RunPipeline = r128RunPipeline;
+ tnl->Driver.Render.Start = r128RenderStart;
+ tnl->Driver.Render.Finish = r128RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = r128BuildVertices;
+
+/* r128Fallback( ctx, 0x100000, 1 ); */
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h
index a279af547..f427f75c5 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h
@@ -1,8 +1,9 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.6 2001/04/10 16:07:53 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.4 2001/01/08 01:07:24 martin Exp $ */
/**************************************************************************
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,7 +20,7 @@ Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+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.
@@ -28,315 +29,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
#ifndef __R128_TRIS_H__
#define __R128_TRIS_H__
-#ifdef GLX_DIRECT_RENDERING
-
-#include "r128_vb.h"
-
-extern void r128DDChooseRenderState( GLcontext *ctx );
-extern void r128DDTriangleFuncsInit( void );
-
-#define R128_FLAT_BIT 0x01
-#define R128_OFFSET_BIT 0x02
-#define R128_TWOSIDE_BIT 0x04
-#define R128_NODRAW_BIT 0x08
-#define R128_FALLBACK_BIT 0x10
-#define R128_MAX_TRIFUNC 0x20
-
-
-static __inline void r128_draw_triangle( r128ContextPtr rmesa,
- r128VertexPtr v0,
- r128VertexPtr v1,
- r128VertexPtr v2 )
-{
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 3 );
- int j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v0->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v1->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v2->ui[j] );
-#endif
-}
-
-static __inline void r128_draw_quad( r128ContextPtr rmesa,
- r128VertexPtr v0,
- r128VertexPtr v1,
- r128VertexPtr v2,
- r128VertexPtr v3 )
-{
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 6 );
- int j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v3)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v3)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v0->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v1->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v3->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v1->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v2->ui[j] );
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- LE32_OUT( vb[j], v3->ui[j] );
-#endif
-}
-
-static __inline void r128_draw_line( r128ContextPtr rmesa,
- r128VertexPtr tmp0,
- r128VertexPtr tmp1,
- GLfloat width )
-{
-#if 1
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 6 );
- GLfloat hw, dx, dy, ix, iy;
- GLuint j;
- GLfloat x0 = tmp0->v.x;
- GLfloat y0 = tmp0->v.y;
- GLfloat x1 = tmp1->v.x;
- GLfloat y1 = tmp1->v.y;
-
- hw = 0.5F * width;
- if (hw > 0.1F && hw < 0.5F) {
- hw = 0.5F;
- }
-
- /* adjust vertices depending on line direction */
- dx = tmp0->v.x - tmp1->v.x;
- dy = tmp0->v.y - tmp1->v.y;
- if (dx * dx > dy * dy) {
- /* X-major line */
- ix = 0.0F;
- iy = hw;
- if (x1 < x0) {
- x0 += 0.5F;
- x1 += 0.5F;
- }
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- else {
- /* Y-major line */
- ix = hw;
- iy = 0.0F;
- if (y1 > y0) {
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- x0 += 0.5F;
- x1 += 0.5F;
- }
-
- LE32_OUT_FLOAT( vb[0], x0 - ix );
- LE32_OUT_FLOAT( vb[1], y0 - iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp0->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x1 + ix );
- LE32_OUT_FLOAT( vb[1], y1 + iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp1->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x0 + ix );
- LE32_OUT_FLOAT( vb[1], y0 + iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp0->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x0 - ix );
- LE32_OUT_FLOAT( vb[1], y0 - iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp0->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x1 - ix );
- LE32_OUT_FLOAT( vb[1], y1 - iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp1->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x1 + ix );
- LE32_OUT_FLOAT( vb[1], y1 + iy );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp1->ui[j] );
-
-#else
-
- int vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 2 );
- int j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)tmp1)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp0->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp1->ui[j];
-#endif
-#endif
-}
-
-static __inline void r128_draw_point( r128ContextPtr rmesa,
- r128VertexPtr tmp, GLfloat sz )
-{
-#if 1
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 6 );
- int j;
- const float x = tmp->v.x + PNT_X_OFFSET;
- const float y = tmp->v.y + PNT_Y_OFFSET;
-
- LE32_OUT_FLOAT( vb[0], x - sz );
- LE32_OUT_FLOAT( vb[1], y - sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x + sz );
- LE32_OUT_FLOAT( vb[1], y - sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x + sz );
- LE32_OUT_FLOAT( vb[1], y + sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x + sz );
- LE32_OUT_FLOAT( vb[1], y + sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
- vb += vertsize;
-
- LE32_OUT_FLOAT( vb[0], x - sz );
- LE32_OUT_FLOAT( vb[1], y + sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
- vb += vertsize;
+#include "mtypes.h"
- LE32_OUT_FLOAT( vb[0], x - sz );
- LE32_OUT_FLOAT( vb[1], y - sz );
- for (j = 2 ; j < vertsize ; j++)
- LE32_OUT( vb[j], tmp->ui[j] );
+extern void r128InitTriFuncs( GLcontext *ctx );
-#else
- int vertsize = rmesa->vertsize;
- CARD32 *vb = r128AllocVerticesInline( rmesa, 1 );
- int j;
+extern void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) r128Fallback( rmesa->glCtx, bit, mode )
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp->ui[j];
-#endif
-#endif
-}
-#endif
#endif /* __R128_TRIS_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
deleted file mode 100644
index a9ca8d1bc..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h
+++ /dev/null
@@ -1,333 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h,v 1.5 2001/01/08 01:07:24 martin Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- *
- */
-
-static __inline void TAG(triangle)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- r128VertexPtr verts = R128_DRIVER_DATA(VB)->verts;
- r128VertexPtr v[3];
-
-#if (IND & R128_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[3];
-#endif
-#if (IND & R128_TWOSIDE_BIT)
- GLuint c[3];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
- v[2] = &verts[e2];
-
-#if (IND & R128_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
-#endif
-
-#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & R128_TWOSIDE_BIT)
- {
- GLuint facing = ( cc > 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if ( IND & R128_FLAT_BIT ) {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- R128_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- R128_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- }
- }
-#endif
-
-#if (IND & R128_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- if ( cc * cc > 1e-16 ) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- }
-#endif
- }
-#endif
-
- r128_draw_triangle( rmesa, v[0], v[1], v[2] );
-
-#if (IND & R128_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
-#endif
-
-#if (IND & R128_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
-#endif
-}
-
-
-static void TAG(quad)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2, GLuint e3,
- GLuint pv )
-{
-#if 0
- TAG(triangle)( ctx, e0, e1, e3, pv );
- TAG(triangle)( ctx, e1, e2, e3, pv );
-#else
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- r128VertexPtr verts = R128_DRIVER_DATA(VB)->verts;
- r128VertexPtr v[4];
-
-#if (IND & R128_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[4];
-#endif
-#if (IND & R128_TWOSIDE_BIT)
- int c[4];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
- v[2] = &verts[e2];
- v[3] = &verts[e3];
-
-#if (IND & R128_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
- c[3] = v[3]->ui[4];
-#endif
-
-#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & R128_TWOSIDE_BIT)
- {
- GLuint facing = ( cc > 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if ( IND & R128_FLAT_BIT ) {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[3]->ui[4] = v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- R128_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- R128_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- R128_COLOR( (char *)&v[3]->ui[4], vbcolor[e3] );
- }
- }
-#endif
-
-#if (IND & R128_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- z[3] = v[3]->v.z;
- if ( cc * cc > 1e-16 ) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- v[3]->v.z += offset;
- }
-#endif
- }
-#endif
-
- r128_draw_quad( rmesa, v[0], v[1], v[2], v[3] );
-
-#if (IND & R128_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
- v[3]->v.z = z[3];
-#endif
-
-#if (IND & R128_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
- v[3]->ui[4] = c[3];
-#endif
-#endif
-}
-
-
-static void TAG(line)( GLcontext *ctx,
- GLuint e0, GLuint e1,
- GLuint pv )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- r128VertexPtr verts = R128_DRIVER_DATA(VB)->verts;
- GLfloat width = ctx->Line.Width;
- r128VertexPtr v[2];
-
-#if (IND & R128_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[2];
-#endif
-#if (IND & R128_TWOSIDE_BIT)
- int c[2];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
-
-#if (IND & R128_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
-#endif
-
-#if (IND & R128_TWOSIDE_BIT)
- {
- GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
- if ( IND & R128_FLAT_BIT ) {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[1]->ui[4] = v[0]->ui[4];
- } else {
- R128_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- R128_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- }
- }
-#endif
-
-#if (IND & R128_OFFSET_BIT)
- offset = ctx->LineZoffset * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- v[0]->v.z += offset;
- v[1]->v.z += offset;
-#endif
-
- r128_draw_line( rmesa, v[0], v[1], width );
-
-#if (IND & R128_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
-#endif
-
-#if (IND & R128_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
-#endif
-}
-
-
-static void TAG(points)( GLcontext *ctx,
- GLuint first, GLuint last )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- r128VertexPtr verts = R128_DRIVER_DATA(VB)->verts;
- GLfloat size = ctx->Point.Size * 0.5;
- int i;
-
- for ( i = first ; i < last ; i++) {
- if ( VB->ClipMask[i] == 0 ) {
- if ( IND & (R128_TWOSIDE_BIT|R128_OFFSET_BIT) ) {
- r128Vertex tmp0 = verts[i];
-
- if ( IND & R128_TWOSIDE_BIT ) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
- R128_COLOR( (char *)&tmp0.v.color, vbcolor[i] );
- }
- if ( IND & R128_OFFSET_BIT ) {
- GLfloat offset = ctx->PointZoffset * rmesa->depth_scale;
- tmp0.v.z += offset;
- }
- r128_draw_point( rmesa, &tmp0, size );
- } else {
- r128_draw_point( rmesa, &verts[i], size );
- }
- }
- }
-}
-
-
-static void TAG(init)( void )
-{
- rast_tab[IND].points = TAG(points);
- rast_tab[IND].line = TAG(line);
- rast_tab[IND].triangle = TAG(triangle);
- rast_tab[IND].quad = TAG(quad);
-}
-
-#undef IND
-#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
index 06a63e152..7358a61d8 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c
@@ -1,8 +1,9 @@
/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.c,v 1.11 2001/01/08 01:07:24 martin Exp $ */
/**************************************************************************
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,7 +20,7 @@ Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+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.
@@ -28,487 +29,494 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
+#include "glheader.h"
+#include "mtypes.h"
+#include "mem.h"
+#include "macros.h"
+#include "colormac.h"
+#include "mmath.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+
#include "r128_context.h"
+#include "r128_vb.h"
#include "r128_ioctl.h"
+#include "r128_tris.h"
#include "r128_state.h"
-#include "r128_vb.h"
-#include "mem.h"
-#include "stages.h"
-
-#define TEX0 \
-do { \
- v->v.tu0 = tc0[i][0]; \
- v->v.tv0 = tc0[i][1]; \
-} while (0)
-
-#define TEX1 \
-do { \
- v->v.tu1 = tc1[i][0]; \
- v->v.tv1 = tc1[i][1]; \
-} while (0)
-
-#define SPC \
-do { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.blue = spec[2]; \
- v->v.specular.green = spec[1]; \
- v->v.specular.red = spec[0]; \
-} while (0)
-
-#define FOG \
-do { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.alpha = spec[3]; \
-} while (0)
-
-#define COL \
-do { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->v.color.blue = col[2]; \
- v->v.color.green = col[1]; \
- v->v.color.red = col[0]; \
- v->v.color.alpha = col[3]; \
-} while (0)
-
-#define TEX0_4 \
-do { \
- if ( VB->TexCoordPtr[0]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
- v = &(R128_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++ ) { \
- float oow = 1.0 / tc[i][3]; \
- v->v.rhw *= tc[i][3]; \
- v->v.tu0 *= oow; \
- v->v.tv0 *= oow; \
- } \
- } \
-} while (0)
-
-#ifdef USE_RHW2
-
-#define TEX1_4 \
-do { \
- if ( VB->TexCoordPtr[1]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data; \
- v = &(R128_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++ ) { \
- float oow = 1.0 / tc[i][3]; \
- v->v.rhw2 *= tc[i][3]; \
- v->v.tu1 *= oow; \
- v->v.tv1 *= oow; \
- } \
- } \
-} while (0)
-
-#define COORD \
-do { \
- GLfloat *win = VB->Win.data[i]; \
- v->v.x = win[0] + xoffset; \
- v->v.y = - win[1] + yoffset; \
- v->v.z = depth_scale * win[2]; \
- v->v.rhw = v->v.rhw2 = win[3]; \
-} while (0)
-
-#else /* USE_RHW2 */
-
-#define TEX1_4
-
-#define COORD \
-do { \
- GLfloat *win = VB->Win.data[i]; \
- v->v.x = win[0] + xoffset; \
- v->v.y = - win[1] + yoffset; \
- v->v.z = depth_scale * win[2]; \
- v->v.rhw = win[3]; \
-} while (0)
-
-#endif /* USE_RHW2 */
-
-#define NOP
-
-
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec,fog) \
-static void name( struct vertex_buffer *VB, GLuint start, GLuint end ) \
-{ \
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx); \
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
- r128VertexPtr v; \
- GLfloat (*tc0)[4]; \
- GLfloat (*tc1)[4]; \
- const GLfloat depth_scale = rmesa->depth_scale; \
- const GLfloat xoffset = SUBPIXEL_X; \
- const GLfloat yoffset = dPriv->h + SUBPIXEL_Y; \
- GLint i; \
- \
- (void) xoffset; (void) yoffset; (void) depth_scale; \
- \
- gl_import_client_data( VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE | VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE) ); \
- \
- tc0 = VB->TexCoordPtr[rmesa->tmu_source[0]]->data; \
- tc1 = VB->TexCoordPtr[rmesa->tmu_source[1]]->data; \
- \
- v = &(R128_DRIVER_DATA(VB)->verts[start]); \
- \
- if ( VB->ClipOrMask == 0 ) { \
- for ( i = start ; i < end ; i++, v++ ) { \
- win; \
- col; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- } else { \
- for ( i = start ; i < end ; i++, v++ ) { \
- if ( VB->ClipMask[i] == 0 ) { \
- win; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- col; \
- } \
- } \
- tex0_4; \
- tex1_4; \
-}
+#define R128_TEX1_BIT 0x1
+#define R128_TEX0_BIT 0x2
+#define R128_RGBA_BIT 0x4
+#define R128_SPEC_BIT 0x8
+#define R128_FOG_BIT 0x10
+#define R128_XYZW_BIT 0x20
+#define R128_PTEX_BIT 0x40
+#define R128_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[R128_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT (R128_CCE_VC_FRMT_DIFFUSE_ARGB)
+
+#define NOTEX_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
+ R128_CCE_VC_FRMT_SPEC_FRGB)
+
+#define TEX0_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
+ R128_CCE_VC_FRMT_SPEC_FRGB | \
+ R128_CCE_VC_FRMT_S_T)
+
+#define TEX1_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
+ R128_CCE_VC_FRMT_SPEC_FRGB | \
+ R128_CCE_VC_FRMT_S_T | \
+ R128_CCE_VC_FRMT_S2_T2)
+
+
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & R128_XYZW_BIT)
+#define DO_RGBA (IND & R128_RGBA_BIT)
+#define DO_SPEC (IND & R128_SPEC_BIT)
+#define DO_FOG (IND & R128_FOG_BIT)
+#define DO_TEX0 (IND & R128_TEX0_BIT)
+#define DO_TEX1 (IND & R128_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & R128_PTEX_BIT)
+
+#define VERTEX r128Vertex
+#define LOCALVARS r128ContextPtr rmesa = R128_CONTEXT(ctx);
+#define GET_VIEWPORT_MAT() rmesa->hw_viewport
+#define GET_TEXSOURCE(n) rmesa->tmu_source[n]
+#define GET_VERTEX_FORMAT() rmesa->vertex_format
+#define GET_VERTEX_STORE() rmesa->verts
+#define GET_VERTEX_STRIDE_SHIFT() rmesa->vertex_stride_shift
+#define INVALIDATE_STORED_VERTICES()
+#define GET_UBYTE_COLOR_STORE() &rmesa->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &rmesa->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0 /* r128 rhw2 not supported by template */
+
+#define UNVIEWPORT_VARS GLfloat h = R128_CONTEXT(ctx)->driDrawable->h
+#define UNVIEWPORT_X(x) x - SUBPIXEL_X
+#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
+#define UNVIEWPORT_Z(z) z / rmesa->depth_scale
+
+#define PTEX_FALLBACK() FALLBACK(R128_CONTEXT(ctx), R128_FALLBACK_TEXTURE, 1)
+
+#define IMPORT_FLOAT_COLORS r128_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS r128_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[rmesa->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[rmesa->SetupIndex].copy_pv
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) r128_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\
+ R128_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\
+ R128_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|\
+ R128_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|\
+ R128_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\
+ R128_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\
+ R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_XYZW_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|\
+ R128_TEX0_BIT|R128_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
-SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC, NOP)
-SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
-SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
-SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_wgfs, COORD, COL, NOP, NOP, NOP, NOP, SPC, FOG)
-SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_wgfst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
-SETUPFUNC(rs_wgfst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
-
-SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC, NOP)
-SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
-SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
-SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_gfs, NOP, COL, NOP, NOP, NOP, NOP, SPC, FOG)
-SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_gfst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
-SETUPFUNC(rs_gfst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
-
-
-static void rs_invalid( struct vertex_buffer *VB, GLuint start, GLuint end )
-{
- fprintf( stderr, "r128RasterSetup(): invalid setup function\n" );
-}
+#define IND (R128_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
-typedef void (*setupFunc)( struct vertex_buffer *, GLuint, GLuint );
-static setupFunc setup_func[R128_MAX_SETUPFUNC];
+#define IND (R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (R128_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
-void r128DDSetupInit( void )
-{
- GLint i;
+#define IND (R128_FOG_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
- for ( i = 0 ; i < R128_MAX_SETUPFUNC ; i++ ) {
- setup_func[i] = rs_invalid;
- }
+#define IND (R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
- /* Functions to build vertices from scratch
- */
- setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0;
- setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1;
- setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wft0;
- setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wft0t1;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgt0t1;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT] = rs_wgf;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_wgfs;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wgft0;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgft0t1;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgfst0;
- setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgfst0t1;
-
- /* Repair functions
- */
- setup_func[R128_TEX0_BIT] = rs_t0;
- setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1;
- setup_func[R128_FOG_BIT] = rs_f;
- setup_func[R128_FOG_BIT|R128_TEX0_BIT] = rs_ft0;
- setup_func[R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_ft0t1;
- setup_func[R128_RGBA_BIT] = rs_g;
- setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs;
- setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0;
- setup_func[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gt0t1;
- setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0;
- setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT] = rs_gf;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_gfs;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_gft0;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gft0t1;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gfst0;
- setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gfst0t1;
-}
+#define IND (R128_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (R128_RGBA_BIT|R128_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
-void r128PrintSetupFlags( char *msg, GLuint flags )
+#define IND (R128_RGBA_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|\
+ R128_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+
+static void init_setup_tab( void )
{
- fprintf( stderr, "%s: %d %s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & R128_WIN_BIT) ? " xyzw," : "",
- (flags & R128_RGBA_BIT) ? " rgba," : "",
- (flags & R128_SPEC_BIT) ? " spec," : "",
- (flags & R128_FOG_BIT) ? " fog," : "",
- (flags & R128_TEX0_BIT) ? " tex-0," : "",
- (flags & R128_TEX1_BIT) ? " tex-1," : "" );
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
}
-/* Initialize the vertex buffer setup functions based on the current
- * rendering state.
- */
-void r128DDChooseRasterSetupFunc( GLcontext *ctx )
-{
- r128ContextPtr rmesa = R128_CONTEXT(ctx);
- GLint index = R128_WIN_BIT | R128_RGBA_BIT;
-
- rmesa->multitex = 0;
- rmesa->vertsize = 8;
- rmesa->vc_format = R128_TEX0_VERTEX_FORMAT;
- rmesa->tmu_source[0] = 0;
- rmesa->tmu_source[1] = 1;
- rmesa->tex_dest[0] = R128_TEX0_BIT;
- rmesa->tex_dest[1] = R128_TEX1_BIT;
- rmesa->blend_flags &= ~R128_BLEND_MULTITEX;
-
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- if ( R128_IS_PLAIN( rmesa ) && /* Pro/M3 support GL_BLEND */
- ctx->Texture.Unit[0].EnvMode == GL_BLEND && rmesa->env_color ) {
- rmesa->multitex = 1;
- rmesa->vertsize = 10;
- rmesa->vc_format = R128_TEX1_VERTEX_FORMAT;
- rmesa->tmu_source[1] = 0;
- index |= R128_TEX1_BIT;
- }
- index |= R128_TEX0_BIT;
- }
+void r128PrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & R128_XYZW_BIT) ? " xyzw," : "",
+ (flags & R128_RGBA_BIT) ? " rgba," : "",
+ (flags & R128_SPEC_BIT) ? " spec," : "",
+ (flags & R128_FOG_BIT) ? " fog," : "",
+ (flags & R128_TEX0_BIT) ? " tex-0," : "",
+ (flags & R128_TEX1_BIT) ? " tex-1," : "");
+}
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX1 ) {
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- rmesa->multitex = 1;
- rmesa->vertsize = 10;
- rmesa->vc_format = R128_TEX1_VERTEX_FORMAT;
- if ( R128_IS_PLAIN( rmesa ) ) /* Pro/M3 support GL_BLEND */
- rmesa->blend_flags |= R128_BLEND_MULTITEX;
- index |= R128_TEX1_BIT;
- } else {
- /* Just a funny way of doing single texturing.
- */
- rmesa->tmu_source[0] = 1;
- rmesa->tex_dest[1] = R128_TEX0_BIT;
-
- if ( R128_IS_PLAIN( rmesa ) && /* Pro/M3 support GL_BLEND */
- ctx->Texture.Unit[1].EnvMode == GL_BLEND && rmesa->env_color ) {
- rmesa->multitex = 1;
- rmesa->vertsize = 10;
- rmesa->vc_format = R128_TEX1_VERTEX_FORMAT;
- rmesa->tmu_source[1] = 1;
- index |= R128_TEX1_BIT;
- }
-
- index |= R128_TEX0_BIT;
- }
- }
- if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )
- index |= R128_SPEC_BIT;
- if ( ctx->Fog.Enabled )
- index |= R128_FOG_BIT;
+void r128CheckTexSizes( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT( ctx );
- if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
- fprintf( stderr, "\n" );
- r128PrintSetupFlags( "full setup function", index );
- }
+ if (!setup_tab[rmesa->SetupIndex].check_tex_sizes(ctx)) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
- rmesa->new_state |= R128_NEW_TEXTURE;
- rmesa->SetupIndex = index;
+ /* Invalidate stored verts
+ */
+ rmesa->SetupNewInputs = ~0;
+ rmesa->SetupIndex |= R128_PTEX_BIT;
- ctx->Driver.RasterSetup = setup_func[index];
+ if (!rmesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[rmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[rmesa->SetupIndex].copy_pv;
+ }
+ }
}
-/* Check to see if any updates of the vertex buffer entries are needed.
- */
-void r128DDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *s )
+void r128BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
{
r128ContextPtr rmesa = R128_CONTEXT( ctx );
- GLint tmp = rmesa->SetupDone;
-
- s->type = 0;
- rmesa->SetupDone = 0;
+ GLubyte *v = ((GLubyte *)rmesa->verts + (start<<rmesa->vertex_stride_shift));
+ GLuint stride = 1<<rmesa->vertex_stride_shift;
- if ( (ctx->Array.Summary & VERT_OBJ_ANY) == 0 )
- return;
+ newinputs |= rmesa->SetupNewInputs;
+ rmesa->SetupNewInputs = 0;
- if ( ctx->IndirectTriangles )
+ if (!newinputs)
return;
- rmesa->SetupDone = tmp;
-}
+ if (newinputs & VERT_CLIP) {
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
-/* Repair existing precalculated vertices with new data.
- */
-void r128DDPartialRasterSetup( struct vertex_buffer *VB )
-{
- r128ContextPtr rmesa = R128_CONTEXT(VB->ctx);
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
- GLuint index = 0;
-
- if ( new & VERT_WIN ) {
- new = available;
- index |= R128_WIN_BIT | R128_FOG_BIT;
- }
+ if (newinputs & VERT_RGBA)
+ ind |= R128_RGBA_BIT;
- if ( new & VERT_RGBA )
- index |= R128_RGBA_BIT | R128_SPEC_BIT;
+ if (newinputs & VERT_SPEC_RGB)
+ ind |= R128_SPEC_BIT;
- if ( new & VERT_TEX0_ANY )
- index |= R128_TEX0_BIT;
+ if (newinputs & VERT_TEX0)
+ ind |= R128_TEX0_BIT;
- if ( new & VERT_TEX1_ANY )
- index |= rmesa->tex_dest[1];
+ if (newinputs & VERT_TEX1)
+ ind |= R128_TEX1_BIT;
- if ( new & VERT_FOG_COORD )
- index |= R128_FOG_BIT;
+ if (newinputs & VERT_FOG_COORD)
+ ind |= R128_FOG_BIT;
- rmesa->SetupDone &= ~index;
- index &= rmesa->SetupIndex;
- rmesa->SetupDone |= index;
+ if (rmesa->SetupIndex & R128_PTEX_BIT)
+ ind = ~0;
- if ( R128_DEBUG & DEBUG_VERBOSE_MSG )
- r128PrintSetupFlags( "partial setup function", index );
+ ind &= rmesa->SetupIndex;
- if ( index )
- setup_func[index]( VB, VB->Start, VB->Count );
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
}
-void r128DDDoRasterSetup( struct vertex_buffer *VB )
+void r128ChooseVertexState( GLcontext *ctx )
{
- GLcontext *ctx = VB->ctx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ r128ContextPtr rmesa = R128_CONTEXT( ctx );
+ GLuint ind = R128_XYZW_BIT|R128_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= R128_SPEC_BIT;
- if ( VB->Type == VB_CVA_PRECALC ) {
- r128DDPartialRasterSetup( VB );
- } else if ( ctx->Driver.RasterSetup ) {
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
+ if (ctx->Fog.Enabled)
+ ind |= R128_FOG_BIT;
+
+ if (ctx->Texture._ReallyEnabled) {
+ ind |= R128_TEX0_BIT;
+ if (ctx->Texture.Unit[0]._ReallyEnabled &&
+ ctx->Texture.Unit[1]._ReallyEnabled)
+ ind |= R128_TEX1_BIT;
+ }
+
+ rmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = r128_interp_extras;
+ tnl->Driver.Render.CopyPV = r128_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != rmesa->vertex_format) {
+ FLUSH_BATCH(rmesa);
+ rmesa->vertex_format = setup_tab[ind].vertex_format;
+ rmesa->vertex_size = setup_tab[ind].vertex_size;
+ rmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
}
}
-/* ================================================================
- * Hardware-format vertex buffers
- */
-void r128DDResizeVB( struct vertex_buffer *VB, GLuint size )
+void r128_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count )
{
- r128VertexBufferPtr rvb = R128_DRIVER_DATA(VB);
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint vertex_size = rmesa->vertex_size * 4;
+ GLuint *dest = r128AllocDmaLow( rmesa, (count-start) * vertex_size);
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
+}
- while ( rvb->size < size )
- rvb->size *= 2;
- ALIGN_FREE( rvb->vert_store );
- rvb->vert_store = ALIGN_MALLOC( sizeof(r128Vertex) * rvb->size, 32 );
- if ( !rvb->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
- }
+#if 0
+void r128_emit_indexed_verts( GLcontext *ctx, GLuint start, GLuint count )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint vertex_size = rmesa->vertex_size * 4;
+ GLuint bufsz = (count-start) * vertex_size;
+ CARD32 *dest;
- rvb->verts = (r128VertexPtr)rvb->vert_store;
+ rmesa->vertex_low = (rmesa->vertex_low + 63) & ~63; /* alignment */
+ rmesa->vertex_last_prim = rmesa->vertex_low;
- gl_vector1ui_free( &rvb->clipped_elements );
- gl_vector1ui_alloc( &rvb->clipped_elements, VEC_WRITABLE, rvb->size, 32 );
- if ( !rvb->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
- }
+ dest = r128AllocDmaLow( rmesa, bufsz, __FUNCTION__);
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * rvb->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
- }
+ rmesa->retained_buffer = rmesa->vertex_buffer;
+ rmesa->vb_offset = (rmesa->vertex_buffer->idx * R128_BUFFER_SIZE +
+ rmesa->vertex_low - bufsz);
+
+ rmesa->vertex_low = (rmesa->vertex_low + 0x7) & ~0x7; /* alignment */
+ rmesa->vertex_last_prim = rmesa->vertex_low;
}
+#endif
+
-void r128DDRegisterVB( struct vertex_buffer *VB )
+void r128InitVB( GLcontext *ctx )
{
- r128VertexBufferPtr rvb;
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
- rvb = (r128VertexBufferPtr)CALLOC( sizeof(*rvb) );
+ rmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
- rvb->size = VB->Size * 2;
- rvb->vert_store = ALIGN_MALLOC( sizeof(r128Vertex) * rvb->size, 32 );
- if ( !rvb->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
}
+}
- rvb->verts = (r128VertexPtr)rvb->vert_store;
-
- gl_vector1ui_alloc( &rvb->clipped_elements, VEC_WRITABLE, rvb->size, 32 );
- if ( !rvb->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
- }
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * rvb->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
+void r128FreeVB( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ if (rmesa->verts) {
+ ALIGN_FREE(rmesa->verts);
+ rmesa->verts = 0;
}
- VB->driver_data = rvb;
-}
-void r128DDUnregisterVB( struct vertex_buffer *VB )
-{
- r128VertexBufferPtr rvb = R128_DRIVER_DATA(VB);
+ if (rmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE(rmesa->UbyteSecondaryColor.Ptr);
+ rmesa->UbyteSecondaryColor.Ptr = 0;
+ }
- if ( rvb ) {
- if ( rvb->vert_store ) ALIGN_FREE( rvb->vert_store );
- gl_vector1ui_free( &rvb->clipped_elements );
- FREE( rvb );
- VB->driver_data = 0;
+ if (rmesa->UbyteColor.Ptr) {
+ ALIGN_FREE(rmesa->UbyteColor.Ptr);
+ rmesa->UbyteColor.Ptr = 0;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
index 797c4c624..4912ccb9b 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h
@@ -1,8 +1,9 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.6 2001/04/10 17:53:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_vb.h,v 1.4 2001/01/08 01:07:24 martin Exp $ */
/**************************************************************************
-Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -19,7 +20,7 @@ Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 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, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+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.
@@ -28,110 +29,46 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- * Michel Dänzer <michdaen@iiic.ethz.ch>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
-#ifndef __R128_VB_H__
-#define __R128_VB_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "X11/Xarch.h"
-#if X_BYTE_ORDER == X_LITTLE_ENDIAN
-typedef struct {
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
-} r128_color_t;
-#else
-typedef struct {
- GLubyte alpha;
- GLubyte red;
- GLubyte green;
- GLubyte blue;
-} r128_color_t;
-#endif
+#ifndef R128VB_INC
+#define R128VB_INC
-/* The vertex structure. The final tu1/tv1 values are only used in
- * multitexture modes, and the rhw2 value is currently never used.
- */
-typedef struct {
- GLfloat x, y, z; /* Coordinates in screen space */
- GLfloat rhw; /* Reciprocal homogeneous w */
- r128_color_t color; /* Diffuse color */
- r128_color_t specular; /* Specular color (alpha is fog) */
- GLfloat tu0, tv0; /* Texture 0 coordinates */
- GLfloat tu1, tv1; /* Texture 1 coordinates */
- GLfloat rhw2; /* Reciprocal homogeneous w2 */
-} r128_vertex;
-
-/* Format of vertices in r128_vertex struct:
- */
-#define R128_TEX0_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
- R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
- R128_CCE_VC_FRMT_SPEC_FRGB | \
- R128_CCE_VC_FRMT_S_T)
-
-#define R128_TEX1_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
- R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
- R128_CCE_VC_FRMT_SPEC_FRGB | \
- R128_CCE_VC_FRMT_S_T | \
- R128_CCE_VC_FRMT_S2_T2)
-
-#define R128_PROJ_TEX1_VERTEX_FORMAT (R128_CCE_VC_FRMT_RHW | \
- R128_CCE_VC_FRMT_DIFFUSE_ARGB |\
- R128_CCE_VC_FRMT_SPEC_FRGB | \
- R128_CCE_VC_FRMT_S_T | \
- R128_CCE_VC_FRMT_S2_T2 | \
- R128_CCE_VC_FRMT_RHW2)
-
-
-/* The fastpath code still expects a 16-float stride vertex.
- */
-union r128_vertex_t {
- r128_vertex v;
- GLfloat f[16];
- GLuint ui[16];
-};
-
-typedef union r128_vertex_t r128Vertex;
-typedef union r128_vertex_t *r128VertexPtr;
-
-typedef struct {
- r128VertexPtr verts;
- GLvector1ui clipped_elements;
- GLint last_vert;
- void *vert_store;
- GLuint size;
-} *r128VertexBufferPtr;
-
-#define R128_DRIVER_DATA(vb) ((r128VertexBufferPtr)((vb)->driver_data))
-
-#define R128_WIN_BIT 0x01
-#define R128_RGBA_BIT 0x02
-#define R128_FOG_BIT 0x04
-#define R128_SPEC_BIT 0x08
-#define R128_TEX0_BIT 0x10
-#define R128_TEX1_BIT 0x20
-#define R128_MAX_SETUPFUNC 0x40
-
-extern void r128DDChooseRasterSetupFunc( GLcontext *ctx );
-extern void r128PrintSetupFlags( char *msg, GLuint flags );
-
-extern void r128DDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *s );
-extern void r128DDPartialRasterSetup( struct vertex_buffer *VB );
-extern void r128DDDoRasterSetup( struct vertex_buffer *VB );
-
-extern void r128DDResizeVB( struct vertex_buffer *VB, GLuint size );
-extern void r128DDRegisterVB( struct vertex_buffer *VB );
-extern void r128DDUnregisterVB( struct vertex_buffer *VB );
-
-extern void r128DDSetupInit( void );
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "r128_context.h"
+
+#define _R128_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _NEW_TEXTURE | \
+ _NEW_FOG)
+
+extern void r128CheckTexSizes( GLcontext *ctx );
+extern void r128ChooseVertexState( GLcontext *ctx );
+
+extern void r128BuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
+
+extern void r128PrintSetupFlags(char *msg, GLuint flags );
+
+extern void r128InitVB( GLcontext *ctx );
+extern void r128FreeVB( GLcontext *ctx );
+
+extern void r128_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void r128_emit_indexed_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void r128_translate_vertex( GLcontext *ctx,
+ const r128Vertex *src,
+ SWvertex *dst );
+
+extern void r128_print_vertex( GLcontext *ctx, const r128Vertex *v );
#endif
-#endif /* __R128_VB_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
deleted file mode 100644
index e65973f5b..000000000
--- a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c,v 1.12 2001/11/26 21:46:35 dawes Exp $ */
-/**************************************************************************
-
-Copyright 1999, 2000 ATI Technologies Inc. and 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
-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, PRECISION INSIGHT 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:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-/* r128 Mesa driver includes */
-#include "r128_context.h"
-#include "r128_ioctl.h"
-#include "r128_state.h"
-#include "r128_tex.h"
-
-/* Mesa src includes */
-#include "context.h"
-#include "simple_list.h"
-#include "mmath.h"
-
-extern void __driRegisterExtensions( void );
-
-static r128ContextPtr r128Ctx = NULL;
-
-
-/* Initialize the driver specific screen private data.
- */
-GLboolean XMesaInitDriver( __DRIscreenPrivate *sPriv )
-{
- sPriv->private = (void *) r128CreateScreen( sPriv );
-
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 || minor < 0 ) {
- char msg[1000];
- sprintf( msg, "R128 DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
- }
- }
-
- /* Check that the DDX driver version is compatible */
- if ( sPriv->ddxMajor != 4 ||
- sPriv->ddxMinor < 0 ) {
- char msg[1000];
- sprintf( msg, "R128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- /* Check that the DRM driver version is compatible */
- if ( sPriv->drmMajor != 2 ||
- sPriv->drmMinor < 2 ) {
- char msg[1000];
- sprintf( msg, "R128 DRI driver expected DRM driver version 2.2 or greater but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- if ( !sPriv->private ) {
- r128DestroyScreen( sPriv );
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-/* Reset the driver specific screen private data.
- */
-void XMesaResetDriver( __DRIscreenPrivate *sPriv )
-{
- r128DestroyScreen( sPriv );
-}
-
-/* Create and initialize the Mesa and driver specific visual data.
- */
-GLvisual *XMesaCreateVisual( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config )
-{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount( visinfo->red_mask ),
- _mesa_bitcount( visinfo->green_mask ),
- _mesa_bitcount( visinfo->blue_mask ),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
-
-/* Create and initialize the Mesa and driver specific context data.
- */
-GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
-{
- return r128CreateContext( dpy, mesaVis, driContextPriv );
-}
-
-/* Destroy the Mesa and driver specific context data.
- */
-void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv)
-{
- r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
-
- if ( rmesa == r128Ctx ) r128Ctx = NULL;
- r128DestroyContext(rmesa);
-}
-
-/* Create and initialize the Mesa and driver specific pixmap buffer
- * data.
- */
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
- GLboolean swStencil;
- swStencil = (mesaVis->StencilBits > 0) /* && (mesaVis->RedBits < 8) */ ;
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- swStencil,
- mesaVis->AccumRedBits > 0,
- GL_FALSE /* software alpha buffer? */ );
-}
-
-/* Create and initialize the Mesa and driver specific pixmap buffer
- * data.
- */
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0 );
-#else
- return NULL; /* not implemented yet */
-#endif
-}
-
-/* Copy the back color buffer to the front color buffer */
-void XMesaSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
-{
- /* FIXME: This assumes buffer is currently bound to a context. This
- * needs to be able to swap buffers when not currently bound. Also,
- * this needs to swap according to buffer, and NOT according to
- * context!
- */
- if ( r128Ctx == NULL )
- return;
-
- /* Only swap buffers when a back buffer exists.
- */
- if ( r128Ctx->glCtx->Visual->DBflag ) {
- FLUSH_VB( r128Ctx->glCtx, "swap buffers" );
- if ( !r128Ctx->doPageFlip ) {
- r128SwapBuffers( r128Ctx );
- } else {
- r128PageFlip( r128Ctx );
- }
- }
-}
-
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean XMesaMakeCurrent( __DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv )
-{
- if ( driContextPriv ) {
- r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
-
- r128Ctx = r128MakeCurrent( r128Ctx, rmesa, driDrawPriv );
-
- gl_make_current2( r128Ctx->glCtx,
- driDrawPriv->mesaBuffer,
- driReadPriv->mesaBuffer );
-
- if ( r128Ctx->driDrawable != driDrawPriv ) {
- r128Ctx->driDrawable = driDrawPriv;
- r128Ctx->dirty = R128_UPLOAD_ALL;
- }
-
- /* GH: We need this to correctly calculate the window offset
- * and aux scissor rects.
- */
- r128Ctx->new_state = R128_NEW_WINDOW | R128_NEW_CLIP;
-
- if ( !r128Ctx->glCtx->Viewport.Width ) {
- gl_Viewport( r128Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
- }
- } else {
- gl_make_current( 0, 0 );
- r128Ctx = NULL;
- }
-
- return GL_TRUE;
-}
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
- return GL_TRUE;
-}
-
-/* This function is called by libGL.so as soon as libGL.so is loaded.
- * This is where we'd register new extension functions with the
- * dispatcher.
- */
-void __driRegisterExtensions( void )
-{
-}
-
-/* Initialize the fullscreen mode.
- */
-GLboolean
-XMesaOpenFullScreen( __DRIcontextPrivate *driContextPriv )
-{
-#if 0
- r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
- GLint ret;
-
- /* FIXME: Do we need to check this?
- */
- if ( !r128Ctx->glCtx->Visual->DBflag )
- return GL_TRUE;
-
- LOCK_HARDWARE( rmesa );
- r128WaitForIdleLocked( rmesa );
-
- /* Ignore errors. If this fails, we simply don't do page flipping.
- */
- ret = drmR128FullScreen( rmesa->driFd, GL_TRUE );
-
- UNLOCK_HARDWARE( rmesa );
-
- rmesa->doPageFlip = ( ret == 0 );
-#endif
-
- return GL_TRUE;
-}
-
-/* Shut down the fullscreen mode.
- */
-GLboolean
-XMesaCloseFullScreen( __DRIcontextPrivate *driContextPriv )
-{
-#if 0
- r128ContextPtr rmesa = (r128ContextPtr)driContextPriv->driverPrivate;
-
- LOCK_HARDWARE( rmesa );
- r128WaitForIdleLocked( rmesa );
-
- /* Don't care if this fails, we're not page flipping anymore.
- */
- drmR128FullScreen( rmesa->driFd, GL_FALSE );
-
- UNLOCK_HARDWARE( rmesa );
-
- rmesa->doPageFlip = GL_FALSE;
- rmesa->currentPage = 0;
-#endif
-
- return GL_TRUE;
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/Imakefile b/xc/lib/GL/mesa/src/drv/radeon/Imakefile
index dbe9a4bfc..f4c1ef7ca 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/radeon/Imakefile
@@ -22,12 +22,14 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/radeon/Imakefile,v 1.7 2001/11/02 23:29:2
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
diff --git a/xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc b/xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc
index 87dae79ba..58c3f4fba 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/radeon/Imakefile.inc
@@ -16,17 +16,17 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
-I$(GLXLIBSRC)/glx \
-I$(INCLUDESRC) \
-I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/ati \
-I$(XF86COMSRC) \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
MESA_INCLUDES = -I$(MESASRCDIR)/src \
@@ -35,98 +35,75 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src \
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
RADEONSRCS = $(MESADRVRADEONBUILDDIR)radeon_context.c \
- $(MESADRVRADEONBUILDDIR)radeon_dd.c \
- $(MESADRVRADEONBUILDDIR)radeon_fastpath.c \
- $(MESADRVRADEONBUILDDIR)radeon_eltpath.c \
$(MESADRVRADEONBUILDDIR)radeon_ioctl.c \
$(MESADRVRADEONBUILDDIR)radeon_lock.c \
- $(MESADRVRADEONBUILDDIR)radeon_pipeline.c \
- $(MESADRVRADEONBUILDDIR)radeon_screen.c \
+ $(MESADRVRADEONBUILDDIR)radeon_render.c \
+ $(MESADRVRADEONBUILDDIR)radeon_screen.c \
$(MESADRVRADEONBUILDDIR)radeon_span.c \
$(MESADRVRADEONBUILDDIR)radeon_state.c \
$(MESADRVRADEONBUILDDIR)radeon_tex.c \
$(MESADRVRADEONBUILDDIR)radeon_texmem.c \
$(MESADRVRADEONBUILDDIR)radeon_texstate.c \
$(MESADRVRADEONBUILDDIR)radeon_tris.c \
- $(MESADRVRADEONBUILDDIR)radeon_vb.c \
- $(MESADRVRADEONBUILDDIR)radeon_xmesa.c
+ $(MESADRVRADEONBUILDDIR)radeon_vb.c
RADEONOBJS = $(MESADRVRADEONBUILDDIR)radeon_context.o \
- $(MESADRVRADEONBUILDDIR)radeon_dd.o \
- $(MESADRVRADEONBUILDDIR)radeon_fastpath.o \
- $(MESADRVRADEONBUILDDIR)radeon_eltpath.o \
$(MESADRVRADEONBUILDDIR)radeon_ioctl.o \
$(MESADRVRADEONBUILDDIR)radeon_lock.o \
- $(MESADRVRADEONBUILDDIR)radeon_pipeline.o \
- $(MESADRVRADEONBUILDDIR)radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)radeon_render.o \
+ $(MESADRVRADEONBUILDDIR)radeon_screen.o \
$(MESADRVRADEONBUILDDIR)radeon_span.o \
$(MESADRVRADEONBUILDDIR)radeon_state.o \
$(MESADRVRADEONBUILDDIR)radeon_tex.o \
$(MESADRVRADEONBUILDDIR)radeon_texmem.o \
$(MESADRVRADEONBUILDDIR)radeon_texstate.o \
$(MESADRVRADEONBUILDDIR)radeon_tris.o \
- $(MESADRVRADEONBUILDDIR)radeon_vb.o \
- $(MESADRVRADEONBUILDDIR)radeon_xmesa.o
+ $(MESADRVRADEONBUILDDIR)radeon_vb.o
RADEONUOBJS = $(MESADRVRADEONBUILDDIR)unshared/radeon_context.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_dd.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_fastpath.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_eltpath.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_ioctl.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_lock.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_pipeline.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_render.o \
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_screen.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_span.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_state.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_tex.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_texmem.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_texstate.o \
$(MESADRVRADEONBUILDDIR)unshared/radeon_tris.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_vb.o \
- $(MESADRVRADEONBUILDDIR)unshared/radeon_xmesa.o
+ $(MESADRVRADEONBUILDDIR)unshared/radeon_vb.o
RADEONDOBJS = $(MESADRVRADEONBUILDDIR)debugger/radeon_context.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_dd.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_fastpath.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_eltpath.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_ioctl.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_lock.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_pipeline.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_render.o \
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_screen.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_span.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_state.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_tex.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_texmem.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_texstate.o \
$(MESADRVRADEONBUILDDIR)debugger/radeon_tris.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_vb.o \
- $(MESADRVRADEONBUILDDIR)debugger/radeon_xmesa.o
+ $(MESADRVRADEONBUILDDIR)debugger/radeon_vb.o
RADEONPOBJS = $(MESADRVRADEONBUILDDIR)profiled/radeon_context.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_dd.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_fastpath.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_eltpath.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_ioctl.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_lock.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_pipeline.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_screen.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_render.o \
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_screen.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_span.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_state.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_tex.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_texmem.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_texstate.o \
$(MESADRVRADEONBUILDDIR)profiled/radeon_tris.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_vb.o \
- $(MESADRVRADEONBUILDDIR)profiled/radeon_xmesa.o
+ $(MESADRVRADEONBUILDDIR)profiled/radeon_vb.o
#ifdef NeedToLinkMesaSrc
LinkSourceFile(radeon_context.c, $(MESADRVSRCDIR)/radeon)
-LinkSourceFile(radeon_dd.c, $(MESADRVSRCDIR)/radeon)
-LinkSourceFile(radeon_fastpath.c, $(MESADRVSRCDIR)/radeon)
-LinkSourceFile(radeon_eltpath.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_ioctl.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_lock.c, $(MESADRVSRCDIR)/radeon)
-LinkSourceFile(radeon_pipeline.c, $(MESADRVSRCDIR)/radeon)
+LinkSourceFile(radeon_render.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_screen.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_span.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_state.c, $(MESADRVSRCDIR)/radeon)
@@ -135,6 +112,4 @@ LinkSourceFile(radeon_texmem.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_texstate.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_tris.c, $(MESADRVSRCDIR)/radeon)
LinkSourceFile(radeon_vb.c, $(MESADRVSRCDIR)/radeon)
-LinkSourceFile(radeon_xmesa.c, $(MESADRVSRCDIR)/radeon)
#endif
-
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
index 55ac23d0b..980640362 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.2 2001/03/21 16:14:24 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -38,16 +38,29 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_context.h"
#include "radeon_ioctl.h"
-#include "radeon_dd.h"
#include "radeon_state.h"
#include "radeon_span.h"
#include "radeon_tex.h"
+#include "radeon_tris.h"
#include "radeon_vb.h"
-#include "radeon_pipeline.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
#include "context.h"
#include "simple_list.h"
#include "mem.h"
+#include "matrix.h"
+#include "extensions.h"
+#if defined(USE_X86_ASM)
+#include "X86/common_x86_asm.h"
+#endif
+
+#define RADEON_DATE "20010624"
#ifndef RADEON_DEBUG
int RADEON_DEBUG = (0
@@ -62,175 +75,362 @@ int RADEON_DEBUG = (0
);
#endif
-#ifdef PER_CONTEXT_SAREA
-char *radeonGetPerContextSAREA(int fd,
- drmContext hHWContext,
- drmSize size)
+
+
+/* Return the width and height of the current color buffer.
+ */
+static void radeonGetBufferSize( GLcontext *ctx,
+ GLuint *width, GLuint *height )
{
- drmHandle handle;
- drmAddress address;
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ LOCK_HARDWARE( rmesa );
+ *width = rmesa->dri.drawable->w;
+ *height = rmesa->dri.drawable->h;
+ UNLOCK_HARDWARE( rmesa );
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ static char buffer[128];
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"VA Linux Systems, Inc.";
+
+ case GL_RENDERER:
+ sprintf( buffer, "Mesa DRI Radeon " RADEON_DATE );
+
+ /* Append any chipset-specific information. None yet.
+ */
+
+ /* Append any AGP-specific information.
+ */
+ switch ( rmesa->radeonScreen->AGPMode ) {
+ case 1:
+ strncat( buffer, " AGP 1x", 7 );
+ break;
+ case 2:
+ strncat( buffer, " AGP 2x", 7 );
+ break;
+ case 4:
+ strncat( buffer, " AGP 4x", 7 );
+ break;
+ }
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+ }
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+#endif
+ return (GLubyte *)buffer;
- if(drmGetContextPrivateMapping(fd, hHWContext, &handle) < 0) {
+ default:
return NULL;
}
- if(drmMap(fd, handle, size, &address) < 0) {
- return NULL;
+}
+
+/* Send all commands to the hardware. If vertex buffers or indirect
+ * buffers are in use, then we need to make sure they are sent to the
+ * hardware. All commands that are normally sent to the ring are
+ * already considered `flushed'.
+ */
+static void radeonFlush( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_FIREVERTICES( rmesa );
+
+ if ( rmesa->boxes ) {
+ LOCK_HARDWARE( rmesa );
+ radeonPerformanceBoxesLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
}
- return address;
+ /* Log the performance counters if necessary */
+ radeonPerformanceCounters( rmesa );
}
-#endif
-/* Create the device specific context.
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
*/
-GLboolean radeonCreateContext( Display *dpy, GLvisual *glVisual,
- __DRIcontextPrivate *driContextPriv )
+static void radeonFinish( GLcontext *ctx )
{
- GLcontext *ctx = driContextPriv->mesaContext;
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- radeonContextPtr rmesa;
- radeonScreenPtr radeonScreen;
- int i;
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ /* Bump the performance counter */
+ rmesa->c_drawWaits++;
+ radeonFlush( ctx );
+ LOCK_HARDWARE( rmesa );
+ radeonWaitForIdleLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+}
- rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );
- if ( !rmesa ) return GL_FALSE;
- rmesa->glCtx = ctx;
- rmesa->display = dpy;
+/* Initialize the extensions supported by this driver.
+ */
+static void radeonInitExtensions( GLcontext *ctx )
+{
+ _mesa_enable_imaging_extensions( ctx );
- rmesa->driContext = driContextPriv;
- rmesa->driScreen = sPriv;
- rmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
+ _mesa_enable_extension( ctx, "GL_ARB_texture_env_add" );
- rmesa->hHWContext = driContextPriv->hHWContext;
- rmesa->driHwLock = &sPriv->pSAREA->lock;
- rmesa->driFd = sPriv->fd;
+ _mesa_enable_extension( ctx, "GL_EXT_blend_logic_op" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_dot3" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_filter_anisotropic" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
- radeonScreen = rmesa->radeonScreen = (radeonScreenPtr)(sPriv->private);
+}
- rmesa->sarea = (RADEONSAREAPrivPtr)((char *)sPriv->pSAREA +
- radeonScreen->sarea_priv_offset);
+extern const struct gl_pipeline_stage _radeon_render_stage;
+extern const struct gl_pipeline_stage _radeon_tcl_render_stage;
+
+static const struct gl_pipeline_stage *radeon_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_radeon_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
-#ifdef PER_CONTEXT_SAREA
- rmesa->private_sarea = radeonGetPerContextSAREA(rmesa->driFd,
- rmesa->hHWContext,
- radeonScreen->private_sarea_size);
- if(!rmesa->private_sarea) {
- fprintf(stderr, "Can't map private SAREA\n");
- FREE( rmesa );
+
+
+/* Initialize the driver's misc functions.
+ */
+static void radeonInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = radeonGetBufferSize;
+ ctx->Driver.GetString = radeonGetString;
+ ctx->Driver.Finish = radeonFinish;
+ ctx->Driver.Flush = radeonFlush;
+
+ ctx->Driver.Error = NULL;
+ ctx->Driver.DrawPixels = NULL;
+ ctx->Driver.Bitmap = NULL;
+}
+
+
+
+/* Create the device specific context.
+ */
+static GLboolean
+radeonCreateContext( Display *dpy, const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr radeonScreen = (radeonScreenPtr)(sPriv->private);
+ radeonContextPtr rmesa;
+ GLcontext *ctx, *shareCtx;
+ int i;
+
+ assert(dpy);
+ assert(glVisual);
+ assert(driContextPriv);
+ assert(radeonScreen);
+
+ /* Allocate the Radeon context */
+ rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );
+ if ( !rmesa )
return GL_FALSE;
- }
-#endif
- rmesa->tmp_matrix = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
- if ( !rmesa->tmp_matrix ) {
- FREE( rmesa );
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx, rmesa, GL_TRUE);
+ if (!rmesa->glCtx) {
+ FREE(rmesa);
return GL_FALSE;
}
+ driContextPriv->driverPrivate = rmesa;
+
+ /* Init radeon context data */
+ rmesa->dri.display = dpy;
+ rmesa->dri.context = driContextPriv;
+ rmesa->dri.screen = sPriv;
+ rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
+ rmesa->dri.hwContext = driContextPriv->hHWContext;
+ rmesa->dri.hwLock = &sPriv->pSAREA->lock;
+ rmesa->dri.fd = sPriv->fd;
+
+ rmesa->radeonScreen = radeonScreen;
+ rmesa->sarea = (RADEONSAREAPrivPtr)((GLubyte *)sPriv->pSAREA +
+ radeonScreen->sarea_priv_offset);
- make_empty_list( &rmesa->SwappedOut );
for ( i = 0 ; i < radeonScreen->numTexHeaps ; i++ ) {
- rmesa->CurrentTexObj[i] = NULL;
- make_empty_list( &rmesa->TexObjList[i] );
- rmesa->texHeap[i] = mmInit( 0, radeonScreen->texSize[i] );
- rmesa->lastTexAge[i] = -1;
+ make_empty_list( &rmesa->texture.objects[i] );
+ rmesa->texture.heap[i] = mmInit( 0, radeonScreen->texSize[i] );
+ rmesa->texture.age[i] = -1;
}
- rmesa->lastTexHeap = radeonScreen->numTexHeaps;
+ rmesa->texture.numHeaps = radeonScreen->numTexHeaps;
+ make_empty_list( &rmesa->texture.swapped );
- rmesa->RenderIndex = -1; /* Impossible value */
- rmesa->OnFastPath = 0;
-
- rmesa->vert_buf = NULL;
- rmesa->num_verts = 0;
-
- rmesa->elt_buf = NULL;
- rmesa->retained_buf = NULL;
- rmesa->vert_heap = radeonScreen->buffers->list->address;
+ rmesa->RenderIndex = ~0;
+ rmesa->state.hw.dirty = RADEON_UPLOAD_CONTEXT_ALL;
+ rmesa->upload_cliprects = 1;
/* KW: Set the maximum texture size small enough that we can
* guarentee that both texture units can bind a maximal texture
- * and have them both in on-card memory at once. (Kevin or
- * Gareth: Please check these numbers are OK)
+ * and have them both in on-card memory at once.
+ * Test for 2 textures * 4 bytes/texel * size * size.
*/
- if ( radeonScreen->texSize[0] < 2*1024*1024 ) {
- ctx->Const.MaxTextureLevels = 9;
- ctx->Const.MaxTextureSize = (1 << 8);
- } else if ( radeonScreen->texSize[0] < 8*1024*1024 ) {
- ctx->Const.MaxTextureLevels = 10;
- ctx->Const.MaxTextureSize = (1 << 9);
- } else {
- ctx->Const.MaxTextureLevels = 11;
- ctx->Const.MaxTextureSize = (1 << 10);
+ ctx = rmesa->glCtx;
+ if (radeonScreen->texSize[RADEON_CARD_HEAP] >= 2 * 4 * 2048 * 2048) {
+ ctx->Const.MaxTextureLevels = 12; /* 2048x2048 */
+ }
+ else if (radeonScreen->texSize[RADEON_CARD_HEAP] >= 2 * 4 * 1024 * 1024) {
+ ctx->Const.MaxTextureLevels = 11; /* 1024x1024 */
+ }
+ else if (radeonScreen->texSize[RADEON_CARD_HEAP] >= 2 * 4 * 512 * 512) {
+ ctx->Const.MaxTextureLevels = 10; /* 512x512 */
+ }
+ else {
+ ctx->Const.MaxTextureLevels = 9; /* 256x256 */
}
ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureMaxAnisotropy = 16.0;
- ctx->DriverCtx = (void *)rmesa;
-
- radeonDDInitExtensions( ctx );
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 10.0;
+ ctx->Const.MaxLineWidthAA = 10.0;
+ ctx->Const.LineWidthGranularity = 0.0625;
+
+ if (getenv("LIBGL_PERFORMANCE_BOXES"))
+ rmesa->boxes = 1;
+ else
+ rmesa->boxes = 0;
+
+ {
+ const char *debug = getenv("LIBGL_DEBUG");
+ if (debug && strstr(debug, "fallbacks")) {
+ rmesa->debugFallbacks = GL_TRUE;
+ }
+ }
- radeonDDInitDriverFuncs( ctx );
- radeonDDInitIoctlFuncs( ctx );
- radeonDDInitStateFuncs( ctx );
- radeonDDInitSpanFuncs( ctx );
- radeonDDInitTextureFuncs( ctx );
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
- ctx->Driver.TriangleCaps = (DD_TRI_CULL |
- DD_TRI_LIGHT_TWOSIDE |
- DD_TRI_STIPPLE |
- DD_TRI_OFFSET);
- /* Ask Mesa to clip fog coordinates for us.
+ /* Install the customized pipeline:
*/
- ctx->TriangleCaps |= DD_CLIP_FOG_COORD;
-
- if ( ctx->VB )
- radeonDDRegisterVB( ctx->VB );
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, radeon_pipeline );
- if ( ctx->NrPipelineStages ) {
- ctx->NrPipelineStages =
- radeonDDRegisterPipelineStages( ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages );
- }
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
- radeonDDInitState( rmesa );
+ radeonInitVB( ctx );
+ radeonInitExtensions( ctx );
+ radeonInitDriverFuncs( ctx );
+ radeonInitIoctlFuncs( ctx );
+ radeonInitStateFuncs( ctx );
+ radeonInitSpanFuncs( ctx );
+ radeonInitTextureFuncs( ctx );
+ radeonInitTriFuncs( ctx );
- driContextPriv->driverPrivate = (void *)rmesa;
+ radeonInitState( rmesa );
return GL_TRUE;
}
+
/* Destroy the device specific context.
*/
-void radeonDestroyContext( radeonContextPtr rmesa )
+/* Destroy the Mesa and driver specific context data.
+ */
+static void
+radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
+ radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
+
+ /* check if we're deleting the currently bound context */
+ if (rmesa == current) {
+ _mesa_make_current2(NULL, NULL, NULL);
+ }
+
+ /* Free radeon context resources */
+ assert(rmesa); /* should never be null */
if ( rmesa ) {
- radeonScreenPtr radeonScreen = rmesa->radeonScreen;
- radeonTexObjPtr t, next_t;
- int i;
-
-#ifdef PER_CONTEXT_SAREA
- if ( rmesa->private_sarea ) {
- drmUnmap( (drmAddress)rmesa->private_sarea,
- radeonScreen->private_sarea_size );
- rmesa->private_sarea = NULL;
+ if (rmesa->glCtx->Shared->RefCount == 1) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ radeonTexObjPtr t, next_t;
+ int i;
+
+ for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
+ foreach_s ( t, next_t, &rmesa->texture.objects[i] ) {
+ radeonDestroyTexObj( rmesa, t );
+ }
+ mmDestroy( rmesa->texture.heap[i] );
+ }
+
+ foreach_s ( t, next_t, &rmesa->texture.swapped ) {
+ radeonDestroyTexObj( rmesa, t );
+ }
}
-#endif
- for ( i = 0 ; i < radeonScreen->numTexHeaps ; i++ ) {
- foreach_s ( t, next_t, &rmesa->TexObjList[i] ) {
- radeonDestroyTexObj( rmesa, t );
- }
- mmDestroy( rmesa->texHeap[i] );
- }
+ _swsetup_DestroyContext( rmesa->glCtx );
+ _tnl_DestroyContext( rmesa->glCtx );
+ _ac_DestroyContext( rmesa->glCtx );
+ _swrast_DestroyContext( rmesa->glCtx );
- foreach_s ( t, next_t, &rmesa->SwappedOut ) {
- radeonDestroyTexObj( rmesa, t );
- }
+ radeonFreeVB( rmesa->glCtx );
+
+ /* free the Mesa context */
+ rmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context( rmesa->glCtx );
- ALIGN_FREE( rmesa->tmp_matrix );
FREE( rmesa );
}
@@ -240,27 +440,226 @@ void radeonDestroyContext( radeonContextPtr rmesa )
#endif
}
-/* Load the device specific context into the hardware. The actual
- * setting of the hardware state is done in the radeonUpdateHWState().
+
+/* Initialize the driver specific screen private data.
*/
-radeonContextPtr radeonMakeCurrent( radeonContextPtr oldCtx,
- radeonContextPtr newCtx,
- __DRIdrawablePrivate *dPriv )
+static GLboolean
+radeonInitDriver( __DRIscreenPrivate *sPriv )
{
- if ( oldCtx ) {
- if ( oldCtx != newCtx ) {
- newCtx->new_state |= RADEON_NEW_CONTEXT;
- newCtx->dirty = RADEON_UPLOAD_ALL;
+ sPriv->private = (void *) radeonCreateScreen( sPriv );
+ if ( !sPriv->private ) {
+ radeonDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+radeonCreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ const GLboolean swDepth = GL_FALSE;
+ const GLboolean swAlpha = GL_FALSE;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24;
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha );
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+
+static void
+radeonSwapBuffers(Display *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ (void) dpy;
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ radeonContextPtr rmesa;
+ GLcontext *ctx;
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = rmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_swapbuffers( ctx ); /* flush pending rendering comands */
+ if ( rmesa->doPageFlip ) {
+ radeonPageFlip( dPriv );
+ }
+ else {
+ radeonCopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "radeonSwapBuffers: drawable has no context!\n");
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+static GLboolean
+radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr oldRadeonCtx = ctx ? RADEON_CONTEXT(ctx) : NULL;
+ radeonContextPtr newRadeonCtx = (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if ( newRadeonCtx != oldRadeonCtx ) {
+ newRadeonCtx->state.hw.dirty = RADEON_UPLOAD_CONTEXT_ALL;
+ if ( newRadeonCtx->state.texture.unit[0].texobj )
+ newRadeonCtx->state.hw.dirty |= RADEON_UPLOAD_TEX0;
+ if ( newRadeonCtx->state.texture.unit[1].texobj )
+ newRadeonCtx->state.hw.dirty |= RADEON_UPLOAD_TEX1;
+ }
+
+ if ( newRadeonCtx->dri.drawable != driDrawPriv ) {
+ newRadeonCtx->dri.drawable = driDrawPriv;
+ newRadeonCtx->upload_cliprects = 1;
+ radeonUpdateWindow( newRadeonCtx->glCtx );
+ radeonUpdateViewportOffset( newRadeonCtx->glCtx );
}
- if ( oldCtx->driDrawable != dPriv ) {
- newCtx->new_state |= RADEON_NEW_WINDOW | RADEON_NEW_CLIP;
+
+ _mesa_make_current2( newRadeonCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if ( !newRadeonCtx->glCtx->Viewport.Width ) {
+ _mesa_set_viewport( newRadeonCtx->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h );
}
} else {
- newCtx->new_state |= RADEON_NEW_CONTEXT;
- newCtx->dirty = RADEON_UPLOAD_ALL;
+ _mesa_make_current( 0, 0 );
}
- newCtx->driDrawable = dPriv;
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+static GLboolean
+radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+/* Initialize the fullscreen mode.
+ */
+static GLboolean
+radeonOpenFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+#if 0
+ radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
+ GLint ret;
+
+ /* FIXME: Do we need to check this?
+ */
+ if ( !rmesa->glCtx->Visual.doubleBufferMode )
+ return GL_TRUE;
+
+ LOCK_HARDWARE( rmesa );
+ radeonWaitForIdleLocked( rmesa );
+
+ /* Ignore errors. If this fails, we simply don't do page flipping.
+ */
+ ret = drmRadeonFullScreen( rmesa->driFd, GL_TRUE );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->doPageFlip = ( ret == 0 );
+#endif
+ return GL_TRUE;
+}
+
+/* Shut down the fullscreen mode.
+ */
+static GLboolean
+radeonCloseFullScreen( __DRIcontextPrivate *driContextPriv )
+{
+#if 0
+ radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
+
+ LOCK_HARDWARE( rmesa );
+ radeonWaitForIdleLocked( rmesa );
- return newCtx;
+ /* Don't care if this fails, we're not page flipping anymore.
+ */
+ drmRadeonFullScreen( rmesa->driFd, GL_FALSE );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->doPageFlip = GL_FALSE;
+ rmesa->currentPage = 0;
+#endif
+ return GL_TRUE;
+}
+
+
+/* This function is called by libGL.so as soon as libGL.so is loaded.
+ * This is where we'd register new extension functions with the dispatcher.
+ */
+void
+__driRegisterExtensions( void )
+{
+}
+
+
+
+static struct __DriverAPIRec radeonAPI = {
+ radeonInitDriver,
+ radeonDestroyScreen,
+ radeonCreateContext,
+ radeonDestroyContext,
+ radeonCreateBuffer,
+ radeonDestroyBuffer,
+ radeonSwapBuffers,
+ radeonMakeCurrent,
+ radeonUnbindContext,
+ radeonOpenFullScreen,
+ radeonCloseFullScreen
+};
+
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &radeonAPI);
+ return (void *) psp;
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
index 0184a5b82..5dfb1f59b 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_context.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.h,v 1.2 2001/03/21 16:14:24 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -31,7 +31,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
- *
+ * Keith Whitwell <keith_whitwell@yahoo.com>
*/
#ifndef __RADEON_CONTEXT_H__
@@ -41,15 +41,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xlibint.h>
-#include "dri_mesaint.h"
-#include "dri_tmm.h"
+#include "dri_util.h"
#include "xf86drm.h"
#include "xf86drmRadeon.h"
-#include "types.h"
+#include "macros.h"
+#include "mtypes.h"
-#include "radeon_sarea.h"
#include "radeon_reg.h"
struct radeon_context;
@@ -57,135 +56,229 @@ typedef struct radeon_context radeonContextRec;
typedef struct radeon_context *radeonContextPtr;
#include "radeon_lock.h"
-#include "radeon_texobj.h"
#include "radeon_screen.h"
-
-/* Flags for what context state needs to be updated */
-#define RADEON_NEW_ALPHA 0x0001
-#define RADEON_NEW_DEPTH 0x0002
-#define RADEON_NEW_FOG 0x0004
-#define RADEON_NEW_CLIP 0x0008
-#define RADEON_NEW_CULL 0x0010
-#define RADEON_NEW_MASKS 0x0020
-#define RADEON_NEW_WINDOW 0x0040
-#define RADEON_NEW_TEXTURE 0x0080
-#define RADEON_NEW_CONTEXT 0x0100
-#define RADEON_NEW_ALL 0x01ff
+#include "mm.h"
/* Flags for software fallback cases */
+/* See correponding strings in radeon_tris.c */
#define RADEON_FALLBACK_TEXTURE 0x0001
#define RADEON_FALLBACK_DRAW_BUFFER 0x0002
-#define RADEON_FALLBACK_READ_BUFFER 0x0004
-#define RADEON_FALLBACK_STENCIL 0x0008
-#define RADEON_FALLBACK_RENDER_MODE 0x0010
-#define RADEON_FALLBACK_MULTIDRAW 0x0020
-#define RADEON_FALLBACK_LOGICOP 0x0040
+#define RADEON_FALLBACK_STENCIL 0x0004
+#define RADEON_FALLBACK_RENDER_MODE 0x0008
+#define RADEON_FALLBACK_BLEND_EQ 0x0010
+#define RADEON_FALLBACK_BLEND_FUNC 0x0020
-/* Subpixel offsets for window coordinates (triangles):
+/* Use the templated vertex format:
*/
-#define SUBPIXEL_X (0.0625)
-#define SUBPIXEL_Y (0.125)
+#define COLOR_IS_RGBA
+#define TAG(x) radeon##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
-/* Offset for points:
- */
-#define PNT_X_OFFSET ( 0.125F)
-#define PNT_Y_OFFSET (-0.125F)
+typedef void (*radeon_tri_func)( radeonContextPtr,
+ radeonVertex *,
+ radeonVertex *,
+ radeonVertex * );
+
+typedef void (*radeon_line_func)( radeonContextPtr,
+ radeonVertex *,
+ radeonVertex * );
+
+typedef void (*radeon_point_func)( radeonContextPtr,
+ radeonVertex * );
typedef void (*radeon_interp_func)( GLfloat t,
- GLfloat *result,
- const GLfloat *in,
- const GLfloat *out );
+ radeonTnlVertex *O,
+ const radeonTnlVertex *I,
+ const radeonTnlVertex *J );
+
+typedef void (*radeon_prim_func)( GLcontext *ctx );
+typedef void (*radeon_flush_func)( GLcontext *ctx, radeonTnlVertex *v );
+
+
+struct radeon_colorbuffer_state {
+ GLuint clear;
+
+ GLint drawOffset, drawPitch;
+};
+
+
+struct radeon_depthbuffer_state {
+ GLuint clear;
+ GLfloat scale;
+};
+
+struct radeon_pixel_state {
+ GLint readOffset, readPitch;
+};
+
+struct radeon_scissor_state {
+ XF86DRIClipRectRec rect;
+ GLboolean enabled;
+};
+
+struct radeon_stencilbuffer_state {
+ GLboolean hwBuffer;
+ GLuint clear; /* rb3d_stencilrefmask value */
+};
-struct radeon_elt_tab {
- void (*emit_unclipped_verts)( struct vertex_buffer *VB );
+struct radeon_stipple_state {
+ GLuint mask[32];
+};
+
+
+
+#define TEX_0 1
+#define TEX_1 2
+
+typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct radeon_tex_obj {
+ radeonTexObjPtr next, prev;
+
+ struct gl_texture_object *tObj; /* Mesa texture object */
+
+ PMemBlock memBlock; /* Memory block containing texture */
+ GLuint bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint dirty_images; /* Flags for whether or not
+ images need to be uploaded to
+ local or AGP texture space */
- void (*build_tri_verts)( radeonContextPtr rmesa,
- struct vertex_buffer *VB,
- GLfloat *O, GLuint *elt );
+ GLint bound; /* Texture unit currently bound to */
+ GLint heap; /* Texture heap currently stored in */
- void (*interp)( GLfloat t, GLfloat *O,
- const GLfloat *I, const GLfloat *J );
+ drmRadeonTexImage image[RADEON_MAX_TEXTURE_LEVELS];
- void (*project_and_emit_verts)( radeonContextPtr rmesa,
- const GLfloat *verts,
- GLuint *elts,
- GLuint nr );
+ GLint totalSize; /* Total size of the texture
+ including all mipmap levels */
+
+ GLuint pp_txfilter; /* hardware register values */
+ GLuint pp_txformat;
+ GLuint pp_txoffset;
+ GLuint pp_border_color;
+
+ /* texObj->Image[firstLevel] through texObj->Image[lastLevel] are the
+ * images to upload.
+ */
+ GLint firstLevel;
+ GLint lastLevel;
+};
+
+
+struct radeon_texture_env_state {
+ radeonTexObjPtr texobj;
+ GLenum format;
+ GLenum envMode;
+};
+
+struct radeon_texture_state {
+ struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS];
};
+struct radeon_state {
+ drmRadeonState hw;
+
+
+ struct radeon_colorbuffer_state color;
+ struct radeon_depthbuffer_state depth;
+ struct radeon_pixel_state pixel;
+ struct radeon_scissor_state scissor;
+ struct radeon_stencilbuffer_state stencil;
+ struct radeon_stipple_state stipple;
+ struct radeon_texture_state texture;
+};
+
+struct radeon_texture {
+ radeonTexObj objects[RADEON_NR_TEX_HEAPS];
+ radeonTexObj swapped;
+
+ memHeap_t *heap[RADEON_NR_TEX_HEAPS];
+ GLint age[RADEON_NR_TEX_HEAPS];
+
+ GLint numHeaps;
+};
+
+
+struct radeon_dma {
+ drmBufPtr buffer;
+ drmBufPtr retained;
+ GLubyte *address;
+ GLuint low, high, last;
+ GLuint offset;
+};
+
+struct radeon_dri_mirror {
+ Display *display; /* X server display */
+
+ __DRIcontextPrivate *context; /* DRI context */
+ __DRIscreenPrivate *screen; /* DRI screen */
+ __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
+
+ drmContext hwContext;
+ drmLock *hwLock;
+ int fd;
+};
+
+struct radeon_store {
+ radeonTexObjPtr texture[2][RADEON_MAX_STATES];
+ drmRadeonState state[RADEON_MAX_STATES];
+ drmRadeonPrim prim[RADEON_MAX_PRIMS];
+ GLuint statenr;
+ GLuint primnr;
+};
+
+
+
+
struct radeon_context {
GLcontext *glCtx; /* Mesa context */
/* Driver and hardware state management
*/
- GLuint new_state;
- GLuint dirty; /* Hardware state to be updated */
- radeon_context_regs_t setup;
-
- GLuint vertsize;
- GLuint vc_format;
- GLfloat depth_scale;
-
- GLuint Color; /* Current draw color */
- GLuint ClearColor; /* Color used to clear color buffer */
- GLuint ClearDepth; /* Value used to clear depth buffer */
- GLuint ClearStencil; /* Value used to clear stencil */
- GLuint DepthMask;
- GLuint StencilMask;
-
- /* Map GL texture units onto hardware
- */
- GLint multitex;
- GLint tmu_source[RADEON_MAX_TEXTURE_UNITS];
- GLint tex_dest[RADEON_MAX_TEXTURE_UNITS];
- GLuint color_combine[RADEON_MAX_TEXTURE_UNITS];
- GLuint alpha_combine[RADEON_MAX_TEXTURE_UNITS];
- GLuint env_color[RADEON_MAX_TEXTURE_UNITS];
- GLuint lod_bias[RADEON_MAX_TEXTURE_UNITS];
+ struct radeon_state state;
/* Texture object bookkeeping
*/
- radeonTexObjPtr CurrentTexObj[RADEON_MAX_TEXTURE_UNITS];
- radeonTexObj TexObjList[RADEON_NR_TEX_HEAPS];
- radeonTexObj SwappedOut;
- memHeap_t *texHeap[RADEON_NR_TEX_HEAPS];
- GLint lastTexAge[RADEON_NR_TEX_HEAPS];
- GLint lastTexHeap;
-
- /* Current rendering state, fallbacks
- */
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
+ struct radeon_texture texture;
- GLuint IndirectTriangles;
- GLuint Fallback;
+ /* Fallback rasterization functions
+ */
+ radeon_point_func draw_point;
+ radeon_line_func draw_line;
+ radeon_tri_func draw_tri;
- /* Fast path
+ /* Rasterization and vertex state:
*/
+ GLuint NewGLState;
+ GLuint Fallback;
GLuint SetupIndex;
- GLuint SetupDone;
+ GLuint SetupNewInputs;
GLuint RenderIndex;
- GLuint OnFastPath;
- radeon_interp_func interp;
- GLfloat *tmp_matrix;
- /* Vertex buffers
- */
- drmBufPtr vert_buf;
- GLuint vert_prim;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
GLuint num_verts;
+ char *verts;
+
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
- /* Elt path
+ /* Vertex buffers
*/
- drmBufPtr elt_buf, retained_buf;
- GLushort *first_elt, *next_elt;
- GLfloat *next_vert, *vert_heap;
- GLushort next_vert_index;
- GLushort first_vert_index;
- GLuint elt_vertsize;
- struct radeon_elt_tab *elt_tab;
- GLfloat device_matrix[16];
+ struct radeon_dma dma;
+
+ struct radeon_store store;
+ GLboolean upload_cliprects;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
/* Page flipping
*/
@@ -194,36 +287,18 @@ struct radeon_context {
/* Drawable, cliprect and scissor information
*/
- GLenum DrawBuffer; /* Optimize draw buffer update */
- GLint drawOffset, drawPitch;
- GLint readOffset, readPitch;
-
GLuint numClipRects; /* Cliprects for the draw buffer */
XF86DRIClipRectPtr pClipRects;
-
- GLuint scissor;
- XF86DRIClipRectRec scissor_rect; /* Current software scissor */
+ GLuint lastStamp;
/* Mirrors of some DRI state
*/
- Display *display; /* X server display */
-
- __DRIcontextPrivate *driContext; /* DRI context */
- __DRIscreenPrivate *driScreen; /* DRI screen */
- __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
-
- int lastStamp; /* mirror driDrawable->lastStamp */
-
- drmContext hHWContext;
- drmLock *driHwLock;
- int driFd;
+ struct radeon_dri_mirror dri;
radeonScreenPtr radeonScreen; /* Screen private DRI data */
RADEONSAREAPrivPtr sarea; /* Private SAREA data */
-#ifdef PER_CONTEXT_SAREA
- char *private_sarea; /* Per-context private SAREA */
-#endif
+ GLboolean debugFallbacks;
/* Performance counters
*/
@@ -239,19 +314,25 @@ struct radeon_context {
#define RADEON_CONTEXT(ctx) ((radeonContextPtr)(ctx->DriverCtx))
-extern GLboolean radeonCreateContext( Display *dpy, GLvisual *glVisual,
- __DRIcontextPrivate *driContextPriv );
-extern void radeonDestroyContext( radeonContextPtr rmesa );
-extern radeonContextPtr radeonMakeCurrent( radeonContextPtr oldCtx,
- radeonContextPtr newCtx,
- __DRIdrawablePrivate *dPriv );
+static __inline GLuint radeonPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
/* ================================================================
* Debugging:
*/
#define DO_DEBUG 0
-#define ENABLE_PERF_BOXES 0
#if DO_DEBUG
extern int RADEON_DEBUG;
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.c
deleted file mode 100644
index e055a0241..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_dd.c,v 1.6 2001/04/10 16:07:53 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "radeon_context.h"
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
-#include "radeon_vb.h"
-#include "radeon_pipeline.h"
-#include "radeon_dd.h"
-
-#include "extensions.h"
-#if defined(USE_X86_ASM) || defined(USE_3DNOW_ASM) || defined(USE_KATMAI_ASM)
-#include "X86/common_x86_asm.h"
-#endif
-
-#define RADEON_DATE "20010402"
-
-
-/* Return the width and height of the current color buffer.
- */
-static void radeonDDGetBufferSize( GLcontext *ctx,
- GLuint *width, GLuint *height )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- LOCK_HARDWARE( rmesa );
- *width = rmesa->driDrawable->w;
- *height = rmesa->driDrawable->h;
- UNLOCK_HARDWARE( rmesa );
-}
-
-/* Return various strings for glGetString().
- */
-static const GLubyte *radeonDDGetString( GLcontext *ctx, GLenum name )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- static char buffer[128];
-
- switch ( name ) {
- case GL_VENDOR:
- return (GLubyte *)"VA Linux Systems, Inc.";
-
- case GL_RENDERER:
- sprintf( buffer, "Mesa DRI Radeon " RADEON_DATE );
-
- /* Append any chipset-specific information. None yet.
- */
-
- /* Append any AGP/PCI-specific information.
- */
- if ( rmesa->radeonScreen->IsPCI ) {
- strncat( buffer, " PCI", 4 );
- } else {
- switch ( rmesa->radeonScreen->AGPMode ) {
- case 1:
- strncat( buffer, " AGP 1x", 7 );
- break;
- case 2:
- strncat( buffer, " AGP 2x", 7 );
- break;
- case 4:
- strncat( buffer, " AGP 4x", 7 );
- break;
- }
- }
-
- /* Append any CPU-specific information.
- */
-#ifdef USE_X86_ASM
- if ( gl_x86_cpu_features ) {
- strncat( buffer, " x86", 4 );
- }
-#endif
-#ifdef USE_MMX_ASM
- if ( cpu_has_mmx ) {
- strncat( buffer, "/MMX", 4 );
- }
-#endif
-#ifdef USE_3DNOW_ASM
- if ( cpu_has_3dnow ) {
- strncat( buffer, "/3DNow!", 7 );
- }
-#endif
-#ifdef USE_KATMAI_ASM
- if ( cpu_has_xmm ) {
- strncat( buffer, "/SSE", 4 );
- }
-#endif
- return (GLubyte *)buffer;
-
- default:
- return NULL;
- }
-}
-
-/* Send all commands to the hardware. If vertex buffers or indirect
- * buffers are in use, then we need to make sure they are sent to the
- * hardware. All commands that are normally sent to the ring are
- * already considered `flushed'.
- */
-static void radeonDDFlush( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- FLUSH_BATCH( rmesa );
-
-#if ENABLE_PERF_BOXES
- if ( rmesa->boxes ) {
- LOCK_HARDWARE( rmesa );
- radeonPerformanceBoxesLocked( rmesa );
- UNLOCK_HARDWARE( rmesa );
- }
-
- /* Log the performance counters if necessary */
- radeonPerformanceCounters( rmesa );
-#endif
-}
-
-/* Make sure all commands have been sent to the hardware and have
- * completed processing.
- */
-static void radeonDDFinish( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
-#if ENABLE_PERF_BOXES
- /* Bump the performance counter */
- rmesa->c_drawWaits++;
-#endif
-
- radeonDDFlush( ctx );
- radeonWaitForIdle( rmesa );
-}
-
-/* Return various parameters requested by Mesa (this is deprecated).
- */
-static GLint radeonDDGetParameteri( const GLcontext *ctx, GLint param )
-{
- switch ( param ) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- return 0;
- }
-}
-
-/* Initialize the extensions supported by this driver.
- */
-void radeonDDInitExtensions( GLcontext *ctx )
-{
- gl_extensions_disable( ctx, "GL_ARB_imaging" );
- gl_extensions_disable( ctx, "GL_ARB_texture_compression" );
- gl_extensions_disable( ctx, "GL_ARB_texture_cube_map" );
-
- gl_extensions_disable( ctx, "GL_EXT_blend_color" );
- gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
- gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
- gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
- gl_extensions_disable( ctx, "GL_EXT_convolution" );
- gl_extensions_disable( ctx, "GL_EXT_paletted_texture" );
- gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
- gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
- gl_extensions_enable( ctx, "GL_EXT_texture_env_combine" );
- gl_extensions_enable( ctx, "GL_EXT_texture_env_dot3" );
-
- gl_extensions_disable( ctx, "GL_HP_occlusion_test" );
-
- gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
-
- gl_extensions_disable( ctx, "GL_SGI_color_matrix" );
- gl_extensions_disable( ctx, "GL_SGI_color_table" );
- gl_extensions_disable( ctx, "GL_SGIX_pixel_texture" );
-}
-
-/* Initialize the driver's misc functions.
- */
-void radeonDDInitDriverFuncs( GLcontext *ctx )
-{
- ctx->Driver.GetBufferSize = radeonDDGetBufferSize;
- ctx->Driver.GetString = radeonDDGetString;
- ctx->Driver.Finish = radeonDDFinish;
- ctx->Driver.Flush = radeonDDFlush;
-
- ctx->Driver.Error = NULL;
- ctx->Driver.GetParameteri = radeonDDGetParameteri;
-
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.Bitmap = NULL;
-
- ctx->Driver.RegisterVB = radeonDDRegisterVB;
- ctx->Driver.UnregisterVB = radeonDDUnregisterVB;
- ctx->Driver.BuildPrecalcPipeline = radeonDDBuildPrecalcPipeline;
-}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.h
deleted file mode 100644
index 5e16e5e62..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_dd.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_dd.h,v 1.1 2001/01/08 01:07:26 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifndef __RADEON_DD_H__
-#define __RADEON_DD_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern void radeonDDInitExtensions( GLcontext *ctx );
-extern void radeonDDInitDriverFuncs( GLcontext *ctx );
-
-#endif
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_eltpath.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_eltpath.c
deleted file mode 100644
index 48947399c..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_eltpath.c
+++ /dev/null
@@ -1,504 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_eltpath.c,v 1.2 2001/04/01 14:00:00 tsi Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-#include <stdio.h>
-
-#include "radeon_context.h"
-#include "radeon_pipeline.h"
-#include "radeon_ioctl.h"
-#include "radeon_tris.h"
-#include "radeon_state.h"
-#include "radeon_vb.h"
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-#include "mmath.h"
-#include "xform.h"
-
-/* Always use a full-sized stride for vertices. [FIXME]
- * Stride in the buffers must be a quadword multiple.
- */
-#define CLIP_STRIDE 10
-
-static void fire_elts( radeonContextPtr rmesa )
-{
- GLuint vertsize = rmesa->vertsize;
-
- LOCK_HARDWARE( rmesa );
-
- /* Fire queued elements and discard that buffer if its contents
- * won't be referenced by future elements.
- */
- if ( rmesa->elt_buf )
- {
- GLuint retain = (rmesa->elt_buf == rmesa->retained_buf);
-
- if ( rmesa->first_elt != rmesa->next_elt ) {
- radeonFireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- !retain );
- } else if ( !retain ) {
- radeonReleaseBufLocked( rmesa, rmesa->elt_buf );
- }
-
- rmesa->elt_buf = 0;
- }
- else if ( rmesa->vert_buf )
- {
- radeonFlushVerticesLocked( rmesa );
- }
-
- radeonGetEltBufLocked( rmesa );
-
- UNLOCK_HARDWARE( rmesa );
-
- /* Give the compiler a chance to optimize the divisions.
- */
- switch ( vertsize ) {
- case 8:
- rmesa->next_vert_index = (GLushort)
- (((rmesa->elt_buf->idx + 1) *
- RADEON_BUFFER_SIZE / (8 * sizeof(GLuint))) - 1);
- rmesa->next_vert = (GLfloat *)
- ((char *)rmesa->vert_heap +
- rmesa->next_vert_index * 8 * sizeof(GLfloat));
- break;
-
- case 10:
- rmesa->next_vert_index = (GLushort)
- (((rmesa->elt_buf->idx + 1) *
- RADEON_BUFFER_SIZE / (10 * sizeof(GLuint))) - 1);
- rmesa->next_vert = (GLfloat *)
- ((char *)rmesa->vert_heap +
- rmesa->next_vert_index * 10 * sizeof(GLfloat));
- break;
- }
-
- rmesa->first_elt = rmesa->next_elt = (GLushort *)
- ((GLubyte *)rmesa->elt_buf->address + RADEON_INDEX_PRIM_OFFSET);
-
- rmesa->elt_vertsize = vertsize;
-}
-
-
-static void release_bufs( radeonContextPtr rmesa )
-{
- if ( rmesa->retained_buf && rmesa->retained_buf != rmesa->elt_buf )
- {
- LOCK_HARDWARE( rmesa );
- if ( rmesa->first_elt != rmesa->next_elt ) {
- radeonFireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- 0 );
-
- ALIGN_NEXT_ELT( rmesa );
- rmesa->first_elt = rmesa->next_elt;
- }
-
- radeonReleaseBufLocked( rmesa, rmesa->retained_buf );
- UNLOCK_HARDWARE( rmesa );
- }
-
- rmesa->retained_buf = 0;
-}
-
-
-
-
-#define NEGATIVE( f ) (f < 0)
-#define DIFFERENT_SIGNS( a, b ) ((a * b) < 0)
-#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
-
-
-#define INTERP_RGBA( t, out, a, b ) { \
- GLuint i; \
- for ( i = 0 ; i < 4 ; i++ ) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR( a[i] ); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR( b[i] ); \
- GLfloat fo = LINTERP( t, fa, fb ); \
- FLOAT_COLOR_TO_UBYTE_COLOR( out[i], fo ); \
- } \
-}
-
-
-#define CLIP( SGN, V, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]]; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- for ( i = n = 0 ; i < nr ; i++ ) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i]; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert]; \
- outdata[n++] = next_vert++; \
- \
- if ( NEGATIVE( dpI ) ) { \
- GLfloat t = dpI / (dpI - dpJ); \
- interp( t, O, I, J ); \
- } \
- else \
- { \
- GLfloat t = dpJ / (dpJ - dpI); \
- interp( t, O, J, I ); \
- } \
- } \
- \
- if ( !NEGATIVE( dpI ) ) \
- outdata[n++] = elt_i; \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if ( n < 3 ) return; \
- } \
-} while (0)
-
-
-static void radeon_tri_clip( radeonContextPtr rmesa,
- struct vertex_buffer *VB,
- GLuint *elt,
- GLubyte mask )
-{
- struct radeon_elt_tab *tab = rmesa->elt_tab;
- radeon_interp_func interp = tab->interp;
- GLuint vertsize = rmesa->vertsize;
- GLuint inlist[2][VB_MAX_CLIPPED_VERTS];
- GLuint in = 0;
- GLuint n = 3, next_vert = 3;
- GLuint i;
- GLfloat verts[VB_MAX_CLIPPED_VERTS][CLIP_STRIDE];
-
- /* Build temporary vertices in clipspace. This is the potential
- * downside to this path.
- */
- tab->build_tri_verts( rmesa, VB, (GLfloat *)verts, elt );
-
- inlist[0][0] = 0;
- inlist[0][1] = 1;
- inlist[0][2] = 2;
-
- CLIP( -, 0, CLIP_RIGHT_BIT );
- CLIP( +, 0, CLIP_LEFT_BIT );
- CLIP( -, 1, CLIP_TOP_BIT );
- CLIP( +, 1, CLIP_BOTTOM_BIT );
- CLIP( -, 2, CLIP_FAR_BIT );
- CLIP( +, 2, CLIP_NEAR_BIT );
-
-
- {
- GLuint *out = inlist[in];
- GLint space = (GLint)((char *)rmesa->next_vert -
- (char *)rmesa->next_elt);
-
- if ( space < (GLint)(n * (vertsize + 2) * sizeof(GLuint)) ) {
- fire_elts( rmesa );
- }
-
- /* Project the new vertices and emit to dma buffers. Translate
- * out values to physical addresses for setup dma.
- */
- tab->project_and_emit_verts( rmesa, (GLfloat *)verts, out, n );
-
- /* Convert the planar polygon to a list of triangles and emit to
- * elt buffers.
- */
- for ( i = 2 ; i < n ; i++ ) {
- rmesa->next_elt[0] = (GLushort) out[0];
- rmesa->next_elt[1] = (GLushort) out[i-1];
- rmesa->next_elt[2] = (GLushort) out[i];
- rmesa->next_elt += 3;
- }
- }
-}
-
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-
-#define INIT( x )
-
-#define TRI_THRESHOLD (GLint)(2 * sizeof(GLuint))
-
-#define UNCLIPPED_VERT( x ) (GLushort)(rmesa->first_vert_index - x)
-
-#define TRIANGLE( e2, e1, e0 ) \
-do { \
- if ( (GLint)((char *)rmesa->next_vert - \
- (char *)rmesa->next_elt) < TRI_THRESHOLD ) { \
- fire_elts( rmesa ); \
- } \
- rmesa->next_elt[0] = UNCLIPPED_VERT( e2 ); \
- rmesa->next_elt[1] = UNCLIPPED_VERT( e1 ); \
- rmesa->next_elt[2] = UNCLIPPED_VERT( e0 ); \
- rmesa->next_elt += 3; \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask = mask[e2] | mask[e1] | mask[e0]; \
- if ( ormask == 0 ) { \
- TRIANGLE( e2, e1, e0 ); \
- } else if ( (mask[e2] & mask[e1] & mask[e0]) == 0 ) { \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- radeon_tri_clip( rmesa, VB, out, ormask ); \
- } \
-} while (0)
-
-#define LOCAL_VARS \
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx); \
- GLuint *elt = VB->EltPtr->data; \
- GLuint out[VB_MAX_CLIPPED_VERTS]; \
- GLubyte *mask = VB->ClipMask; \
- (void) mask; (void) out; (void) elt; (void) rmesa;
-
-
-
-#define RENDER_POINTS( start, count )
-#define RENDER_LINE( i1, i0 )
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
- CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] )
-
-#define TAG(x) radeon_##x##_elt
-#include "render_tmp.h"
-
-
-
-#define LOCAL_VARS \
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx); \
- GLuint *elt = VB->EltPtr->data; \
- (void) elt; (void) rmesa;
-
-#define RENDER_POINTS( start, count )
-#define RENDER_LINE( i1, i0 )
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
- TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- TRIANGLE( elt[i2], elt[i1], elt[i0] )
-
-#define TAG(x) radeon_##x##_elt_unclipped
-#include "render_tmp.h"
-
-
-
-
-static void refresh_projection_matrix( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- GLfloat *m = rmesa->device_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY];
- m[MAT_SZ] = mat->m[MAT_SZ];
- m[MAT_TZ] = mat->m[MAT_TZ];
-}
-
-#define CLIP_UBYTE_R 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_B 2
-#define CLIP_UBYTE_A 3
-
-
-#define TYPE (0)
-#define TAG(x) x
-#include "radeon_elttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "radeon_elttmp.h"
-
-#define TYPE (RADEON_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "radeon_elttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT|RADEON_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "radeon_elttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "radeon_elttmp.h"
-
-#define TYPE (RADEON_TEX0_BIT|RADEON_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "radeon_elttmp.h"
-
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct radeon_elt_tab radeonEltTab[RADEON_MAX_SETUPFUNC];
-
-void radeonDDEltPathInit( void )
-{
- radeon_render_init_elt();
- radeon_render_init_elt_unclipped();
-
- radeon_init_eltpath( &radeonEltTab[0] );
- radeon_init_eltpath_RGBA( &radeonEltTab[RADEON_RGBA_BIT] );
- radeon_init_eltpath_TEX0( &radeonEltTab[RADEON_TEX0_BIT] );
- radeon_init_eltpath_RGBA_TEX0( &radeonEltTab[(RADEON_RGBA_BIT |
- RADEON_TEX0_BIT)] );
- radeon_init_eltpath_TEX0_TEX1( &radeonEltTab[(RADEON_TEX0_BIT |
- RADEON_TEX1_BIT)] );
- radeon_init_eltpath_RGBA_TEX0_TEX1( &radeonEltTab[(RADEON_RGBA_BIT |
- RADEON_TEX0_BIT |
- RADEON_TEX1_BIT)] );
-}
-
-#define VALID_SETUP (RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT)
-
-
-
-/* Use a temporary array for device coordinates, so that we can easily
- * tap into existing mesa assembly. Otherwise consider emitting
- * device coordinates to dma buffers directly from the project/cliptest
- * routine. (requires output stride, potential loss of writecombining
- * efficiency?)
- *
- * This path is a lot closer to the standard vertex path in the
- * initial stages than the original fastpath. A slightly more optimal
- * path could be constructed, but would require us to write new
- * assembly.
- */
-void radeonDDEltPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct radeon_elt_tab *tab =
- &radeonEltTab[rmesa->SetupIndex & VALID_SETUP];
- GLint vertsize = rmesa->vertsize;
- GLint space;
-
- VB->ClipPtr = TransformRaw( &VB->Clip,
- &ctx->ModelProjectMatrix,
- VB->ObjPtr );
-
- refresh_projection_matrix( ctx );
-
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- VB->Projected = gl_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &VB->Win,
- VB->ClipMask,
- &VB->ClipOrMask,
- &VB->ClipAndMask );
-
- if ( VB->ClipAndMask )
- return;
-
- if ( rmesa->vert_buf )
- radeonFlushVertices( rmesa );
-
- if ( rmesa->new_state )
- radeonDDUpdateHWState( ctx );
-
- space = (GLint)((char *)rmesa->next_vert -
- (char *)rmesa->next_elt);
-
- /* Allocate a single buffer to hold unclipped vertices. All
- * unclipped vertices must be contiguous.
- */
- if ( space < (GLint)(VB->Count * vertsize * sizeof(GLuint)) ||
- rmesa->vertsize != rmesa->elt_vertsize ) {
- fire_elts( rmesa );
- }
-
- rmesa->retained_buf = rmesa->elt_buf;
-
- /* Emit unclipped vertices to the buffer.
- */
- tab->emit_unclipped_verts( VB );
-
- /* Emit indices and clipped vertices to one or more buffers.
- */
- if ( VB->ClipOrMask ) {
- rmesa->elt_tab = tab;
- radeon_render_tab_elt[prim]( VB, 0, VB->EltPtr->count, 0 );
- } else {
- radeon_render_tab_elt_unclipped[prim]( VB, 0, VB->EltPtr->count, 0 );
- }
-
- /* Send to hardware and release the elt buffer.
- */
- release_bufs( rmesa );
-
- /* This indicates that there is no cached data to reuse.
- */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-
- FLUSH_BATCH( rmesa );
-}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_elttmp.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_elttmp.h
deleted file mode 100644
index 56c0ccedd..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_elttmp.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_elttmp.h,v 1.1 2001/01/08 01:07:27 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keithw@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-/* Buffers fill from high addresses down with vertices and from low
- * addresses up with elements.
- */
-
-
-/* Emit the bulk of the vertices to the first dma buffer. Leave
- * empty slots for clipped vertices so that we can still address
- * vertices by index.
- */
-static void TAG(emit_unclipped_verts)( struct vertex_buffer *VB )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx);
- GLfloat *dev = VB->Projected->start;
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
- GLuint buffer_stride = rmesa->vertsize;
-
- GLfloat *f = rmesa->next_vert;
- GLuint count = VB->Count;
- GLubyte *clipmask = VB->ClipMask;
-
- const GLfloat *m = rmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
- GLuint i;
-
- rmesa->retained_buf = rmesa->elt_buf;
- rmesa->first_vert_index = rmesa->next_vert_index;
-
- for ( i = 0 ; i < count ; f -= buffer_stride, i++ )
- {
- if ( !clipmask[i] )
- {
- f[0] = sx * dev[0] + tx;
- f[1] = sy * dev[1] + ty;
- f[2] = sz * dev[2] + tz;
- f[3] = dev[3];
-
- if ( TYPE & RADEON_RGBA_BIT ) {
- *(GLuint *)&f[4] = *(GLuint *)color;
- }
-
- if ( TYPE & RADEON_TEX0_BIT ) {
- *(GLuint *)&f[6] = *(GLuint *)&tex0_data[0];
- *(GLuint *)&f[7] = *(GLuint *)&tex0_data[1];
- }
-
- if ( TYPE & RADEON_TEX1_BIT ) {
- *(GLuint *)&f[8] = *(GLuint *)&tex1_data[0];
- *(GLuint *)&f[9] = *(GLuint *)&tex1_data[1];
- }
- }
-
- STRIDE_F( dev, 16 );
- if ( TYPE & RADEON_RGBA_BIT ) color += color_stride;
- if ( TYPE & RADEON_TEX0_BIT ) STRIDE_F( tex0_data, tex0_stride );
- if ( TYPE & RADEON_TEX1_BIT ) STRIDE_F( tex1_data, tex1_stride );
- }
-
- rmesa->next_vert = f;
- rmesa->next_vert_index -= count;
-}
-
-
-/* Build three temporary clipspace vertex for clipping a triangle.
- * Recreate from the VB data rather than trying to read back from
- * uncached memory.
- */
-static void TAG(build_tri_verts)( radeonContextPtr rmesa,
- struct vertex_buffer *VB,
- GLfloat *O,
- GLuint *elt )
-{
- GLint i;
-
- for ( i = 0 ; i < 3 ; i++, O += CLIP_STRIDE ) {
- GLfloat *clip = VB->Clip.start + elt[i]*4;
-
- O[0] = clip[0];
- O[1] = clip[1];
- O[2] = clip[2];
- O[3] = clip[3];
-
- if ( TYPE & RADEON_RGBA_BIT ) {
- GLubyte *color = VEC_ELT(VB->ColorPtr, GLubyte, elt[i]);
- *(GLuint *)&O[4] = *(GLuint *)color;
- }
-
- *(GLuint *)&O[5] = UNCLIPPED_VERT(elt[i]);
-
- if ( TYPE & RADEON_TEX0_BIT ) {
- GLfloat *tex0_data = VEC_ELT(VB->TexCoordPtr[0], GLfloat, elt[i]);
- *(GLuint *)&O[6] = *(GLuint *)&tex0_data[0];
- *(GLuint *)&O[7] = *(GLuint *)&tex0_data[1];
- }
-
- if ( TYPE & RADEON_TEX1_BIT ) {
- GLfloat *tex1_data = VEC_ELT(VB->TexCoordPtr[1], GLfloat, elt[i]);
- *(GLuint *)&O[8] = *(GLuint *)&tex1_data[0];
- *(GLuint *)&O[9] = *(GLuint *)&tex1_data[1];
- }
- }
-}
-
-
-/* Interpolate between two of the vertices constructed above.
- */
-static void TAG(interp)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP( t, I[0], J[0] );
- O[1] = LINTERP( t, I[1], J[1] );
- O[2] = LINTERP( t, I[2], J[2] );
- O[3] = LINTERP( t, I[3], J[3] );
-
- if ( TYPE & RADEON_RGBA_BIT ) {
- INTERP_RGBA( t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])) );
- }
-
- *(GLuint *)&O[5] = ~0; /* note that this is a new vertex */
-
- if ( TYPE & RADEON_TEX0_BIT ) {
- O[6] = LINTERP( t, I[6], J[6] );
- O[7] = LINTERP( t, I[7], J[7] );
- }
-
- if ( TYPE & RADEON_TEX1_BIT ) {
- O[8] = LINTERP( t, I[8], J[8] );
- O[9] = LINTERP( t, I[9], J[9] );
- }
-}
-
-
-
-/* When clipping is complete, scan the final vertex list and emit any
- * new ones to dma buffers. Update the element list to a format
- * suitable for sending to hardware.
- */
-static void TAG(project_and_emit_verts)( radeonContextPtr rmesa,
- const GLfloat *verts,
- GLuint *elt,
- GLuint nr)
-{
- GLfloat *O = rmesa->next_vert;
- GLushort index = rmesa->next_vert_index;
- GLuint buffer_stride = rmesa->vertsize;
-
- const GLfloat *m = rmesa->device_matrix;
- const GLfloat sx = m[0], sy = m[5], sz = m[10];
- const GLfloat tx = m[12], ty = m[13], tz = m[14];
- GLuint i;
-
- for ( i = 0 ; i < nr ; i++ ) {
- const GLfloat *I = &verts[elt[i] * CLIP_STRIDE];
- GLuint tmp = *(GLuint *)&I[5];
-
- if ( (elt[i] = tmp) == ~0 ) {
- GLfloat oow = 1.0 / I[3];
-
- elt[i] = index--;
-
- O[0] = sx * I[0] * oow + tx;
- O[1] = sy * I[1] * oow + ty;
- O[2] = sz * I[2] * oow + tz;
- O[3] = oow;
-
- if ( TYPE & RADEON_RGBA_BIT ) {
- *(GLuint *)&O[4] = *(GLuint *)&I[4];
- }
-
- if ( TYPE & RADEON_TEX0_BIT ) {
- *(GLuint *)&O[6] = *(GLuint *)&I[6];
- *(GLuint *)&O[7] = *(GLuint *)&I[7];
- }
-
- if ( TYPE & RADEON_TEX1_BIT ) {
- *(GLuint *)&O[8] = *(GLuint *)&I[8];
- *(GLuint *)&O[9] = *(GLuint *)&I[9];
- }
-
- O -= buffer_stride;
- }
- }
-
- rmesa->next_vert = O;
- rmesa->next_vert_index = index;
-}
-
-
-
-static void TAG(radeon_init_eltpath)( struct radeon_elt_tab *tab )
-{
- tab->emit_unclipped_verts = TAG(emit_unclipped_verts);
- tab->build_tri_verts = TAG(build_tri_verts);
- tab->interp = TAG(interp);
- tab->project_and_emit_verts = TAG(project_and_emit_verts);
-}
-
-#undef TYPE
-#undef TAG
-#undef STRIDE
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_fastpath.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_fastpath.c
deleted file mode 100644
index 1ff701435..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_fastpath.c
+++ /dev/null
@@ -1,542 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_fastpath.c,v 1.1 2001/01/08 01:07:27 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keithw@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "radeon_state.h"
-#include "radeon_vb.h"
-#include "radeon_pipeline.h"
-#include "radeon_ioctl.h"
-#include "radeon_tris.h"
-
-#include "mmath.h"
-#include "cva.h"
-#include "vertices.h"
-
-
-struct radeon_fast_tab {
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
- void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
-};
-
-#define POINT(x) radeon_draw_point( rmesa, &vert[x], psize )
-#define LINE(x,y) radeon_draw_line( rmesa, &vert[x], &vert[y], lwidth )
-#define TRI(x,y,z) radeon_draw_triangle( rmesa, &vert[x], &vert[y], &vert[z] )
-
-
-/* Direct, and no clipping required. The clip funcs have not been
- * written yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for ( e = start ; e < count ; e++ ) \
- POINT( elt[e] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if ( parity ) { \
- GLuint tmp = e2; \
- e2 = e1; \
- e1 = tmp; \
- } \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI( e3, e2, e ); \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define LOCAL_VARS \
- radeonVertexPtr vert = RADEON_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
- const GLfloat lwidth = ctx->Line.Width; \
- const GLfloat psize = ctx->Point.Size; \
- (void) lwidth; (void) psize; (void) vert;
-
-#define TAG(x) radeon_##x##_smooth_indirect
-#include "render_tmp.h"
-
-
-
-#define NEGATIVE( f ) (f < 0)
-#define DIFFERENT_SIGNS( a, b ) ((a * b) < 0)
-#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
-
-
-#define INTERP_RGBA( t, out, a, b ) \
-do { \
- int i; \
- for ( i = 0 ; i < 4 ; i++ ) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR( a[i] ); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR( b[i] ); \
- GLfloat fo = LINTERP( t, fa, fb ); \
- FLOAT_COLOR_TO_UBYTE_COLOR( out[i], fo ); \
- } \
-} while (0)
-
-
-#define CLIP( SGN, V, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- inlist[0] = vlist1; \
- for ( i = n = 0 ; i < nr ; i++ ) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t, *in, *out; \
- \
- if ( NEGATIVE( dpI ) ) { \
- t = dpI / (dpI - dpJ); \
- in = I; \
- out = J; \
- } else { \
- t = dpJ / (dpJ - dpI); \
- in = J; \
- out = I; \
- } \
- \
- interp( t, O, in, out ); \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if ( !NEGATIVE( dpI ) ) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if ( n < 3 ) return; \
- } \
-} while (0)
-
-#define LINE_CLIP( x, y, z, w, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLfloat dpI = DOT4V( I, x, y, z, w); \
- GLfloat dpJ = DOT4V( J, x, y, z, w); \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- \
- interp( t, O, I, J ); \
- \
- clipmask[next_vert] = 0; \
- \
- if ( NEGATIVE( dpI ) ) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; \
- elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; \
- elts[1] = next_vert++; \
- } \
- } else if ( NEGATIVE( dpI ) ) return; \
- } \
-} while (0)
-
-
-static __inline void radeon_tri_clip( GLuint **p_elts,
- radeonVertexPtr verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- radeon_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint in = 0;
- GLuint n = 3;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP( -, 0, CLIP_RIGHT_BIT );
- CLIP( +, 0, CLIP_LEFT_BIT );
- CLIP( -, 1, CLIP_TOP_BIT );
- CLIP( +, 1, CLIP_BOTTOM_BIT );
- CLIP( -, 2, CLIP_FAR_BIT );
- CLIP( +, 2, CLIP_NEAR_BIT );
-
- /* Convert the planar polygon to a list of triangles */
- out = inlist[in];
-
- for ( i = 2 ; i < n ; i++ ) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static __inline void radeon_line_clip( GLuint **p_elts,
- radeonVertexPtr verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- radeon_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP( 1, 0, 0, -1, CLIP_LEFT_BIT );
- LINE_CLIP( -1, 0, 0, 1, CLIP_RIGHT_BIT );
- LINE_CLIP( 0, 1, 0, -1, CLIP_TOP_BIT );
- LINE_CLIP( 0, -1, 0, 1, CLIP_BOTTOM_BIT );
- LINE_CLIP( 0, 0, 1, -1, CLIP_FAR_BIT );
- LINE_CLIP( 0, 0, -1, 1, CLIP_NEAR_BIT );
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-
-#define CLIP_POINT( e ) \
-do { \
- if ( mask[e] ) *out++ = e; \
-} while (0)
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out += 2; \
- if ( ormask ) { \
- out-=2; \
- if ( !(mask[e0] & mask[e1]) ) { \
- radeon_line_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if ( ormask ) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0]) ) { \
- radeon_tri_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-#define LOCAL_VARS \
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx); \
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB); \
- GLuint *elt = VB->EltPtr->data; \
- radeonVertexPtr verts = rvb->verts; \
- GLuint next_vert = rvb->last_vert; \
- GLuint *out = rvb->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
- radeon_interp_func interp = rmesa->interp; \
- (void) interp; (void) verts;
-
-#define POSTFIX \
- rvb->clipped_elements.count = out - rvb->clipped_elements.data; \
- rvb->last_vert = next_vert;
-
-
-#define INIT( x )
-
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint i; \
- for ( i = start; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i0 ) \
-do { \
- CLIP_LINE( elt[i1], elt[i0] ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
-do { \
- CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] ); \
-} while (0)
-
-#define TAG(x) radeon_##x##_clip_elt
-#include "render_tmp.h"
-
-
-
-/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_UBYTE_COLOR 4
-#define CLIP_UBYTE_R 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_B 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define TYPE (0)
-#define TAG(x) x
-#include "radeon_fasttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "radeon_fasttmp.h"
-
-#define TYPE (RADEON_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "radeon_fasttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT | RADEON_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "radeon_fasttmp.h"
-
-#define TYPE (RADEON_RGBA_BIT | RADEON_TEX0_BIT | RADEON_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "radeon_fasttmp.h"
-
-/* This one *could* get away with sneaking TEX1 into the color and
- * specular slots, thus fitting inside a cache line. Would be even
- * better to switch to a smaller vertex.
- */
-#define TYPE (RADEON_TEX0_BIT | RADEON_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "radeon_fasttmp.h"
-
-
-
-static void radeon_render_elements_direct( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = radeon_render_tab_smooth_indirect[prim];
- GLuint p = 0;
-
- if ( rmesa->new_state )
- radeonDDUpdateHWState( ctx );
-
- do {
- func( VB, 0, nr, 0 );
- } while ( ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ) );
-}
-
-/* GH: These should go away altogether on the Radeon. We should disable
- * the viewport mapping entirely in Mesa and let the hardware do it in
- * all cases.
- */
-static void radeon_project_vertices( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB);
- GLfloat *m = rmesa->tmp_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY];
- m[MAT_SZ] = mat->m[MAT_SZ];
- m[MAT_TZ] = mat->m[MAT_TZ];
-
- gl_project_v16( rvb->verts[VB->CopyStart].f,
- rvb->verts[rvb->last_vert].f,
- m,
- 16 * 4 );
-}
-
-static void radeon_project_clipped_vertices( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB);
- GLfloat *m = rmesa->tmp_matrix;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX];
- m[MAT_SY] = -mat->m[MAT_SY];
- m[MAT_TY] = -mat->m[MAT_TY];
- m[MAT_SZ] = mat->m[MAT_SZ];
- m[MAT_TZ] = mat->m[MAT_TZ];
-
- gl_project_clipped_v16( rvb->verts[VB->CopyStart].f,
- rvb->verts[rvb->last_vert].f,
- m,
- 16 * 4,
- VB->ClipMask + VB->CopyStart );
-}
-
-static struct radeon_fast_tab radeonFastTab[RADEON_MAX_SETUPFUNC];
-
-void radeonDDFastPathInit( void )
-{
- radeon_render_init_clip_elt();
- radeon_render_init_smooth_indirect();
-
- radeon_init_fastpath( &radeonFastTab[0] );
- radeon_init_fastpath_RGBA( &radeonFastTab[RADEON_RGBA_BIT] );
- radeon_init_fastpath_TEX0( &radeonFastTab[RADEON_TEX0_BIT] );
- radeon_init_fastpath_RGBA_TEX0( &radeonFastTab[(RADEON_RGBA_BIT |
- RADEON_TEX0_BIT)] );
- radeon_init_fastpath_TEX0_TEX1( &radeonFastTab[(RADEON_TEX0_BIT |
- RADEON_TEX1_BIT)] );
- radeon_init_fastpath_RGBA_TEX0_TEX1( &radeonFastTab[(RADEON_RGBA_BIT |
- RADEON_TEX0_BIT |
- RADEON_TEX1_BIT)] );
-}
-
-#define VALID_SETUP (RADEON_RGBA_BIT | RADEON_TEX0_BIT | RADEON_TEX1_BIT)
-
-void radeonDDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
- struct radeon_fast_tab *tab =
- &radeonFastTab[rmesa->SetupIndex & VALID_SETUP];
- GLuint do_cliptest = 1;
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- if ( ( gl_reduce_prim[prim] == GL_TRIANGLES ) &&
- ( VB->Count < (RADEON_BUFFER_SIZE / (10 * sizeof(GLuint))) ) &&
- ( ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL |
- MAT_FLAG_PERSPECTIVE) ) )
- {
- radeonDDEltPath( VB );
- return;
- }
-
- /* Reserve enough space for the pathological case */
- if ( VB->EltPtr->count * 12 > RADEON_DRIVER_DATA(VB)->size ) {
- radeonDDResizeVB( VB, VB->EltPtr->count * 12 );
- do_cliptest = 1;
- }
-
- tab->build_vertices( VB, do_cliptest ); /* object->clip space */
-
- if ( rmesa->new_state )
- radeonDDUpdateHWState( ctx );
-
- if ( VB->ClipOrMask ) {
- if ( !VB->ClipAndMask ) {
- render_func *clip = radeon_render_tab_clip_elt;
-
- rmesa->interp = tab->interp;
-
- clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(RADEON_DRIVER_DATA(VB)->clipped_elements);
-
- radeon_project_clipped_vertices( VB ); /* clip->device space */
- radeon_render_elements_direct( VB ); /* render using new list */
- }
- } else {
- radeon_project_vertices( VB ); /* clip->device space */
- radeon_render_elements_direct( VB ); /* render using orig list */
- }
-
- /* This indicates that there is no cached data to reuse */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_fasttmp.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_fasttmp.h
deleted file mode 100644
index dc444aa8a..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_fasttmp.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_fasttmp.h,v 1.1 2001/01/08 01:07:27 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keithw@valinux.com>
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-/* The first part of setup is applied to all vertices, clipped or
- * unclipped. This data w!ill be used for clipping, and then all
- * vertices with a zero clipmask will be projected to device space.
- *
- * This could be split into several loops, but - it seems that the
- * large stride of the fxVertices makes cache issues the big
- * performance factor, and that multiple loops mean multiple cache
- * misses....
- */
-static void TAG(radeon_setup_full)( struct vertex_buffer *VB,
- GLuint do_cliptest )
-{
- GLcontext *ctx = VB->ctx;
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB);
- const GLfloat *m = ctx->ModelProjectMatrix.m;
- GLuint start = VB->CopyStart;
- GLuint count = VB->Count;
-
- gl_xform_points3_v16_general( rvb->verts[start].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count - start );
-
- if ( do_cliptest ) {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16( rvb->verts[start].f,
- rvb->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask + start );
- }
-
- /* These branches are all resolved at compile time. Hopefully all
- * the pointers are valid addresses even when not enabled.
- */
- if ( TYPE ) {
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[0]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[1]->start;
-
- GLuint color_stride = VB->ColorPtr->stride;
- GLuint tex0_stride = VB->TexCoordPtr[0]->stride;
- GLuint tex1_stride = VB->TexCoordPtr[1]->stride;
-
- GLfloat *f = rvb->verts[start].f;
- GLfloat *end = f + (16 * (count - start));
-
- while ( f != end ) {
- if ( TYPE & RADEON_RGBA_BIT ) {
-#if defined (USE_X86_ASM)
- /* GH: Finally! Some damned hardware manufacturer uses
- * little-endian RGBA for vertex color...
- */
- __asm__ ( "movl (%%ecx), %%eax \n"
- "movl %%eax, 16(%%edi) \n"
- :
- : "c" (color), "D" (f)
- : "%eax" );
-#else
- *(GLuint *)(f+CLIP_UBYTE_COLOR) = *(GLuint *)color;
-#endif
- }
- if ( TYPE & RADEON_TEX0_BIT ) {
-#if defined (USE_X86_ASM)
- __asm__ ( "movl (%%ecx), %%eax \n"
- "movl %%eax, 24(%%edi) \n"
- "movl 4(%%ecx), %%eax \n"
- "movl %%eax, 28(%%edi)"
- :
- : "c" (tex0_data), "D" (f)
- : "%eax" );
-#else
- *(GLuint *)(f+CLIP_S0) = *(GLuint *)tex0_data;
- *(GLuint *)(f+CLIP_T0) = *(GLuint *)(tex0_data+1);
-#endif
- }
- if ( TYPE & RADEON_TEX1_BIT ) {
- /* Hits a second cache line.
- */
-#if defined (USE_X86_ASM)
- __asm__ ( "movl (%%esi), %%eax \n"
- "movl %%eax, 32(%%edi) \n"
- "movl 4(%%esi), %%eax \n"
- "movl %%eax, 36(%%edi)"
- :
- : "S" (tex1_data), "D" (f)
- : "%eax" );
-#else
- *(GLuint *)(f+CLIP_S1) = *(GLuint *)tex1_data;
- *(GLuint *)(f+CLIP_T1) = *(GLuint *)(tex1_data+1);
-#endif
- }
- if ( TYPE & RADEON_RGBA_BIT ) color += color_stride;
- if ( TYPE & RADEON_TEX0_BIT ) STRIDE_F( tex0_data, tex0_stride );
- if ( TYPE & RADEON_TEX1_BIT ) STRIDE_F( tex1_data, tex1_stride );
- f += 16;
- }
- }
-
- rvb->clipped_elements.count = start;
- rvb->last_vert = count;
-}
-
-
-/* Changed to just put the interp func instead of the whole clip
- * routine into the header. Less code and better chance of doing some
- * of this stuff in assembly.
- */
-static void TAG(radeon_interp_vert)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP( t, I[0], J[0] );
- O[1] = LINTERP( t, I[1], J[1] );
- O[2] = LINTERP( t, I[2], J[2] );
- O[3] = LINTERP( t, I[3], J[3] );
-
- if ( TYPE & RADEON_RGBA_BIT ) {
- INTERP_RGBA( t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])) );
- }
-
- if ( TYPE & RADEON_TEX0_BIT ) {
- O[6] = LINTERP( t, I[6], J[6] );
- O[7] = LINTERP( t, I[7], J[7] );
- }
-
- if ( TYPE & RADEON_TEX1_BIT ) {
- O[8] = LINTERP( t, I[8], J[8] );
- O[9] = LINTERP( t, I[9], J[9] );
- }
-}
-
-
-static void TAG(radeon_init_fastpath)( struct radeon_fast_tab *tab )
-{
- tab->build_vertices = TAG(radeon_setup_full);
- tab->interp = TAG(radeon_interp_vert);
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c
index 0889cc9d2..f621cb826 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c,v 1.4 2001/04/10 16:07:53 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -39,9 +39,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_ioctl.h"
#include "mem.h"
+#include "macros.h"
+#include "swrast/swrast.h"
-#define RADEON_TIMEOUT 2048
-#define USE_IN_MEMORY_SCRATCH_REGS 0
+#define RADEON_TIMEOUT 512
/* =============================================================
@@ -52,7 +53,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa )
{
- int fd = rmesa->radeonScreen->driScreen->fd;
+ int fd = rmesa->dri.fd;
int index = 0;
int size = 0;
drmDMAReq dma;
@@ -60,7 +61,7 @@ drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa )
int to = 0;
int ret;
- dma.context = rmesa->hHWContext;
+ dma.context = rmesa->dri.hwContext;
dma.send_count = 0;
dma.send_list = NULL;
dma.send_sizes = NULL;
@@ -77,10 +78,8 @@ drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa )
if ( ret == 0 ) {
buf = &rmesa->radeonScreen->buffers->list[index];
buf->used = 0;
-#if ENABLE_PERF_BOXES
/* Bump the performance counter */
rmesa->c_vertexBuffers++;
-#endif
return buf;
}
}
@@ -95,6 +94,7 @@ drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa )
return buf;
}
+
static GLboolean intersect_rect( XF86DRIClipRectPtr out,
XF86DRIClipRectPtr a,
XF86DRIClipRectPtr b )
@@ -109,156 +109,254 @@ static GLboolean intersect_rect( XF86DRIClipRectPtr out,
return GL_TRUE;
}
-void radeonFlushVerticesLocked( radeonContextPtr rmesa )
+static void emit_state( radeonContextPtr rmesa,
+ drmRadeonState *dest,
+ int dirty )
{
- XF86DRIClipRectPtr pbox = rmesa->pClipRects;
- int nbox = rmesa->numClipRects;
- drmBufPtr buffer = rmesa->vert_buf;
- int count = rmesa->num_verts;
- int prim = RADEON_TRIANGLES;
- int fd = rmesa->driScreen->fd;
- int i;
+ struct radeon_state *state = &rmesa->state;
- rmesa->vert_buf = NULL;
- rmesa->num_verts = 0;
+ if ( dirty & RADEON_UPLOAD_CONTEXT )
+ memcpy( &dest->context, &state->hw.context, sizeof(dest->context) );
- if ( !buffer )
- return;
+ if ( dirty & RADEON_UPLOAD_VERTFMT )
+ memcpy( &dest->vertex, &state->hw.vertex, sizeof(dest->vertex) );
- if ( rmesa->dirty & ~RADEON_UPLOAD_CLIPRECTS )
- radeonEmitHwStateLocked( rmesa );
+ if ( dirty & RADEON_UPLOAD_LINE )
+ memcpy( &dest->line, &state->hw.line, sizeof(dest->line) );
- if ( !nbox )
- count = 0;
+ if ( dirty & RADEON_UPLOAD_BUMPMAP )
+ memcpy( &dest->bumpmap, &state->hw.bumpmap, sizeof(dest->bumpmap) );
- if ( nbox >= RADEON_NR_SAREA_CLIPRECTS )
- rmesa->dirty |= RADEON_UPLOAD_CLIPRECTS;
+ if ( dirty & RADEON_UPLOAD_MASKS )
+ memcpy( &dest->mask, &state->hw.mask, sizeof(dest->mask) );
- if ( !count || !(rmesa->dirty & RADEON_UPLOAD_CLIPRECTS) )
- {
- if ( nbox == 1 ) {
- rmesa->sarea->nbox = 0;
- } else {
- rmesa->sarea->nbox = nbox;
- }
+ if ( dirty & RADEON_UPLOAD_VIEWPORT )
+ memcpy( &dest->viewport, &state->hw.viewport, sizeof(dest->viewport) );
- drmRadeonFlushVertexBuffer( fd, prim, buffer->idx, count, 1 );
+ if ( dirty & RADEON_UPLOAD_SETUP ) {
+ memcpy( &dest->setup1, &state->hw.setup1, sizeof(dest->setup1) );
+ memcpy( &dest->setup2, &state->hw.setup2, sizeof(dest->setup2) );
}
- else
- {
- for ( i = 0 ; i < nbox ; ) {
- int nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, nbox );
- XF86DRIClipRectPtr b = rmesa->sarea->boxes;
- int discard = 0;
- if ( rmesa->scissor ) {
- rmesa->sarea->nbox = 0;
+ if ( dirty & RADEON_UPLOAD_MISC )
+ memcpy( &dest->misc, &state->hw.misc, sizeof(dest->misc) );
- for ( ; i < nr ; i++ ) {
- *b = pbox[i];
- if ( intersect_rect( b, b, &rmesa->scissor_rect ) ) {
- rmesa->sarea->nbox++;
- b++;
- }
- }
+ if ( dirty & RADEON_UPLOAD_ZBIAS )
+ memcpy( &dest->zbias, &state->hw.zbias, sizeof(dest->zbias) );
- /* Culled?
- */
- if ( !rmesa->sarea->nbox ) {
- if ( nr < nbox ) continue;
- count = 0;
- }
- } else {
- rmesa->sarea->nbox = nr - i;
- for ( ; i < nr ; i++) {
- *b++ = pbox[i];
- }
- }
+ /* Assemble the texture state, combining the texture object and
+ * texture environment state into the hardware texture unit state.
+ */
+ if ( dirty & RADEON_UPLOAD_TEX0 ) {
+ radeonTexObjPtr t0 = state->texture.unit[0].texobj;
+
+ dest->texture[0].pp_txfilter = t0->pp_txfilter | state->hw.texture[0].pp_txfilter;
+ dest->texture[0].pp_txformat = t0->pp_txformat | RADEON_TXFORMAT_ST_ROUTE_STQ0;
+ dest->texture[0].pp_txoffset = t0->pp_txoffset;
+ dest->texture[0].pp_border_color = t0->pp_border_color;
+ dest->texture[0].pp_txcblend = state->hw.texture[0].pp_txcblend;
+ dest->texture[0].pp_txablend = state->hw.texture[0].pp_txablend;
+ dest->texture[0].pp_tfactor = state->hw.texture[0].pp_tfactor;
+ }
- /* Finished with the buffer?
- */
- if ( nr == nbox ) {
- discard = 1;
- }
+ if ( dirty & RADEON_UPLOAD_TEX1 ) {
+ radeonTexObjPtr t1 = state->texture.unit[1].texobj;
- rmesa->sarea->dirty |= RADEON_UPLOAD_CLIPRECTS;
- drmRadeonFlushVertexBuffer( fd, prim, buffer->idx, count, discard );
- }
+ dest->texture[1].pp_txfilter = t1->pp_txfilter | state->hw.texture[1].pp_txfilter;
+ dest->texture[1].pp_txformat = t1->pp_txformat | RADEON_TXFORMAT_ST_ROUTE_STQ1;
+ dest->texture[1].pp_txoffset = t1->pp_txoffset;
+ dest->texture[1].pp_border_color = t1->pp_border_color;
+ dest->texture[1].pp_txcblend = state->hw.texture[1].pp_txcblend;
+ dest->texture[1].pp_txablend = state->hw.texture[1].pp_txablend;
+ dest->texture[1].pp_tfactor = state->hw.texture[1].pp_tfactor;
}
+}
+
+
+static void print_values( const char *name, const void *vals, int sz )
+{
+ const int *ivals = (const int *)vals;
+ int i;
- rmesa->dirty &= ~RADEON_UPLOAD_CLIPRECTS;
+ for (i = 0; i < sz/4 ; i++)
+ fprintf(stderr, "%s %d: 0x%x\n", name, i, ivals[i]);
}
+static void print_state( drmRadeonState *state )
+{
+ int dirty = state->dirty;
+ if ( dirty & RADEON_UPLOAD_CONTEXT )
+ print_values( "CONTEXT", &state->context, sizeof(state->context) );
-/* ================================================================
- * Indexed vertex buffer handling
- */
+ if ( dirty & RADEON_UPLOAD_VERTFMT )
+ print_values( "VERTFMT", &state->vertex, sizeof(state->vertex) );
+
+ if ( dirty & RADEON_UPLOAD_LINE )
+ print_values( "LINE", &state->line, sizeof(state->line) );
+
+ if ( dirty & RADEON_UPLOAD_BUMPMAP )
+ print_values( "BUMPMAP", &state->bumpmap, sizeof(state->bumpmap) );
+
+ if ( dirty & RADEON_UPLOAD_MASKS )
+ print_values( "MASKS", &state->mask, sizeof(state->mask) );
-void radeonGetEltBufLocked( radeonContextPtr rmesa )
+ if ( dirty & RADEON_UPLOAD_VIEWPORT )
+ print_values( "VIEWPORT", &state->viewport, sizeof(state->viewport) );
+
+ if ( dirty & RADEON_UPLOAD_SETUP ) {
+ print_values( "SETUP", &state->setup1, sizeof(state->setup1) );
+ print_values( "SETUP2", &state->setup2, sizeof(state->setup2) );
+ }
+
+ if ( dirty & RADEON_UPLOAD_MISC )
+ print_values( "MISC", &state->misc, sizeof(state->misc) );
+
+ if ( dirty & RADEON_UPLOAD_ZBIAS )
+ print_values( "ZBIAS", &state->zbias, sizeof(state->zbias) );
+
+ if ( dirty & RADEON_UPLOAD_TEX0 )
+ print_values( "TEX0", &state->texture[0], sizeof(state->texture[0]) );
+
+ if ( dirty & RADEON_UPLOAD_TEX1 )
+ print_values( "TEX1", &state->texture[1], sizeof(state->texture[1]) );
+}
+
+
+static void emit_prim( radeonContextPtr rmesa )
{
- rmesa->elt_buf = radeonGetBufferLocked( rmesa );
+ GLuint prim = rmesa->store.primnr++;
+ GLuint dirty = rmesa->state.hw.dirty;
+
+ rmesa->store.prim[prim].prim = rmesa->hw_primitive;
+ rmesa->store.prim[prim].start = rmesa->dma.last;
+ rmesa->store.prim[prim].finish = rmesa->dma.low;
+ rmesa->store.prim[prim].vc_format = rmesa->vertex_format;
+
+ if (rmesa->hw_primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND)
+ rmesa->store.prim[prim].numverts = rmesa->dma.offset / 64;
+ else
+ rmesa->store.prim[prim].numverts = rmesa->num_verts;
+
+ rmesa->num_verts = 0;
+ rmesa->dma.last = rmesa->dma.low;
+
+
+
+
+ /* Make sure we keep a copy of the initial state.
+ */
+ if (prim == 0) {
+ dirty = RADEON_UPLOAD_CONTEXT_ALL;
+ if (rmesa->state.texture.unit[0].texobj) dirty |= RADEON_UPLOAD_TEX0;
+ if (rmesa->state.texture.unit[1].texobj) dirty |= RADEON_UPLOAD_TEX1;
+ }
+
+
+ if (dirty)
+ {
+ GLuint state = rmesa->store.statenr++;
+
+ emit_state( rmesa, &rmesa->store.state[state], dirty );
+/* fprintf(stderr, "emit state %d, dirty %x rmesa->dirty %x\n", */
+/* state, dirty, rmesa->state.hw.dirty ); */
+ rmesa->store.state[state].dirty = rmesa->state.hw.dirty; /* override */
+ rmesa->store.texture[0][state] = rmesa->state.texture.unit[0].texobj;
+ rmesa->store.texture[1][state] = rmesa->state.texture.unit[1].texobj;
+ rmesa->state.hw.dirty = 0;
+/* print_state( &rmesa->store.state[state] ); */
+ }
+
+ rmesa->store.prim[prim].stateidx = rmesa->store.statenr - 1;
+
+/* fprintf(stderr, "emit_prim %d hwprim 0x%x vfmt 0x%x %d..%d %d verts stateidx %x\n", */
+/* prim, */
+/* rmesa->store.prim[prim].prim, */
+/* rmesa->store.prim[prim].vc_format, */
+/* rmesa->store.prim[prim].start, */
+/* rmesa->store.prim[prim].finish, */
+/* rmesa->store.prim[prim].numverts, */
+/* rmesa->store.prim[prim].stateidx); */
}
-void radeonFireEltsLocked( radeonContextPtr rmesa,
- GLuint start, GLuint end,
- GLuint discard )
+
+void radeonFlushPrimsLocked( radeonContextPtr rmesa )
{
- XF86DRIClipRectPtr pbox = rmesa->pClipRects;
+ XF86DRIClipRectPtr pbox = (XF86DRIClipRectPtr)rmesa->pClipRects;
int nbox = rmesa->numClipRects;
- drmBufPtr buffer = rmesa->elt_buf;
- int prim = RADEON_TRIANGLES;
- int fd = rmesa->driScreen->fd;
+ drmBufPtr buffer = rmesa->dma.buffer;
+ RADEONSAREAPrivPtr sarea = rmesa->sarea;
+ int fd = rmesa->dri.fd;
+ int discard_sz = rmesa->dma.high - rmesa->dma.low < 4096;
+ int discard = (rmesa->dma.retained != rmesa->dma.buffer &&
+ discard_sz);
int i;
- if ( !buffer )
- return;
-
- if ( rmesa->dirty & ~RADEON_UPLOAD_CLIPRECTS )
- radeonEmitHwStateLocked( rmesa );
-
if ( !nbox )
- end = start;
+ rmesa->store.primnr = 0;
+ else if ( nbox >= RADEON_NR_SAREA_CLIPRECTS ) {
+ rmesa->upload_cliprects = 1;
+ for ( i = 0 ; i < rmesa->store.statenr ; i++ )
+ rmesa->store.state[0].dirty |= rmesa->store.state[i].dirty;
+ if ( !rmesa->store.texture[0][0] )
+ rmesa->store.state[0].dirty &= ~RADEON_UPLOAD_TEX0;
+ if ( !rmesa->store.texture[1][0] )
+ rmesa->store.state[0].dirty &= ~RADEON_UPLOAD_TEX1;
+ }
+
- if ( nbox >= RADEON_NR_SAREA_CLIPRECTS )
- rmesa->dirty |= RADEON_UPLOAD_CLIPRECTS;
+/* fprintf(stderr, "%s: boxes: %d prims: %d states: %d vertexstore: 0x%x\n", */
+/* __FUNCTION__, */
+/* sarea->nbox, rmesa->store.primnr, rmesa->store.statenr, */
+/* rmesa->dma.low - rmesa->store.prim[0].start); */
- if ( start == end || !(rmesa->dirty & RADEON_UPLOAD_CLIPRECTS) )
+ if ( !rmesa->upload_cliprects || !rmesa->store.primnr )
{
if ( nbox == 1 ) {
- rmesa->sarea->nbox = 0;
+ sarea->nbox = 0;
} else {
- rmesa->sarea->nbox = nbox;
+ sarea->nbox = nbox;
}
- drmRadeonFlushIndices( fd, prim, buffer->idx, start, end, discard );
+/* fprintf(stderr, "case a %d boxes %d prims %d states\n", */
+/* sarea->nbox, rmesa->store.primnr, rmesa->store.statenr); */
+ if (discard || rmesa->store.primnr)
+ drmRadeonFlushPrims( fd,
+ buffer->idx,
+ discard,
+ rmesa->store.statenr,
+ rmesa->store.state,
+ rmesa->store.primnr,
+ rmesa->store.prim);
}
else
{
for ( i = 0 ; i < nbox ; ) {
int nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, nbox );
- XF86DRIClipRectPtr b = rmesa->sarea->boxes;
- int d = 0;
+ XF86DRIClipRectPtr b = sarea->boxes;
+ int discard_now = 0;
- if ( rmesa->scissor ) {
- rmesa->sarea->nbox = 0;
+ /* TODO: Precalculate this intersection:
+ */
+ if ( rmesa->state.scissor.enabled ) {
+ sarea->nbox = 0;
for ( ; i < nr ; i++ ) {
*b = pbox[i];
- if ( intersect_rect( b, b, &rmesa->scissor_rect ) ) {
- rmesa->sarea->nbox++;
+ if ( intersect_rect( b, b, &rmesa->state.scissor.rect ) ) {
+ sarea->nbox++;
b++;
}
}
/* Culled?
*/
- if ( !rmesa->sarea->nbox ) {
+ if ( !sarea->nbox ) {
if ( nr < nbox ) continue;
- end = start;
+ rmesa->store.primnr = 0;
}
} else {
- rmesa->sarea->nbox = nr - i;
+ sarea->nbox = nr - i;
for ( ; i < nr ; i++) {
*b++ = pbox[i];
}
@@ -267,49 +365,88 @@ void radeonFireEltsLocked( radeonContextPtr rmesa,
/* Finished with the buffer?
*/
if ( nr == nbox ) {
- d = discard;
+ discard_now = discard;
}
- rmesa->sarea->dirty |= RADEON_UPLOAD_CLIPRECTS;
- drmRadeonFlushIndices( fd, prim, buffer->idx, start, end, d );
+/* fprintf(stderr, "case a %d boxes %d prims %d states, discard: %d\n", */
+/* sarea->nbox, rmesa->store.primnr, rmesa->store.statenr, discard); */
+ drmRadeonFlushPrims( fd,
+ buffer->idx,
+ discard_now,
+ rmesa->store.statenr,
+ rmesa->store.state,
+ rmesa->store.primnr,
+ rmesa->store.prim);
}
}
- rmesa->dirty &= ~RADEON_UPLOAD_CLIPRECTS;
+ if (discard_sz) {
+ rmesa->dma.buffer = 0;
+ rmesa->dma.address = 0;
+ rmesa->dma.low = 0;
+ rmesa->dma.high = 0;
+ }
+ else {
+ rmesa->dma.low = (rmesa->dma.low + 0x7) & ~0x7; /* alignment */
+ }
+ rmesa->dma.last = rmesa->dma.low;
+ rmesa->store.primnr = 0;
+ rmesa->store.statenr = 0;
+ rmesa->upload_cliprects = 0;
+ rmesa->num_verts = 0;
}
-void radeonFlushEltsLocked( radeonContextPtr rmesa )
+void radeonFlushPrimsGetBuffer( radeonContextPtr rmesa )
{
- if ( rmesa->first_elt != rmesa->next_elt ) {
- radeonFireEltsLocked( rmesa,
- ((char *)rmesa->first_elt -
- (char *)rmesa->elt_buf->address),
- ((char *)rmesa->next_elt -
- (char *)rmesa->elt_buf->address),
- 0 );
+ if (rmesa->dma.low != rmesa->dma.last)
+ emit_prim( rmesa );
+
+ LOCK_HARDWARE(rmesa);
- ALIGN_NEXT_ELT( rmesa );
- rmesa->first_elt = rmesa->next_elt;
+ if (rmesa->dma.buffer) {
+ rmesa->dma.low = rmesa->dma.high; /* force discard */
+ rmesa->dma.last = rmesa->dma.low;
+ radeonFlushPrimsLocked( rmesa );
}
+
+ rmesa->dma.buffer = radeonGetBufferLocked( rmesa );
+ rmesa->dma.high = rmesa->dma.buffer->total;
+ rmesa->dma.address = (GLubyte *)rmesa->dma.buffer->address;
+ rmesa->dma.low = 0;
+ rmesa->num_verts = 0;
+ rmesa->dma.last = rmesa->dma.low;
+ UNLOCK_HARDWARE(rmesa);
}
-void radeonReleaseBufLocked( radeonContextPtr rmesa, drmBufPtr buffer )
-{
- int fd = rmesa->driScreen->fd;
- if ( !buffer )
- return;
+void radeonFlushPrims( radeonContextPtr rmesa )
+{
+ if (rmesa->dma.buffer) {
+ if (rmesa->dma.low != rmesa->dma.last)
+ emit_prim( rmesa );
- drmRadeonFlushVertexBuffer( fd, RADEON_TRIANGLES, buffer->idx, 0, 1 );
+ LOCK_HARDWARE( rmesa );
+ radeonFlushPrimsLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ }
}
-
-/* Allocate some space in the current vertex buffer. If the current
- * buffer is full, flush it and grab another one.
- */
-CARD32 *radeonAllocVertices( radeonContextPtr rmesa, GLuint count )
+void radeonEmitPrim( radeonContextPtr rmesa )
{
- return radeonAllocVerticesInline( rmesa, count );
+ ASSERT(rmesa->dma.buffer);
+ emit_prim( rmesa );
+
+ if (rmesa->store.primnr == RADEON_MAX_PRIMS ||
+ rmesa->store.statenr == RADEON_MAX_STATES) {
+ LOCK_HARDWARE(rmesa);
+ radeonFlushPrimsLocked(rmesa);
+ UNLOCK_HARDWARE(rmesa);
+ }
+ else {
+ rmesa->dma.low = (rmesa->dma.low + 0x7) & ~0x7; /* alignment */
+ rmesa->dma.last = rmesa->dma.low;
+ rmesa->num_verts = 0;
+ }
}
@@ -324,7 +461,7 @@ void radeonFireBlitLocked( radeonContextPtr rmesa, drmBufPtr buffer,
#if 0
GLint ret;
- ret = drmRadeonTextureBlit( rmesa->driFd, buffer->idx,
+ ret = drmRadeonTextureBlit( rmesa->dri.fd, buffer->idx,
offset, pitch, format,
x, y, width, height );
@@ -343,36 +480,6 @@ void radeonFireBlitLocked( radeonContextPtr rmesa, drmBufPtr buffer,
#define RADEON_MAX_OUTSTANDING 2
-/* Throttle the frame rate -- only allow one pending swap buffers
- * request at a time.
- * GH: We probably don't want a timeout here, as we can wait as
- * long as we want for a frame to complete. If it never does, then
- * the card has locked.
- */
-#if USE_IN_MEMORY_SCRATCH_REGS
-static int radeonWaitForFrameCompletion( radeonContextPtr rmesa )
-{
- RADEONSAREAPrivPtr sarea = rmesa->sarea;
- __volatile__ CARD32 *scratch = rmesa->radeonScreen->scratch;
- CARD32 frame;
- int wait = 0;
-
- while ( 1 ) {
- /* Read the frame counter from the in-memory copy of the scratch
- * register. Nifty, eh? Should significantly reduce the bus
- * traffic for SwapBuffers-limited apps (generally pretty trivial
- * ones, but anyway).
- */
- frame = scratch[0];
- if ( sarea->last_frame - frame <= RADEON_MAX_OUTSTANDING ) {
- break;
- }
- wait++;
- }
-
- return wait;
-}
-#else
static void delay( void ) {
/* Prevent an optimizing compiler from removing a spin loop */
}
@@ -386,14 +493,7 @@ static int radeonWaitForFrameCompletion( radeonContextPtr rmesa )
int i;
while ( 1 ) {
-#if defined(__alpha__)
- /* necessary to preserve the Alpha paradigm */
- /* NOTE: this will not work on SPARSE machines */
- mem_barrier();
- frame = *(volatile CARD32 *)(void *)(RADEONMMIO + RADEON_LAST_FRAME_REG);
-#else
frame = INREG( RADEON_LAST_FRAME_REG );
-#endif
if ( sarea->last_frame - frame <= RADEON_MAX_OUTSTANDING ) {
break;
}
@@ -406,25 +506,29 @@ static int radeonWaitForFrameCompletion( radeonContextPtr rmesa )
return wait;
}
-#endif
/* Copy the back color buffer to the front color buffer.
*/
-void radeonSwapBuffers( radeonContextPtr rmesa )
+void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
{
- GLint nbox;
- GLint i;
- GLint ret;
+ radeonContextPtr rmesa;
+ GLint nbox, i, ret;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, rmesa->glCtx );
}
- FLUSH_BATCH( rmesa );
+ RADEON_FIREVERTICES( rmesa );
LOCK_HARDWARE( rmesa );
- nbox = rmesa->numClipRects; /* must be in locked region */
+ nbox = rmesa->dri.drawable->numClipRects; /* must be in locked region */
/* Throttle the frame rate -- only allow one pending swap buffers
* request at a time.
@@ -435,19 +539,21 @@ void radeonSwapBuffers( radeonContextPtr rmesa )
rmesa->hardwareWentIdle = 0;
}
+ nbox = dPriv->numClipRects;
+
for ( i = 0 ; i < nbox ; ) {
GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
- XF86DRIClipRectPtr box = rmesa->pClipRects;
+ XF86DRIClipRectPtr box = rmesa->dri.drawable->pClipRects;
XF86DRIClipRectPtr b = rmesa->sarea->boxes;
GLint n = 0;
for ( ; i < nr ; i++ ) {
- *b++ = *(XF86DRIClipRectPtr)&box[i];
+ *b++ = box[i];
n++;
}
rmesa->sarea->nbox = n;
- ret = drmRadeonSwapBuffers( rmesa->driFd );
+ ret = drmRadeonSwapBuffers( rmesa->dri.fd );
if ( ret ) {
fprintf( stderr, "drmRadeonSwapBuffers: return = %d\n", ret );
@@ -458,27 +564,36 @@ void radeonSwapBuffers( radeonContextPtr rmesa )
UNLOCK_HARDWARE( rmesa );
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= (RADEON_UPLOAD_CONTEXT |
- RADEON_UPLOAD_MASKS |
- RADEON_UPLOAD_CLIPRECTS);
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT_ALL );
+ if ( rmesa->state.texture.unit[0].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ if ( rmesa->state.texture.unit[1].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
+
+
+ rmesa->upload_cliprects = 1;
-#if ENABLE_PERF_BOXES
/* Log the performance counters if necessary */
radeonPerformanceCounters( rmesa );
-#endif
}
-void radeonPageFlip( radeonContextPtr rmesa )
+void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
{
+ radeonContextPtr rmesa;
GLint ret;
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "\n%s( %p ): page=%d\n\n",
__FUNCTION__, rmesa->glCtx, rmesa->currentPage );
}
- FLUSH_BATCH( rmesa );
+ RADEON_FIREVERTICES( rmesa );
LOCK_HARDWARE( rmesa );
@@ -494,7 +609,7 @@ void radeonPageFlip( radeonContextPtr rmesa )
/* The kernel will have been initialized to perform page flipping
* on a swapbuffers ioctl.
*/
- ret = drmRadeonSwapBuffers( rmesa->driFd );
+ ret = drmRadeonSwapBuffers( rmesa->dri.fd );
UNLOCK_HARDWARE( rmesa );
@@ -504,54 +619,47 @@ void radeonPageFlip( radeonContextPtr rmesa )
}
if ( rmesa->currentPage == 0 ) {
- rmesa->drawOffset = rmesa->radeonScreen->frontOffset;
- rmesa->drawPitch = rmesa->radeonScreen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
rmesa->currentPage = 1;
} else {
- rmesa->drawOffset = rmesa->radeonScreen->backOffset;
- rmesa->drawPitch = rmesa->radeonScreen->backPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
rmesa->currentPage = 0;
}
- rmesa->setup.rb3d_coloroffset = rmesa->drawOffset;
- rmesa->setup.rb3d_colorpitch = rmesa->drawPitch;
-
- rmesa->new_state |= RADEON_NEW_WINDOW;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_coloroffset = rmesa->state.color.drawOffset;
+ rmesa->state.hw.context.rb3d_colorpitch = rmesa->state.color.drawPitch;
- /* FIXME: Do we need this anymore? */
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= (RADEON_UPLOAD_CONTEXT |
- RADEON_UPLOAD_MASKS |
- RADEON_UPLOAD_CLIPRECTS);
-
-#if ENABLE_PERF_BOXES
/* Log the performance counters if necessary */
radeonPerformanceCounters( rmesa );
-#endif
}
+void radeonPerformanceCounters( radeonContextPtr rmesa )
+{
+}
+
+void radeonPerformanceBoxesLocked( radeonContextPtr rmesa )
+{
+}
/* ================================================================
* Buffer clear
*/
#define RADEON_MAX_CLEARS 256
-static GLbitfield radeonDDClear( GLcontext *ctx, GLbitfield mask,
- GLboolean all,
- GLint cx, GLint cy, GLint cw, GLint ch )
+static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
RADEONSAREAPrivPtr sarea = rmesa->sarea;
-#if USE_IN_MEMORY_SCRATCH_REGS
- __volatile__ CARD32 *scratch = rmesa->radeonScreen->scratch;
-#else
unsigned char *RADEONMMIO = rmesa->radeonScreen->mmio.map;
-#endif
CARD32 clear;
GLuint flags = 0;
GLuint color_mask = 0;
- GLuint depth_mask = 0;
+/* GLuint depth_mask = 0; */
GLint ret, i;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
@@ -559,149 +667,137 @@ static GLbitfield radeonDDClear( GLcontext *ctx, GLbitfield mask,
__FUNCTION__, all, cx, cy, cw, ch );
}
- FLUSH_BATCH( rmesa );
-
- /* Update and emit any new state. We need to do this here to catch
- * changes to the masks.
- * FIXME: Just update the masks?
- */
- if ( rmesa->new_state )
- radeonDDUpdateHWState( ctx );
+ RADEON_FIREVERTICES( rmesa );
if ( mask & DD_FRONT_LEFT_BIT ) {
- flags |= DRM_RADEON_FRONT;
- color_mask = rmesa->setup.rb3d_planemask;
+ flags |= RADEON_FRONT;
+ color_mask = rmesa->state.hw.mask.rb3d_planemask;
mask &= ~DD_FRONT_LEFT_BIT;
}
if ( mask & DD_BACK_LEFT_BIT ) {
- flags |= DRM_RADEON_BACK;
- color_mask = rmesa->setup.rb3d_planemask;
+ flags |= RADEON_BACK;
+ color_mask = rmesa->state.hw.mask.rb3d_planemask;
mask &= ~DD_BACK_LEFT_BIT;
}
if ( mask & DD_DEPTH_BIT ) {
- if ( ctx->Depth.Mask ) {
- flags |= DRM_RADEON_DEPTH;
- depth_mask |= rmesa->DepthMask;
- }
+ if ( ctx->Depth.Mask ) flags |= RADEON_DEPTH; /* FIXME: ??? */
mask &= ~DD_DEPTH_BIT;
}
-#if 0
- /* FIXME: Add stencil support */
- if ( mask & DD_STENCIL_BIT ) {
- flags |= DRM_RADEON_DEPTH;
- depth_mask |= rmesa->StencilMask;
+
+ if ( (mask & DD_STENCIL_BIT) && rmesa->state.stencil.hwBuffer ) {
+ flags |= RADEON_STENCIL;
mask &= ~DD_STENCIL_BIT;
}
-#endif
-
- if ( !flags )
- return mask;
-
- /* Flip top to bottom */
- cx += dPriv->x;
- cy = dPriv->y + dPriv->h - cy - ch;
-
- LOCK_HARDWARE( rmesa );
- /* Throttle the number of clear ioctls we do.
- */
-#if USE_IN_MEMORY_SCRATCH_REGS
- while ( 1 ) {
- clear = scratch[2];
- if ( sarea->last_clear - clear <= RADEON_MAX_CLEARS ) {
- break;
- }
- }
-#else
- while ( 1 ) {
-#if defined(__alpha__)
- /* necessary to preserve the Alpha paradigm */
- /* NOTE: this will not work on SPARSE machines */
- mem_barrier();
- clear = *(volatile CARD32 *)(void *)(RADEONMMIO + RADEON_LAST_CLEAR_REG);
-#else
- clear = INREG( RADEON_LAST_CLEAR_REG );
-#endif
- if ( sarea->last_clear - clear <= RADEON_MAX_CLEARS ) {
- break;
- }
- /* Spin in place a bit so we aren't hammering the bus */
- for ( i = 0 ; i < 1024 ; i++ ) {
- delay();
- }
- }
-#endif
+ if ( flags ) {
+ /* Flip top to bottom */
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
- for ( i = 0 ; i < rmesa->numClipRects ; ) {
- GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, rmesa->numClipRects );
- XF86DRIClipRectPtr box = rmesa->pClipRects;
- XF86DRIClipRectPtr b = rmesa->sarea->boxes;
- GLint n = 0;
+ LOCK_HARDWARE( rmesa );
- if ( !all ) {
- for ( ; i < nr ; i++ ) {
- GLint x = box[i].x1;
- GLint y = box[i].y1;
- GLint w = box[i].x2 - x;
- GLint h = box[i].y2 - y;
-
- if ( x < cx ) w -= cx - x, x = cx;
- if ( y < cy ) h -= cy - y, y = cy;
- if ( x + w > cx + cw ) w = cx + cw - x;
- if ( y + h > cy + ch ) h = cy + ch - y;
- if ( w <= 0 ) continue;
- if ( h <= 0 ) continue;
-
- b->x1 = x;
- b->y1 = y;
- b->x2 = x + w;
- b->y2 = y + h;
- b++;
- n++;
+ /* Throttle the number of clear ioctls we do.
+ */
+ while ( 1 ) {
+ clear = INREG( RADEON_LAST_CLEAR_REG );
+ if ( sarea->last_clear - clear <= RADEON_MAX_CLEARS ) {
+ break;
}
- } else {
- for ( ; i < nr ; i++ ) {
- *b++ = *(XF86DRIClipRectPtr)&box[i];
- n++;
+ /* Spin in place a bit so we aren't hammering the bus */
+ for ( i = 0 ; i < 1024 ; i++ ) {
+ delay();
}
}
- rmesa->sarea->nbox = n;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_IOCTL ) {
- fprintf( stderr,
- "drmRadeonClear: flag 0x%x color %x depth %x nbox %d\n",
- flags,
- (GLuint)rmesa->ClearColor,
- (GLuint)rmesa->ClearDepth,
- rmesa->sarea->nbox );
+ /* Emit any new MASKS state. This ioctl uses the old
+ * sarea-based state mechanism, which is why I'm not using
+ * emit_state() above. Time for a new ioctl?
+ */
+ if ( rmesa->state.hw.dirty ) {
+ memcpy( &sarea->ContextState, &rmesa->state.hw,
+ sizeof(sarea->ContextState));
+ sarea->dirty |= RADEON_UPLOAD_CONTEXT_ALL;
}
- ret = drmRadeonClear( rmesa->driFd, flags,
- rmesa->ClearColor, rmesa->ClearDepth,
- color_mask, depth_mask,
- rmesa->sarea->boxes, rmesa->sarea->nbox );
- if ( ret ) {
- UNLOCK_HARDWARE( rmesa );
- fprintf( stderr, "drmRadeonClear: return = %d\n", ret );
- exit( 1 );
+ for ( i = 0 ; i < dPriv->numClipRects ; ) {
+ GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
+ XF86DRIClipRectPtr box = dPriv->pClipRects;
+ XF86DRIClipRectPtr b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ if ( x < cx ) w -= cx - x, x = cx;
+ if ( y < cy ) h -= cy - y, y = cy;
+ if ( x + w > cx + cw ) w = cx + cw - x;
+ if ( y + h > cy + ch ) h = cy + ch - y;
+ if ( w <= 0 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ rmesa->sarea->nbox = n;
+
+/* fprintf( stderr, */
+/* "drmRadeonClear: flag 0x%x color %x depth %x sten %x nbox %d\n", */
+/* flags, */
+/* rmesa->state.color.clear, */
+/* rmesa->state.depth.clear, */
+/* rmesa->state.stencil.clear, */
+/* rmesa->sarea->nbox ); */
+
+ ret = drmRadeonClear( rmesa->dri.fd, flags,
+ rmesa->state.color.clear,
+ rmesa->state.depth.clear,
+ rmesa->state.hw.mask.rb3d_planemask,
+ rmesa->state.stencil.clear,
+ rmesa->sarea->boxes, rmesa->sarea->nbox );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "drmRadeonClear: return = %d\n", ret );
+ exit( 1 );
+ }
}
- }
- UNLOCK_HARDWARE( rmesa );
+ UNLOCK_HARDWARE( rmesa );
- rmesa->dirty |= RADEON_UPLOAD_CLIPRECTS;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT_ALL );
+ if ( rmesa->state.texture.unit[0].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ if ( rmesa->state.texture.unit[1].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
+ rmesa->upload_cliprects = 1;
+ }
- return mask;
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
}
void radeonWaitForIdleLocked( radeonContextPtr rmesa )
{
- int fd = rmesa->radeonScreen->driScreen->fd;
+ int fd = rmesa->dri.fd;
int to = 0;
int ret;
@@ -718,7 +814,32 @@ void radeonWaitForIdleLocked( radeonContextPtr rmesa )
}
-void radeonDDInitIoctlFuncs( GLcontext *ctx )
+void radeonInitIoctlFuncs( GLcontext *ctx )
{
- ctx->Driver.Clear = radeonDDClear;
+ ctx->Driver.Clear = radeonClear;
+}
+
+
+
+void radeonReleaseRetainedBuffer( radeonContextPtr rmesa )
+{
+ ASSERT(rmesa->dma.retained);
+
+ if (rmesa->dma.retained &&
+ rmesa->dma.retained != rmesa->dma.buffer) {
+ RADEON_FIREVERTICES(rmesa); /* FIX ME: dependency tracking for retained */
+
+/* fprintf(stderr, "releaseRetained: retained %p current %p\n", */
+/* rmesa->dma.retained, rmesa->dma.buffer); */
+
+ LOCK_HARDWARE(rmesa);
+ drmRadeonFlushPrims( rmesa->dri.fd,
+ rmesa->dma.retained->idx,
+ 1,
+ 0, rmesa->store.state,
+ 0, rmesa->store.prim);
+ UNLOCK_HARDWARE(rmesa);
+ }
+
+ rmesa->dma.retained = 0;
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h
index c8f631ab0..030864f42 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h,v 1.2 2001/04/01 14:00:00 tsi Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -49,113 +49,82 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
extern drmBufPtr radeonGetBufferLocked( radeonContextPtr rmesa );
-extern void radeonFlushVerticesLocked( radeonContextPtr rmesa );
-
-extern void radeonGetEltBufLocked( radeonContextPtr rmesa );
-extern void radeonFlushEltsLocked( radeonContextPtr rmesa );
-extern void radeonFireEltsLocked( radeonContextPtr rmesa,
- GLuint start, GLuint end,
- GLuint discard );
-extern void radeonReleaseBufLocked( radeonContextPtr rmesa, drmBufPtr buffer );
-
-/* Make this available as both a regular and an inline function.
- */
-extern CARD32 *radeonAllocVertices( radeonContextPtr rmesa, GLuint count );
-
-static __inline CARD32 *radeonAllocVerticesInline( radeonContextPtr rmesa,
- GLuint count )
-{
- int bytes = count * rmesa->vertsize * 4;
- CARD32 *head;
-
- if ( !rmesa->vert_buf ) {
- LOCK_HARDWARE( rmesa );
-
- if ( rmesa->first_elt != rmesa->next_elt ) {
- radeonFlushEltsLocked( rmesa );
- }
-
- rmesa->vert_buf = radeonGetBufferLocked( rmesa );
-
- UNLOCK_HARDWARE( rmesa );
- } else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
- LOCK_HARDWARE( rmesa );
-
- radeonFlushVerticesLocked( rmesa );
- rmesa->vert_buf = radeonGetBufferLocked( rmesa );
-
- UNLOCK_HARDWARE( rmesa );
- }
-
- head = (CARD32 *)((char *)rmesa->vert_buf->address +
- rmesa->vert_buf->used);
-
- rmesa->vert_buf->used += bytes;
- rmesa->num_verts += count;
- return head;
-}
-
+extern void radeonEmitPrim( radeonContextPtr rmesa );
+extern void radeonFlushPrims( radeonContextPtr rmesa );
+extern void radeonFlushPrimsLocked( radeonContextPtr rmesa );
+extern void radeonFlushPrimsGetBuffer( radeonContextPtr rmesa );
extern void radeonFireBlitLocked( radeonContextPtr rmesa,
drmBufPtr buffer,
GLint offset, GLint pitch, GLint format,
GLint x, GLint y,
GLint width, GLint height );
-
-extern void radeonSwapBuffers( radeonContextPtr rmesa );
-extern void radeonPageFlip( radeonContextPtr rmesa );
-
+extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable );
+extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
-
-
-extern void radeonDDInitIoctlFuncs( GLcontext *ctx );
+extern void radeonPerformanceCounters( radeonContextPtr rmesa );
+extern void radeonPerformanceBoxesLocked( radeonContextPtr rmesa );
+extern void radeonInitIoctlFuncs( GLcontext *ctx );
+extern void radeonReleaseRetainedBuffer( radeonContextPtr rmesa );
/* ================================================================
* Helper macros:
*/
-#define FLUSH_BATCH( rmesa ) \
+/* Can accomodate several state changes and primitive changes without
+ * actually firing the buffer.
+ */
+#define RADEON_STATECHANGE( rmesa, flag ) \
do { \
- if ( RADEON_DEBUG & DEBUG_VERBOSE_IOCTL ) \
- fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
- if ( rmesa->vert_buf ) { \
- radeonFlushVertices( rmesa ); \
- } else if ( rmesa->next_elt != rmesa->first_elt ) { \
- radeonFlushElts( rmesa ); \
- } \
+ if ( 0 ) radeonPrintDirty( __FUNCTION__, flag ); \
+ if ( rmesa->dma.low != rmesa->dma.last ) \
+ radeonEmitPrim( rmesa ); \
+ rmesa->state.hw.dirty |= flag; \
} while (0)
-/* 64-bit align the next element address, and then make room for the
- * next indexed prim packet header.
+
+/* Fire the buffered vertices no matter what.
*/
-#define ALIGN_NEXT_ELT( rmesa ) \
+#define RADEON_FIREVERTICES( rmesa ) \
do { \
- rmesa->next_elt = (GLushort *) \
- (((unsigned long)rmesa->next_elt + 7) & ~0x7); \
- rmesa->next_elt = (GLushort *) \
- ((GLubyte *)rmesa->next_elt + RADEON_INDEX_PRIM_OFFSET); \
+ if ( rmesa->store.primnr || rmesa->dma.low != rmesa->dma.last ) { \
+ if ( 0 ) \
+ fprintf( stderr, "RADEON_FIREVERTICES in "__FUNCTION__"\n" ); \
+ radeonFlushPrims( rmesa ); \
+ } \
} while (0)
-#define radeonFlushVertices( rmesa ) \
-do { \
- LOCK_HARDWARE( rmesa ); \
- radeonFlushVerticesLocked( rmesa ); \
- UNLOCK_HARDWARE( rmesa ); \
-} while (0)
-#define radeonFlushElts( rmesa ) \
-do { \
- LOCK_HARDWARE( rmesa ); \
- radeonFlushEltsLocked( rmesa ); \
- UNLOCK_HARDWARE( rmesa ); \
-} while (0)
+static __inline void *radeonAllocDmaLow( radeonContextPtr rmesa,
+ int bytes, const char *where )
+{
+ if ( rmesa->dma.low + bytes > rmesa->dma.high ) {
+ if (0) fprintf( stderr, "%s flush for %d (%d/%d/%d)\n",
+ where, bytes, rmesa->dma.last,
+ rmesa->dma.low, rmesa->dma.high );
+ radeonFlushPrimsGetBuffer( rmesa );
+ }
+
+ {
+ GLubyte *head = rmesa->dma.address + rmesa->dma.low;
+ if (0) fprintf( stderr, "%s: alloc %d (%d/%d/%d)\n",
+ where, bytes, rmesa->dma.last,
+ rmesa->dma.low, rmesa->dma.high );
+ rmesa->dma.low += bytes;
+ return head;
+ }
+}
+
+static __inline void *radeonAllocDmaHigh( radeonContextPtr rmesa, int bytes )
+{
+ if ( rmesa->dma.low + bytes > rmesa->dma.high )
+ radeonFlushPrimsGetBuffer( rmesa );
+
+ rmesa->dma.high -= bytes;
+ return (void *)(rmesa->dma.address + rmesa->dma.high);
+}
+
-#define radeonWaitForIdle( rmesa ) \
-do { \
- LOCK_HARDWARE( rmesa ); \
- radeonWaitForIdleLocked( rmesa ); \
- UNLOCK_HARDWARE( rmesa ); \
-} while (0)
#endif
#endif /* __RADEON_IOCTL_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
index aec7677fa..6fd9a1389 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c,v 1.3 2001/04/10 16:07:53 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -37,6 +37,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_context.h"
#include "radeon_lock.h"
#include "radeon_tex.h"
+#include "radeon_state.h"
#if DEBUG_LOCKING
char *prevLockFile = NULL;
@@ -54,12 +55,12 @@ int prevLockLine = 0;
*/
void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
{
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
- __DRIscreenPrivate *sPriv = rmesa->driScreen;
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
RADEONSAREAPrivPtr sarea = rmesa->sarea;
int i;
- drmGetLock( rmesa->driFd, rmesa->hHWContext, flags );
+ drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
/* The window might have moved, so we might need to get new clip
* rects.
@@ -69,27 +70,37 @@ void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
* Since the hardware state depends on having the latest drawable
* clip rects, all state checking must be done _after_ this call.
*/
- XMESA_VALIDATE_DRAWABLE_INFO( rmesa->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( rmesa->dri.display, sPriv, dPriv );
- if ( rmesa->lastStamp != *(dPriv->pStamp) ) {
- rmesa->lastStamp = *(dPriv->pStamp);
- rmesa->new_state |= RADEON_NEW_WINDOW | RADEON_NEW_CLIP;
- rmesa->SetupDone = 0;
+ if ( rmesa->lastStamp != dPriv->lastStamp ) {
+ radeonSetCliprects( rmesa, rmesa->glCtx->Color.DriverDrawBuffer );
+ radeonUpdateViewportOffset( rmesa->glCtx );
+ rmesa->lastStamp = dPriv->lastStamp;
}
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_CLIPRECTS;
+ if ( sarea->ctxOwner != rmesa->dri.hwContext ) {
+ sarea->ctxOwner = rmesa->dri.hwContext;
- rmesa->numClipRects = dPriv->numClipRects;
- rmesa->pClipRects = dPriv->pClipRects;
-
- if ( sarea->ctxOwner != rmesa->hHWContext ) {
- sarea->ctxOwner = rmesa->hHWContext;
- rmesa->dirty = RADEON_UPLOAD_ALL;
- }
+ rmesa->upload_cliprects = 1;
+ if ( rmesa->store.statenr ) {
+ rmesa->store.state[0].dirty = RADEON_UPLOAD_CONTEXT_ALL;
+ if ( rmesa->store.texture[0][0] )
+ rmesa->store.state[0].dirty |= RADEON_UPLOAD_TEX0;
+ if ( rmesa->store.texture[1][0] )
+ rmesa->store.state[0].dirty |= RADEON_UPLOAD_TEX1;
+ }
+ else {
+ rmesa->state.hw.dirty = RADEON_UPLOAD_CONTEXT_ALL;
+ if ( rmesa->state.texture.unit[0].texobj )
+ rmesa->state.hw.dirty |= RADEON_UPLOAD_TEX0;
+ if ( rmesa->state.texture.unit[1].texobj )
+ rmesa->state.hw.dirty |= RADEON_UPLOAD_TEX1;
+ }
- for ( i = 0 ; i < rmesa->lastTexHeap ; i++ ) {
- if ( sarea->texAge[i] != rmesa->lastTexAge[i] ) {
- radeonAgeTextures( rmesa, i );
+ for ( i = 0 ; i < rmesa->texture.numHeaps ; i++ ) {
+ if ( sarea->texAge[i] != rmesa->texture.age[i] ) {
+ radeonAgeTextures( rmesa, i );
+ }
}
}
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h
index 7cdb1b23d..229eb65e6 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h,v 1.1 2001/01/08 01:07:27 martin Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -91,8 +91,8 @@ extern int prevLockLine;
do { \
char __ret = 0; \
DEBUG_CHECK_LOCK(); \
- DRM_CAS( rmesa->driHwLock, rmesa->hHWContext, \
- (DRM_LOCK_HELD | rmesa->hHWContext), __ret ); \
+ DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
+ (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
if ( __ret ) \
radeonGetLock( rmesa, 0 ); \
DEBUG_LOCK(); \
@@ -102,9 +102,9 @@ extern int prevLockLine;
*/
#define UNLOCK_HARDWARE( rmesa ) \
do { \
- DRM_UNLOCK( rmesa->driFd, \
- rmesa->driHwLock, \
- rmesa->hHWContext ); \
+ DRM_UNLOCK( rmesa->dri.fd, \
+ rmesa->dri.hwLock, \
+ rmesa->dri.hwContext ); \
DEBUG_RESET(); \
} while (0)
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.c
deleted file mode 100644
index fe0eb013e..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.c,v 1.1 2001/01/08 01:07:27 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "radeon_context.h"
-#include "radeon_vb.h"
-#include "radeon_pipeline.h"
-
-#include "types.h"
-#include "fog.h"
-
-static struct gl_pipeline_stage radeon_fast_stage = {
- "Radeon Fast Path",
- (PIPE_OP_VERT_XFORM |
- PIPE_OP_RAST_SETUP_0 |
- PIPE_OP_RAST_SETUP_1 |
- PIPE_OP_RENDER),
- PIPE_PRECALC,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- radeonDDFastPath
-};
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D | \
- TEXTURE1_3D | \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-/* Build the PRECALC pipeline with our stage, if possible. Otherwise,
- * return GL_FALSE.
- */
-GLboolean radeonDDBuildPrecalcPipeline( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct gl_pipeline *pipe = &ctx->CVA.pre;
-
- if ( rmesa->RenderIndex == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
- (ctx->Array.Flags & (VERT_OBJ_234 |
- VERT_TEX0_4 |
- VERT_TEX1_4 |
- VERT_ELT)) == (VERT_OBJ_23 | VERT_ELT) )
- {
- pipe->stages[0] = &radeon_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
-
- rmesa->OnFastPath = GL_TRUE;
- return GL_TRUE;
- }
-
- if ( rmesa->OnFastPath ) {
- rmesa->OnFastPath = GL_FALSE;
-
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
- ctx->Array.NewArrayState |= ctx->Array.Summary;
- }
-
- return GL_FALSE;
-}
-
-
-/* Still do the normal fixup and copy-to-current, so this isn't so
- * bad.
- */
-#define ILLEGAL_INPUTS_IMM (VERT_OBJ_4 | \
- VERT_TEX0_4 | \
- VERT_TEX1_4 | \
- VERT_MATERIAL)
-
-static void radeonDDCheckRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d )
-{
- d->type = PIPE_IMMEDIATE | PIPE_PRECALC;
- d->inputs = ctx->RenderFlags;
-
- /* Radeon requires an extra input:
- */
- if ( ctx->FogMode == FOG_FRAGMENT )
- d->inputs |= VERT_FOG_COORD;
-
- d->outputs = VERT_SETUP_FULL;
-
- if ( ctx->IndirectTriangles & DD_SW_SETUP )
- d->type = PIPE_IMMEDIATE;
-}
-
-
-GLuint radeonDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- int i, o;
-
- for ( i = o = 0 ; i < nr ; i++ ) {
- switch ( in[i].ops ) {
- /* Completely replace Mesa's fog processing to generate fog
- * coordinates instead of messing with colors.
- */
- case PIPE_OP_FOG:
- out[o] = gl_fog_coord_stage;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = (NEW_LIGHTING |
- NEW_TEXTURING |
- NEW_RASTER_OPS);
- out[o].state_change = ~0;
- out[o].check = radeonDDCheckPartialRasterSetup;
- out[o].run = radeonDDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].check = radeonDDCheckRasterSetup;
- out[o].run = radeonDDDoRasterSetup;
- o++;
- break;
-
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.h
deleted file mode 100644
index 1af4e3eec..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_pipeline.h,v 1.1 2001/01/08 01:07:27 martin Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifndef __RADEON_PIPELINE_H__
-#define __RADEON_PIPELINE_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-extern GLboolean radeonDDBuildPrecalcPipeline( GLcontext *ctx );
-extern GLuint radeonDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
-
-extern void radeonDDFastPathInit( void );
-extern void radeonDDFastPath( struct vertex_buffer *VB );
-
-extern void radeonDDEltPathInit( void );
-extern void radeonDDEltPath( struct vertex_buffer *VB );
-
-#endif
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_render.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_render.c
new file mode 100644
index 000000000..abde2f0be
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_render.c
@@ -0,0 +1,258 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, California.
+
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to 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.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mem.h"
+#include "mtypes.h"
+#include "mmath.h"
+
+#include "tnl/t_context.h"
+
+#include "radeon_context.h"
+#include "radeon_tris.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_vb.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_POLYGONS 0
+
+#define HAVE_ELTS 1
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ 0,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN,
+ 0,
+ 0,
+ 0
+};
+
+static __inline void radeonDmaPrimitive( radeonContextPtr rmesa, GLenum prim )
+{
+ RADEON_STATECHANGE( rmesa, 0 );
+ rmesa->hw_primitive = hw_prim[prim];
+}
+
+static __inline void radeonEltPrimitive( radeonContextPtr rmesa, GLenum prim )
+{
+ RADEON_STATECHANGE( rmesa, 0 );
+ rmesa->hw_primitive = hw_prim[prim] | RADEON_CP_VC_CNTL_PRIM_WALK_IND;
+}
+
+
+static void VERT_FALLBACK( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+ tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
+ tnl->Driver.Render.PrimTabVerts[flags&PRIM_MODE_MASK]( ctx, start, count, flags );
+ RADEON_CONTEXT(ctx)->SetupNewInputs = VERT_CLIP;
+}
+
+static void ELT_FALLBACK( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+ tnl->Driver.Render.BuildVertices( ctx, 0, tnl->vb.Count, ~0 ); /* argh! */
+ tnl->Driver.Render.PrimTabElts[flags&PRIM_MODE_MASK]( ctx, start, count, flags );
+ RADEON_CONTEXT(ctx)->SetupNewInputs = VERT_CLIP;
+}
+
+
+#define LOCAL_VARS radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+#define ELTS_VARS GLushort *dest
+#define INIT( prim ) radeonDmaPrimitive( rmesa, prim )
+#define ELT_INIT(prim) radeonEltPrimitive( rmesa, prim )
+#define NEW_PRIMITIVE() RADEON_STATECHANGE( rmesa, 0 )
+#define NEW_BUFFER() RADEON_FIREVERTICES( rmesa )
+#define GET_CURRENT_VB_MAX_ELTS() \
+ (((int)rmesa->dma.high - (int)rmesa->dma.low - 20) / 2)
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (((int)rmesa->dma.high - (int)rmesa->dma.low) / (rmesa->vertex_size*4))
+#define GET_SUBSEQUENT_VB_MAX_ELTS() \
+ ((RADEON_BUFFER_SIZE - 20) / 2)
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ RADEON_BUFFER_SIZE / (rmesa->vertex_size * 4)
+
+#define ALLOC_ELTS_NEW_PRIMITIVE(nr) do { \
+ dest = (GLushort *)radeonAllocDmaLow( rmesa, 20 + nr * 2, \
+ __FUNCTION__); \
+ dest += RADEON_INDEX_PRIM_OFFSET / sizeof(*dest); \
+} while (0)
+
+#define ALLOC_ELTS(nr) do { \
+ if (rmesa->dma.low == rmesa->dma.last) { \
+ ALLOC_ELTS_NEW_PRIMITIVE( nr ); \
+ } else { \
+ dest = (GLushort *)radeonAllocDmaLow( rmesa, nr * 2, \
+ __FUNCTION__); \
+ } \
+} while (0)
+
+#define EMIT_ELT(offset, x) (dest)[offset] = (GLushort) (x)
+#if defined(__i386__)
+#define EMIT_TWO_ELTS(offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x);
+#endif
+#define INCR_ELTS( nr ) dest += nr
+#define RELEASE_ELT_VERTS() radeonReleaseRetainedBuffer( rmesa )
+#define EMIT_VERTS( ctx, j, nr ) \
+ radeon_emit_contiguous_verts(ctx, j, (j)+(nr))
+#define EMIT_INDEXED_VERTS( ctx, start, count ) \
+ radeon_emit_indexed_verts( ctx, start, count )
+
+
+#define TAG(x) radeon_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean radeon_run_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i, length, flags = 0;
+ render_func *tab;
+
+ if (rmesa->dma.retained && (!VB->Elts || stage->changed_inputs))
+ radeonReleaseRetainedBuffer( rmesa );
+
+ if (VB->ClipOrMask || /* No clipping */
+ rmesa->RenderIndex != 0 || /* No per-vertex manipulations */
+ ctx->Line.StippleFlag) /* GH: THIS IS A HACK!!! */
+ return GL_TRUE;
+
+ if (VB->Elts) {
+ tab = TAG(render_tab_elts);
+ if (!rmesa->dma.retained)
+ if (!TAG(emit_elt_verts)(ctx, 0, VB->Count))
+ return GL_TRUE; /* too many vertices */
+ } else {
+ tab = TAG(render_tab_verts);
+ }
+
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length)
+ {
+ flags = VB->Primitive[i];
+ length = VB->PrimitiveLength[i];
+ if (length)
+ tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+static void radeon_check_render( GLcontext *ctx,
+ struct gl_pipeline_stage *stage )
+{
+ GLuint inputs = VERT_CLIP|VERT_RGBA;
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ inputs |= VERT_SPEC_RGB;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled)
+ inputs |= VERT_TEX(0);
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled)
+ inputs |= VERT_TEX(1);
+
+ if (ctx->Fog.Enabled)
+ inputs |= VERT_FOG_COORD;
+ }
+
+ stage->inputs = inputs;
+}
+
+
+static void dtr( struct gl_pipeline_stage *stage )
+{
+ (void)stage;
+}
+
+
+const struct gl_pipeline_stage _radeon_render_stage =
+{
+ "radeon render",
+ (_DD_NEW_SEPARATE_SPECULAR |
+ _NEW_TEXTURE|
+ _NEW_FOG|
+ _NEW_RENDERMODE), /* re-check (new inputs) */
+ 0, /* re-run (always runs) */
+ GL_TRUE, /* active */
+ 0, 0, /* inputs (set in check_render), outputs */
+ 0, 0, /* changed_inputs, private */
+ dtr, /* destructor */
+ radeon_check_render, /* check - initially set to alloc data */
+ radeon_run_render /* run */
+};
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
index 6854b62e5..0ea25d772 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c,v 1.3 2001/05/02 15:06:04 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -34,13 +34,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
-#include "radeon_dri.h"
-
+#include "radeon_screen.h"
#include "radeon_context.h"
#include "radeon_ioctl.h"
-#include "radeon_tris.h"
-#include "radeon_vb.h"
-#include "radeon_pipeline.h"
#include "mem.h"
@@ -51,7 +47,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define PCI_CHIP_RADEON_QE 0x5145
#define PCI_CHIP_RADEON_QF 0x5146
#define PCI_CHIP_RADEON_QG 0x5147
-#define PCI_CHIP_RADEON_VE 0x5159
#endif
@@ -62,9 +57,37 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
radeonScreenPtr radeonScreen;
RADEONDRIPtr radeonDRIPriv = (RADEONDRIPtr)sPriv->pDevPriv;
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
+ if ( major != 4 || minor < 0 ) {
+ __driUtilMessage( "Radeon DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch );
+ return NULL;
+ }
+ }
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( sPriv->ddxMajor != 4 ||
+ sPriv->ddxMinor < 0 ) {
+ __driUtilMessage( "Radeon DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
+ return NULL;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( sPriv->drmMajor != 1 ||
+ sPriv->drmMinor < 2 ) {
+ __driUtilMessage( "Radeon DRI driver expected DRM driver version 1.2.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
+ return NULL;
+ }
+
/* Allocate the private area */
radeonScreen = (radeonScreenPtr) CALLOC( sizeof(*radeonScreen) );
- if ( !radeonScreen ) return NULL;
+ if ( !radeonScreen ) {
+ __driUtilMessage("radeonCreateScreen(): CALLOC radeonScreen struct failed");
+ return NULL;
+ }
/* This is first since which regions we map depends on whether or
* not we are using a PCI card.
@@ -78,6 +101,7 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
radeonScreen->mmio.size,
&radeonScreen->mmio.map ) ) {
FREE( radeonScreen );
+ __driUtilMessage("radeonCreateScreen(): drmMap failed\n");
return NULL;
}
@@ -89,6 +113,7 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
&radeonScreen->status.map ) ) {
drmUnmap( radeonScreen->mmio.map, radeonScreen->mmio.size );
FREE( radeonScreen );
+ __driUtilMessage("radeonCreateScreen(): drmMap (2) failed\n");
return NULL;
}
radeonScreen->scratch = (__volatile__ CARD32 *)
@@ -99,6 +124,7 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
drmUnmap( radeonScreen->status.map, radeonScreen->status.size );
drmUnmap( radeonScreen->mmio.map, radeonScreen->mmio.size );
FREE( radeonScreen );
+ __driUtilMessage("radeonCreateScreen(): drmMapBufs failed\n");
return NULL;
}
@@ -113,6 +139,7 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
drmUnmap( radeonScreen->status.map, radeonScreen->status.size );
drmUnmap( radeonScreen->mmio.map, radeonScreen->mmio.size );
FREE( radeonScreen );
+ __driUtilMessage("radeonCreateScreen(): IsPCI failed\n");
return NULL;
}
}
@@ -123,7 +150,6 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
case PCI_CHIP_RADEON_QE:
case PCI_CHIP_RADEON_QF:
case PCI_CHIP_RADEON_QG:
- case PCI_CHIP_RADEON_VE:
radeonScreen->chipset = RADEON_CARD_TYPE_RADEON;
break;
default:
@@ -162,16 +188,6 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
radeonScreen->driScreen = sPriv;
radeonScreen->sarea_priv_offset = radeonDRIPriv->sarea_priv_offset;
-
-#ifdef PER_CONTEXT_SAREA
- radeonScreen->perctx_sarea_size = radeonDRIPriv->perctx_sarea_size;
-#endif
-
- radeonDDSetupInit();
- radeonDDTriangleFuncsInit();
- radeonDDFastPathInit();
- radeonDDEltPathInit();
-
return radeonScreen;
}
@@ -181,6 +197,9 @@ void radeonDestroyScreen( __DRIscreenPrivate *sPriv )
{
radeonScreenPtr radeonScreen = (radeonScreenPtr)sPriv->private;
+ if (!radeonScreen)
+ return;
+
if ( !radeonScreen->IsPCI ) {
drmUnmap( radeonScreen->agpTextures.map,
radeonScreen->agpTextures.size );
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h
index e2ee91708..1098afa2c 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -39,6 +39,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
+#include <X11/Xlibint.h>
+#include "dri_util.h"
+#include "xf86drm.h"
+#include "xf86drmRadeon.h"
#include "radeon_sarea.h"
typedef struct {
@@ -49,18 +53,18 @@ typedef struct {
typedef struct {
- GLint chipset;
- GLint cpp;
- GLint IsPCI; /* Current card is a PCI card */
- GLint AGPMode;
+ int chipset;
+ int cpp;
+ int IsPCI; /* Current card is a PCI card */
+ int AGPMode;
- GLuint frontOffset;
- GLuint frontPitch;
- GLuint backOffset;
- GLuint backPitch;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
- GLuint depthOffset;
- GLuint depthPitch;
+ unsigned int depthOffset;
+ unsigned int depthPitch;
/* Shared texture data */
int numTexHeaps;
@@ -68,10 +72,6 @@ typedef struct {
int texSize[RADEON_NR_TEX_HEAPS];
int logTexGranularity[RADEON_NR_TEX_HEAPS];
-#ifdef PER_CONTEXT_SAREA
- drmSize private_sarea_size;
-#endif
-
radeonRegionRec mmio;
radeonRegionRec status;
radeonRegionRec agpTextures;
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_span.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_span.c
index 917f8aa1d..7f7de7ee3 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_span.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_span.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.c,v 1.4 2001/04/10 16:07:53 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -39,22 +39,25 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_ioctl.h"
#include "radeon_state.h"
#include "radeon_span.h"
+#include "radeon_tex.h"
+
+#include "swrast/swrast.h"
#define DBG 0
#define LOCAL_VARS \
radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
radeonScreenPtr radeonScreen = rmesa->radeonScreen; \
- __DRIscreenPrivate *sPriv = rmesa->driScreen; \
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
GLuint pitch = radeonScreen->frontPitch * radeonScreen->cpp; \
GLuint height = dPriv->h; \
char *buf = (char *)(sPriv->pFB + \
- rmesa->drawOffset + \
+ rmesa->state.color.drawOffset + \
(dPriv->x * radeonScreen->cpp) + \
(dPriv->y * pitch)); \
char *read_buf = (char *)(sPriv->pFB + \
- rmesa->readOffset + \
+ rmesa->state.pixel.readOffset + \
(dPriv->x * radeonScreen->cpp) + \
(dPriv->y * pitch)); \
GLuint p; \
@@ -63,8 +66,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LOCAL_DEPTH_VARS \
radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
radeonScreenPtr radeonScreen = rmesa->radeonScreen; \
- __DRIscreenPrivate *sPriv = rmesa->driScreen; \
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
GLuint height = dPriv->h; \
GLuint xo = dPriv->x; \
GLuint yo = dPriv->y; \
@@ -73,7 +76,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
-#define INIT_MONO_PIXEL( p ) p = rmesa->Color
#define CLIPPIXEL( _x, _y ) \
((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
@@ -92,15 +94,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define Y_FLIP( _y ) (height - _y - 1)
-#define HW_LOCK() \
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
- FLUSH_BATCH( rmesa ); \
- LOCK_HARDWARE( rmesa ); \
- radeonWaitForIdleLocked( rmesa );
+#define HW_LOCK()
#define HW_CLIPLOOP() \
do { \
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
int _nc = dPriv->numClipRects; \
\
while ( _nc-- ) { \
@@ -113,8 +111,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
} \
} while (0)
-#define HW_UNLOCK() \
- UNLOCK_HARDWARE( rmesa )
+#define HW_UNLOCK()
@@ -124,6 +121,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 16 bit, RGB565 color spanline and pixel functions
*/
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
@@ -135,13 +135,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define READ_RGBA( rgba, _x, _y ) \
do { \
GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \
- rgba[0] = (p >> 8) & 0xf8; \
- rgba[1] = (p >> 3) & 0xfc; \
- rgba[2] = (p << 3) & 0xf8; \
+ rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
+ rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+ rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
rgba[3] = 0xff; \
- if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
- if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
- if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \
} while (0)
#define TAG(x) radeon##x##_RGB565
@@ -149,6 +146,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* 32 bit, ARGB8888 color spanline and pixel functions
*/
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
(g << 8) | \
@@ -260,7 +261,6 @@ do { \
* Stencil buffer
*/
-#if 0
/* 24 bit depth, 8 bit stencil depthbuffer functions
*/
#define WRITE_STENCIL( _x, _y, d ) \
@@ -282,69 +282,105 @@ do { \
#define TAG(x) radeon##x##_24_8
#include "stenciltmp.h"
-#endif
-void radeonDDInitSpanFuncs( GLcontext *ctx )
+static void radeonSetReadBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->frontPitch;
+ break;
+ case GL_BACK_LEFT:
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->backPitch;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+/* Move locking out to get reasonable span performance (10x better
+ * than doing this in HW_LOCK above). WaitForIdle() is the main
+ * culprit.
+ */
+
+static void radeonSpanRenderStart( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+ radeonWaitForIdleLocked( rmesa );
+}
+
+static void radeonSpanRenderFinish( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+void radeonInitSpanFuncs( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetReadBuffer = radeonSetReadBuffer;
switch ( rmesa->radeonScreen->cpp ) {
case 2:
- ctx->Driver.WriteRGBASpan = radeonWriteRGBASpan_RGB565;
- ctx->Driver.WriteRGBSpan = radeonWriteRGBSpan_RGB565;
- ctx->Driver.WriteMonoRGBASpan = radeonWriteMonoRGBASpan_RGB565;
- ctx->Driver.WriteRGBAPixels = radeonWriteRGBAPixels_RGB565;
- ctx->Driver.WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_RGB565;
- ctx->Driver.ReadRGBASpan = radeonReadRGBASpan_RGB565;
- ctx->Driver.ReadRGBAPixels = radeonReadRGBAPixels_RGB565;
+ swdd->WriteRGBASpan = radeonWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = radeonWriteRGBSpan_RGB565;
+ swdd->WriteMonoRGBASpan = radeonWriteMonoRGBASpan_RGB565;
+ swdd->WriteRGBAPixels = radeonWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = radeonReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = radeonReadRGBAPixels_RGB565;
break;
case 4:
- ctx->Driver.WriteRGBASpan = radeonWriteRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBSpan = radeonWriteRGBSpan_ARGB8888;
- ctx->Driver.WriteMonoRGBASpan = radeonWriteMonoRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBAPixels = radeonWriteRGBAPixels_ARGB8888;
- ctx->Driver.WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_ARGB8888;
- ctx->Driver.ReadRGBASpan = radeonReadRGBASpan_ARGB8888;
- ctx->Driver.ReadRGBAPixels = radeonReadRGBAPixels_ARGB8888;
+ swdd->WriteRGBASpan = radeonWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = radeonWriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = radeonWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = radeonWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = radeonWriteMonoRGBAPixels_ARGB8888;
+ swdd->ReadRGBASpan = radeonReadRGBASpan_ARGB8888;
+ swdd->ReadRGBAPixels = radeonReadRGBAPixels_ARGB8888;
break;
default:
break;
}
- switch ( rmesa->glCtx->Visual->DepthBits ) {
+ switch ( rmesa->glCtx->Visual.depthBits ) {
case 16:
- ctx->Driver.ReadDepthSpan = radeonReadDepthSpan_16;
- ctx->Driver.WriteDepthSpan = radeonWriteDepthSpan_16;
- ctx->Driver.ReadDepthPixels = radeonReadDepthPixels_16;
- ctx->Driver.WriteDepthPixels = radeonWriteDepthPixels_16;
+ swdd->ReadDepthSpan = radeonReadDepthSpan_16;
+ swdd->WriteDepthSpan = radeonWriteDepthSpan_16;
+ swdd->ReadDepthPixels = radeonReadDepthPixels_16;
+ swdd->WriteDepthPixels = radeonWriteDepthPixels_16;
+ break;
+
+ case 24:
+ swdd->ReadDepthSpan = radeonReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = radeonWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = radeonReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = radeonWriteDepthPixels_24_8;
+
+ swdd->ReadStencilSpan = radeonReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = radeonWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = radeonReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = radeonWriteStencilPixels_24_8;
break;
- case 24:
- ctx->Driver.ReadDepthSpan = radeonReadDepthSpan_24_8;
- ctx->Driver.WriteDepthSpan = radeonWriteDepthSpan_24_8;
- ctx->Driver.ReadDepthPixels = radeonReadDepthPixels_24_8;
- ctx->Driver.WriteDepthPixels = radeonWriteDepthPixels_24_8;
-
-#if 0 /* only need these for hardware stencil buffers */
- ctx->Driver.ReadStencilSpan = radeonReadStencilSpan_24_8;
- ctx->Driver.WriteStencilSpan = radeonWriteStencilSpan_24_8;
- ctx->Driver.ReadStencilPixels = radeonReadStencilPixels_24_8;
- ctx->Driver.WriteStencilPixels = radeonWriteStencilPixels_24_8;
-#endif
- break;
-
- default:
- break;
- }
-
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
+ default:
+ break;
+ }
+
+ swdd->SpanRenderStart = radeonSpanRenderStart;
+ swdd->SpanRenderFinish = radeonSpanRenderFinish;
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_span.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_span.h
index 241f11c1e..31def61a8 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_span.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_span.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.h,v 1.1 2001/01/08 01:07:28 martin Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -39,7 +39,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef GLX_DIRECT_RENDERING
-extern void radeonDDInitSpanFuncs( GLcontext *ctx );
+extern void radeonInitSpanFuncs( GLcontext *ctx );
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c
index 05b4cdf86..e7862393f 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_state.c
@@ -1,38 +1,31 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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$ */
/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
+ * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California.
*
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*/
#include "radeon_context.h"
@@ -43,180 +36,180 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_tex.h"
#include "mmath.h"
-#include "pb.h"
#include "enums.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
/* =============================================================
* Alpha blending
*/
-static void radeonUpdateAlphaMode( GLcontext *ctx )
+static void radeonAlphaFunc( GLcontext *ctx, GLenum func, GLchan ref )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint a = rmesa->setup.pp_misc;
- GLuint p = rmesa->setup.pp_cntl;
- GLuint b = rmesa->setup.rb3d_blendcntl;
- GLuint c = rmesa->setup.rb3d_cntl;
- if ( ctx->Color.AlphaEnabled ) {
- GLubyte ref = ctx->Color.AlphaRef;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
- a &= ~(RADEON_ALPHA_TEST_OP_MASK | RADEON_REF_ALPHA_MASK);
+ rmesa->state.hw.context.pp_misc &= ~(RADEON_ALPHA_TEST_OP_MASK |
+ RADEON_REF_ALPHA_MASK);
- switch ( ctx->Color.AlphaFunc ) {
- case GL_NEVER:
- a |= RADEON_ALPHA_TEST_FAIL;
- break;
- case GL_LESS:
- a |= RADEON_ALPHA_TEST_LESS;
- break;
- case GL_LEQUAL:
- a |= RADEON_ALPHA_TEST_LEQUAL;
- break;
- case GL_EQUAL:
- a |= RADEON_ALPHA_TEST_EQUAL;
- break;
- case GL_GEQUAL:
- a |= RADEON_ALPHA_TEST_GEQUAL;
- break;
- case GL_GREATER:
- a |= RADEON_ALPHA_TEST_GREATER;
- break;
- case GL_NOTEQUAL:
- a |= RADEON_ALPHA_TEST_NEQUAL;
- break;
- case GL_ALWAYS:
- a |= RADEON_ALPHA_TEST_PASS;
- break;
- }
-
- a |= (ref & RADEON_REF_ALPHA_MASK);
- p |= RADEON_ALPHA_TEST_ENABLE;
- } else {
- p &= ~RADEON_ALPHA_TEST_ENABLE;
- }
-
- if ( ctx->Color.BlendEnabled ) {
- b &= ~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK);
-
- switch ( ctx->Color.BlendSrcRGB ) {
- case GL_ZERO:
- b |= RADEON_SRC_BLEND_GL_ZERO;
- break;
- case GL_ONE:
- b |= RADEON_SRC_BLEND_GL_ONE;
- break;
- case GL_DST_COLOR:
- b |= RADEON_SRC_BLEND_GL_DST_COLOR;
- break;
- case GL_ONE_MINUS_DST_COLOR:
- b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_COLOR;
- break;
- case GL_SRC_ALPHA:
- b |= RADEON_SRC_BLEND_GL_SRC_ALPHA;
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- b |= RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA;
- break;
- case GL_DST_ALPHA:
- b |= RADEON_SRC_BLEND_GL_DST_ALPHA;
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA;
- break;
- case GL_SRC_ALPHA_SATURATE:
- b |= RADEON_SRC_BLEND_GL_SRC_ALPHA_SATURATE;
- break;
- }
-
- switch ( ctx->Color.BlendDstRGB ) {
- case GL_ZERO:
- b |= RADEON_DST_BLEND_GL_ZERO;
- break;
- case GL_ONE:
- b |= RADEON_DST_BLEND_GL_ONE;
- break;
- case GL_SRC_COLOR:
- b |= RADEON_DST_BLEND_GL_SRC_COLOR;
- break;
- case GL_ONE_MINUS_SRC_COLOR:
- b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_COLOR;
- break;
- case GL_SRC_ALPHA:
- b |= RADEON_DST_BLEND_GL_SRC_ALPHA;
- break;
- case GL_ONE_MINUS_SRC_ALPHA:
- b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA;
- break;
- case GL_DST_ALPHA:
- b |= RADEON_DST_BLEND_GL_DST_ALPHA;
- break;
- case GL_ONE_MINUS_DST_ALPHA:
- b |= RADEON_DST_BLEND_GL_ONE_MINUS_DST_ALPHA;
- break;
- }
-
- c |= RADEON_ALPHA_BLEND_ENABLE;
- } else {
- c &= ~RADEON_ALPHA_BLEND_ENABLE;
+ switch ( func ) {
+ case GL_NEVER:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_FAIL;
+ break;
+ case GL_LESS:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->state.hw.context.pp_misc |= RADEON_ALPHA_TEST_PASS;
+ break;
}
- if ( rmesa->setup.pp_misc != a ) {
- rmesa->setup.pp_misc = a;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
- }
- if ( rmesa->setup.pp_cntl != p ) {
- rmesa->setup.pp_cntl = p;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
- }
- if ( rmesa->setup.rb3d_blendcntl != b ) {
- rmesa->setup.rb3d_blendcntl = b;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
- }
- if ( rmesa->setup.rb3d_cntl != c ) {
- rmesa->setup.rb3d_cntl = c;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
- }
+ rmesa->state.hw.context.pp_misc |= (ref & RADEON_REF_ALPHA_MASK);
}
-static void radeonDDAlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
+static void radeonBlendEquation( GLcontext *ctx, GLenum mode )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint b = rmesa->state.hw.context.rb3d_blendcntl & ~RADEON_COMB_FCN_MASK;
+ GLboolean fallback = GL_FALSE;
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
-}
+ switch ( mode ) {
+ case GL_FUNC_ADD_EXT:
+ case GL_LOGIC_OP:
+ b |= RADEON_COMB_FCN_ADD_CLAMP;
+ break;
-static void radeonDDBlendEquation( GLcontext *ctx, GLenum mode )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ case GL_FUNC_SUBTRACT_EXT:
+ b |= RADEON_COMB_FCN_SUB_CLAMP;
+ break;
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
+ default:
+ fallback = GL_TRUE;
+ break;
+ }
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- rmesa->Fallback |= RADEON_FALLBACK_LOGICOP;
- else
- rmesa->Fallback &= ~RADEON_FALLBACK_LOGICOP;
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_EQ, fallback );
+ if ( !fallback ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_blendcntl = b;
+ if ( ctx->Color.ColorLogicOpEnabled ) {
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_ROP_ENABLE;
+ } else {
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_ROP_ENABLE;
+ }
+ }
}
-static void radeonDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
+static void radeonBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint b = rmesa->state.hw.context.rb3d_blendcntl & ~(RADEON_SRC_BLEND_MASK |
+ RADEON_DST_BLEND_MASK);
+ GLboolean fallback = GL_FALSE;
+
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ b |= RADEON_SRC_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ b |= RADEON_SRC_BLEND_GL_ONE;
+ break;
+ case GL_DST_COLOR:
+ b |= RADEON_SRC_BLEND_GL_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ b |= RADEON_SRC_BLEND_GL_SRC_ALPHA_SATURATE;
+ break;
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ b |= RADEON_DST_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ b |= RADEON_DST_BLEND_GL_ONE;
+ break;
+ case GL_SRC_COLOR:
+ b |= RADEON_DST_BLEND_GL_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ b |= RADEON_DST_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ b |= RADEON_DST_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ }
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, fallback );
+ if ( !fallback ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_blendcntl = b;
+ }
}
-static void radeonDDBlendFuncSeparate( GLcontext *ctx,
- GLenum sfactorRGB, GLenum dfactorRGB,
- GLenum sfactorA, GLenum dfactorA )
+static void radeonBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
+ radeonBlendFunc( ctx, sfactorRGB, dfactorRGB );
}
@@ -224,89 +217,66 @@ static void radeonDDBlendFuncSeparate( GLcontext *ctx,
* Depth testing
*/
-static void radeonUpdateZMode( GLcontext *ctx )
+static void radeonDepthFunc( GLcontext *ctx, GLenum func )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint z = rmesa->setup.rb3d_zstencilcntl;
- GLuint c = rmesa->setup.rb3d_cntl;
-
- if ( ctx->Depth.Test ) {
- z &= ~RADEON_Z_TEST_MASK;
-
- switch ( ctx->Depth.Func ) {
- case GL_NEVER:
- z |= RADEON_Z_TEST_NEVER;
- break;
- case GL_ALWAYS:
- z |= RADEON_Z_TEST_ALWAYS;
- break;
- case GL_LESS:
- z |= RADEON_Z_TEST_LESS;
- break;
- case GL_LEQUAL:
- z |= RADEON_Z_TEST_LEQUAL;
- break;
- case GL_EQUAL:
- z |= RADEON_Z_TEST_EQUAL;
- break;
- case GL_GEQUAL:
- z |= RADEON_Z_TEST_GEQUAL;
- break;
- case GL_GREATER:
- z |= RADEON_Z_TEST_GREATER;
- break;
- case GL_NOTEQUAL:
- z |= RADEON_Z_TEST_NEQUAL;
- break;
- }
- c |= RADEON_Z_ENABLE;
- } else {
- c &= ~RADEON_Z_ENABLE;
- }
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_zstencilcntl &= ~RADEON_Z_TEST_MASK;
- if ( ctx->Depth.Mask ) {
- z |= RADEON_Z_WRITE_ENABLE;
- } else {
- z &= ~RADEON_Z_WRITE_ENABLE;
- }
-
- if ( rmesa->setup.rb3d_zstencilcntl != z ) {
- rmesa->setup.rb3d_zstencilcntl = z;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
- if ( rmesa->setup.rb3d_cntl != c ) {
- rmesa->setup.rb3d_cntl = c;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_TEST_ALWAYS;
+ break;
}
}
-static void radeonDDDepthFunc( GLcontext *ctx, GLenum func )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_DEPTH;
-}
-static void radeonDDDepthMask( GLcontext *ctx, GLboolean flag )
+static void radeonDepthMask( GLcontext *ctx, GLboolean flag )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_DEPTH;
+ if ( ctx->Depth.Mask ) {
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_Z_WRITE_ENABLE;
+ } else {
+ rmesa->state.hw.context.rb3d_zstencilcntl &= ~RADEON_Z_WRITE_ENABLE;
+ }
}
-static void radeonDDClearDepth( GLcontext *ctx, GLclampd d )
+static void radeonClearDepth( GLcontext *ctx, GLclampd d )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint format = (rmesa->state.hw.context.rb3d_zstencilcntl &
+ RADEON_DEPTH_FORMAT_MASK);
- switch ( rmesa->setup.rb3d_zstencilcntl & RADEON_DEPTH_FORMAT_MASK ) {
+ switch ( format ) {
case RADEON_DEPTH_FORMAT_16BIT_INT_Z:
- rmesa->ClearDepth = d * 0x0000ffff;
+ rmesa->state.depth.clear = d * 0x0000ffff;
break;
case RADEON_DEPTH_FORMAT_24BIT_INT_Z:
- rmesa->ClearDepth = d * 0x00ffffff;
+ rmesa->state.depth.clear = d * 0x00ffffff;
break;
}
}
@@ -316,38 +286,15 @@ static void radeonDDClearDepth( GLcontext *ctx, GLclampd d )
* Fog
*/
-static void radeonUpdateFogAttrib( GLcontext *ctx )
+static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint p = rmesa->setup.pp_cntl;
- GLubyte c[4];
- GLuint col;
-
- if ( ctx->FogMode == FOG_FRAGMENT ) {
- p |= RADEON_FOG_ENABLE;
- } else {
- p &= ~RADEON_FOG_ENABLE;
- }
-
- FLOAT_RGB_TO_UBYTE_RGB( c, ctx->Fog.Color );
- col = radeonPackColor( 4, c[0], c[1], c[2], 0 );
+ GLchan c[4];
- if ( rmesa->setup.pp_fog_color != col ) {
- rmesa->setup.pp_fog_color = col;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
- if ( rmesa->setup.pp_cntl != p ) {
- rmesa->setup.pp_cntl = p;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
-}
-
-static void radeonDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_FOG;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( c, ctx->Fog.Color );
+ rmesa->state.hw.context.pp_fog_color =
+ radeonPackColor( 4, c[0], c[1], c[2], 0 );
}
@@ -355,48 +302,38 @@ static void radeonDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
* Clipping
*/
-static void radeonUpdateClipping( GLcontext *ctx )
+static void radeonUpdateScissor( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- if ( rmesa->driDrawable ) {
- __DRIdrawablePrivate *drawable = rmesa->driDrawable;
- int x = 0;
- int y = 0;
- int w = drawable->w - 1;
- int h = drawable->h - 1;
+ if ( rmesa->dri.drawable ) {
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
- if ( ctx->Scissor.Enabled ) {
- if ( ctx->Scissor.X > x ) {
- x = ctx->Scissor.X;
- }
- if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y ) {
- y = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height;
- }
- if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < w ) {
- w = ctx->Scissor.X + ctx->Scissor.Width - 1;
- }
- if ( drawable->h - ctx->Scissor.Y - 1 < h ) {
- h = drawable->h - ctx->Scissor.Y - 1;
- }
- }
+ int x = ctx->Scissor.X;
+ int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
+ int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ int h = dPriv->h - ctx->Scissor.Y - 1;
- rmesa->scissor_rect.x1 = x + rmesa->driDrawable->x;
- rmesa->scissor_rect.y1 = y + rmesa->driDrawable->y;
- rmesa->scissor_rect.x2 = w + rmesa->driDrawable->x + 1;
- rmesa->scissor_rect.y2 = h + rmesa->driDrawable->y + 1;
+ rmesa->state.scissor.rect.x1 = x + dPriv->x;
+ rmesa->state.scissor.rect.y1 = y + dPriv->y;
+ rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
+ rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
- rmesa->dirty |= RADEON_UPLOAD_CLIPRECTS;
+ if ( ctx->Scissor.Enabled )
+ rmesa->upload_cliprects = 1;
}
}
-static void radeonDDScissor( GLcontext *ctx,
- GLint x, GLint y, GLsizei w, GLsizei h )
+
+static void radeonScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_CLIP;
+ if ( ctx->Scissor.Enabled )
+ RADEON_FIREVERTICES( rmesa ); /* don't pipeline cliprect changes */
+
+ radeonUpdateScissor( ctx );
}
@@ -404,25 +341,14 @@ static void radeonDDScissor( GLcontext *ctx,
* Culling
*/
-static void radeonUpdateCull( GLcontext *ctx )
+static void radeonCullFace( GLcontext *ctx, GLenum unused )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint s = rmesa->setup.se_cntl;
-
- s &= ~RADEON_FFACE_CULL_DIR_MASK;
-
- switch ( ctx->Polygon.FrontFace ) {
- case GL_CW:
- s |= RADEON_FFACE_CULL_CW;
- break;
- case GL_CCW:
- s |= RADEON_FFACE_CULL_CCW;
- break;
- }
+ GLuint s = rmesa->state.hw.setup1.se_cntl;
s |= RADEON_FFACE_SOLID | RADEON_BFACE_SOLID;
- if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
+ if ( ctx->Polygon.CullFlag ) {
switch ( ctx->Polygon.CullFaceMode ) {
case GL_FRONT:
s &= ~RADEON_FFACE_SOLID;
@@ -436,60 +362,114 @@ static void radeonUpdateCull( GLcontext *ctx )
}
}
- if ( rmesa->setup.se_cntl != s ) {
- rmesa->setup.se_cntl = s;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_SETUP;
+ if ( rmesa->state.hw.setup1.se_cntl != s ) {
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_SETUP);
+ rmesa->state.hw.setup1.se_cntl = s;
+ }
+}
+
+static void radeonFrontFace( GLcontext *ctx, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_SETUP );
+ rmesa->state.hw.setup1.se_cntl &= ~RADEON_FFACE_CULL_DIR_MASK;
+
+ switch ( mode ) {
+ case GL_CW:
+ rmesa->state.hw.setup1.se_cntl |= RADEON_FFACE_CULL_CW;
+ break;
+ case GL_CCW:
+ rmesa->state.hw.setup1.se_cntl |= RADEON_FFACE_CULL_CCW;
+ break;
}
}
-static void radeonDDCullFace( GLcontext *ctx, GLenum mode )
+
+/* =============================================================
+ * Line state
+ */
+static void radeonLineWidth( GLcontext *ctx, GLfloat widthf )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_CULL;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_LINE | RADEON_UPLOAD_SETUP );
+
+ /* Line width is stored in U6.4 format.
+ */
+ rmesa->state.hw.line.se_line_width = (GLuint)(widthf * 16.0);
+ if ( widthf > 1.0 ) {
+ rmesa->state.hw.setup1.se_cntl |= RADEON_WIDELINE_ENABLE;
+ } else {
+ rmesa->state.hw.setup1.se_cntl &= ~RADEON_WIDELINE_ENABLE;
+ }
}
-static void radeonDDFrontFace( GLcontext *ctx, GLenum mode )
+static void radeonLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_CULL;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_LINE );
+
+ rmesa->state.hw.line.re_line_pattern = ((((GLuint)factor & 0xff) << 16) |
+ ((GLuint)pattern));
}
/* =============================================================
* Masks
*/
-
-static void radeonUpdateMasks( GLcontext *ctx )
+static void radeonColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
GLuint mask = radeonPackColor( rmesa->radeonScreen->cpp,
ctx->Color.ColorMask[RCOMP],
ctx->Color.ColorMask[GCOMP],
ctx->Color.ColorMask[BCOMP],
ctx->Color.ColorMask[ACOMP] );
- if ( rmesa->setup.rb3d_planemask != mask ) {
- rmesa->setup.rb3d_planemask = mask;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
+ if ( rmesa->state.hw.mask.rb3d_planemask != mask ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_MASKS );
+ rmesa->state.hw.mask.rb3d_planemask = mask;
}
}
-static GLboolean radeonDDColorMask( GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+
+/* =============================================================
+ * Polygon state
+ */
+
+static void radeonPolygonOffset( GLcontext *ctx,
+ GLfloat factor, GLfloat units )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat constant = units * rmesa->state.depth.scale;
+
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_ZBIAS );
+ rmesa->state.hw.zbias.se_zbias_factor = *(GLuint *)&factor;
+ rmesa->state.hw.zbias.se_zbias_constant = *(GLuint *)&constant;
+}
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_MASKS;
+static void radeonPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint i;
- return GL_FALSE; /* This forces the software paths to do colormasking. */
- /* This function will return void when we use Mesa 3.5 */
+ /* Must flip pattern upside down.
+ */
+ for ( i = 0 ; i < 32 ; i++ ) {
+ rmesa->state.stipple.mask[31 - i] = ((GLuint *) mask)[i];
+ }
+
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ /* FIXME: Use window x,y offsets into stipple RAM.
+ */
+ drmRadeonPolygonStipple( rmesa->dri.fd, rmesa->state.stipple.mask );
+ UNLOCK_HARDWARE( rmesa );
}
@@ -501,34 +481,40 @@ static GLboolean radeonDDColorMask( GLcontext *ctx,
* sense to break them out of the core texture state update routines.
*/
-static void radeonDDLightModelfv( GLcontext *ctx, GLenum pname,
- const GLfloat *param )
+/* Examine lighting and texture state to determine if separate specular
+ * should be enabled.
+ */
+static void radeonUpdateSpecular( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ CARD32 p = rmesa->state.hw.context.pp_cntl;
- if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
- GLuint p = rmesa->setup.pp_cntl;
+ if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled) {
+ p |= RADEON_SPECULAR_ENABLE;
+ } else {
+ p &= ~RADEON_SPECULAR_ENABLE;
+ }
- FLUSH_BATCH( rmesa );
+ if ( rmesa->state.hw.context.pp_cntl != p ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.pp_cntl = p;
+ }
+}
- if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
- ctx->Light.Enabled && ctx->Texture.ReallyEnabled) {
- p |= RADEON_SPECULAR_ENABLE;
- } else {
- p &= ~RADEON_SPECULAR_ENABLE;
- }
- if ( rmesa->setup.pp_cntl != p ) {
- rmesa->setup.pp_cntl = p;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
+static void radeonLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
+ radeonUpdateSpecular(ctx);
}
}
-static void radeonDDShadeModel( GLcontext *ctx, GLenum mode )
+static void radeonShadeModel( GLcontext *ctx, GLenum mode )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint s = rmesa->setup.se_cntl;
+ GLuint s = rmesa->state.hw.setup1.se_cntl;
s &= ~(RADEON_DIFFUSE_SHADE_MASK |
RADEON_ALPHA_SHADE_MASK |
@@ -552,191 +538,375 @@ static void radeonDDShadeModel( GLcontext *ctx, GLenum mode )
return;
}
- if ( rmesa->setup.se_cntl != s ) {
- FLUSH_BATCH( rmesa );
- rmesa->setup.se_cntl = s;
-
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= RADEON_UPLOAD_SETUP;
+ if ( rmesa->state.hw.setup1.se_cntl != s ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_SETUP );
+ rmesa->state.hw.setup1.se_cntl = s;
}
}
/* =============================================================
- * Window position
+ * Stencil
*/
-void radeonUpdateWindow( GLcontext *ctx )
+static void radeonStencilFunc( GLcontext *ctx, GLenum func,
+ GLint ref, GLuint mask )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
- GLfloat xoffset = (GLfloat)dPriv->x;
- GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
- const GLfloat one = 1.0;
- GLuint m = rmesa->setup.re_misc;
- GLuint sx, sy;
-
- rmesa->setup.se_vport_xscale = *(GLuint *)&one;
- rmesa->setup.se_vport_xoffset = *(GLuint *)&xoffset;
- rmesa->setup.se_vport_yscale = *(GLuint *)&one;
- rmesa->setup.se_vport_yoffset = *(GLuint *)&yoffset;
- rmesa->setup.se_vport_zscale = *(GLuint *)&rmesa->depth_scale;
- rmesa->setup.se_vport_zoffset = 0x00000000;
-
- /* Update polygon stipple offsets */
- m &= ~(RADEON_STIPPLE_X_OFFSET_MASK |
- RADEON_STIPPLE_Y_OFFSET_MASK);
-
- /* add magic offsets, then invert */
- sx = 31 - ((rmesa->driDrawable->x - 1) & RADEON_STIPPLE_COORD_MASK);
- sy = 31 - ((rmesa->driDrawable->y + rmesa->driDrawable->h - 1)
- & RADEON_STIPPLE_COORD_MASK);
-
- m |= ((sx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
- (sy << RADEON_STIPPLE_Y_OFFSET_SHIFT));
-
- if ( rmesa->setup.re_misc != m ) {
- rmesa->setup.re_misc = m;
- rmesa->dirty |= RADEON_UPLOAD_MISC;
+ GLuint refmask = ((ctx->Stencil.Ref << RADEON_STENCIL_REF_SHIFT) |
+ (ctx->Stencil.ValueMask << RADEON_STENCIL_MASK_SHIFT));
+
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS );
+
+ rmesa->state.hw.context.rb3d_zstencilcntl &= ~RADEON_STENCIL_TEST_MASK;
+ rmesa->state.hw.mask.rb3d_stencilrefmask &= ~(RADEON_STENCIL_REF_MASK|
+ RADEON_STENCIL_VALUE_MASK);
+
+ switch ( ctx->Stencil.Function ) {
+ case GL_NEVER:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_TEST_ALWAYS;
+ break;
}
- rmesa->dirty |= RADEON_UPLOAD_VIEWPORT;
+ rmesa->state.hw.mask.rb3d_stencilrefmask |= refmask;
}
+static void radeonStencilMask( GLcontext *ctx, GLuint mask )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-/* =============================================================
- * Miscellaneous
- */
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_MASKS );
+ rmesa->state.hw.mask.rb3d_stencilrefmask &= ~RADEON_STENCIL_WRITE_MASK;
-static void radeonDDClearColor( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+ rmesa->state.hw.mask.rb3d_stencilrefmask |=
+ (ctx->Stencil.WriteMask << RADEON_STENCIL_WRITEMASK_SHIFT);
+}
+
+static void radeonStencilOp( GLcontext *ctx, GLenum fail,
+ GLenum zfail, GLenum zpass )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- rmesa->ClearColor = radeonPackColor( rmesa->radeonScreen->cpp,
- r, g, b, a );
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_zstencilcntl &= ~(RADEON_STENCIL_FAIL_MASK |
+ RADEON_STENCIL_ZFAIL_MASK |
+ RADEON_STENCIL_ZPASS_MASK);
+
+ switch ( ctx->Stencil.FailFunc ) {
+ case GL_KEEP:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_DEC;
+ break;
+ case GL_INVERT:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_FAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZFailFunc ) {
+ case GL_KEEP:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_DEC;
+ break;
+ case GL_INVERT:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZFAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZPassFunc ) {
+ case GL_KEEP:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_INC;
+ break;
+ case GL_DECR:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_DEC;
+ break;
+ case GL_INVERT:
+ rmesa->state.hw.context.rb3d_zstencilcntl |= RADEON_STENCIL_ZPASS_INVERT;
+ break;
+ }
}
-static void radeonDDColor( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+static void radeonClearStencil( GLcontext *ctx, GLint s )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- rmesa->Color = radeonPackColor( rmesa->radeonScreen->cpp,
- r, g, b, a );
+ rmesa->state.stencil.clear = ((GLuint) ctx->Stencil.Clear |
+ (0xff << RADEON_STENCIL_MASK_SHIFT) |
+ (ctx->Stencil.WriteMask << RADEON_STENCIL_WRITEMASK_SHIFT));
}
-static void radeonDDLogicOpCode( GLcontext *ctx, GLenum opcode )
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+/*
+ * To correctly position primitives:
+ */
+#define SUBPIXEL_X 0.125
+
+void radeonUpdateWindow( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat sy = - v[MAT_SY];
+ GLfloat ty = (- v[MAT_TY]) + yoffset;
+ GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
+ GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+
+/* fprintf(stderr, "radeonUpdateWindow %d,%d %dx%d\n", */
+/* dPriv->x, dPriv->y, dPriv->w, dPriv->h); */
+
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_VIEWPORT);
+ rmesa->state.hw.viewport.se_vport_xscale = *(GLuint *)&sx;
+ rmesa->state.hw.viewport.se_vport_xoffset = *(GLuint *)&tx;
+ rmesa->state.hw.viewport.se_vport_yscale = *(GLuint *)&sy;
+ rmesa->state.hw.viewport.se_vport_yoffset = *(GLuint *)&ty;
+ rmesa->state.hw.viewport.se_vport_zscale = *(GLuint *)&sz;
+ rmesa->state.hw.viewport.se_vport_zoffset = *(GLuint *)&tz;
+}
- if ( ctx->Color.ColorLogicOpEnabled ) {
- FLUSH_BATCH( rmesa );
- /* FIXME: We can do color logic ops.
- */
- if ( opcode == GL_COPY ) {
- rmesa->Fallback &= ~RADEON_FALLBACK_LOGICOP;
- } else {
- rmesa->Fallback |= RADEON_FALLBACK_LOGICOP;
- }
- }
- else
- rmesa->Fallback &= ~RADEON_FALLBACK_LOGICOP;
+
+static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* Don't pipeline viewport changes, conflict with window offset
+ * setting below. Could apply deltas to rescue pipelined viewport
+ * values, or keep the originals hanging around.
+ */
+ RADEON_FIREVERTICES( RADEON_CONTEXT(ctx) );
+ radeonUpdateWindow( ctx );
}
-static GLboolean radeonDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
+static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ radeonUpdateWindow( ctx );
+}
+
+void radeonUpdateViewportOffset( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- int found = GL_TRUE;
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat ty = (- v[MAT_TY]) + yoffset;
+
+ if ( rmesa->state.hw.viewport.se_vport_xoffset != tx ||
+ rmesa->state.hw.viewport.se_vport_yoffset != ty )
+ {
+ rmesa->state.hw.viewport.se_vport_xoffset = *(GLuint *)&tx;
+ rmesa->state.hw.viewport.se_vport_yoffset = *(GLuint *)&ty;
+
+ if (rmesa->store.statenr) {
+ int i;
+ rmesa->store.state[0].dirty |= RADEON_UPLOAD_VIEWPORT;
+ /* Note: assume vport x/yoffset are constant over the buffer:
+ */
+ for (i = 0 ; i < rmesa->store.statenr ; i++) {
+ rmesa->store.state[i].viewport.se_vport_xoffset = *(GLuint *)&tx;
+ rmesa->store.state[i].viewport.se_vport_yoffset = *(GLuint *)&ty;
+ }
+ } else {
+ rmesa->state.hw.dirty |= RADEON_UPLOAD_VIEWPORT;
+ }
- FLUSH_BATCH( rmesa );
+ /* update polygon stipple x/y screen offset */
+ {
+ GLuint stx, sty;
+ GLuint m = rmesa->state.hw.misc.re_misc;
- if ( rmesa->DrawBuffer != mode ) {
- rmesa->DrawBuffer = mode;
- rmesa->Fallback &= ~RADEON_FALLBACK_DRAW_BUFFER;
+ m &= ~(RADEON_STIPPLE_X_OFFSET_MASK |
+ RADEON_STIPPLE_Y_OFFSET_MASK);
- switch ( mode ) {
- case GL_FRONT_LEFT:
- rmesa->drawOffset = rmesa->radeonScreen->frontOffset;
- rmesa->drawPitch = rmesa->radeonScreen->frontPitch;
- break;
- case GL_BACK_LEFT:
- rmesa->drawOffset = rmesa->radeonScreen->backOffset;
- rmesa->drawPitch = rmesa->radeonScreen->backPitch;
- break;
- default:
- rmesa->Fallback |= RADEON_FALLBACK_DRAW_BUFFER;
- found = GL_FALSE;
- break;
- }
+ /* add magic offsets, then invert */
+ stx = 31 - ((rmesa->dri.drawable->x - 1) & RADEON_STIPPLE_COORD_MASK);
+ sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
+ & RADEON_STIPPLE_COORD_MASK);
- rmesa->setup.rb3d_coloroffset =
- (rmesa->drawOffset & RADEON_COLOROFFSET_MASK);
- rmesa->setup.rb3d_colorpitch = rmesa->drawPitch;
+ m |= ((stx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
+ (sty << RADEON_STIPPLE_Y_OFFSET_SHIFT));
- rmesa->new_state |= RADEON_NEW_WINDOW;
+ if ( rmesa->state.hw.misc.re_misc != m ) {
+ rmesa->state.hw.misc.re_misc = m;
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_MISC);
+ }
+ }
}
- return found;
+ radeonUpdateScissor( ctx );
+}
+
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void radeonClearColor( GLcontext *ctx, const GLchan c[4] )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ rmesa->state.color.clear = radeonPackColor( rmesa->radeonScreen->cpp,
+ c[0], c[1], c[2], c[3] );
}
-static void radeonDDSetReadBuffer( GLcontext *ctx,
- GLframebuffer *colorBuffer,
- GLenum mode )
+
+static void radeonRenderMode( GLcontext *ctx, GLenum mode )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ FALLBACK( rmesa, RADEON_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
- rmesa->Fallback &= ~RADEON_FALLBACK_READ_BUFFER;
+
+static GLuint radeon_rop_tab[] = {
+ RADEON_ROP_CLEAR,
+ RADEON_ROP_AND,
+ RADEON_ROP_AND_REVERSE,
+ RADEON_ROP_COPY,
+ RADEON_ROP_AND_INVERTED,
+ RADEON_ROP_NOOP,
+ RADEON_ROP_XOR,
+ RADEON_ROP_OR,
+ RADEON_ROP_NOR,
+ RADEON_ROP_EQUIV,
+ RADEON_ROP_INVERT,
+ RADEON_ROP_OR_REVERSE,
+ RADEON_ROP_COPY_INVERTED,
+ RADEON_ROP_OR_INVERTED,
+ RADEON_ROP_NAND,
+ RADEON_ROP_SET,
+};
+
+static void radeonLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint rop = (GLuint)opcode - GL_CLEAR;
+
+ ASSERT( rop < 16 );
+
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_MASKS );
+ rmesa->state.hw.mask.rb3d_ropcntl = radeon_rop_tab[rop];
+}
+
+
+void radeonSetCliprects( radeonContextPtr rmesa, GLenum mode )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
switch ( mode ) {
case GL_FRONT_LEFT:
- rmesa->readOffset = rmesa->radeonScreen->frontOffset;
- rmesa->readPitch = rmesa->radeonScreen->frontPitch;
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
break;
case GL_BACK_LEFT:
- rmesa->readOffset = rmesa->radeonScreen->backOffset;
- rmesa->readPitch = rmesa->radeonScreen->backPitch;
+ if ( dPriv->numBackClipRects == 0 ) {
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pClipRects;
+ }
+ else {
+ rmesa->numClipRects = dPriv->numBackClipRects;
+ rmesa->pClipRects = (XF86DRIClipRectPtr)dPriv->pBackClipRects;
+ }
break;
default:
- rmesa->Fallback |= RADEON_FALLBACK_READ_BUFFER;
- break;
+ return;
}
-}
+ rmesa->upload_cliprects = 1;
+}
-/* =============================================================
- * Polygon stipple
- */
-static void radeonDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+static GLboolean radeonSetDrawBuffer( GLcontext *ctx, GLenum mode )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint i, stipple[32];
- /* must flip pattern upside down */
- for (i = 0; i < 32; i++) {
- stipple[31 - i] = ((GLuint *) mask)[i];
- }
-
- FLUSH_BATCH( rmesa );
+ RADEON_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
- if ( ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON ) {
- rmesa->setup.pp_cntl |= RADEON_STIPPLE_ENABLE;
- } else {
- rmesa->setup.pp_cntl &= ~RADEON_STIPPLE_ENABLE;
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ radeonSetCliprects( rmesa, GL_FRONT_LEFT );
+ break;
+ case GL_BACK_LEFT:
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ radeonSetCliprects( rmesa, GL_BACK_LEFT );
+ break;
+ default:
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return GL_FALSE;
}
- LOCK_HARDWARE( rmesa );
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.rb3d_coloroffset = (rmesa->state.color.drawOffset &
+ RADEON_COLOROFFSET_MASK);
+ rmesa->state.hw.context.rb3d_colorpitch = rmesa->state.color.drawPitch;
- /* FIXME: Use window x,y offsets into stipple RAM.
- */
- drmRadeonPolygonStipple( rmesa->driFd, stipple );
-
- UNLOCK_HARDWARE( rmesa );
-
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
+ return GL_TRUE;
}
@@ -744,107 +914,164 @@ static void radeonDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
* State enable/disable
*/
-static void radeonDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ if ( RADEON_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, __FUNCTION__"( %s = %s )\n",
+ _mesa_lookup_enum_by_nr( cap ),
+ state ? "GL_TRUE" : "GL_FALSE" );
+
switch ( cap ) {
+ /* Fast track this one...
+ */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+
case GL_ALPHA_TEST:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if (state) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_ALPHA_TEST_ENABLE;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_ALPHA_TEST_ENABLE;
+ }
break;
case GL_BLEND:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_ALPHA;
-
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- rmesa->Fallback |= RADEON_FALLBACK_LOGICOP;
- else
- rmesa->Fallback &= ~RADEON_FALLBACK_LOGICOP;
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if (state) {
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_ALPHA_BLEND_ENABLE;
+ } else {
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_ALPHA_BLEND_ENABLE;
+ }
break;
case GL_CULL_FACE:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_CULL;
+ radeonCullFace( ctx, 0 );
break;
case GL_DEPTH_TEST:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_DEPTH;
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if ( state ) {
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_Z_ENABLE;
+ } else {
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_Z_ENABLE;
+ }
break;
case GL_DITHER:
- do {
- GLuint r = rmesa->setup.rb3d_cntl;
- FLUSH_BATCH( rmesa );
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if ( state ) {
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_DITHER_ENABLE;
+ } else {
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_DITHER_ENABLE;
+ }
+ break;
- if ( ctx->Color.DitherFlag ) {
- r |= RADEON_DITHER_ENABLE;
- } else {
- r &= ~RADEON_DITHER_ENABLE;
- }
+ case GL_FOG:
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if ( state ) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_FOG_ENABLE;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_FOG_ENABLE;
+ }
+ break;
- if ( rmesa->setup.rb3d_cntl != r ) {
- rmesa->setup.rb3d_cntl = r;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
- } while (0);
+ case GL_LIGHTING:
+ radeonUpdateSpecular(ctx);
break;
- case GL_FOG:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_FOG;
+ case GL_LINE_SMOOTH:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ if ( state ) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_ANTI_ALIAS_LINE;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_ANTI_ALIAS_LINE;
+ }
+ break;
+
+ case GL_LINE_STIPPLE:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ if ( state ) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_PATTERN_ENABLE;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_PATTERN_ENABLE;
+ }
break;
case GL_COLOR_LOGIC_OP:
- FLUSH_BATCH( rmesa );
- if ( state && ctx->Color.LogicOp != GL_COPY ) {
- rmesa->Fallback |= RADEON_FALLBACK_LOGICOP;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ if ( state ) {
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_ROP_ENABLE;
} else {
- rmesa->Fallback &= ~RADEON_FALLBACK_LOGICOP;
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_ROP_ENABLE;
}
break;
- case GL_LIGHTING:
- {
- GLuint p = rmesa->setup.pp_cntl;
- if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
- ctx->Light.Enabled && ctx->Texture.ReallyEnabled) {
- p |= RADEON_SPECULAR_ENABLE;
- } else {
- p &= ~RADEON_SPECULAR_ENABLE;
- }
- if ( rmesa->setup.pp_cntl != p ) {
- rmesa->setup.pp_cntl = p;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
- }
- break;
+ case GL_POLYGON_OFFSET_POINT:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_SETUP );
+ if ( state ) {
+ rmesa->state.hw.setup1.se_cntl |= RADEON_ZBIAS_ENABLE_POINT;
+ } else {
+ rmesa->state.hw.setup1.se_cntl &= ~RADEON_ZBIAS_ENABLE_POINT;
}
+ break;
- case GL_SCISSOR_TEST:
- FLUSH_BATCH( rmesa );
- rmesa->scissor = state;
- rmesa->new_state |= RADEON_NEW_CLIP;
+ case GL_POLYGON_OFFSET_LINE:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_SETUP );
+ if ( state ) {
+ rmesa->state.hw.setup1.se_cntl |= RADEON_ZBIAS_ENABLE_LINE;
+ } else {
+ rmesa->state.hw.setup1.se_cntl &= ~RADEON_ZBIAS_ENABLE_LINE;
+ }
break;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_3D:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_TEXTURE;
+ case GL_POLYGON_OFFSET_FILL:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_SETUP );
+ if ( state ) {
+ rmesa->state.hw.setup1.se_cntl |= RADEON_ZBIAS_ENABLE_TRI;
+ } else {
+ rmesa->state.hw.setup1.se_cntl &= ~RADEON_ZBIAS_ENABLE_TRI;
+ }
+ break;
+
+ case GL_POLYGON_SMOOTH:
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ if ( state ) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_ANTI_ALIAS_POLY;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_ANTI_ALIAS_POLY;
+ }
break;
case GL_POLYGON_STIPPLE:
- if ( ctx->PB->primitive == GL_POLYGON ) {
- FLUSH_BATCH( rmesa );
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_CONTEXT);
+ if ( state ) {
+ rmesa->state.hw.context.pp_cntl |= RADEON_STIPPLE_ENABLE;
+ } else {
+ rmesa->state.hw.context.pp_cntl &= ~RADEON_STIPPLE_ENABLE;
+ }
+ break;
+
+ case GL_SCISSOR_TEST:
+ RADEON_FIREVERTICES( rmesa );
+ rmesa->state.scissor.enabled = state;
+ rmesa->upload_cliprects = 1;
+ break;
+
+ case GL_STENCIL_TEST:
+ if ( rmesa->state.stencil.hwBuffer ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
if ( state ) {
- rmesa->setup.pp_cntl |= RADEON_STIPPLE_ENABLE;
+ rmesa->state.hw.context.rb3d_cntl |= RADEON_STENCIL_ENABLE;
} else {
- rmesa->setup.pp_cntl &= ~RADEON_STIPPLE_ENABLE;
+ rmesa->state.hw.context.rb3d_cntl &= ~RADEON_STENCIL_ENABLE;
}
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
+ } else {
+ FALLBACK( rmesa, RADEON_FALLBACK_STENCIL, state );
}
break;
@@ -858,14 +1085,13 @@ static void radeonDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
* State initialization, management
*/
-static void radeonDDPrintDirty( const char *msg, GLuint state )
+void radeonPrintDirty( const char *msg, GLuint state )
{
fprintf( stderr,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
msg,
state,
(state & RADEON_UPLOAD_CONTEXT) ? "context, " : "",
- (state & RADEON_UPLOAD_VERTFMT) ? "vertfmt, " : "",
(state & RADEON_UPLOAD_LINE) ? "line, " : "",
(state & RADEON_UPLOAD_BUMPMAP) ? "bumpmap, " : "",
(state & RADEON_UPLOAD_MASKS) ? "masks, " : "",
@@ -875,246 +1101,30 @@ static void radeonDDPrintDirty( const char *msg, GLuint state )
(state & RADEON_UPLOAD_MISC) ? "misc, " : "",
(state & RADEON_UPLOAD_TEX0) ? "tex0, " : "",
(state & RADEON_UPLOAD_TEX1) ? "tex1, " : "",
- (state & RADEON_UPLOAD_TEX2) ? "tex2, " : "",
- (state & RADEON_UPLOAD_TEX0IMAGES) ? "tex0 images, " : "",
- (state & RADEON_UPLOAD_TEX1IMAGES) ? "tex1 images, " : "",
- (state & RADEON_UPLOAD_TEX2IMAGES) ? "tex2 images, " : "",
- (state & RADEON_UPLOAD_CLIPRECTS) ? "cliprects, " : "",
- (state & RADEON_REQUIRE_QUIESCENCE) ? "quiescence, " : "" );
-}
-
-/*
- * Load the current context's state into the hardware.
- *
- * NOTE: Be VERY careful about ensuring the context state is marked for
- * upload, the only place it shouldn't be uploaded is when the setup
- * state has changed in ReducedPrimitiveChange as this comes right after
- * a state update.
- *
- * Blits of any type should always upload the context and masks after
- * they are done.
- */
-void radeonEmitHwStateLocked( radeonContextPtr rmesa )
-{
- RADEONSAREAPrivPtr sarea = rmesa->sarea;
- radeon_context_regs_t *regs = &(rmesa->setup);
- radeonTexObjPtr t0 = rmesa->CurrentTexObj[0];
- radeonTexObjPtr t1 = rmesa->CurrentTexObj[1];
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG ) {
- radeonDDPrintDirty( "radeonEmitHwStateLocked", rmesa->dirty );
- }
-
- if ( (rmesa->dirty & RADEON_UPLOAD_TEX0IMAGES) && t0 ) {
- radeonUploadTexImages( rmesa, t0 );
- rmesa->dirty &= ~RADEON_UPLOAD_TEX0IMAGES;
- }
- if ( (rmesa->dirty & RADEON_UPLOAD_TEX1IMAGES) && t1 ) {
- radeonUploadTexImages( rmesa, t1 );
- rmesa->dirty &= ~RADEON_UPLOAD_TEX1IMAGES;
- }
- if ( rmesa->dirty & RADEON_UPLOAD_TEX2IMAGES ) {
- /* FIXME: Enable the third texture unit... */
- rmesa->dirty &= ~RADEON_UPLOAD_TEX2IMAGES;
- }
-
- if ( rmesa->dirty & (RADEON_UPLOAD_CONTEXT |
- RADEON_UPLOAD_VERTFMT |
- RADEON_UPLOAD_LINE |
- RADEON_UPLOAD_BUMPMAP |
- RADEON_UPLOAD_MASKS |
- RADEON_UPLOAD_VIEWPORT |
- RADEON_UPLOAD_SETUP |
- RADEON_UPLOAD_TCL |
- RADEON_UPLOAD_MISC) ) {
- memcpy( &sarea->ContextState, regs, sizeof(sarea->ContextState) );
- }
-
- /* Assemble the texture state, combining the texture object and
- * texture environment state into the hardware texture unit state.
- */
- if ( (rmesa->dirty & RADEON_UPLOAD_TEX0) && t0 ) {
- radeon_texture_regs_t *tex = &sarea->TexState[0];
-
- tex->pp_txfilter = t0->pp_txfilter | rmesa->lod_bias[0] << 8;
- tex->pp_txformat = t0->pp_txformat | RADEON_TXFORMAT_ST_ROUTE_STQ0;
- tex->pp_txoffset = t0->pp_txoffset;
-
- tex->pp_txcblend = rmesa->color_combine[0];
- tex->pp_txablend = rmesa->alpha_combine[0];
- tex->pp_tfactor = rmesa->env_color[0];
-
- tex->pp_border_color = t0->pp_border_color;
- }
-
- if ( (rmesa->dirty & RADEON_UPLOAD_TEX1) && t1 ) {
- radeon_texture_regs_t *tex = &sarea->TexState[1];
-
- tex->pp_txfilter = t1->pp_txfilter | rmesa->lod_bias[1] << 8;
- tex->pp_txformat = t1->pp_txformat | RADEON_TXFORMAT_ST_ROUTE_STQ1;
- tex->pp_txoffset = t1->pp_txoffset;
-
- tex->pp_txcblend = rmesa->color_combine[1];
- tex->pp_txablend = rmesa->alpha_combine[1];
- tex->pp_tfactor = rmesa->env_color[1];
-
- tex->pp_border_color = t1->pp_border_color;
- }
-
- if ( rmesa->dirty & RADEON_UPLOAD_TEX2 ) {
- /* FIXME: Enable the third texture unit... */
- memset( &sarea->TexState[2], 0, sizeof(sarea->TexState[2]) );
- }
-
- sarea->vertsize = rmesa->vertsize;
- sarea->vc_format = rmesa->vc_format;
-
- sarea->dirty |= rmesa->dirty;
- rmesa->dirty &= RADEON_UPLOAD_CLIPRECTS;
-}
-
-static void radeonDDPrintState( const char *msg, GLuint flags )
-{
- fprintf( stderr,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
- msg,
- flags,
- (flags & RADEON_NEW_CONTEXT) ? "context, " : "",
- (flags & RADEON_NEW_ALPHA) ? "alpha, " : "",
- (flags & RADEON_NEW_DEPTH) ? "depth, " : "",
- (flags & RADEON_NEW_FOG) ? "fog, " : "",
- (flags & RADEON_NEW_CLIP) ? "clip, " : "",
- (flags & RADEON_NEW_TEXTURE) ? "texture, " : "",
- (flags & RADEON_NEW_CULL) ? "cull, " : "",
- (flags & RADEON_NEW_MASKS) ? "masks, " : "",
- (flags & RADEON_NEW_WINDOW) ? "window, " : "" );
+ (state & RADEON_UPLOAD_TEX2) ? "tex2, " : "");
}
-void radeonDDUpdateHWState( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- int new_state = rmesa->new_state;
-
- if ( new_state ) {
- FLUSH_BATCH( rmesa );
-
- rmesa->new_state = 0;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG )
- radeonDDPrintState( "radeonUpdateHwState", new_state );
-
- /* Update the various parts of the context's state.
- */
- if ( new_state & RADEON_NEW_ALPHA )
- radeonUpdateAlphaMode( ctx );
-
- if ( new_state & RADEON_NEW_DEPTH )
- radeonUpdateZMode( ctx );
- if ( new_state & RADEON_NEW_FOG )
- radeonUpdateFogAttrib( ctx );
- if ( new_state & RADEON_NEW_CLIP )
- radeonUpdateClipping( ctx );
- if ( new_state & RADEON_NEW_CULL )
- radeonUpdateCull( ctx );
- if ( new_state & RADEON_NEW_MASKS )
- radeonUpdateMasks( ctx );
-
- if ( new_state & RADEON_NEW_WINDOW )
- radeonUpdateWindow( ctx );
-
- if ( new_state & RADEON_NEW_TEXTURE )
- radeonUpdateTextureState( ctx );
- }
-}
-
-/* This is called when Mesa switches between rendering triangle
- * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc),
- * and lines, points and bitmaps.
- *
- * As the radeon uses triangles to render lines and points, it is
- * necessary to turn off hardware culling when rendering these
- * primitives.
- */
-static void radeonDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
+static void radeonInvalidateState( GLcontext *ctx, GLuint new_state )
{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint s = rmesa->setup.se_cntl;
-
- s |= RADEON_FFACE_SOLID | RADEON_BFACE_SOLID;
-
- if ( ctx->Polygon.CullFlag && ctx->PB->primitive == GL_POLYGON ) {
- switch ( ctx->Polygon.CullFaceMode ) {
- case GL_FRONT:
- s &= ~RADEON_FFACE_SOLID;
- break;
- case GL_BACK:
- s &= ~RADEON_BFACE_SOLID;
- break;
- case GL_FRONT_AND_BACK:
- s &= ~(RADEON_FFACE_SOLID | RADEON_BFACE_SOLID);
- break;
- }
- }
-
- if ( rmesa->setup.se_cntl != s ) {
- FLUSH_BATCH( rmesa );
- rmesa->setup.se_cntl = s;
-
- /* NOTE: Only upload the setup state, everything else has been
- * uploaded by the usual means already. Also, note that this is
- * an optimization (see comment in the kernel's radeon_state.c),
- * which will not be necessary when/if we use the Radeon's
- * native point/line support.
- */
- rmesa->dirty |= RADEON_UPLOAD_SETUP;
- }
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ RADEON_CONTEXT(ctx)->NewGLState |= new_state;
}
-#define INTERESTED (~(NEW_MODELVIEW | \
- NEW_PROJECTION | \
- NEW_TEXTURE_MATRIX | \
- NEW_USER_CLIP | \
- NEW_CLIENT_STATE))
-
-void radeonDDUpdateState( GLcontext *ctx )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- if ( ctx->NewState & INTERESTED ) {
- radeonDDChooseRenderState( ctx );
- radeonDDChooseRasterSetupFunc( ctx );
- }
-
- /* Need to do this here to detect texture fallbacks before
- * setting triangle functions.
- * GH: Do we need this anymore? The Radeon doesn't really have
- * texturing fallbacks like the r128...
- */
- if ( rmesa->new_state & RADEON_NEW_TEXTURE ) {
- radeonDDUpdateHWState( ctx );
- }
-
- if ( !rmesa->Fallback ) {
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
- ctx->IndirectTriangles |= rmesa->IndirectTriangles;
-
- ctx->Driver.PointsFunc = rmesa->PointsFunc;
- ctx->Driver.LineFunc = rmesa->LineFunc;
- ctx->Driver.TriangleFunc = rmesa->TriangleFunc;
- ctx->Driver.QuadFunc = rmesa->QuadFunc;
- }
-}
/* Initialize the context's hardware state.
*/
-void radeonDDInitState( radeonContextPtr rmesa )
+void radeonInitState( radeonContextPtr rmesa )
{
+ GLcontext *ctx = rmesa->glCtx;
GLuint color_fmt, depth_fmt;
switch ( rmesa->radeonScreen->cpp ) {
@@ -1129,248 +1139,212 @@ void radeonDDInitState( radeonContextPtr rmesa )
exit( -1 );
}
- rmesa->ClearColor = 0x00000000;
+ rmesa->state.color.clear = 0x00000000;
- switch ( rmesa->glCtx->Visual->DepthBits ) {
+ switch ( ctx->Visual.depthBits ) {
case 16:
- rmesa->ClearDepth = 0x0000ffff;
- rmesa->DepthMask= 0xffffffff;
+ rmesa->state.depth.clear = 0x0000ffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffff;
depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
- rmesa->depth_scale = 1.0 / (GLfloat)0xffff;
+ rmesa->state.stencil.clear = 0x00000000;
break;
case 24:
- rmesa->ClearDepth = 0x00ffffff;
- rmesa->DepthMask= 0x00ffffff;
+ rmesa->state.depth.clear = 0x00ffffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffffff;
depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
- rmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
+ rmesa->state.stencil.clear = 0xffff0000;
break;
default:
fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
- rmesa->glCtx->Visual->DepthBits );
+ ctx->Visual.depthBits );
exit( -1 );
}
- rmesa->RenderIndex = RADEON_FALLBACK_BIT;
- rmesa->PointsFunc = NULL;
- rmesa->LineFunc = NULL;
- rmesa->TriangleFunc = NULL;
- rmesa->QuadFunc = NULL;
+ /* Only have hw stencil when depth buffer is 24 bits deep */
+ rmesa->state.stencil.hwBuffer = ( ctx->Visual.stencilBits > 0 &&
+ ctx->Visual.depthBits == 24 );
- rmesa->IndirectTriangles = 0;
+ rmesa->RenderIndex = ~0;
rmesa->Fallback = 0;
+ rmesa->render_primitive = GL_TRIANGLES;
+ rmesa->hw_primitive = RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST;
- if ( rmesa->glCtx->Visual->DBflag ) {
- rmesa->DrawBuffer = GL_BACK_LEFT;
- rmesa->drawOffset = rmesa->readOffset = rmesa->radeonScreen->backOffset;
- rmesa->drawPitch = rmesa->readPitch = rmesa->radeonScreen->backPitch;
+ if ( ctx->Visual.doubleBufferMode ) {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
} else {
- rmesa->DrawBuffer = GL_FRONT_LEFT;
- rmesa->drawOffset = rmesa->readOffset = rmesa->radeonScreen->frontOffset;
- rmesa->drawPitch = rmesa->readPitch = rmesa->radeonScreen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
}
+ rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
+ rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
/* Harware state:
*/
- rmesa->setup.pp_misc = (RADEON_ALPHA_TEST_PASS |
- RADEON_CHROMA_FUNC_FAIL |
- RADEON_CHROMA_KEY_NEAREST |
- RADEON_SHADOW_FUNC_EQUAL |
- RADEON_SHADOW_PASS_1 |
- RADEON_RIGHT_HAND_CUBE_OGL);
-
- rmesa->setup.pp_fog_color = ((0x00000000 & RADEON_FOG_COLOR_MASK) |
- RADEON_FOG_VERTEX |
- RADEON_FOG_USE_DEPTH);
-
- rmesa->setup.re_solid_color = 0x00000000;
-
- rmesa->setup.rb3d_blendcntl = (RADEON_SRC_BLEND_GL_ONE |
- RADEON_DST_BLEND_GL_ZERO );
-
- rmesa->setup.rb3d_depthoffset = rmesa->radeonScreen->depthOffset;
-
- rmesa->setup.rb3d_depthpitch = ((rmesa->radeonScreen->depthPitch &
- RADEON_DEPTHPITCH_MASK) |
- RADEON_DEPTH_ENDIAN_NO_SWAP);
-
- rmesa->setup.rb3d_zstencilcntl = (depth_fmt |
- RADEON_Z_TEST_LESS |
- RADEON_STENCIL_TEST_ALWAYS |
- RADEON_STENCIL_S_FAIL_KEEP |
- RADEON_STENCIL_ZPASS_KEEP |
- RADEON_STENCIL_ZFAIL_KEEP |
- RADEON_Z_WRITE_ENABLE);
-
- rmesa->setup.pp_cntl = (RADEON_SCISSOR_ENABLE |
- RADEON_ANTI_ALIAS_NONE);
-
- rmesa->setup.rb3d_cntl = (RADEON_PLANE_MASK_ENABLE |
- color_fmt |
- RADEON_ZBLOCK16);
-
- rmesa->setup.rb3d_coloroffset = (rmesa->drawOffset &
- RADEON_COLOROFFSET_MASK);
-
- rmesa->setup.re_width_height = ((0x7ff << RADEON_RE_WIDTH_SHIFT) |
- (0x7ff << RADEON_RE_HEIGHT_SHIFT));
-
- rmesa->setup.rb3d_colorpitch = ((rmesa->drawPitch &
- RADEON_COLORPITCH_MASK) |
- RADEON_COLOR_ENDIAN_NO_SWAP);
-
- rmesa->setup.se_cntl = (RADEON_FFACE_CULL_CW |
- RADEON_BFACE_SOLID |
- RADEON_FFACE_SOLID |
- RADEON_FLAT_SHADE_VTX_LAST |
- RADEON_DIFFUSE_SHADE_GOURAUD |
- RADEON_ALPHA_SHADE_GOURAUD |
- RADEON_SPECULAR_SHADE_GOURAUD |
- RADEON_FOG_SHADE_GOURAUD |
- RADEON_VPORT_XY_XFORM_ENABLE |
- RADEON_VPORT_Z_XFORM_ENABLE |
- RADEON_VTX_PIX_CENTER_OGL |
- RADEON_ROUND_MODE_TRUNC |
- RADEON_ROUND_PREC_8TH_PIX);
-
- rmesa->setup.se_coord_fmt = (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
- RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
- RADEON_TEX1_W_ROUTING_USE_Q1);
-
- rmesa->setup.re_line_pattern = ((0x0000 & RADEON_LINE_PATTERN_MASK) |
- (0 << RADEON_LINE_REPEAT_COUNT_SHIFT) |
- (0 << RADEON_LINE_PATTERN_START_SHIFT) |
- RADEON_LINE_PATTERN_LITTLE_BIT_ORDER);
-
- rmesa->setup.re_line_state = ((0 << RADEON_LINE_CURRENT_PTR_SHIFT) |
- (0 << RADEON_LINE_CURRENT_COUNT_SHIFT));
-
- rmesa->setup.se_line_width = 0x0000000;
-
- rmesa->setup.pp_lum_matrix = 0x00000000;
-
- rmesa->setup.pp_rot_matrix_0 = 0x00000000;
- rmesa->setup.pp_rot_matrix_1 = 0x00000000;
-
- rmesa->setup.rb3d_stencilrefmask = ((0x00 << RADEON_STENCIL_REF_SHIFT) |
- (0xff << RADEON_STENCIL_MASK_SHIFT) |
- (0xff << RADEON_STENCIL_WRITEMASK_SHIFT));
-
- rmesa->setup.rb3d_ropcntl = 0x00000000;
- rmesa->setup.rb3d_planemask = 0xffffffff;
-
- rmesa->setup.se_vport_xscale = 0x00000000;
- rmesa->setup.se_vport_xoffset = 0x00000000;
- rmesa->setup.se_vport_yscale = 0x00000000;
- rmesa->setup.se_vport_yoffset = 0x00000000;
- rmesa->setup.se_vport_zscale = 0x00000000;
- rmesa->setup.se_vport_zoffset = 0x00000000;
-
- rmesa->setup.se_cntl_status = (RADEON_VC_NO_SWAP |
- RADEON_TCL_BYPASS);
-
-#ifdef TCL_ENABLE
- /* FIXME: Obviously these need to be properly initialized */
- rmesa->setup.se_tcl_material_emmissive.red = 0x00000000;
- rmesa->setup.se_tcl_material_emmissive.green = 0x00000000;
- rmesa->setup.se_tcl_material_emmissive.blue = 0x00000000;
- rmesa->setup.se_tcl_material_emmissive.alpha = 0x00000000;
-
- rmesa->setup.se_tcl_material_ambient.red = 0x00000000;
- rmesa->setup.se_tcl_material_ambient.green = 0x00000000;
- rmesa->setup.se_tcl_material_ambient.blue = 0x00000000;
- rmesa->setup.se_tcl_material_ambient.alpha = 0x00000000;
-
- rmesa->setup.se_tcl_material_diffuse.red = 0x00000000;
- rmesa->setup.se_tcl_material_diffuse.green = 0x00000000;
- rmesa->setup.se_tcl_material_diffuse.blue = 0x00000000;
- rmesa->setup.se_tcl_material_diffuse.alpha = 0x00000000;
-
- rmesa->setup.se_tcl_material_specular.red = 0x00000000;
- rmesa->setup.se_tcl_material_specular.green = 0x00000000;
- rmesa->setup.se_tcl_material_specular.blue = 0x00000000;
- rmesa->setup.se_tcl_material_specular.alpha = 0x00000000;
-
- rmesa->setup.se_tcl_shininess = 0x00000000;
- rmesa->setup.se_tcl_output_vtx_fmt = 0x00000000;
- rmesa->setup.se_tcl_output_vtx_sel = 0x00000000;
- rmesa->setup.se_tcl_matrix_select_0 = 0x00000000;
- rmesa->setup.se_tcl_matrix_select_1 = 0x00000000;
- rmesa->setup.se_tcl_ucp_vert_blend_ctl = 0x00000000;
- rmesa->setup.se_tcl_texture_proc_ctl = 0x00000000;
- rmesa->setup.se_tcl_light_model_ctl = 0x00000000;
- for ( i = 0 ; i < 4 ; i++ ) {
- rmesa->setup.se_tcl_per_light_ctl[i] = 0x00000000;
- }
+ rmesa->state.hw.context.pp_misc = (RADEON_ALPHA_TEST_PASS |
+ RADEON_CHROMA_FUNC_FAIL |
+ RADEON_CHROMA_KEY_NEAREST |
+ RADEON_SHADOW_FUNC_EQUAL |
+ RADEON_SHADOW_PASS_1 |
+ RADEON_RIGHT_HAND_CUBE_OGL);
+
+ rmesa->state.hw.context.pp_fog_color = ((0x00000000 & RADEON_FOG_COLOR_MASK) |
+ RADEON_FOG_VERTEX |
+ RADEON_FOG_USE_DEPTH);
+
+ rmesa->state.hw.context.re_solid_color = 0x00000000;
+
+ rmesa->state.hw.context.rb3d_blendcntl = (RADEON_COMB_FCN_ADD_CLAMP |
+ RADEON_SRC_BLEND_GL_ONE |
+ RADEON_DST_BLEND_GL_ZERO );
+
+ rmesa->state.hw.context.rb3d_depthoffset = rmesa->radeonScreen->depthOffset;
+
+ rmesa->state.hw.context.rb3d_depthpitch = ((rmesa->radeonScreen->depthPitch &
+ RADEON_DEPTHPITCH_MASK) |
+ RADEON_DEPTH_ENDIAN_NO_SWAP);
+
+ rmesa->state.hw.context.rb3d_zstencilcntl = (depth_fmt |
+ RADEON_Z_TEST_LESS |
+ RADEON_STENCIL_TEST_ALWAYS |
+ RADEON_STENCIL_FAIL_KEEP |
+ RADEON_STENCIL_ZPASS_KEEP |
+ RADEON_STENCIL_ZFAIL_KEEP |
+ RADEON_Z_WRITE_ENABLE);
+
+ rmesa->state.hw.context.pp_cntl = (RADEON_SCISSOR_ENABLE |
+ RADEON_ANTI_ALIAS_NONE);
+
+ rmesa->state.hw.context.rb3d_cntl = (RADEON_PLANE_MASK_ENABLE |
+ color_fmt |
+ RADEON_ZBLOCK16);
+
+ rmesa->state.hw.context.rb3d_coloroffset = (rmesa->state.color.drawOffset &
+ RADEON_COLOROFFSET_MASK);
+
+ rmesa->state.hw.context.re_width_height = ((0x7ff << RADEON_RE_WIDTH_SHIFT) |
+ (0x7ff << RADEON_RE_HEIGHT_SHIFT));
+
+ rmesa->state.hw.context.rb3d_colorpitch = ((rmesa->state.color.drawPitch &
+ RADEON_COLORPITCH_MASK) |
+ RADEON_COLOR_ENDIAN_NO_SWAP);
+
+ rmesa->state.hw.setup1.se_cntl = (RADEON_FFACE_CULL_CCW |
+ RADEON_BFACE_SOLID |
+ RADEON_FFACE_SOLID |
+ RADEON_FLAT_SHADE_VTX_LAST |
+ RADEON_DIFFUSE_SHADE_GOURAUD |
+ RADEON_ALPHA_SHADE_GOURAUD |
+ RADEON_SPECULAR_SHADE_GOURAUD |
+ RADEON_FOG_SHADE_GOURAUD |
+ RADEON_VPORT_XY_XFORM_ENABLE |
+ RADEON_VPORT_Z_XFORM_ENABLE |
+ RADEON_VTX_PIX_CENTER_OGL |
+ RADEON_ROUND_MODE_TRUNC |
+ RADEON_ROUND_PREC_8TH_PIX);
+
+ rmesa->state.hw.vertex.se_coord_fmt = (
+#if 1
+ RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
+ RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
+#else
+ RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
#endif
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+
+ rmesa->state.hw.setup2.se_cntl_status = (RADEON_VC_NO_SWAP |
+ RADEON_TCL_BYPASS);
+
+ rmesa->state.hw.line.re_line_pattern = ((0x0000 & RADEON_LINE_PATTERN_MASK) |
+ (0 << RADEON_LINE_REPEAT_COUNT_SHIFT) |
+ (0 << RADEON_LINE_PATTERN_START_SHIFT) |
+ RADEON_LINE_PATTERN_LITTLE_BIT_ORDER);
+
+ rmesa->state.hw.line.re_line_state = ((0 << RADEON_LINE_CURRENT_PTR_SHIFT) |
+ (1 << RADEON_LINE_CURRENT_COUNT_SHIFT));
+
+ rmesa->state.hw.line.se_line_width = (1 << 4);
+
+ rmesa->state.hw.bumpmap.pp_lum_matrix = 0x00000000;
+ rmesa->state.hw.bumpmap.pp_rot_matrix_0 = 0x00000000;
+ rmesa->state.hw.bumpmap.pp_rot_matrix_1 = 0x00000000;
- rmesa->setup.re_top_left = ((0 << RADEON_RE_LEFT_SHIFT) |
- (0 << RADEON_RE_TOP_SHIFT) );
+ rmesa->state.hw.mask.rb3d_stencilrefmask = ((0x00 << RADEON_STENCIL_REF_SHIFT) |
+ (0xff << RADEON_STENCIL_MASK_SHIFT) |
+ (0xff << RADEON_STENCIL_WRITEMASK_SHIFT));
- rmesa->setup.re_misc = ((0 << RADEON_STIPPLE_X_OFFSET_SHIFT) |
- (0 << RADEON_STIPPLE_Y_OFFSET_SHIFT) |
- RADEON_STIPPLE_BIG_BIT_ORDER);
+ rmesa->state.hw.mask.rb3d_ropcntl = RADEON_ROP_COPY;
+ rmesa->state.hw.mask.rb3d_planemask = 0xffffffff;
- rmesa->env_color[0] = 0x00000000;
- rmesa->env_color[1] = 0x00000000;
- rmesa->env_color[2] = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_xscale = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_xoffset = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_yscale = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_yoffset = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_zscale = 0x00000000;
+ rmesa->state.hw.viewport.se_vport_zoffset = 0x00000000;
- rmesa->new_state = RADEON_NEW_ALL;
+ rmesa->state.hw.misc.re_misc = ((0 << RADEON_STIPPLE_X_OFFSET_SHIFT) |
+ (0 << RADEON_STIPPLE_Y_OFFSET_SHIFT) |
+ RADEON_STIPPLE_BIG_BIT_ORDER);
+
+ rmesa->state.hw.dirty = RADEON_UPLOAD_CONTEXT_ALL;
}
/* Initialize the driver's state functions.
*/
-void radeonDDInitStateFuncs( GLcontext *ctx )
+void radeonInitStateFuncs( GLcontext *ctx )
{
- ctx->Driver.UpdateState = radeonDDUpdateState;
+ ctx->Driver.UpdateState = radeonInvalidateState;
- ctx->Driver.ClearIndex = NULL;
- ctx->Driver.ClearColor = radeonDDClearColor;
- ctx->Driver.Index = NULL;
- ctx->Driver.Color = radeonDDColor;
- ctx->Driver.SetDrawBuffer = radeonDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = radeonDDSetReadBuffer;
+ ctx->Driver.SetDrawBuffer = radeonSetDrawBuffer;
- ctx->Driver.IndexMask = NULL;
- ctx->Driver.ColorMask = radeonDDColorMask;
- ctx->Driver.LogicOp = NULL;
- ctx->Driver.Dither = NULL;
-
- ctx->Driver.NearFar = NULL;
-
- ctx->Driver.RenderStart = radeonDDUpdateHWState;
- ctx->Driver.RenderFinish = NULL;
- ctx->Driver.RasterSetup = NULL;
-
- ctx->Driver.RenderVBClippedTab = NULL;
- ctx->Driver.RenderVBCulledTab = NULL;
- ctx->Driver.RenderVBRawTab = NULL;
-
- ctx->Driver.ReducedPrimitiveChange = radeonDDReducedPrimitiveChange;
- ctx->Driver.MultipassFunc = NULL;
-
- ctx->Driver.AlphaFunc = radeonDDAlphaFunc;
- ctx->Driver.BlendEquation = radeonDDBlendEquation;
- ctx->Driver.BlendFunc = radeonDDBlendFunc;
- ctx->Driver.BlendFuncSeparate = radeonDDBlendFuncSeparate;
- ctx->Driver.ClearDepth = radeonDDClearDepth;
- ctx->Driver.CullFace = radeonDDCullFace;
- ctx->Driver.FrontFace = radeonDDFrontFace;
- ctx->Driver.DepthFunc = radeonDDDepthFunc;
- ctx->Driver.DepthMask = radeonDDDepthMask;
- ctx->Driver.DepthRange = NULL;
- ctx->Driver.Enable = radeonDDEnable;
- ctx->Driver.Fogfv = radeonDDFogfv;
+ ctx->Driver.AlphaFunc = radeonAlphaFunc;
+ ctx->Driver.BlendEquation = radeonBlendEquation;
+ ctx->Driver.BlendFunc = radeonBlendFunc;
+ ctx->Driver.BlendFuncSeparate = radeonBlendFuncSeparate;
+ ctx->Driver.ClearColor = radeonClearColor;
+ ctx->Driver.ClearDepth = radeonClearDepth;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearStencil = radeonClearStencil;
+ ctx->Driver.ColorMask = radeonColorMask;
+ ctx->Driver.CullFace = radeonCullFace;
+ ctx->Driver.DepthFunc = radeonDepthFunc;
+ ctx->Driver.DepthMask = radeonDepthMask;
+ ctx->Driver.DepthRange = radeonDepthRange;
+ ctx->Driver.Enable = radeonEnable;
+ ctx->Driver.Fogfv = radeonFogfv;
+ ctx->Driver.FrontFace = radeonFrontFace;
ctx->Driver.Hint = NULL;
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.LightModelfv = radeonLightModelfv;
ctx->Driver.Lightfv = NULL;
- ctx->Driver.LightModelfv = radeonDDLightModelfv;
- ctx->Driver.LogicOpcode = radeonDDLogicOpCode;
+ ctx->Driver.LineStipple = radeonLineStipple;
+ ctx->Driver.LineWidth = radeonLineWidth;
+ ctx->Driver.LogicOpcode = radeonLogicOpCode;
ctx->Driver.PolygonMode = NULL;
- ctx->Driver.PolygonStipple = radeonDDPolygonStipple;
- ctx->Driver.Scissor = radeonDDScissor;
- ctx->Driver.ShadeModel = radeonDDShadeModel;
- ctx->Driver.ClearStencil = NULL;
- ctx->Driver.StencilFunc = NULL;
- ctx->Driver.StencilMask = NULL;
- ctx->Driver.StencilOp = NULL;
- ctx->Driver.Viewport = NULL;
+ ctx->Driver.PolygonOffset = radeonPolygonOffset;
+ ctx->Driver.PolygonStipple = radeonPolygonStipple;
+ ctx->Driver.RenderMode = radeonRenderMode;
+ ctx->Driver.Scissor = radeonScissor;
+ ctx->Driver.ShadeModel = radeonShadeModel;
+ ctx->Driver.StencilFunc = radeonStencilFunc;
+ ctx->Driver.StencilMask = radeonStencilMask;
+ ctx->Driver.StencilOp = radeonStencilOp;
+ ctx->Driver.Viewport = radeonViewport;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_state.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_state.h
index 9a368d989..47406fcfc 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_state.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_state.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.h,v 1.1 2001/01/08 01:07:28 martin Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -41,15 +41,23 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_context.h"
-extern void radeonDDInitState( radeonContextPtr rmesa );
-extern void radeonDDInitStateFuncs( GLcontext *ctx );
-
-extern void radeonDDUpdateState( GLcontext *ctx );
-extern void radeonDDUpdateHWState( GLcontext *ctx );
+extern void radeonInitState( radeonContextPtr rmesa );
+extern void radeonInitStateFuncs( GLcontext *ctx );
extern void radeonUpdateWindow( GLcontext *ctx );
+extern void radeonSetCliprects( radeonContextPtr rmesa, GLenum mode );
+extern void radeonUpdateViewportOffset( GLcontext *ctx );
+
+extern void radeonPrintDirty( const char *msg, GLuint state );
+
+
+extern void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) do { \
+ if ( 0 ) fprintf( stderr, "FALLBACK in "__FUNCTION__": #%d=%d\n", \
+ bit, mode ); \
+ radeonFallback( rmesa->glCtx, bit, mode ); \
+} while (0)
-extern void radeonEmitHwStateLocked( radeonContextPtr rmesa );
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
index 83c22f878..7f8cd7584 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c
@@ -1,37 +1,32 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c,v 1.4 2001/05/21 21:43:52 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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$ */
/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
+ * Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ * VA Linux Systems Inc., Fremont, California.
*
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to 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.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
*/
#include "radeon_context.h"
@@ -40,13 +35,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_vb.h"
#include "radeon_tex.h"
-#include "mmath.h"
-#include "simple_list.h"
+#include "colormac.h"
+#include "context.h"
#include "enums.h"
+#include "image.h"
#include "mem.h"
+#include "mmath.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "texstore.h"
#include "texutil.h"
+/* =============================================================
+ * Utility functions:
+ */
+
static void radeonSetTexWrap( radeonTexObjPtr t, GLenum swrap, GLenum twrap )
{
t->pp_txfilter &= ~(RADEON_CLAMP_S_MASK | RADEON_CLAMP_T_MASK);
@@ -76,29 +80,67 @@ static void radeonSetTexWrap( radeonTexObjPtr t, GLenum swrap, GLenum twrap )
}
}
+static void radeonSetTexMaxAnisotropy( radeonTexObjPtr t, GLfloat max )
+{
+ t->pp_txfilter &= ~RADEON_MAX_ANISO_MASK;
+
+ if ( max == 1.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_1_TO_1;
+ } else if ( max <= 2.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_2_TO_1;
+ } else if ( max <= 4.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_4_TO_1;
+ } else if ( max <= 8.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_8_TO_1;
+ } else {
+ t->pp_txfilter |= RADEON_MAX_ANISO_16_TO_1;
+ }
+}
+
static void radeonSetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
{
+ GLuint anisotropy = (t->pp_txfilter & RADEON_MAX_ANISO_MASK);
+
t->pp_txfilter &= ~(RADEON_MIN_FILTER_MASK | RADEON_MAG_FILTER_MASK);
- switch ( minf ) {
- case GL_NEAREST:
- t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST;
- break;
- case GL_LINEAR:
- t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR;
- break;
- case GL_NEAREST_MIPMAP_NEAREST:
- t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_NEAREST;
- break;
- case GL_NEAREST_MIPMAP_LINEAR:
- t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_NEAREST;
- break;
- case GL_LINEAR_MIPMAP_NEAREST:
- t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_LINEAR;
- break;
- case GL_LINEAR_MIPMAP_LINEAR:
- t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_LINEAR;
- break;
+ if ( anisotropy == RADEON_MAX_ANISO_1_TO_1 ) {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+ } else {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
+ break;
+ }
}
switch ( magf ) {
@@ -116,14 +158,17 @@ static void radeonSetTexBorderColor( radeonTexObjPtr t, GLubyte c[4] )
t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
}
+
static radeonTexObjPtr radeonAllocTexObj( struct gl_texture_object *texObj )
{
radeonTexObjPtr t;
t = CALLOC_STRUCT( radeon_tex_obj );
+ if (!t)
+ return NULL;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, texObj, t );
+ fprintf( stderr, __FUNCTION__"( %p, %p )\n", texObj, t );
}
/* Initialize non-image-dependent parts of the state:
@@ -139,6 +184,7 @@ static radeonTexObjPtr radeonAllocTexObj( struct gl_texture_object *texObj )
make_empty_list( t );
radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
radeonSetTexBorderColor( t, texObj->BorderColor );
@@ -146,113 +192,66 @@ static radeonTexObjPtr radeonAllocTexObj( struct gl_texture_object *texObj )
}
-static GLint radeonChooseTexFormat( radeonContextPtr rmesa,
- struct gl_texture_image *texImage,
- GLenum format, GLenum type )
+static const struct gl_texture_format *
+radeonChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
const GLboolean do32bpt = ( rmesa->radeonScreen->cpp == 4 );
- const struct gl_texture_format *texFormat;
- GLint ret;
-
- if ( 0 )
- fprintf( stderr, "internal=%s format=%s type=%s\n",
- texImage->IntFormat == 3 ? "GL_RGB (3)" :
- texImage->IntFormat == 4 ? "GL_RGBA (4)" :
- gl_lookup_enum_by_nr( texImage->IntFormat ),
- gl_lookup_enum_by_nr( format ),
- gl_lookup_enum_by_nr( type ) );
-
-#define SET_FORMAT( r, gl ) \
- do { \
- ret = (r); \
- texFormat = &(gl); \
- } while (0)
-
-#define SET_FORMAT_32BPT( r32, gl32, r16, gl16 ) \
- do { \
- if ( do32bpt ) { \
- ret = (r32); \
- texFormat = &(gl32); \
- } else { \
- ret = (r16); \
- texFormat = &(gl16); \
- } \
- } while (0)
-
- switch ( texImage->IntFormat ) {
- /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
- * got to be better than sticking them way down the end of this
- * huge list.
- */
- case GL_RGBA:
+
+ switch ( internalFormat ) {
case 4:
+ case GL_RGBA:
if ( format == GL_BGRA ) {
if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
- SET_FORMAT( RADEON_TXFORMAT_ARGB8888, _mesa_texformat_argb8888 );
- break;
- } else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- SET_FORMAT( RADEON_TXFORMAT_ARGB4444, _mesa_texformat_argb4444 );
- break;
- } else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- SET_FORMAT( RADEON_TXFORMAT_ARGB1555, _mesa_texformat_argb1555 );
- break;
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
}
}
- SET_FORMAT_32BPT( RADEON_TXFORMAT_RGBA8888, _mesa_texformat_rgba8888,
- RADEON_TXFORMAT_ARGB4444, _mesa_texformat_argb4444 );
- break;
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
- case GL_RGB:
case 3:
+ case GL_RGB:
if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
- SET_FORMAT( RADEON_TXFORMAT_RGB565, _mesa_texformat_rgb565 );
- break;
+ return &_mesa_texformat_rgb565;
}
- SET_FORMAT_32BPT( RADEON_TXFORMAT_RGBA8888, _mesa_texformat_rgba8888,
- RADEON_TXFORMAT_RGB565, _mesa_texformat_rgb565 );
- break;
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
- /* GH: Okay, keep checking as normal. Still test for GL_RGB,
- * GL_RGBA formats first.
- */
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- SET_FORMAT_32BPT( RADEON_TXFORMAT_RGBA8888, _mesa_texformat_rgba8888,
- RADEON_TXFORMAT_ARGB4444, _mesa_texformat_argb4444 );
- break;
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_argb4444;
case GL_RGBA4:
case GL_RGBA2:
- SET_FORMAT( RADEON_TXFORMAT_ARGB4444, _mesa_texformat_argb4444 );
- break;
+ return &_mesa_texformat_argb4444;
case GL_RGB5_A1:
- SET_FORMAT( RADEON_TXFORMAT_ARGB1555, _mesa_texformat_argb1555 );
- break;
+ return &_mesa_texformat_argb1555;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- SET_FORMAT_32BPT( RADEON_TXFORMAT_RGBA8888, _mesa_texformat_rgba8888,
- RADEON_TXFORMAT_RGB565, _mesa_texformat_rgb565 );
- break;
+ return do32bpt ? &_mesa_texformat_rgba8888 : &_mesa_texformat_rgb565;
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- SET_FORMAT( RADEON_TXFORMAT_RGB565, _mesa_texformat_rgb565 );
- break;
+ return &_mesa_texformat_rgb565;
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
- SET_FORMAT( RADEON_TXFORMAT_AI88, _mesa_texformat_al88 );
- break;
+ return &_mesa_texformat_al88;
case 1:
case GL_LUMINANCE:
@@ -260,8 +259,7 @@ static GLint radeonChooseTexFormat( radeonContextPtr rmesa,
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
- SET_FORMAT( RADEON_TXFORMAT_AI88, _mesa_texformat_al88 );
- break;
+ return &_mesa_texformat_al88;
case 2:
case GL_LUMINANCE_ALPHA:
@@ -271,550 +269,326 @@ static GLint radeonChooseTexFormat( radeonContextPtr rmesa,
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
- SET_FORMAT( RADEON_TXFORMAT_AI88, _mesa_texformat_al88 );
- break;
+ return &_mesa_texformat_al88;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
- SET_FORMAT( RADEON_TXFORMAT_I8, _mesa_texformat_i8 );
- break;
+ return &_mesa_texformat_i8;
- case GL_COLOR_INDEX:
- case GL_COLOR_INDEX1_EXT:
- case GL_COLOR_INDEX2_EXT:
- case GL_COLOR_INDEX4_EXT:
- case GL_COLOR_INDEX8_EXT:
- case GL_COLOR_INDEX12_EXT:
- case GL_COLOR_INDEX16_EXT:
default:
- fprintf( stderr, "bad texture format in radeonChooseTexFormat() %d",
- texImage->IntFormat );
- return -1;
+ _mesa_problem(ctx, "unexpected texture format in radeonChoosTexFormat");
+ return NULL;
}
- texImage->TexFormat = texFormat;
-
- return ret;
+ return NULL; /* never get here */
}
-/* ================================================================
- * Texture image callbacks
- */
-
-static GLboolean
-radeonDDTexImage1D( GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy )
+static void radeonTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
- GLuint texSize;
- GLint txformat;
- GLubyte *data;
-
- if ( target != GL_TEXTURE_1D )
- return GL_FALSE;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, texObj, level );
- }
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
if ( t ) {
- if ( t->bound ) FLUSH_BATCH( rmesa );
radeonSwapOutTexObj( rmesa, t );
- } else {
+ }
+ else {
t = radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
texObj->DriverData = t;
}
- txformat = radeonChooseTexFormat( rmesa, texImage, format, type );
- if ( txformat < 0 )
- return GL_FALSE;
-
- texFormat = texImage->TexFormat;
- texSize = texImage->Width * texFormat->TexelBytes;
-
- /* We really shouldn't have to keep the texture image, it should be
- * hung from the main texImage structure.
- */
- if ( t->image[level].data ) {
- FREE( t->image[level].data );
- t->image[level].data = NULL;
- }
-
- data = (GLubyte *) MALLOC( texSize );
- if ( !data )
- return GL_FALSE;
+ /* Note, this will call radeonChooseTextureFormat */
+ _mesa_store_teximage1d(ctx, target, level, internalFormat,
+ width, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
- if ( !_mesa_convert_texsubimage1d( texFormat->IntFormat,
- 0, texImage->Width,
- format, type, packing,
- pixels, data ) ) {
- /*fprintf( stderr, " *** convert failed!\n" );*/
- FREE( data );
- return GL_FALSE;
- }
-
- t->image[level].data = data;
t->dirty_images |= (1 << level);
- /* Format-specific hardware state:
- */
- t->pp_txformat &= ~(RADEON_TXFORMAT_FORMAT_MASK |
- RADEON_TXFORMAT_ALPHA_IN_MAP);
- t->pp_txformat |= txformat;
-
- if ( txformat == RADEON_TXFORMAT_RGBA8888 ||
- txformat == RADEON_TXFORMAT_ARGB4444 ||
- txformat == RADEON_TXFORMAT_ARGB1555 ||
- txformat == RADEON_TXFORMAT_AI88 ) {
- t->pp_txformat |= RADEON_TXFORMAT_ALPHA_IN_MAP;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
}
-
- ASSERT( t->image[level].data );
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
-
- *retainInternalCopy = GL_FALSE;
- return GL_TRUE;
}
-static GLboolean
-radeonDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy )
+
+static void radeonTexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
- GLuint texSize;
- GLint txformat;
- GLubyte *data;
-
- if ( target != GL_TEXTURE_2D )
- return GL_FALSE;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, texObj, level );
- }
+ assert( t ); /* this _should_ be true */
if ( t ) {
- if ( t->bound ) FLUSH_BATCH( rmesa );
- if ( t->image[level].data ) radeonSwapOutTexObj( rmesa, t );
- } else {
- t = radeonAllocTexObj( texObj );
- texObj->DriverData = t;
+ radeonSwapOutTexObj( rmesa, t );
+ t->dirty_images |= (1 << level);
}
-
- txformat = radeonChooseTexFormat( rmesa, texImage, format, type );
- if ( txformat < 0 )
- return GL_FALSE;
-
- texFormat = texImage->TexFormat;
- texSize = texImage->Width * texImage->Height * texFormat->TexelBytes;
-
- /* We really shouldn't have to keep the texture image, it should be
- * hung from the main texImage structure.
- */
- if ( t->image[level].data ) {
- FREE( t->image[level].data );
- t->image[level].data = NULL;
+ else {
+ t = radeonAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ texObj->DriverData = t;
}
- data = (GLubyte *) MALLOC( texSize );
- if ( !data )
- return GL_FALSE;
-
- if ( !_mesa_convert_texsubimage2d( texFormat->IntFormat,
- 0, 0, texImage->Width, texImage->Height,
- texImage->Width, format, type, packing,
- pixels, data ) ) {
- if ( 0 )
- fprintf( stderr, " *** convert failed! %s/%s-> %s\n",
- gl_lookup_enum_by_nr( format ),
- gl_lookup_enum_by_nr( type ),
- gl_lookup_enum_by_nr( texImage->IntFormat ) );
- FREE( data );
- return GL_FALSE;
- }
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
- t->image[level].data = data;
t->dirty_images |= (1 << level);
- /* Format-specific hardware state:
- */
- t->pp_txformat &= ~(RADEON_TXFORMAT_FORMAT_MASK |
- RADEON_TXFORMAT_ALPHA_IN_MAP);
- t->pp_txformat |= txformat;
-
- if ( txformat == RADEON_TXFORMAT_RGBA8888 ||
- txformat == RADEON_TXFORMAT_ARGB4444 ||
- txformat == RADEON_TXFORMAT_ARGB1555 ||
- txformat == RADEON_TXFORMAT_AI88 ) {
- t->pp_txformat |= RADEON_TXFORMAT_ALPHA_IN_MAP;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
}
-
- ASSERT( t->image[level].data );
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
-
- *retainInternalCopy = GL_FALSE;
- return GL_TRUE;
}
-/* GH: This is undoubtedly broken...
- */
-static GLboolean
-radeonDDTexImage3D( GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy )
+
+static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
- GLuint texSize;
- GLint txformat;
- GLubyte *data;
-
- if ( target != GL_TEXTURE_3D )
- return GL_FALSE;
if ( t ) {
- if ( t->bound ) FLUSH_BATCH( rmesa );
radeonSwapOutTexObj( rmesa, t );
- } else {
+ }
+ else {
t = radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
texObj->DriverData = t;
}
- txformat = radeonChooseTexFormat( rmesa, texImage, format, type );
- if ( txformat < 0 )
- return GL_FALSE;
+ /* Note, this will call radeonChooseTextureFormat */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
- texFormat = texImage->TexFormat;
- texSize = (texImage->Width * texImage->Height *
- texImage->Depth * texFormat->TexelBytes);
+ t->dirty_images |= (1 << level);
- /* We really shouldn't have to keep the texture image, it should be
- * hung from the main texImage structure.
- */
- if ( t->image[level].data ) {
- FREE( t->image[level].data );
- t->image[level].data = NULL;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
}
-
- data = (GLubyte *) MALLOC( texSize );
- if ( !data )
- return GL_FALSE;
-
- if ( !_mesa_convert_texsubimage3d( texFormat->IntFormat,
- 0, 0, 0, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->Width, texImage->Height,
- format, type, packing,
- pixels, data ) ) {
- FREE( data );
- return GL_FALSE;
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
}
-
- t->image[level].data = data;
- t->dirty_images |= (1 << level);
-
- ASSERT( t->image[level].data );
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
-
- *retainInternalCopy = GL_FALSE;
- return GL_TRUE;
}
-/* ================================================================
- * Texture subimage callbacks
- */
-
-static GLboolean
-radeonDDTexSubImage1D( GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLsizei width,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage )
+static void radeonTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
-
- if ( target != GL_TEXTURE_1D )
- return GL_FALSE;
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
- /* FIXME: Can this ever be NULL???
- */
- ASSERT( t );
- ASSERT( t->image[level].data );
-
- if ( t->bound )
- FLUSH_BATCH( rmesa );
-
- texFormat = texImage->TexFormat;
-
- if ( !_mesa_convert_texsubimage1d( texFormat->IntFormat,
- xoffset, width, format, type, packing,
- pixels, t->image[level].data ) ) {
- /*fprintf( stderr, " *** convert failed!\n" );*/
- return GL_FALSE;
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ radeonSwapOutTexObj( rmesa, t );
+ t->dirty_images |= (1 << level);
}
-
- t->dirty_images |= (1 << level);
- rmesa->new_state |= RADEON_NEW_TEXTURE;
-
- return GL_TRUE;
-}
-
-static GLboolean
-radeonDDTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
-
- if ( target != GL_TEXTURE_2D )
- return GL_FALSE;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, texObj, level );
+ else {
+ t = radeonAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ texObj->DriverData = t;
}
- /* FIXME: Can this ever be NULL???
- */
- ASSERT( t );
- ASSERT( t->image[level].data );
-
- if ( t->bound )
- FLUSH_BATCH( rmesa );
-
- texFormat = texImage->TexFormat;
-
- if ( !_mesa_convert_texsubimage2d( texFormat->IntFormat,
- xoffset, yoffset, width, height,
- texImage->Width, format, type, packing,
- pixels, t->image[level].data ) ) {
- /*fprintf( stderr, " *** convert failed!\n" );*/
- return GL_FALSE;
- }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
t->dirty_images |= (1 << level);
- rmesa->new_state |= RADEON_NEW_TEXTURE;
- return GL_TRUE;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
+ }
}
-/* GH: This is undoubtedly broken...
- */
-static GLboolean
-radeonDDTexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLint depth,
- GLenum format, GLenum type,
- const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage )
+#if 0
+static void radeonTexImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- const struct gl_texture_format *texFormat;
-
- if ( target != GL_TEXTURE_3D )
- return GL_FALSE;
- /* FIXME: Can this ever be NULL???
- */
- ASSERT( t );
- ASSERT( t->image[level].data );
-
- if ( t->bound )
- FLUSH_BATCH( rmesa );
-
- texFormat = texImage->TexFormat;
-
- if ( !_mesa_convert_texsubimage3d( texFormat->IntFormat,
- xoffset, yoffset, zoffset,
- width, height, depth,
- texImage->Width, texImage->Height,
- format, type, packing,
- pixels, t->image[level].data ) ) {
- /*fprintf( stderr, " *** convert failed!\n" );*/
- return GL_FALSE;
+ if ( t ) {
+ radeonSwapOutTexObj( rmesa, t );
}
+ else {
+ t = radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ /* Note, this will call radeonChooseTextureFormat */
+ _mesa_store_teximage3d(ctx, target, level, internalFormat,
+ width, height, depth, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
t->dirty_images |= (1 << level);
- rmesa->new_state |= RADEON_NEW_TEXTURE;
- return GL_TRUE;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
+ }
}
-/* ================================================================
- * DEPRECATED...
- */
-
-static GLvoid *radeonDDGetTexImage( GLcontext *ctx, GLenum target, GLint level,
- const struct gl_texture_object *texObj,
- GLenum *formatOut, GLenum *typeOut,
- GLboolean *freeImageOut )
+static void radeonTexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLint depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- const struct gl_texture_image *texImage = texObj->Image[level];
- const struct gl_texture_format *texFormat = texImage->TexFormat;
- radeonTexObjPtr t = (radeonTexObjPtr)texObj->DriverData;
- GLubyte *data;
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
- if ( !t || !t->image[level].data )
- return NULL;
+ assert( t ); /* this _should_ be true */
- data = (GLubyte *) MALLOC( texImage->Width * texImage->Height * 4 );
- if ( !data )
- return NULL;
+ _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
+ width, height, depth, format, type, pixels,
+ packing, texObj, texImage);
- if ( 0 )
- fprintf( stderr, " in=%d out=%s\n",
- texFormat->IntFormat,
- gl_lookup_enum_by_nr( texImage->Format ) );
+ t->dirty_images |= (1 << level);
- switch ( target ) {
- case GL_TEXTURE_1D:
- _mesa_unconvert_teximage1d( texFormat->IntFormat, texImage->Format,
- texImage->Width,
- t->image[level].data, data );
- break;
- case GL_TEXTURE_2D:
- _mesa_unconvert_teximage2d( texFormat->IntFormat, texImage->Format,
- texImage->Width, texImage->Height,
- t->image[level].data, data );
- break;
- default:
- return NULL;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
}
-
- *formatOut = texImage->Format;
- *typeOut = GL_UNSIGNED_BYTE;
- *freeImageOut = GL_TRUE;
-
- return data;
}
+#endif
-/* ================================================================
- * Texture state callbacks
- */
-
#define SCALED_FLOAT_TO_BYTE( x, scale ) \
((((GLint)((256.0F / scale) * (x))) - 1) / 2)
-static void radeonDDTexEnv( GLcontext *ctx, GLenum target,
- GLenum pname, const GLfloat *param )
+static void radeonTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct gl_texture_unit *texUnit;
- GLuint source;
- GLubyte c[4];
- GLuint col;
- GLfloat bias;
- GLubyte b;
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s( %s )\n",
- __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
}
switch ( pname ) {
- case GL_TEXTURE_ENV_MODE:
- FLUSH_BATCH( rmesa );
- rmesa->new_state |= RADEON_NEW_TEXTURE | RADEON_NEW_ALPHA;
- break;
-
- case GL_TEXTURE_ENV_COLOR:
- source = rmesa->tmu_source[ctx->Texture.CurrentUnit];
- texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- FLOAT_RGBA_TO_UBYTE_RGBA( c, texUnit->EnvColor );
- col = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
- if ( rmesa->env_color[source] != col ) {
- FLUSH_BATCH( rmesa );
- rmesa->env_color[source] = col;
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
+ case GL_TEXTURE_ENV_COLOR: {
+ GLubyte c[4];
+ GLuint envColor;
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
+ if ( rmesa->state.hw.texture[unit].pp_tfactor != envColor ) {
+ if ( rmesa->state.texture.unit[unit].texobj ) {
+ RADEON_STATECHANGE( rmesa, (RADEON_UPLOAD_TEX0 << unit) );
+ }
+ rmesa->state.hw.texture[unit].pp_tfactor = envColor;
}
break;
+ }
+
+ case GL_TEXTURE_LOD_BIAS_EXT: {
+ GLfloat bias;
+ GLuint b;
- case GL_TEXTURE_LOD_BIAS_EXT:
/* The Radeon's LOD bias is a signed 2's complement value with a
* range of -1.0 <= bias < 4.0. We break this into two linear
* functions, one mapping [-1.0,0.0] to [-128,0] and one mapping
* [0.0,4.0] to [0,127].
*/
- source = rmesa->tmu_source[ctx->Texture.CurrentUnit];
bias = CLAMP( *param, -1.0, 4.0 );
if ( bias == 0 ) {
b = 0;
} else if ( bias > 0 ) {
- b = (GLubyte) SCALED_FLOAT_TO_BYTE( bias, 4.0 );
+ b = ((GLuint)SCALED_FLOAT_TO_BYTE( bias, 4.0 )) << 8;
} else {
- b = (GLubyte) SCALED_FLOAT_TO_BYTE( bias, 1.0 );
+ b = ((GLuint)SCALED_FLOAT_TO_BYTE( bias, 1.0 )) << 8;
}
- if ( rmesa->lod_bias[source] != (GLuint)b ) {
- FLUSH_BATCH( rmesa );
- rmesa->lod_bias[source] = (GLuint)b;
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
+ if ( rmesa->state.hw.texture[unit].pp_txfilter != b ) {
+ if ( rmesa->state.texture.unit[unit].texobj )
+ RADEON_STATECHANGE( rmesa, (RADEON_UPLOAD_TEX0 << unit) );
+ rmesa->state.hw.texture[unit].pp_txfilter = b;
}
break;
+ }
default:
return;
}
}
-static void radeonDDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
+static void radeonTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLfloat *params )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %s )\n",
- __FUNCTION__, gl_lookup_enum_by_nr( pname ) );
+ fprintf( stderr, __FUNCTION__"( %s )\n",
+ _mesa_lookup_enum_by_nr( pname ) );
}
- /* If we don't have a hardware texture, it will be automatically
- * created with current state before it is used, so we don't have
- * to do anything now.
- */
- if ( !t )
- return;
-
if ( ( target != GL_TEXTURE_2D ) &&
( target != GL_TEXTURE_1D ) )
return;
@@ -822,94 +596,95 @@ static void radeonDDTexParameter( GLcontext *ctx, GLenum target,
switch ( pname ) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
- if ( t->bound ) FLUSH_BATCH( rmesa );
- radeonSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
break;
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
- if ( t->bound ) FLUSH_BATCH( rmesa );
- radeonSetTexWrap( t, tObj->WrapS, tObj->WrapT );
+ radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
break;
case GL_TEXTURE_BORDER_COLOR:
- if ( t->bound ) FLUSH_BATCH( rmesa );
- radeonSetTexBorderColor( t, tObj->BorderColor );
+ radeonSetTexBorderColor( t, texObj->BorderColor );
+ break;
+
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Radeon. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ radeonSwapOutTexObj( rmesa, t );
break;
default:
return;
}
- rmesa->new_state |= RADEON_NEW_TEXTURE;
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+ }
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
+ }
}
-static void radeonDDBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj )
+
+
+static void radeonBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
GLuint unit = ctx->Texture.CurrentUnit;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p ) unit=%d\n",
- __FUNCTION__, tObj, unit );
+ fprintf( stderr, __FUNCTION__"( %p ) unit=%d\n", texObj, unit );
}
- FLUSH_BATCH( rmesa );
-
- if ( !t ) {
- t = radeonAllocTexObj( tObj );
- tObj->DriverData = t;
- }
-
- /* Unbind a currently bound texture.
- */
- if ( rmesa->CurrentTexObj[unit] ) {
- rmesa->CurrentTexObj[unit]->bound &= ~(unit + 1);
- rmesa->CurrentTexObj[unit] = NULL;
+ if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
+ if ( !t ) {
+ t = radeonAllocTexObj( texObj );
+ texObj->DriverData = t;
+ }
}
-
- /* Bind to the given texture unit.
- */
- rmesa->CurrentTexObj[unit] = t;
- t->bound |= unit + 1;
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
}
-static void radeonDDDeleteTexture( GLcontext *ctx,
- struct gl_texture_object *tObj )
+static void radeonDeleteTexture( GLcontext *ctx,
+ struct gl_texture_object *texObj )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, __FUNCTION__ "( %p )\n", tObj );
+ fprintf( stderr, __FUNCTION__"( %p )\n", texObj );
}
if ( t ) {
- if ( t->bound ) {
- FLUSH_BATCH( rmesa );
- if ( t->bound & TEX_0 ) rmesa->CurrentTexObj[0] = NULL;
- if ( t->bound & TEX_1 ) rmesa->CurrentTexObj[1] = NULL;
- rmesa->new_state |= RADEON_NEW_TEXTURE;
+ if ( rmesa ) {
+ RADEON_FIREVERTICES( rmesa );
}
-
radeonDestroyTexObj( rmesa, t );
- tObj->DriverData = NULL;
+ texObj->DriverData = NULL;
}
}
-static GLboolean radeonDDIsTextureResident( GLcontext *ctx,
- struct gl_texture_object *tObj )
+static GLboolean radeonIsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *texObj )
{
- radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
return ( t && t->memBlock );
}
-static void radeonDDInitTextureObjects( GLcontext *ctx )
+
+static void radeonInitTextureObjects( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
struct gl_texture_object *texObj;
@@ -917,44 +692,57 @@ static void radeonDDInitTextureObjects( GLcontext *ctx )
ctx->Texture.CurrentUnit = 0;
- texObj = ctx->Texture.Unit[0].CurrentD[1];
- radeonDDBindTexture( ctx, GL_TEXTURE_1D, texObj );
- move_to_tail( &rmesa->SwappedOut, (radeonTexObjPtr)texObj->DriverData );
+ texObj = ctx->Texture.Unit[0].Current1D;
+ radeonBindTexture( ctx, GL_TEXTURE_1D, texObj );
+ move_to_tail( &rmesa->texture.swapped,
+ (radeonTexObjPtr)texObj->DriverData );
- texObj = ctx->Texture.Unit[0].CurrentD[2];
- radeonDDBindTexture( ctx, GL_TEXTURE_2D, texObj );
- move_to_tail( &rmesa->SwappedOut, (radeonTexObjPtr)texObj->DriverData );
+ texObj = ctx->Texture.Unit[0].Current2D;
+ radeonBindTexture( ctx, GL_TEXTURE_2D, texObj );
+ move_to_tail( &rmesa->texture.swapped,
+ (radeonTexObjPtr)texObj->DriverData );
ctx->Texture.CurrentUnit = 1;
- texObj = ctx->Texture.Unit[1].CurrentD[1];
- radeonDDBindTexture( ctx, GL_TEXTURE_1D, texObj );
- move_to_tail( &rmesa->SwappedOut, (radeonTexObjPtr)texObj->DriverData );
+ texObj = ctx->Texture.Unit[1].Current1D;
+ radeonBindTexture( ctx, GL_TEXTURE_1D, texObj );
+ move_to_tail( &rmesa->texture.swapped,
+ (radeonTexObjPtr)texObj->DriverData );
- texObj = ctx->Texture.Unit[1].CurrentD[2];
- radeonDDBindTexture( ctx, GL_TEXTURE_2D, texObj );
- move_to_tail( &rmesa->SwappedOut, (radeonTexObjPtr)texObj->DriverData );
+ texObj = ctx->Texture.Unit[1].Current2D;
+ radeonBindTexture( ctx, GL_TEXTURE_2D, texObj );
+ move_to_tail( &rmesa->texture.swapped,
+ (radeonTexObjPtr)texObj->DriverData );
ctx->Texture.CurrentUnit = tmp;
}
-void radeonDDInitTextureFuncs( GLcontext *ctx )
+void radeonInitTextureFuncs( GLcontext *ctx )
{
- ctx->Driver.TexImage1D = radeonDDTexImage1D;
- ctx->Driver.TexImage2D = radeonDDTexImage2D;
- ctx->Driver.TexImage3D = NULL; (void) radeonDDTexImage3D;
- ctx->Driver.TexSubImage1D = radeonDDTexSubImage1D;
- ctx->Driver.TexSubImage2D = radeonDDTexSubImage2D;
- ctx->Driver.TexSubImage3D = NULL; (void) radeonDDTexSubImage3D;
- ctx->Driver.GetTexImage = radeonDDGetTexImage;
- ctx->Driver.TexEnv = radeonDDTexEnv;
- ctx->Driver.TexParameter = radeonDDTexParameter;
- ctx->Driver.BindTexture = radeonDDBindTexture;
- ctx->Driver.DeleteTexture = radeonDDDeleteTexture;
- ctx->Driver.IsTextureResident = radeonDDIsTextureResident;
+ ctx->Driver.ChooseTextureFormat = radeonChooseTextureFormat;
+ ctx->Driver.TexImage1D = radeonTexImage1D;
+ ctx->Driver.TexImage2D = radeonTexImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = radeonTexSubImage1D;
+ ctx->Driver.TexSubImage2D = radeonTexSubImage2D;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
+ ctx->Driver.BindTexture = radeonBindTexture;
+ ctx->Driver.CreateTexture = NULL; /* FIXME: Is this used??? */
+ ctx->Driver.DeleteTexture = radeonDeleteTexture;
+ ctx->Driver.IsTextureResident = radeonIsTextureResident;
ctx->Driver.PrioritizeTexture = NULL;
ctx->Driver.ActiveTexture = NULL;
ctx->Driver.UpdateTexturePalette = NULL;
- radeonDDInitTextureObjects( ctx );
+ ctx->Driver.TexEnv = radeonTexEnv;
+ ctx->Driver.TexParameter = radeonTexParameter;
+
+ radeonInitTextureObjects( ctx );
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h
index b521b8f96..2d3613220 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -49,50 +49,9 @@ extern void radeonSwapOutTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
extern void radeonPrintLocalLRU( radeonContextPtr rmesa, int heap );
extern void radeonPrintGlobalLRU( radeonContextPtr rmesa, int heap );
-extern void radeonUpdateTexLRU(radeonContextPtr rmesa, radeonTexObjPtr t );
+extern void radeonUpdateTexLRU( radeonContextPtr rmesa, radeonTexObjPtr t );
-extern void radeonDDInitTextureFuncs( GLcontext *ctx );
-
-
-/* ================================================================
- * Color conversion macros:
- */
-
-#define RADEONPACKCOLOR332( r, g, b ) \
- (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
-
-#define RADEONPACKCOLOR1555( r, g, b, a ) \
- ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define RADEONPACKCOLOR565( r, g, b ) \
- ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define RADEONPACKCOLOR88( i, a ) \
- (((a) << 8) | (i))
-
-#define RADEONPACKCOLOR888( r, g, b ) \
- (((r) << 16) | ((g) << 8) | (b))
-
-#define RADEONPACKCOLOR8888( r, g, b, a ) \
- (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-
-#define RADEONPACKCOLOR4444( r, g, b, a ) \
- ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-static __inline__ CARD32 radeonPackColor( GLuint cpp,
- GLubyte r, GLubyte g,
- GLubyte b, GLubyte a )
-{
- switch ( cpp ) {
- case 2:
- return RADEONPACKCOLOR565( r, g, b );
- case 4:
- return RADEONPACKCOLOR8888( r, g, b, a );
- default:
- return 0;
- }
-}
+extern void radeonInitTextureFuncs( GLcontext *ctx );
#endif
#endif /* __RADEON_TEX_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c
index c022bfcd3..82461e034 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c,v 1.2 2001/04/10 16:07:53 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -40,29 +40,25 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_vb.h"
#include "radeon_tex.h"
+#include "context.h"
+#include "colormac.h"
#include "mmath.h"
+#include "macros.h"
#include "simple_list.h"
#include "enums.h"
#include "mem.h"
+
/* Destroy hardware state associated with texture `t'.
*/
void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
- GLint i;
-#if ENABLE_PERF_BOXES
- /* Bump the performace counter */
- rmesa->c_textureSwaps++;
-#endif
- if ( !t ) return;
+ if ( !t )
+ return;
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, t, t->tObj );
- }
-
- for ( i = 0 ; i < RADEON_MAX_TEXTURE_LEVELS ; i++ ) {
- if ( t->image[i].data ) FREE( t->image[i].data );
+ fprintf( stderr, __FUNCTION__"( %p, %p )\n", t, t->tObj );
}
if ( t->memBlock ) {
@@ -73,8 +69,20 @@ void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
if ( t->tObj )
t->tObj->DriverData = NULL;
- if ( t->bound & TEX_0 ) rmesa->CurrentTexObj[0] = NULL;
- if ( t->bound & TEX_1 ) rmesa->CurrentTexObj[1] = NULL;
+ if ( rmesa ) {
+ /* Bump the performace counter */
+ rmesa->c_textureSwaps++;
+
+ if ( t == rmesa->state.texture.unit[0].texobj ) {
+ rmesa->state.texture.unit[0].texobj = NULL;
+ rmesa->state.hw.dirty &= ~RADEON_UPLOAD_TEX0;
+ }
+
+ if ( t == rmesa->state.texture.unit[1].texobj ) {
+ rmesa->state.texture.unit[1].texobj = NULL;
+ rmesa->state.hw.dirty &= ~RADEON_UPLOAD_TEX1;
+ }
+ }
remove_from_list( t );
FREE( t );
@@ -85,19 +93,19 @@ void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
void radeonSwapOutTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, t, t->tObj );
+ fprintf( stderr, __FUNCTION__"( %p, %p )\n", t, t->tObj );
}
-#if ENABLE_PERF_BOXES
+
/* Bump the performace counter */
rmesa->c_textureSwaps++;
-#endif
+
if ( t->memBlock ) {
mmFreeMem( t->memBlock );
t->memBlock = NULL;
}
t->dirty_images = ~0;
- move_to_tail( &rmesa->SwappedOut, t );
+ move_to_tail( &rmesa->texture.swapped, t );
}
/* Print out debugging information about texture LRU.
@@ -109,7 +117,7 @@ void radeonPrintLocalLRU( radeonContextPtr rmesa, int heap )
fprintf( stderr, "\nLocal LRU, heap %d:\n", heap );
- foreach ( t, &rmesa->TexObjList[heap] ) {
+ foreach ( t, &rmesa->texture.objects[heap] ) {
if (!t->tObj) {
fprintf( stderr, "Placeholder %d at 0x%x sz 0x%x\n",
t->memBlock->ofs / sz,
@@ -182,7 +190,7 @@ static void radeonResetGlobalLRU( radeonContextPtr rmesa, int heap )
/* Update the local and glock texture LRUs.
*/
-void radeonUpdateTexLRU( radeonContextPtr rmesa, radeonTexObjPtr t )
+void radeonUpdateTexLRU(radeonContextPtr rmesa, radeonTexObjPtr t )
{
int heap = t->heap;
radeon_tex_region_t *list = rmesa->sarea->texList[heap];
@@ -191,7 +199,7 @@ void radeonUpdateTexLRU( radeonContextPtr rmesa, radeonTexObjPtr t )
int end = (t->memBlock->ofs + t->memBlock->size-1) >> sz;
int i;
- rmesa->lastTexAge[heap] = ++rmesa->sarea->texAge[heap];
+ rmesa->texture.age[heap] = ++rmesa->sarea->texAge[heap];
if ( !t->memBlock ) {
fprintf( stderr, "no memblock\n\n" );
@@ -199,12 +207,12 @@ void radeonUpdateTexLRU( radeonContextPtr rmesa, radeonTexObjPtr t )
}
/* Update our local LRU */
- move_to_head( &rmesa->TexObjList[heap], t );
+ move_to_head( &rmesa->texture.objects[heap], t );
/* Update the global LRU */
for ( i = start ; i <= end ; i++ ) {
list[i].in_use = 1;
- list[i].age = rmesa->lastTexAge[heap];
+ list[i].age = rmesa->texture.age[heap];
/* remove_from_list(i) */
list[(CARD32)list[i].next].prev = list[i].prev;
@@ -234,7 +242,7 @@ static void radeonTexturesGone( radeonContextPtr rmesa, int heap,
{
radeonTexObjPtr t, tmp;
- foreach_s ( t, tmp, &rmesa->TexObjList[heap] ) {
+ foreach_s ( t, tmp, &rmesa->texture.objects[heap] ) {
if ( t->memBlock->ofs >= offset + size ||
t->memBlock->ofs + t->memBlock->size <= offset )
continue;
@@ -249,14 +257,14 @@ static void radeonTexturesGone( radeonContextPtr rmesa, int heap,
t = (radeonTexObjPtr) CALLOC( sizeof(*t) );
if ( !t ) return;
- t->memBlock = mmAllocMem( rmesa->texHeap[heap], size, 0, offset );
+ t->memBlock = mmAllocMem( rmesa->texture.heap[heap], size, 0, offset );
if ( !t->memBlock ) {
fprintf( stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
(int)size, (int)offset );
- mmDumpMemInfo( rmesa->texHeap[heap] );
+ mmDumpMemInfo( rmesa->texture.heap[heap] );
return;
}
- insert_at_head( &rmesa->TexObjList[heap], t );
+ insert_at_head( &rmesa->texture.objects[heap], t );
}
}
@@ -269,7 +277,7 @@ void radeonAgeTextures( radeonContextPtr rmesa, int heap )
{
RADEONSAREAPrivPtr sarea = rmesa->sarea;
- if ( sarea->texAge[heap] != rmesa->lastTexAge[heap] ) {
+ if ( sarea->texAge[heap] != rmesa->texture.age[heap] ) {
int sz = 1 << rmesa->radeonScreen->logTexGranularity[heap];
int nr = 0;
int idx;
@@ -287,7 +295,7 @@ void radeonAgeTextures( radeonContextPtr rmesa, int heap )
break;
}
- if ( sarea->texList[heap][idx].age > rmesa->lastTexAge[heap] ) {
+ if ( sarea->texList[heap][idx].age > rmesa->texture.age[heap] ) {
radeonTexturesGone( rmesa, heap, idx * sz, sz,
sarea->texList[heap][idx].in_use );
}
@@ -299,16 +307,13 @@ void radeonAgeTextures( radeonContextPtr rmesa, int heap )
radeonResetGlobalLRU( rmesa, heap );
}
- rmesa->dirty |= (RADEON_UPLOAD_CONTEXT |
- RADEON_UPLOAD_TEX0IMAGES |
- RADEON_UPLOAD_TEX1IMAGES);
- rmesa->lastTexAge[heap] = sarea->texAge[heap];
+ rmesa->texture.age[heap] = sarea->texAge[heap];
}
}
-/* ================================================================
- * Texture image uploads
+/* =============================================================
+ * Texture image conversions
*/
/* Upload the texture image associated with texture `t' at level `level'
@@ -321,23 +326,28 @@ static void radeonUploadSubImage( radeonContextPtr rmesa,
struct gl_texture_image *texImage;
const struct gl_texture_format *texFormat;
GLint texelsPerDword = 0;
- GLint imageX, imageY, imageWidth, imageHeight;
- GLint blitX, blitY, blitWidth, blitHeight;
GLuint format, pitch, offset;
+ GLint imageWidth, imageHeight;
GLint ret;
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, t, t->tObj );
+ fprintf( stderr, __FUNCTION__"( %p, %p )\n", t, t->tObj );
}
/* Ensure we have a valid texture to upload */
+ level += t->firstLevel;
+ if ( ( level < 0 ) || ( level >= RADEON_MAX_TEXTURE_LEVELS ) ) {
+ _mesa_problem(NULL, "bad texture level in radeonUploadSubimage");
+ return;
+ }
+
texImage = t->tObj->Image[level];
if ( !texImage ) {
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE )
fprintf( stderr, __FUNCTION__ ": texImage %d is NULL!\n", level );
return;
}
- if ( !t->image[level].data ) {
+ if ( !texImage->Data ) {
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE )
fprintf( stderr, __FUNCTION__ ": image data is NULL!\n" );
return;
@@ -359,20 +369,24 @@ static void radeonUploadSubImage( radeonContextPtr rmesa,
format = t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK;
- imageX = 0;
- imageY = 0;
imageWidth = texImage->Width;
imageHeight = texImage->Height;
- blitX = t->image[level].x;
- blitY = t->image[level].y;
- blitWidth = t->image[level].width;
- blitHeight = t->image[level].height;
-
offset = t->bufAddr;
pitch = (t->image[0].width * texFormat->TexelBytes) / 64;
+#if 0
+ /* Bump the performace counter */
+ rmesa->c_textureBytes += (dwords << 2);
+#endif
+
if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG ) {
+ GLint imageX = 0;
+ GLint imageY = 0;
+ GLint blitX = t->image[level].x;
+ GLint blitY = t->image[level].y;
+ GLint blitWidth = t->image[level].width;
+ GLint blitHeight = t->image[level].height;
fprintf( stderr, " upload image: %d,%d at %d,%d\n",
imageWidth, imageHeight, imageX, imageY );
fprintf( stderr, " upload blit: %d,%d at %d,%d\n",
@@ -382,7 +396,8 @@ static void radeonUploadSubImage( radeonContextPtr rmesa,
(GLuint)offset, (GLuint)pitch, level, format );
}
- ret = drmRadeonLoadTexture( rmesa->driFd, offset, pitch, format,
+ t->image[level].data = texImage->Data;
+ ret = drmRadeonLoadTexture( rmesa->dri.fd, offset, pitch, format,
imageWidth, imageHeight, &t->image[level] );
if ( ret ) {
@@ -398,8 +413,7 @@ static void radeonUploadSubImage( radeonContextPtr rmesa,
exit( 1 );
}
- rmesa->new_state |= RADEON_NEW_CONTEXT;
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS;
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_MASKS );
}
/* Upload the texture images associated with texture `t'. This might
@@ -408,17 +422,21 @@ static void radeonUploadSubImage( radeonContextPtr rmesa,
*/
int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t )
{
+ const int numLevels = t->lastLevel - t->firstLevel + 1;
int i;
int heap;
if ( RADEON_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- fprintf( stderr, "%s( %p, %p ) sz=%d\n",
- __FUNCTION__, rmesa->glCtx, t->tObj, t->totalSize );
+ fprintf( stderr, __FUNCTION__"( %p, %p ) sz=%d lvls=%d-%d\n",
+ rmesa->glCtx, t->tObj, t->totalSize,
+ t->firstLevel, t->lastLevel );
}
if ( !t || t->totalSize == 0 )
return 0;
+ LOCK_HARDWARE( rmesa );
+
/* Choose the heap appropriately */
heap = t->heap = RADEON_CARD_HEAP;
#if 0
@@ -431,13 +449,13 @@ int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t )
/* Do we need to eject LRU texture objects? */
if ( !t->memBlock ) {
/* Allocate a memory block on a 4k boundary (1<<12 == 4096) */
- t->memBlock = mmAllocMem( rmesa->texHeap[heap],
+ t->memBlock = mmAllocMem( rmesa->texture.heap[heap],
t->totalSize, 12, 0 );
#if 0
/* Try AGP before kicking anything out of local mem */
if ( !t->memBlock && heap == RADEON_CARD_HEAP ) {
- t->memBlock = mmAllocMem( rmesa->texHeap[RADEON_AGP_HEAP],
+ t->memBlock = mmAllocMem( rmesa->texture.heap[RADEON_AGP_HEAP],
t->totalSize, 12, 0 );
if ( t->memBlock )
@@ -447,16 +465,19 @@ int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t )
/* Kick out textures until the requested texture fits */
while ( !t->memBlock ) {
- if ( rmesa->TexObjList[heap].prev->bound ) {
+ if ( rmesa->texture.objects[heap].prev->bound ) {
fprintf( stderr,
"radeonUploadTexImages: ran into bound texture\n" );
+ UNLOCK_HARDWARE( rmesa );
return -1;
}
- if ( rmesa->TexObjList[heap].prev == &rmesa->TexObjList[heap] ) {
+ if ( rmesa->texture.objects[heap].prev ==
+ &rmesa->texture.objects[heap] ) {
if ( rmesa->radeonScreen->IsPCI ) {
fprintf( stderr, "radeonUploadTexImages: upload texture "
"failure on local texture heaps, sz=%d\n",
t->totalSize );
+ UNLOCK_HARDWARE( rmesa );
return -1;
#if 0
} else if ( heap == RADEON_CARD_HEAP ) {
@@ -468,20 +489,21 @@ int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t )
"failure on both local and AGP texture heaps, "
"sz=%d\n",
t->totalSize );
+ UNLOCK_HARDWARE( rmesa );
return -1;
}
}
- radeonSwapOutTexObj( rmesa, rmesa->TexObjList[heap].prev );
+ radeonSwapOutTexObj( rmesa, rmesa->texture.objects[heap].prev );
- t->memBlock = mmAllocMem( rmesa->texHeap[heap],
+ t->memBlock = mmAllocMem( rmesa->texture.heap[heap],
t->totalSize, 12, 0 );
}
/* Set the base offset of the texture image */
t->bufAddr = rmesa->radeonScreen->texOffset[heap] + t->memBlock->ofs;
-
t->pp_txoffset = t->bufAddr;
+
#if 0
/* Fix AGP texture offsets */
if ( heap == RADEON_AGP_HEAP ) {
@@ -490,33 +512,29 @@ int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t )
}
#endif
- /* Force loading the new state into the hardware */
- if ( t->bound & TEX_0 ) {
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_TEX0;
- }
- if ( t->bound & TEX_1 ) {
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_TEX1;
- }
+ if ( t == rmesa->state.texture.unit[0].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX0 );
+
+ if ( t == rmesa->state.texture.unit[1].texobj )
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_TEX1 );
}
/* Let the world know we've used this memory recently */
radeonUpdateTexLRU( rmesa, t );
/* Upload any images that are new */
- if ( t->dirty_images ) {
- int levels = ((t->pp_txfilter & RADEON_MAX_MIP_LEVEL_MASK) >>
- RADEON_MAX_MIP_LEVEL_SHIFT);
-
- for ( i = 0 ; i <= levels ; i++ ) {
- if ( (t->dirty_images & (1 << i)) && t->image[i].data ) {
- radeonUploadSubImage( rmesa, t, i, 0, 0,
- t->image[i].width, t->image[i].height );
- }
+ if (t->dirty_images) {
+ for ( i = 0 ; i < numLevels ; i++ ) {
+ if ( t->dirty_images & (1 << i) ) {
+ radeonUploadSubImage( rmesa, t, i, 0, 0,
+ t->image[i].width, t->image[i].height );
+ }
}
-
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
+ t->dirty_images = 0;
}
- t->dirty_images = 0;
+
+ UNLOCK_HARDWARE( rmesa );
+
return 0;
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_texobj.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_texobj.h
deleted file mode 100644
index 8ed4ecdb9..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_texobj.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_texobj.h,v 1.3 2001/04/10 16:07:53 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifndef __RADEON_TEXOBJ_H__
-#define __RADEON_TEXOBJ_H__
-
-#include "radeon_sarea.h"
-#include "mm.h"
-
-#define TEX_0 1
-#define TEX_1 2
-
-typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
-
-/* Texture object in locally shared texture space.
- */
-struct radeon_tex_obj {
- radeonTexObjPtr next, prev;
-
- struct gl_texture_object *tObj; /* Mesa texture object */
-
- PMemBlock memBlock; /* Memory block containing texture */
- GLuint bufAddr; /* Offset to start of locally
- shared texture block */
-
- GLuint dirty_images; /* Flags for whether or not
- images need to be uploaded to
- local or AGP texture space */
-
- GLint bound; /* Texture unit currently bound to */
- GLint heap; /* Texture heap currently stored in */
-
- drmRadeonTexImage image[RADEON_MAX_TEXTURE_LEVELS];
-
- GLint totalSize; /* Total size of the texture
- including all mipmap levels */
-
- GLuint pp_txfilter; /* Hardware register values */
- GLuint pp_txformat;
- GLuint pp_txoffset;
- GLuint pp_border_color;
-};
-
-#endif /* __RADEON_TEXOBJ_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c
index 6a9f53255..d35b664c3 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c,v 1.1 2001/03/21 16:14:25 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -40,49 +40,85 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "radeon_vb.h"
#include "radeon_tex.h"
-#include "mmath.h"
-#include "simple_list.h"
+#include "colormac.h"
+#include "context.h"
#include "enums.h"
+#include "macros.h"
#include "mem.h"
+#include "mmath.h"
+#include "simple_list.h"
+#include "texformat.h"
+
static void radeonSetTexImages( radeonContextPtr rmesa,
struct gl_texture_object *tObj )
{
radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
- struct gl_texture_image *texImage = tObj->Image[0];
- const struct gl_texture_format *texFormat = texImage->TexFormat;
- GLint log2Width, log2Height, log2Size;
+ const struct gl_texture_image *baseImage = tObj->Image[tObj->BaseLevel];
GLint totalSize;
GLint texelsPerDword = 0, blitWidth = 0, blitPitch = 0;
GLint x, y, width, height;
GLint i;
+ GLint firstLevel, lastLevel, numLevels;
+ GLint log2Width, log2Height;
+ GLuint txformat = 0;
- /* Calculate dimensions in log domain.
+ /* Set the hardware texture format
*/
- for ( i = 1, log2Height = 0 ; i < texImage->Height ; i *= 2 ) {
- log2Height++;
+ switch (baseImage->TexFormat->MesaFormat) {
+ case MESA_FORMAT_I8:
+ txformat = RADEON_TXFORMAT_I8;
+ break;
+ case MESA_FORMAT_AL88:
+ txformat = RADEON_TXFORMAT_AI88;
+ break;
+ case MESA_FORMAT_RGBA8888:
+ txformat = RADEON_TXFORMAT_RGBA8888;
+ break;
+ case MESA_FORMAT_ARGB8888:
+ txformat = RADEON_TXFORMAT_ARGB8888;
+ break;
+ case MESA_FORMAT_RGB565:
+ txformat = RADEON_TXFORMAT_RGB565;
+ break;
+ case MESA_FORMAT_ARGB1555:
+ txformat = RADEON_TXFORMAT_ARGB1555;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ txformat = RADEON_TXFORMAT_ARGB4444;
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected texture format in radeonTexImage2D");
+ return;
}
- for ( i = 1, log2Width = 0 ; i < texImage->Width ; i *= 2 ) {
- log2Width++;
+
+ t->pp_txformat &= ~(RADEON_TXFORMAT_FORMAT_MASK |
+ RADEON_TXFORMAT_ALPHA_IN_MAP);
+ t->pp_txformat |= txformat;
+
+ if ( txformat == RADEON_TXFORMAT_RGBA8888 ||
+ txformat == RADEON_TXFORMAT_ARGB4444 ||
+ txformat == RADEON_TXFORMAT_ARGB1555 ||
+ txformat == RADEON_TXFORMAT_AI88 ) {
+ t->pp_txformat |= RADEON_TXFORMAT_ALPHA_IN_MAP;
}
- log2Size = MAX2( log2Width, log2Height );
/* The Radeon has a 64-byte minimum pitch for all blits. We
* calculate the equivalent number of texels to simplify the
* calculation of the texture image area.
*/
- switch ( texFormat->TexelBytes ) {
- case 4:
- texelsPerDword = 1;
- blitPitch = 16;
+ switch ( baseImage->TexFormat->TexelBytes ) {
+ case 1:
+ texelsPerDword = 4;
+ blitPitch = 64;
break;
case 2:
texelsPerDword = 2;
blitPitch = 32;
break;
- case 1:
- texelsPerDword = 4;
- blitPitch = 64;
+ case 4:
+ texelsPerDword = 1;
+ blitPitch = 16;
break;
}
@@ -91,7 +127,7 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
* can't upload mipmaps directly and have to reference their location
* from the aligned start of the whole image.
*/
- blitWidth = MAX2( texImage->Width, blitPitch );
+ blitWidth = MAX2( baseImage->Width, blitPitch );
/* Calculate mipmap offsets and dimensions.
*/
@@ -99,10 +135,33 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
x = 0;
y = 0;
- for ( i = 0 ; i <= log2Size ; i++ ) {
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ log2Width = tObj->Image[firstLevel]->WidthLog2;
+ log2Height = tObj->Image[firstLevel]->HeightLog2;
+
+ for ( i = 0 ; i < numLevels ; i++ ) {
+ const struct gl_texture_image *texImage;
GLuint size;
- texImage = tObj->Image[i];
+ texImage = tObj->Image[i + firstLevel];
if ( !texImage )
break;
@@ -118,7 +177,7 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
width = blitPitch / 2;
}
- size = width * height * texFormat->TexelBytes;
+ size = width * height * baseImage->TexFormat->TexelBytes;
totalSize += size;
ASSERT( (totalSize & 31) == 0 );
@@ -127,6 +186,7 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
height /= 2;
}
+ assert(i < RADEON_MAX_TEXTURE_LEVELS);
t->image[i].x = x;
t->image[i].y = y;
@@ -147,12 +207,11 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
}
}
- if ( 0 ) {
+ if ( 0 )
fprintf( stderr, "level=%d p=%d %dx%d -> %dx%d at (%d,%d)\n",
- i, blitWidth, texImage->Width, texImage->Height,
+ i, blitWidth, baseImage->Width, baseImage->Height,
t->image[i].width, t->image[i].height,
t->image[i].x, t->image[i].y );
- }
}
/* Align the total size of texture memory block.
@@ -162,15 +221,18 @@ static void radeonSetTexImages( radeonContextPtr rmesa,
/* Hardware state:
*/
t->pp_txfilter &= ~RADEON_MAX_MIP_LEVEL_MASK;
- t->pp_txfilter |= i << RADEON_MAX_MIP_LEVEL_SHIFT;
+ t->pp_txfilter |= (numLevels - 1) << RADEON_MAX_MIP_LEVEL_SHIFT;
t->pp_txformat &= ~(RADEON_TXFORMAT_WIDTH_MASK |
RADEON_TXFORMAT_HEIGHT_MASK);
t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_WIDTH_SHIFT) |
(log2Height << RADEON_TXFORMAT_HEIGHT_SHIFT));
+
+ radeonUploadTexImages( rmesa, t );
}
+
/* ================================================================
* Texture combine functions
*/
@@ -664,36 +726,18 @@ do { \
static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- int source = rmesa->tmu_source[unit];
- struct gl_texture_object *tObj;
- struct gl_texture_unit *texUnit;
- GLuint enabled;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLenum format = tObj->Image[tObj->BaseLevel]->Format;
GLuint color_combine, alpha_combine;
GLuint color_arg[3], alpha_arg[3];
GLuint i, numColorArgs = 0, numAlphaArgs = 0;
- GLuint op;
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG ) {
- fprintf( stderr, "%s( %p, %d )\n",
- __FUNCTION__, ctx, unit );
+ if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, __FUNCTION__"( %p, %d ) format=%s\n",
+ ctx, unit, _mesa_lookup_enum_by_nr( format ) );
}
- enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
- if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D )
- return;
-
- /* Only update the hardware texture state if the texture is current,
- * complete and enabled.
- */
- texUnit = &ctx->Texture.Unit[source];
- tObj = texUnit->Current;
- if ( !tObj || !tObj->Complete )
- return;
-
- if ( ( tObj != texUnit->CurrentD[2] ) &&
- ( tObj != texUnit->CurrentD[1] ) )
- return;
-
/* Set the texture environment state. Isn't this nice and clean?
* The Radeon will automagically set the texture alpha to 0xff when
* the texture format does not include an alpha component. This
@@ -702,10 +746,8 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
*/
switch ( texUnit->EnvMode ) {
case GL_REPLACE:
- switch ( tObj->Image[0]->Format ) {
+ switch ( format ) {
case GL_RGBA:
- case GL_RGB:
- case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_INTENSITY:
color_combine = radeon_color_combine[unit][RADEON_REPLACE];
@@ -715,6 +757,11 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
color_combine = radeon_color_combine[unit][RADEON_DISABLE];
alpha_combine = radeon_alpha_combine[unit][RADEON_REPLACE];
break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ color_combine = radeon_color_combine[unit][RADEON_REPLACE];
+ alpha_combine = radeon_alpha_combine[unit][RADEON_DISABLE];
+ break;
case GL_COLOR_INDEX:
default:
return;
@@ -722,10 +769,8 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
break;
case GL_MODULATE:
- switch ( tObj->Image[0]->Format ) {
+ switch ( format ) {
case GL_RGBA:
- case GL_RGB:
- case GL_LUMINANCE:
case GL_LUMINANCE_ALPHA:
case GL_INTENSITY:
color_combine = radeon_color_combine[unit][RADEON_MODULATE];
@@ -735,6 +780,11 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
color_combine = radeon_color_combine[unit][RADEON_DISABLE];
alpha_combine = radeon_alpha_combine[unit][RADEON_MODULATE];
break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ color_combine = radeon_color_combine[unit][RADEON_MODULATE];
+ alpha_combine = radeon_alpha_combine[unit][RADEON_DISABLE];
+ break;
case GL_COLOR_INDEX:
default:
return;
@@ -742,7 +792,7 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
break;
case GL_DECAL:
- switch ( tObj->Image[0]->Format ) {
+ switch ( format ) {
case GL_RGBA:
case GL_RGB:
color_combine = radeon_color_combine[unit][RADEON_DECAL];
@@ -762,7 +812,7 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
break;
case GL_BLEND:
- switch ( tObj->Image[0]->Format ) {
+ switch ( format ) {
case GL_RGBA:
case GL_RGB:
case GL_LUMINANCE:
@@ -785,7 +835,7 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
break;
case GL_ADD:
- switch ( tObj->Image[0]->Format ) {
+ switch ( format ) {
case GL_RGBA:
case GL_RGB:
case GL_LUMINANCE:
@@ -808,6 +858,11 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
break;
case GL_COMBINE_EXT:
+ /* Don't cache these results.
+ */
+ rmesa->state.texture.unit[unit].format = 0;
+ rmesa->state.texture.unit[unit].envMode = 0;
+
/* Step 0:
* Calculate how many arguments we need to process.
*/
@@ -849,7 +904,9 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
* Extract the color and alpha combine function arguments.
*/
for ( i = 0 ; i < numColorArgs ; i++ ) {
- op = texUnit->CombineOperandRGB[i] - GL_SRC_COLOR;
+ const GLuint op = texUnit->CombineOperandRGB[i] - GL_SRC_COLOR;
+ ASSERT(op >= 0);
+ ASSERT(op <= 3);
switch ( texUnit->CombineSourceRGB[i] ) {
case GL_TEXTURE:
color_arg[i] = radeon_texture_color[op][unit];
@@ -869,7 +926,9 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
}
for ( i = 0 ; i < numAlphaArgs ; i++ ) {
- op = texUnit->CombineOperandA[i] - GL_SRC_ALPHA;
+ const GLuint op = texUnit->CombineOperandA[i] - GL_SRC_ALPHA;
+ ASSERT(op >= 0);
+ ASSERT(op <= 1);
switch ( texUnit->CombineSourceA[i] ) {
case GL_TEXTURE:
alpha_arg[i] = radeon_texture_alpha[op][unit];
@@ -997,7 +1056,9 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
texUnit->CombineModeRGB != GL_DOT3_RGBA_EXT ) {
color_combine |= (texUnit->CombineScaleShiftRGB << 21);
alpha_combine |= (texUnit->CombineScaleShiftA << 21);
- } else {
+ }
+ else
+ {
color_combine |= RADEON_SCALE_4X;
alpha_combine |= RADEON_SCALE_4X;
}
@@ -1010,94 +1071,82 @@ static void radeonUpdateTextureEnv( GLcontext *ctx, int unit )
return;
}
- rmesa->color_combine[source] = color_combine;
- rmesa->alpha_combine[source] = alpha_combine;
+ if ( rmesa->state.hw.texture[unit].pp_txcblend != color_combine ||
+ rmesa->state.hw.texture[unit].pp_txablend != alpha_combine ) {
+ RADEON_STATECHANGE( rmesa, (RADEON_UPLOAD_TEX0 << unit) );
+ rmesa->state.hw.texture[unit].pp_txcblend = color_combine;
+ rmesa->state.hw.texture[unit].pp_txablend = alpha_combine;
+ }
}
-static void radeonUpdateTextureObject( GLcontext *ctx, int unit )
+static void radeonUpdateTextureUnit( GLcontext *ctx, int unit )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- int source = rmesa->tmu_source[unit];
- struct gl_texture_object *tObj;
- radeonTexObjPtr t;
- GLuint enabled;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG ) {
- fprintf( stderr, "%s( %p, %d )\n",
- __FUNCTION__, ctx, unit );
- }
-
- enabled = (ctx->Texture.ReallyEnabled >> (source * 4)) & TEXTURE0_ANY;
- if ( enabled != TEXTURE0_2D && enabled != TEXTURE0_1D ) {
- if ( enabled )
- rmesa->Fallback |= RADEON_FALLBACK_TEXTURE;
- return;
- }
-
- /* Only update the hardware texture state if the texture is current,
- * complete and enabled.
- */
- tObj = ctx->Texture.Unit[source].Current;
- if ( !tObj || !tObj->Complete )
- return;
-
- if ( ( tObj != ctx->Texture.Unit[source].CurrentD[2] ) &&
- ( tObj != ctx->Texture.Unit[source].CurrentD[1] ) )
- return;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if ( texUnit->_ReallyEnabled & (TEXTURE0_1D|TEXTURE0_2D) ) {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+ GLuint flag = RADEON_UPLOAD_TEX0 << unit;
+ GLenum format;
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[tObj->BaseLevel]->Border > 0 ) {
+ FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
- /* We definately have a valid texture now */
- t = tObj->DriverData;
+ /* Upload teximages (not pipelined)
+ */
+ if ( t->dirty_images ) {
+ RADEON_FIREVERTICES( rmesa );
+ radeonSetTexImages( rmesa, tObj );
+ if ( !t->memBlock ) {
+ FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ }
- /* Force the texture unit state to be loaded into the hardware */
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT | (RADEON_UPLOAD_TEX0 << unit);
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if ( rmesa->state.texture.unit[unit].texobj != t ) {
+ if ( rmesa->state.texture.unit[unit].texobj == NULL ) {
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.pp_cntl |= (RADEON_TEX_0_ENABLE |
+ RADEON_TEX_BLEND_0_ENABLE)<<unit;
+ }
+ RADEON_STATECHANGE( rmesa, flag );
+ rmesa->state.texture.unit[unit].texobj = t;
+ radeonUpdateTexLRU( rmesa, t ); /* done too often */
+ }
- /* Force any texture images to be loaded into the hardware */
- if ( t->dirty_images ) {
- if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, " t->dirty_images = 0x%x\n", t->dirty_images );
+ format = tObj->Image[tObj->BaseLevel]->Format;
+ if ( rmesa->state.texture.unit[unit].format != format ||
+ rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode ) {
+ rmesa->state.texture.unit[unit].format = format;
+ rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
+ radeonUpdateTextureEnv( ctx, unit );
}
- radeonSetTexImages( rmesa, tObj );
- rmesa->dirty |= (RADEON_UPLOAD_TEX0IMAGES << unit);
}
-
- if ( t->memBlock )
- radeonUpdateTexLRU( rmesa, t );
-
- switch ( unit ) {
- case 0:
- rmesa->setup.pp_cntl |= (RADEON_TEX_0_ENABLE |
- RADEON_TEX_BLEND_0_ENABLE);
- break;
- case 1:
- rmesa->setup.pp_cntl |= (RADEON_TEX_1_ENABLE |
- RADEON_TEX_BLEND_1_ENABLE);
- break;
+ else if ( texUnit->_ReallyEnabled ) {
+ FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ else {
+ /* Texture unit disabled */
+ rmesa->state.texture.unit[unit].texobj = 0;
+ rmesa->state.hw.dirty &= ~(RADEON_UPLOAD_TEX0 << unit);
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_CONTEXT );
+ rmesa->state.hw.context.pp_cntl &= ~((RADEON_TEX_0_ENABLE |
+ RADEON_TEX_BLEND_0_ENABLE) << unit);
}
}
void radeonUpdateTextureState( GLcontext *ctx )
{
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s( %p ) en=0x%x\n",
- __FUNCTION__, ctx, ctx->Texture.ReallyEnabled );
- }
-
- /* Clear any texturing fallbacks */
- rmesa->Fallback &= ~RADEON_FALLBACK_TEXTURE;
-
- /* Disable all texturing until it is known to be good */
- rmesa->setup.pp_cntl &= ~(RADEON_TEX_ENABLE_MASK |
- RADEON_TEX_BLEND_ENABLE_MASK);
-
- radeonUpdateTextureObject( ctx, 0 );
- radeonUpdateTextureEnv( ctx, 0 );
-
- if ( rmesa->multitex ) {
- radeonUpdateTextureObject( ctx, 1 );
- radeonUpdateTextureEnv( ctx, 1 );
- }
-
- rmesa->dirty |= RADEON_UPLOAD_CONTEXT;
+ FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, GL_FALSE );
+ radeonUpdateTextureUnit( ctx, 0 );
+ radeonUpdateTextureUnit( ctx, 1 );
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c
index 4555bce6d..1bbb89491 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tris.c,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -29,197 +29,543 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
-#include "radeon_context.h"
-#include "radeon_ioctl.h"
-#include "radeon_vb.h"
+#include <stdio.h>
+#include <math.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
#include "radeon_tris.h"
#include "radeon_state.h"
+#include "radeon_tex.h"
+#include "radeon_vb.h"
+#include "radeon_ioctl.h"
-#include "pipeline.h"
-#include "vbindirect.h"
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST
+};
+
+static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim );
+static void radeonResetLineStipple( GLcontext *ctx );
+
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
-static struct {
- points_func points;
- line_func line;
- triangle_func triangle;
- quad_func quad;
-} rast_tab[RADEON_MAX_TRIFUNC];
-#define RADEON_COLOR( to, from ) \
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
do { \
- *(GLuint *)(to) = *(GLuint *)(from); \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
} while (0)
-
-#define RADEON_COLOR3( to, from ) \
-do { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
} while (0)
+#endif
-
-static void radeon_null_quad( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint v3, GLuint pv )
+static __inline void radeon_draw_quad( radeonContextPtr rmesa,
+ radeonVertexPtr v0,
+ radeonVertexPtr v1,
+ radeonVertexPtr v2,
+ radeonVertexPtr v3 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)radeonAllocDmaLow( rmesa, 6 * vertsize * 4,
+ __FUNCTION__);
+ GLuint j;
+
+ rmesa->num_verts += 6;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
}
-static void radeon_null_triangle( GLcontext *ctx, GLuint v0,
- GLuint v1, GLuint v2, GLuint pv )
-{
-}
-static void radeon_null_line( GLcontext *ctx,
- GLuint v1, GLuint v2, GLuint pv )
+
+
+static __inline void radeon_draw_triangle( radeonContextPtr rmesa,
+ radeonVertexPtr v0,
+ radeonVertexPtr v1,
+ radeonVertexPtr v2 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)radeonAllocDmaLow( rmesa, 3 * vertsize * 4,
+ __FUNCTION__);
+ GLuint j;
+
+ /*
+ printf("radeon_draw_triangle\n");
+ radeon_print_vertex(rmesa->glCtx, v0);
+ radeon_print_vertex(rmesa->glCtx, v1);
+ radeon_print_vertex(rmesa->glCtx, v2);
+ */
+ rmesa->num_verts += 3;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
}
-static void radeon_null_points( GLcontext *ctx, GLuint first, GLuint last )
+
+static __inline void radeon_draw_line( radeonContextPtr rmesa,
+ radeonVertexPtr v0,
+ radeonVertexPtr v1 )
{
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)radeonAllocDmaLow( rmesa, 2 * vertsize * 4,
+ __FUNCTION__);
+ GLuint j;
+
+ rmesa->num_verts += 2;
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
}
-static void radeonPrintRenderState( const char *msg, GLuint state )
+static __inline void radeon_draw_point( radeonContextPtr rmesa,
+ radeonVertexPtr v0 )
{
- fprintf( stderr, "%s: (0x%x) %s%s%s%s%s\n",
- msg, state,
- (state & RADEON_FLAT_BIT) ? "flat, " : "",
- (state & RADEON_OFFSET_BIT) ? "offset, " : "",
- (state & RADEON_TWOSIDE_BIT) ? "twoside, " : "",
- (state & RADEON_NODRAW_BIT) ? "no-draw, " : "",
- (state & RADEON_FALLBACK_BIT) ? "fallback" : "" );
+ int vertsize = rmesa->vertex_size;
+ GLuint *vb = (GLuint *)radeonAllocDmaLow( rmesa, vertsize * 4,
+ __FUNCTION__);
+ int j;
+
+ /*
+ printf("radeon_draw_point\n");
+ radeon_print_vertex(rmesa->glCtx, v0);
+ */
+ rmesa->num_verts += 1;
+ COPY_DWORDS( j, vb, vertsize, v0 );
}
-#define IND (0)
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define QUAD( a, b, c, d ) radeon_draw_quad( rmesa, a, b, c, d )
+#define TRI( a, b, c ) radeon_draw_triangle( rmesa, a, b, c )
+#define LINE( a, b ) radeon_draw_line( rmesa, a, b )
+#define POINT( a ) radeon_draw_point( rmesa, a )
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define RADEON_TWOSIDE_BIT 0x01
+#define RADEON_UNFILLED_BIT 0x02
+#define RADEON_MAX_TRIFUNC 0x04
+
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[RADEON_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK 0
+#define DO_OFFSET 0
+#define DO_UNFILLED (IND & RADEON_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & RADEON_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_INDEX 0
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX radeonVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (rmesa->verts + (e<<rmesa->vertex_stride_shift))
+
+
+#define VERT_SET_RGBA( v, c ) v->ui[coloroffset] = *(GLuint *)c
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) COPY_3V(v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (rmesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (rmesa->vertex_size > 4); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (rmesa->hw_primitive != hw_prim[x]) \
+ radeonRasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE rmesa->render_primitive
#define TAG(x) x
-#include "radeon_tritmp.h"
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
-#define IND (RADEON_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "radeon_tritmp.h"
-#define IND (RADEON_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "radeon_tritmp.h"
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
-#define IND (RADEON_OFFSET_BIT | RADEON_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "radeon_tritmp.h"
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (RADEON_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "radeon_tritmp.h"
-
-#define IND (RADEON_TWOSIDE_BIT | RADEON_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "radeon_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (RADEON_TWOSIDE_BIT | RADEON_OFFSET_BIT)
-#define TAG(x) x##_twoside_offset
-#include "radeon_tritmp.h"
+#define IND (RADEON_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (RADEON_TWOSIDE_BIT | RADEON_OFFSET_BIT | RADEON_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "radeon_tritmp.h"
+#define IND (RADEON_TWOSIDE_BIT|RADEON_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
-void radeonDDTriangleFuncsInit( void )
+static void init_rast_tab( void )
{
- GLint i;
-
init();
- init_flat();
- init_offset();
- init_offset_flat();
init_twoside();
- init_twoside_flat();
- init_twoside_offset();
- init_twoside_offset_flat();
-
- for ( i = 0 ; i < RADEON_MAX_TRIFUNC ; i++ ) {
- if ( i & RADEON_NODRAW_BIT ) {
- rast_tab[i].points = radeon_null_points;
- rast_tab[i].line = radeon_null_line;
- rast_tab[i].triangle = radeon_null_triangle;
- rast_tab[i].quad = radeon_null_quad;
- }
+ init_unfilled();
+ init_twoside_unfilled();
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (radeonVertex *)(radeonverts + (x << shift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ radeon_draw_point( rmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ radeon_draw_line( rmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ radeon_draw_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ radeon_draw_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ radeonRenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ const GLuint shift = rmesa->vertex_stride_shift; \
+ const char *radeonverts = (char *)rmesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) elt; (void) stipple;
+#define RESET_STIPPLE if ( stipple ) radeonResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) radeon_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) radeon_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void radeonRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+}
+
+static void radeonFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = radeonAllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize,
+ __FUNCTION__);
+ GLubyte *radeonverts = (GLubyte *)rmesa->verts;
+ const GLuint shift = rmesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i,j;
+
+ rmesa->num_verts += (n-2) * 3;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, start );
+ COPY_DWORDS( j, vb, vertsize, VERT(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, VERT(elts[i]) );
}
}
-/* FIXME: Only enable software fallback for stencil in 16 bpp mode after
- * we have hardware stencil support.
- */
-#define ALL_FALLBACK (DD_SELECT | DD_FEEDBACK | DD_STENCIL)
-#define POINT_FALLBACK (ALL_FALLBACK | DD_POINT_SMOOTH | DD_POINT_ATTEN)
-#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_SMOOTH | DD_LINE_STIPPLE)
-#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_UNFILLED)
-#define ANY_FALLBACK (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
-#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET | DD_Z_NEVER)
-
-/* Setup the Point, Line, Triangle and Quad functions based on the
- * current rendering state. Wherever possible, use the hardware to
- * render the primitive. Otherwise, fallback to software rendering.
- */
-void radeonDDChooseRenderState( GLcontext *ctx )
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define _RADEON_NEW_RENDER_STATE (_DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_UNFILLED)
+
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)
+
+
+static void radeonChooseRenderState(GLcontext *ctx)
{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLuint flags = ctx->TriangleCaps;
+ GLuint flags = ctx->_TriangleCaps;
GLuint index = 0;
- if ( rmesa->Fallback ) {
- rmesa->RenderIndex = RADEON_FALLBACK_BIT;
- /* fixes vorder.c failure: */
- if (flags & DD_TRI_LIGHT_TWOSIDE) {
- rmesa->IndirectTriangles = DD_TRI_LIGHT_TWOSIDE;
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= RADEON_UNFILLED_BIT;
+
+ if (index != rmesa->RenderIndex) {
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = radeon_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = radeon_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = radeonFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = radeonRenderClippedPoly;
}
- return;
- }
- if ( flags & ANY_RASTER_FLAGS ) {
- if ( flags & DD_FLATSHADE ) index |= RADEON_FLAT_BIT;
- if ( flags & DD_TRI_LIGHT_TWOSIDE ) index |= RADEON_TWOSIDE_BIT;
- if ( flags & DD_TRI_OFFSET ) index |= RADEON_OFFSET_BIT;
- if ( flags & DD_Z_NEVER ) index |= RADEON_NODRAW_BIT;
+ rmesa->RenderIndex = index;
}
+}
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
- rmesa->PointsFunc = rast_tab[index].points;
- rmesa->LineFunc = rast_tab[index].line;
- rmesa->TriangleFunc = rast_tab[index].triangle;
- rmesa->QuadFunc = rast_tab[index].quad;
+static void radeonWrapRunPipeline( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- rmesa->RenderIndex = index;
- rmesa->IndirectTriangles = 0;
+ /* Validate state:
+ */
+ if (rmesa->NewGLState) {
+ if (rmesa->NewGLState & _NEW_TEXTURE)
+ radeonUpdateTextureState( ctx );
- if ( flags & ANY_FALLBACK ) {
- if ( flags & POINT_FALLBACK ) {
- rmesa->RenderIndex |= RADEON_FALLBACK_BIT;
- rmesa->PointsFunc = 0;
- rmesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- }
+ if (!rmesa->Fallback) {
+ if (rmesa->NewGLState & _RADEON_NEW_VERTEX_STATE)
+ radeonChooseVertexState( ctx );
- if ( flags & LINE_FALLBACK ) {
- rmesa->RenderIndex |= RADEON_FALLBACK_BIT;
- rmesa->LineFunc = 0;
- rmesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
+ if (rmesa->NewGLState & _RADEON_NEW_RENDER_STATE)
+ radeonChooseRenderState( ctx );
}
- if ( flags & TRI_FALLBACK ) {
- rmesa->RenderIndex |= RADEON_FALLBACK_BIT;
- rmesa->TriangleFunc = 0;
- rmesa->QuadFunc = 0;
- rmesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- }
+ rmesa->NewGLState = 0;
+ }
+
+ /* Run the pipeline.
+ */
+ _tnl_run_pipeline( ctx );
+
+ /* Nothing left to do.
+ */
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ if (rmesa->hw_primitive != hwprim) {
+ RADEON_STATECHANGE( rmesa, 0 );
+ rmesa->hw_primitive = hwprim;
+ }
+}
+
+static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint hw = hw_prim[prim];
+ rmesa->render_primitive = prim;
+ if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+ radeonRasterPrimitive( ctx, hw );
+}
+
+static void radeonRenderFinish( GLcontext *ctx )
+{
+}
+
+static void radeonResetLineStipple( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ /* Reset the hardware stipple counter.
+ */
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ RADEON_STATECHANGE( rmesa, RADEON_UPLOAD_LINE );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "glBlendEquation",
+ "glBlendFunc(mode != ADD)"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
- /* fixes vorder.c failure: */
- if (flags & DD_TRI_LIGHT_TWOSIDE) {
- rmesa->IndirectTriangles |= DD_TRI_LIGHT_TWOSIDE;
+void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->Fallback;
+
+ if (mode) {
+ rmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ RADEON_FIREVERTICES( rmesa );
+ _swsetup_Wakeup( ctx );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ rmesa->RenderIndex = ~0;
+ if (rmesa->debugFallbacks) {
+ fprintf(stderr, "Radeon begin software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
}
}
+ else {
+ rmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ /*printf("End fallback 0x%x\n", bit);*/
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = radeonCheckTexSizes;
+ tnl->Driver.Render.PrimitiveNotify = radeonRenderPrimitive;
+ tnl->Driver.Render.Finish = radeonRenderFinish;
+ tnl->Driver.Render.BuildVertices = radeonBuildVertices;
+ tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
+ rmesa->NewGLState |= (_RADEON_NEW_RENDER_STATE|
+ _RADEON_NEW_VERTEX_STATE);
+ if (rmesa->debugFallbacks) {
+ fprintf(stderr, "Radeon end software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
- if ( 0 ) {
- gl_print_tri_caps( "tricaps", ctx->TriangleCaps );
- radeonPrintRenderState( "radeon render state", rmesa->RenderIndex );
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void radeonInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
}
+
+ tnl->Driver.RunPipeline = radeonWrapRunPipeline;
+ tnl->Driver.Render.Start = radeonCheckTexSizes;
+ tnl->Driver.Render.Finish = radeonRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = radeonRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
+ tnl->Driver.Render.BuildVertices = radeonBuildVertices;
+
+/* radeonFallback( ctx, 0x100000, 1 ); */
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h
index 00c07e184..b6193c92f 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tris.h,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -29,313 +29,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
#ifndef __RADEON_TRIS_H__
#define __RADEON_TRIS_H__
-#ifdef GLX_DIRECT_RENDERING
+#include "mtypes.h"
-#include "radeon_vb.h"
-
-extern void radeonDDChooseRenderState( GLcontext *ctx );
-extern void radeonDDTriangleFuncsInit( void );
-
-#define RADEON_ANTIALIAS_BIT 0x00 /* GH: Do we need this? */
-#define RADEON_FLAT_BIT 0x01
-#define RADEON_OFFSET_BIT 0x02
-#define RADEON_TWOSIDE_BIT 0x04
-#define RADEON_NODRAW_BIT 0x08
-#define RADEON_FALLBACK_BIT 0x10
-#define RADEON_MAX_TRIFUNC 0x20
-
-
-static __inline void radeon_draw_triangle( radeonContextPtr rmesa,
- radeonVertexPtr v0,
- radeonVertexPtr v1,
- radeonVertexPtr v2 )
-{
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, 3 );
- GLuint j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v0->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v1->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v2->ui[j];
-#endif
-}
-
-static __inline void radeon_draw_quad( radeonContextPtr rmesa,
- radeonVertexPtr v0,
- radeonVertexPtr v1,
- radeonVertexPtr v2,
- radeonVertexPtr v3 )
-{
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, 6 );
- GLuint j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)v0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v3)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v1)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v2)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)v3)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v0->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v1->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v3->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v1->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v2->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = v3->ui[j];
-#endif
-}
-
-static __inline void radeon_draw_line( radeonContextPtr rmesa,
- radeonVertexPtr tmp0,
- radeonVertexPtr tmp1,
- GLfloat width )
-{
-#if 1
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, 6 );
- GLfloat hw, dx, dy, ix, iy;
- GLuint j;
- GLfloat x0 = tmp0->v.x;
- GLfloat y0 = tmp0->v.y;
- GLfloat x1 = tmp1->v.x;
- GLfloat y1 = tmp1->v.y;
-
- hw = 0.5F * width;
- if (hw > 0.1F && hw < 0.5F) {
- hw = 0.5F;
- }
-
- /* adjust vertices depending on line direction */
- dx = tmp0->v.x - tmp1->v.x;
- dy = tmp0->v.y - tmp1->v.y;
- if (dx * dx > dy * dy) {
- /* X-major line */
- ix = 0.0F;
- iy = hw;
- if (x1 < x0) {
- x0 += 0.5F;
- x1 += 0.5F;
- }
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- else {
- /* Y-major line */
- ix = hw;
- iy = 0.0F;
- if (y1 > y0) {
- y0 -= 0.5F;
- y1 -= 0.5F;
- }
- x0 += 0.5F;
- x1 += 0.5F;
- }
-
- *(float *)&vb[0] = x0 - ix;
- *(float *)&vb[1] = y0 - iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp0->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x1 + ix;
- *(float *)&vb[1] = y1 + iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp1->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x0 + ix;
- *(float *)&vb[1] = y0 + iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp0->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x0 - ix;
- *(float *)&vb[1] = y0 - iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp0->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x1 - ix;
- *(float *)&vb[1] = y1 - iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp1->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x1 + ix;
- *(float *)&vb[1] = y1 + iy;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp1->ui[j];
-#else
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, RADEON_LINES, 2 );
- GLuint j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp0)
- : "memory" );
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "S" ((long)tmp1)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp0->ui[j];
-
- vb += vertsize;
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp1->ui[j];
-#endif
-#endif
-}
-
-static __inline void radeon_draw_point( radeonContextPtr rmesa,
- radeonVertexPtr tmp, GLfloat sz )
-{
-#if 1
- GLuint vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, 6 );
- GLuint j;
- const float x = tmp->v.x + PNT_X_OFFSET;
- const float y = tmp->v.y + PNT_Y_OFFSET;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x + sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y + sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
- vb += vertsize;
-
- *(float *)&vb[0] = x - sz;
- *(float *)&vb[1] = y - sz;
- for (j = 2 ; j < vertsize ; j++)
- vb[j] = tmp->ui[j];
-
-#else
- int vertsize = rmesa->vertsize;
- CARD32 *vb = radeonAllocVerticesInline( rmesa, RADEON_3_VERTEX_POINTS, 1 );
- int j;
-
-#if defined (USE_X86_ASM)
- /* GH: We can safely assume the vertex stride is some number of
- * dwords, and thus a "rep movsd" is okay. The vb pointer is
- * automagically updated with this instruction, so we don't have
- * to manually take care of incrementing it.
- */
- __asm__ __volatile__( "rep ; movsl"
- : "=%c" (j)
- : "0" (vertsize), "D" ((long)vb), "S" ((long)tmp)
- : "memory" );
-#else
- for ( j = 0 ; j < vertsize ; j++ )
- vb[j] = tmp->ui[j];
-#endif
-#endif
-}
+extern void radeonInitTriFuncs( GLcontext *ctx );
#endif
-#endif /* __RADEON_TRIS_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_tritmp.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_tritmp.h
deleted file mode 100644
index 690e74bd2..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_tritmp.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tritmp.h,v 1.2 2001/03/21 16:14:25 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-static __inline void TAG(triangle)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- radeonVertexPtr verts = RADEON_DRIVER_DATA(VB)->verts;
- radeonVertexPtr v[3];
-
-#if (IND & RADEON_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[3];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- GLuint c[3];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
- v[2] = &verts[e2];
-
-#if (IND & RADEON_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
-#endif
-
-#if (IND & (RADEON_TWOSIDE_BIT | RADEON_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & RADEON_TWOSIDE_BIT)
- {
- GLuint facing = ( cc > 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if ( IND & RADEON_FLAT_BIT ) {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- RADEON_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- RADEON_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- }
- }
-#endif
-
-#if (IND & RADEON_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- if ( cc * cc > 1e-16 ) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- }
-#endif
- }
-#endif
-
- radeon_draw_triangle( rmesa, v[0], v[1], v[2] );
-
-#if (IND & RADEON_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
-#endif
-}
-
-
-static void TAG(quad)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2, GLuint e3,
- GLuint pv )
-{
-#if 0
- TAG(triangle)( ctx, e0, e1, e3, pv );
- TAG(triangle)( ctx, e1, e2, e3, pv );
-#else
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- radeonVertexPtr verts = RADEON_DRIVER_DATA(VB)->verts;
- radeonVertexPtr v[4];
-
-#if (IND & RADEON_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[4];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- int c[4];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
- v[2] = &verts[e2];
- v[3] = &verts[e3];
-
-#if (IND & RADEON_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
- c[3] = v[3]->ui[4];
-#endif
-
-#if (IND & (RADEON_TWOSIDE_BIT | RADEON_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & RADEON_TWOSIDE_BIT)
- {
- GLuint facing = ( cc > 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if ( IND & RADEON_FLAT_BIT ) {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[3]->ui[4] = v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- RADEON_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- RADEON_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- RADEON_COLOR( (char *)&v[3]->ui[4], vbcolor[e3] );
- }
- }
-#endif
-
-#if (IND & RADEON_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- z[3] = v[3]->v.z;
- if ( cc * cc > 1e-16 ) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- v[3]->v.z += offset;
- }
-#endif
- }
-#endif
-
- radeon_draw_quad( rmesa, v[0], v[1], v[2], v[3] );
-
-#if (IND & RADEON_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
- v[3]->v.z = z[3];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
- v[3]->ui[4] = c[3];
-#endif
-#endif
-}
-
-
-static void TAG(line)( GLcontext *ctx,
- GLuint e0, GLuint e1,
- GLuint pv )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- radeonVertexPtr verts = RADEON_DRIVER_DATA(VB)->verts;
- GLfloat width = ctx->Line.Width;
- radeonVertexPtr v[2];
-
-#if (IND & RADEON_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[2];
-#endif
-#if (IND & RADEON_TWOSIDE_BIT)
- GLuint c[2];
- GLuint s[2];
-#endif
-
- v[0] = &verts[e0];
- v[1] = &verts[e1];
-
-#if (IND & RADEON_TWOSIDE_BIT)
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- s[0] = v[0]->ui[5];
- s[1] = v[1]->ui[5];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- {
- GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
- GLubyte (*vbspec)[4] = ctx->VB->Specular;
- if ( IND & RADEON_FLAT_BIT ) {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[1]->ui[4] = v[0]->ui[4];
- RADEON_COLOR3( (char *)&v[0]->ui[5], vbspec[pv] );
- v[1]->ui[5] = v[0]->ui[5];
- } else {
- RADEON_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- RADEON_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- RADEON_COLOR3( (char *)&v[0]->ui[5], vbspec[e0] );
- RADEON_COLOR3( (char *)&v[1]->ui[5], vbspec[e1] );
- }
- }
-#endif
-
-#if (IND & RADEON_OFFSET_BIT)
- offset = ctx->LineZoffset * rmesa->depth_scale;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- v[0]->v.z += offset;
- v[1]->v.z += offset;
-#endif
-
- radeon_draw_line( rmesa, v[0], v[1], width );
-
-#if (IND & RADEON_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
-#endif
-
-#if (IND & RADEON_TWOSIDE_BIT)
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[0]->ui[5] = s[0];
- v[1]->ui[5] = s[1];
-#endif
-}
-
-
-static void TAG(points)( GLcontext *ctx,
- GLuint first, GLuint last )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- radeonVertexPtr verts = RADEON_DRIVER_DATA(VB)->verts;
- GLfloat size = ctx->Point.Size * 0.5;
- int i;
-
- for ( i = first ; i < last ; i++ ) {
- if ( VB->ClipMask[i] == 0 ) {
- if ( IND & (RADEON_TWOSIDE_BIT|RADEON_OFFSET_BIT) ) {
- radeonVertex tmp0 = verts[i];
-
- if ( IND & RADEON_TWOSIDE_BIT ) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
- GLubyte (*vbspec)[4] = VB->Specular;
- RADEON_COLOR( (char *)&tmp0.v.color, vbcolor[i] );
- if (vbspec)
- RADEON_COLOR3( (char *)&tmp0.v.specular, vbspec[i] );
- }
- if ( IND & RADEON_OFFSET_BIT ) {
- GLfloat offset = ctx->PointZoffset * rmesa->depth_scale;
- tmp0.v.z += offset;
- }
- radeon_draw_point( rmesa, &tmp0, size );
- } else {
- radeon_draw_point( rmesa, &verts[i], size );
- }
- }
- }
-}
-
-
-static void TAG(init)( void )
-{
- rast_tab[IND].points = TAG(points);
- rast_tab[IND].line = TAG(line);
- rast_tab[IND].triangle = TAG(triangle);
- rast_tab[IND].quad = TAG(quad);
-}
-
-#undef IND
-#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c
index 12461373b..a2a79af92 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vb.c,v 1.4 2001/03/25 05:32:00 tsi Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -29,455 +29,523 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "mem.h"
+#include "mmath.h"
+#include "macros.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
#include "radeon_context.h"
+#include "radeon_vb.h"
#include "radeon_ioctl.h"
#include "radeon_state.h"
-#include "radeon_vb.h"
-#include "mem.h"
-#include "stages.h"
-
-#define TEX0 \
-do { \
- v->v.tu0 = tc0[i][0]; \
- v->v.tv0 = tc0[i][1]; \
-} while (0)
-
-#define TEX1 \
-do { \
- v->v.tu1 = tc1[i][0]; \
- v->v.tv1 = tc1[i][1]; \
-} while (0)
-
-#define SPC \
-do { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.red = spec[0]; \
- v->v.specular.green = spec[1]; \
- v->v.specular.blue = spec[2]; \
-} while (0)
-
-#define FOG \
-do { \
- GLubyte *spec = &(VB->Spec[0][i][0]); \
- v->v.specular.alpha = spec[3]; \
-} while (0)
-
-#define COL \
-do { \
- GLubyte *col = &(VB->Color[0]->data[i][0]); \
- v->ui[4] = *(GLuint *)col; \
-} while (0)
-
-#define TEX0_4 \
-do { \
- if ( VB->TexCoordPtr[0]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
- v = &(RADEON_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++ ) { \
- float oow = 1.0 / tc[i][3]; \
- v->v.rhw *= tc[i][3]; \
- v->v.tu0 *= oow; \
- v->v.tv0 *= oow; \
- } \
- } \
-} while (0)
-
-#ifdef USE_RHW2
-
-#define TEX1_4 \
-do { \
- if ( VB->TexCoordPtr[1]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data; \
- v = &(RADEON_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++ ) { \
- float oow = 1.0 / tc[i][3]; \
- v->v.rhw2 *= tc[i][3]; \
- v->v.tu1 *= oow; \
- v->v.tv1 *= oow; \
- } \
- } \
-} while (0)
-
-#define COORD \
-do { \
- GLfloat *win = VB->Win.data[i]; \
- v->v.x = win[0]; \
- v->v.y = - win[1]; \
- v->v.z = win[2]; \
- v->v.rhw = v->v.rhw2 = win[3]; \
-} while (0)
-
-#else /* USE_RHW2 */
-
-#define TEX1_4
-
-#define COORD \
-do { \
- GLfloat *win = VB->Win.data[i]; \
- v->v.x = win[0] + SUBPIXEL_X; \
- v->v.y = - win[1] + SUBPIXEL_Y; \
- v->v.z = win[2]; \
- v->v.rhw = win[3]; \
-} while (0) \
-
-#endif /* USE_RHW2 */
-
-#define NOP
-
-
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec,fog) \
-static void name( struct vertex_buffer *VB, GLuint start, GLuint end ) \
-{ \
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx); \
- radeonVertexPtr v; \
- GLfloat (*tc0)[4]; \
- GLfloat (*tc1)[4]; \
- GLint i; \
- \
- gl_import_client_data( VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE | VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE) ); \
- \
- tc0 = VB->TexCoordPtr[rmesa->tmu_source[0]]->data; \
- tc1 = VB->TexCoordPtr[rmesa->tmu_source[1]]->data; \
- \
- v = &(RADEON_DRIVER_DATA(VB)->verts[start]); \
- \
- if ( VB->ClipOrMask == 0 ) { \
- for ( i = start ; i < end ; i++, v++ ) { \
- win; \
- col; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- } else { \
- for ( i = start ; i < end ; i++, v++ ) { \
- if ( VB->ClipMask[i] == 0 ) { \
- win; \
- spec; \
- fog; \
- tex0; \
- tex1; \
- } \
- col; \
- } \
- } \
- tex0_4; \
- tex1_4; \
-}
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+
+#define RADEON_XYZW_BIT 0x01
+#define RADEON_RGBA_BIT 0x02
+#define RADEON_FOG_BIT 0x04
+#define RADEON_SPEC_BIT 0x08
+#define RADEON_TEX0_BIT 0x10
+#define RADEON_TEX1_BIT 0x20
+#define RADEON_PTEX_BIT 0x40
+#define RADEON_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[RADEON_MAX_SETUP];
+
+
+#define TINY_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
+ RADEON_CP_VC_FRMT_Z | \
+ RADEON_CP_VC_FRMT_PKCOLOR)
+
+#define NOTEX_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
+ RADEON_CP_VC_FRMT_Z | \
+ RADEON_CP_VC_FRMT_W0 | \
+ RADEON_CP_VC_FRMT_PKCOLOR | \
+ RADEON_CP_VC_FRMT_PKSPEC)
+
+#define TEX0_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
+ RADEON_CP_VC_FRMT_Z | \
+ RADEON_CP_VC_FRMT_W0 | \
+ RADEON_CP_VC_FRMT_PKCOLOR | \
+ RADEON_CP_VC_FRMT_PKSPEC | \
+ RADEON_CP_VC_FRMT_ST0)
+
+#define TEX1_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
+ RADEON_CP_VC_FRMT_Z | \
+ RADEON_CP_VC_FRMT_W0 | \
+ RADEON_CP_VC_FRMT_PKCOLOR | \
+ RADEON_CP_VC_FRMT_PKSPEC | \
+ RADEON_CP_VC_FRMT_ST0 | \
+ RADEON_CP_VC_FRMT_ST1)
+
+#define PROJ_TEX1_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
+ RADEON_CP_VC_FRMT_Z | \
+ RADEON_CP_VC_FRMT_W0 | \
+ RADEON_CP_VC_FRMT_PKCOLOR | \
+ RADEON_CP_VC_FRMT_PKSPEC | \
+ RADEON_CP_VC_FRMT_ST0 | \
+ RADEON_CP_VC_FRMT_Q0 | \
+ RADEON_CP_VC_FRMT_ST1 | \
+ RADEON_CP_VC_FRMT_Q1)
+
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & RADEON_XYZW_BIT)
+#define DO_RGBA (IND & RADEON_RGBA_BIT)
+#define DO_SPEC (IND & RADEON_SPEC_BIT)
+#define DO_FOG (IND & RADEON_FOG_BIT)
+#define DO_TEX0 (IND & RADEON_TEX0_BIT)
+#define DO_TEX1 (IND & RADEON_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & RADEON_PTEX_BIT)
+
+#define VERTEX radeonVertex
+#define GET_VIEWPORT_MAT() 0
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() RADEON_CONTEXT(ctx)->vertex_format
+#define GET_VERTEX_STORE() RADEON_CONTEXT(ctx)->verts
+#define GET_VERTEX_STRIDE_SHIFT() RADEON_CONTEXT(ctx)->vertex_stride_shift
+#define GET_UBYTE_COLOR_STORE() &RADEON_CONTEXT(ctx)->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &RADEON_CONTEXT(ctx)->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 1
+#define HAVE_HW_DIVIDE (IND & ~(RADEON_XYZW_BIT|RADEON_RGBA_BIT))
+#define HAVE_RGBA_COLOR 1
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 1
+
+#define CHECK_HW_DIVIDE (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE| \
+ DD_TRI_UNFILLED)))
+
+
+#define IMPORT_FLOAT_COLORS radeon_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS radeon_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[RADEON_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[RADEON_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) radeon_##x
+#define IND ~0
+#include "tnl_dd/t_dd_vb.c"
+#undef IND
+
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT|\
+ RADEON_PTEX_BIT)
+#define TAG(x) x##_wgpt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|\
+ RADEON_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|\
+ RADEON_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|\
+ RADEON_TEX1_BIT|RADEON_PTEX_BIT)
+#define TAG(x) x##_wgspt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|\
+ RADEON_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|\
+ RADEON_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|\
+ RADEON_TEX1_BIT|RADEON_PTEX_BIT)
+#define TAG(x) x##_wgfpt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|\
+ RADEON_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
-SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC, NOP)
-SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
-SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
-SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_wgfs, COORD, COL, NOP, NOP, NOP, NOP, SPC, FOG)
-SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_wgfst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
-SETUPFUNC(rs_wgfst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
-
-SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC, NOP)
-SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP)
-SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP)
-SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP)
-SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP)
-SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_gfs, NOP, COL, NOP, NOP, NOP, NOP, SPC, FOG)
-SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG)
-SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG)
-SETUPFUNC(rs_gfst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG)
-SETUPFUNC(rs_gfst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG)
-
-
-static void rs_invalid( struct vertex_buffer *VB, GLuint start, GLuint end )
-{
- fprintf( stderr, "radeonRasterSetup(): invalid setup function\n" );
-}
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|\
+ RADEON_TEX0_BIT|RADEON_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
-typedef void (*setupFunc)( struct vertex_buffer *, GLuint, GLuint );
-static setupFunc setup_func[RADEON_MAX_SETUPFUNC];
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|\
+ RADEON_TEX0_BIT|RADEON_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|\
+ RADEON_TEX0_BIT|RADEON_TEX1_BIT|RADEON_PTEX_BIT)
+#define TAG(x) x##_wgfspt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+
+/* Specialized emit, hardwired with q3 strides.
+ */
+static void emit_q3( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint *coord;
+ GLuint coord_stride;
+ int i;
+
+ if (CHECK_HW_DIVIDE) {
+ coord = (GLuint *)VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ }
+ else {
+ coord = (GLuint *)VB->ProjectedClipPtr->data;
+ coord_stride = VB->ProjectedClipPtr->stride;
+ }
+ if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
+ IMPORT_FLOAT_COLORS( ctx );
-void radeonDDSetupInit( void )
-{
- GLint i;
+ if (coord_stride != 4 * sizeof(GLfloat) ||
+ VB->TexCoordPtr[0]->stride != 2 * sizeof(GLfloat) ||
+ VB->ColorPtr[0]->StrideB != 4 * sizeof(GLubyte) ||
+ start != 0) {
+ emit_wgt0( ctx, start, end, dest, stride );
+ return;
+ }
- for ( i = 0 ; i < RADEON_MAX_SETUPFUNC ; i++ ) {
- setup_func[i] = rs_invalid;
+ ASSERT(stride == 8*sizeof(GLuint));
+
+ {
+ GLuint *tc0 = (GLuint *)VB->TexCoordPtr[0]->data;
+ GLuint *col = (GLuint *)VB->ColorPtr[0]->Ptr;
+ GLuint *v = (GLuint *)dest;
+
+ for (i=end+1; --i ; ) {
+ GLuint *x;
+ x = coord; coord += 4;
+ v[0] = x[0];
+ v[1] = x[1];
+ v[2] = x[2];
+ v[3] = x[3];
+ v[4] = *col++;
+ x = tc0; tc0 += 2;
+ v[6] = x[0];
+ v[7] = x[1];
+ v += 8;
+ }
}
+}
- /* Functions to build vertices from scratch
- */
- setup_func[RADEON_WIN_BIT|RADEON_TEX0_BIT] = rs_wt0;
- setup_func[RADEON_WIN_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wt0t1;
- setup_func[RADEON_WIN_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT] = rs_wft0;
- setup_func[RADEON_WIN_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wft0t1;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT] = rs_wg;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT] = rs_wgs;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT] = rs_wgt0;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wgt0t1;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT] = rs_wgst0;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wgst0t1;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT] = rs_wgf;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT] = rs_wgfs;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT] = rs_wgft0;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wgft0t1;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT] = rs_wgfst0;
- setup_func[RADEON_WIN_BIT|RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_wgfst0t1;
-
- /* Repair functions
- */
- setup_func[RADEON_TEX0_BIT] = rs_t0;
- setup_func[RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_t0t1;
- setup_func[RADEON_FOG_BIT] = rs_f;
- setup_func[RADEON_FOG_BIT|RADEON_TEX0_BIT] = rs_ft0;
- setup_func[RADEON_FOG_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_ft0t1;
- setup_func[RADEON_RGBA_BIT] = rs_g;
- setup_func[RADEON_RGBA_BIT|RADEON_SPEC_BIT] = rs_gs;
- setup_func[RADEON_RGBA_BIT|RADEON_TEX0_BIT] = rs_gt0;
- setup_func[RADEON_RGBA_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_gt0t1;
- setup_func[RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT] = rs_gst0;
- setup_func[RADEON_RGBA_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_gst0t1;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT] = rs_gf;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT] = rs_gfs;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT] = rs_gft0;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_gft0t1;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT] = rs_gfst0;
- setup_func[RADEON_RGBA_BIT|RADEON_FOG_BIT|RADEON_SPEC_BIT|RADEON_TEX0_BIT|RADEON_TEX1_BIT] = rs_gfst0t1;
+
+
+/***********************************************************************
+ * Initialization
+ ***********************************************************************/
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgpt0();
+ init_wgt0t1();
+ init_wgpt0t1();
+ init_wgst0();
+ init_wgspt0();
+ init_wgst0t1();
+ init_wgspt0t1();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgfpt0();
+ init_wgft0t1();
+ init_wgfpt0t1();
+ init_wgfst0();
+ init_wgfspt0();
+ init_wgfst0t1();
+ init_wgfspt0t1();
+
+ setup_tab[RADEON_XYZW_BIT|RADEON_RGBA_BIT|RADEON_TEX0_BIT].emit = emit_q3;
}
-void radeonPrintSetupFlags( char *msg, GLuint flags )
+
+void radeonPrintSetupFlags(char *msg, GLuint flags )
{
- fprintf( stderr, "%s: %d %s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & RADEON_WIN_BIT) ? " xyzw," : "",
- (flags & RADEON_RGBA_BIT) ? " rgba," : "",
- (flags & RADEON_SPEC_BIT) ? " spec," : "",
- (flags & RADEON_FOG_BIT) ? " fog," : "",
- (flags & RADEON_TEX0_BIT) ? " tex-0," : "",
- (flags & RADEON_TEX1_BIT) ? " tex-1," : "" );
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & RADEON_XYZW_BIT) ? " xyzw," : "",
+ (flags & RADEON_RGBA_BIT) ? " rgba," : "",
+ (flags & RADEON_SPEC_BIT) ? " spec," : "",
+ (flags & RADEON_FOG_BIT) ? " fog," : "",
+ (flags & RADEON_TEX0_BIT) ? " tex-0," : "",
+ (flags & RADEON_TEX1_BIT) ? " tex-1," : "",
+ (flags & RADEON_PTEX_BIT) ? " proj-tex," : "");
}
-/* Initialize the vertex buffer setup functions based on the current
- * rendering state.
- */
-void radeonDDChooseRasterSetupFunc( GLcontext *ctx )
+void radeonCheckTexSizes( GLcontext *ctx )
{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
- GLint index = RADEON_WIN_BIT | RADEON_RGBA_BIT;
-
- rmesa->vertsize = 8;
- rmesa->vc_format = RADEON_TEX0_VERTEX_FORMAT;
- rmesa->tmu_source[0] = 0;
- rmesa->tmu_source[1] = 1;
- rmesa->tex_dest[0] = RADEON_TEX0_BIT;
- rmesa->tex_dest[1] = RADEON_TEX1_BIT;
- rmesa->multitex = 0;
-
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- index |= RADEON_TEX0_BIT;
- }
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX1 ) {
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- rmesa->multitex = 1;
- rmesa->vertsize = 10;
- rmesa->vc_format = RADEON_TEX1_VERTEX_FORMAT;
- index |= RADEON_TEX1_BIT;
- } else {
- /* Just a funny way of doing single texturing.
- */
- rmesa->tmu_source[0] = 1;
- rmesa->tex_dest[1] = RADEON_TEX0_BIT;
- index |= RADEON_TEX0_BIT;
+ if (!setup_tab[rmesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = rmesa->SetupIndex |= (RADEON_PTEX_BIT|RADEON_RGBA_BIT);
+
+ /* Radeon handles projective textures nicely; just have to change
+ * up to the new vertex format.
+ */
+ if (setup_tab[ind].vertex_format != rmesa->vertex_format) {
+ RADEON_STATECHANGE(rmesa, 0);
+ rmesa->vertex_format = setup_tab[ind].vertex_format;
+ rmesa->vertex_size = setup_tab[ind].vertex_size;
+ rmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
}
- }
- if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR )
- index |= RADEON_SPEC_BIT;
-
- if ( ctx->Fog.Enabled )
- index |= RADEON_FOG_BIT;
-
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG ) {
- radeonPrintSetupFlags( "full setup function", index );
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[rmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[rmesa->SetupIndex].copy_pv;
+ }
}
-
- rmesa->new_state |= RADEON_NEW_TEXTURE;
- rmesa->SetupIndex = index;
-
- ctx->Driver.RasterSetup = setup_func[index];
}
-/* Check to see if any updates of the vertex buffer entries are needed.
- */
-void radeonDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *s )
-{
- radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
- GLint tmp = rmesa->SetupDone;
- s->type = 0;
- rmesa->SetupDone = 0;
+void radeonBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ GLubyte *v = ((GLubyte *)rmesa->verts + (start<<rmesa->vertex_stride_shift));
+ GLuint stride = 1<<rmesa->vertex_stride_shift;
- if ( (ctx->Array.Summary & VERT_OBJ_ANY) == 0 )
- return;
+ newinputs |= rmesa->SetupNewInputs;
+ rmesa->SetupNewInputs = 0;
- if ( ctx->IndirectTriangles )
+ if (!newinputs)
return;
- rmesa->SetupDone = tmp;
+ /* No longer try to repair vertices.
+ */
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, v, stride );
}
-/* Repair existing precalculated vertices with new data.
- */
-void radeonDDPartialRasterSetup( struct vertex_buffer *VB )
+void radeonChooseVertexState( GLcontext *ctx )
{
- radeonContextPtr rmesa = RADEON_CONTEXT(VB->ctx);
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
- GLuint index = 0;
-
- if ( new & VERT_WIN ) {
- new = available;
- index |= RADEON_WIN_BIT | RADEON_FOG_BIT;
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = (RADEON_XYZW_BIT | RADEON_RGBA_BIT);
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= RADEON_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= RADEON_FOG_BIT;
+
+ if (ctx->Texture._ReallyEnabled & 0x0f0)
+ ind |= RADEON_TEX0_BIT|RADEON_TEX1_BIT;
+ else if (ctx->Texture._ReallyEnabled & 0x00f)
+ ind |= RADEON_TEX0_BIT;
+
+ rmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ /* In these modes the hardware vertices don't contain all the
+ * necessary information for interpolation (edgeflag,
+ * back-colors).
+ *
+ * Wrap the standard functions with ones that also interpolate
+ * the back colors and edgeflags.
+ */
+ tnl->Driver.Render.Interp = radeon_interp_extras;
+ tnl->Driver.Render.CopyPV = radeon_copy_pv_extras;
+ }
+ else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}
- if ( new & VERT_RGBA )
- index |= RADEON_RGBA_BIT | RADEON_SPEC_BIT;
-
- if ( new & VERT_TEX0_ANY )
- index |= RADEON_TEX0_BIT;
- if ( new & VERT_TEX1_ANY )
- index |= rmesa->tex_dest[1];
+ if (setup_tab[ind].vertex_format != rmesa->vertex_format) {
+ RADEON_STATECHANGE(rmesa, 0);
+ rmesa->vertex_format = setup_tab[ind].vertex_format;
+ rmesa->vertex_size = setup_tab[ind].vertex_size;
+ rmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
+ }
- if ( new & VERT_FOG_COORD )
- index |= RADEON_FOG_BIT;
+ {
+ GLuint se_coord_fmt, needproj;
+
+ /* HW perspective divide is a win, but tiny vertex formats are a
+ * bigger one.
+ */
+ if (setup_tab[ind].vertex_format == TINY_VERTEX_FORMAT ||
+ (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ needproj = GL_TRUE;
+ se_coord_fmt = (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
+ RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+ }
+ else {
+ needproj = GL_FALSE;
+ se_coord_fmt = (RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+ }
- rmesa->SetupDone &= ~index;
- index &= rmesa->SetupIndex;
- rmesa->SetupDone |= index;
+ if ( se_coord_fmt != rmesa->state.hw.vertex.se_coord_fmt ) {
+ RADEON_STATECHANGE(rmesa, RADEON_UPLOAD_VERTFMT);
+ rmesa->state.hw.vertex.se_coord_fmt = se_coord_fmt;
+ _tnl_need_projected_coords( ctx, needproj );
+ }
+ }
+}
- if ( RADEON_DEBUG & DEBUG_VERBOSE_MSG )
- radeonPrintSetupFlags( "partial setup function", index );
- if ( index )
- setup_func[index]( VB, VB->Start, VB->Count );
-}
-void radeonDDDoRasterSetup( struct vertex_buffer *VB )
+void radeon_emit_contiguous_verts( GLcontext *ctx, GLuint start, GLuint count )
{
- GLcontext *ctx = VB->ctx;
-
- if ( VB->Type == VB_CVA_PRECALC ) {
- radeonDDPartialRasterSetup( VB );
- } else if ( ctx->Driver.RasterSetup ) {
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
- }
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint vertex_size = rmesa->vertex_size * 4;
+ CARD32 *dest = radeonAllocDmaLow( rmesa, (count-start)*vertex_size,
+ __FUNCTION__ );
+ rmesa->num_verts += count - start;
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
}
-/* ================================================================
- * Hardware-format vertex buffers
- */
-
-void radeonDDResizeVB( struct vertex_buffer *VB, GLuint size )
+void radeon_emit_indexed_verts( GLcontext *ctx, GLuint start, GLuint count )
{
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint vertex_size = rmesa->vertex_size * 4;
+ GLuint bufsz = (count-start) * vertex_size;
+ CARD32 *dest;
- while ( rvb->size < size )
- rvb->size *= 2;
+ rmesa->dma.low = (rmesa->dma.low + 63) & ~63; /* alignment */
+ rmesa->dma.last = rmesa->dma.low;
- ALIGN_FREE( rvb->vert_store );
- rvb->vert_store = ALIGN_MALLOC( sizeof(radeonVertex) * rvb->size, 32 );
- if ( !rvb->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
- }
+ dest = radeonAllocDmaLow( rmesa, bufsz, __FUNCTION__);
+ setup_tab[rmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
- rvb->verts = (radeonVertexPtr)rvb->vert_store;
-
- gl_vector1ui_free( &rvb->clipped_elements );
- gl_vector1ui_alloc( &rvb->clipped_elements, VEC_WRITABLE, rvb->size, 32 );
- if ( !rvb->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
- }
+ rmesa->dma.retained = rmesa->dma.buffer;
+ rmesa->dma.offset = (rmesa->dma.buffer->idx * RADEON_BUFFER_SIZE +
+ rmesa->dma.low - bufsz);
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * rvb->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
- }
+ rmesa->dma.low = (rmesa->dma.low + 0x7) & ~0x7; /* alignment */
+ rmesa->dma.last = rmesa->dma.low;
}
-void radeonDDRegisterVB( struct vertex_buffer *VB )
-{
- radeonVertexBufferPtr rvb;
-
- rvb = (radeonVertexBufferPtr)CALLOC( sizeof(*rvb) );
- rvb->size = VB->Size * 2;
- rvb->vert_store = ALIGN_MALLOC( sizeof(radeonVertex) * rvb->size, 32 );
- if ( !rvb->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
+void radeonInitVB( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ rmesa->verts = (char *)ALIGN_MALLOC( size * 16 * 4, 32 );
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
}
+}
- rvb->verts = (radeonVertexPtr)rvb->vert_store;
- gl_vector1ui_alloc( &rvb->clipped_elements, VEC_WRITABLE, rvb->size, 32 );
- if ( !rvb->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
+void radeonFreeVB( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ if (rmesa->verts) {
+ ALIGN_FREE(rmesa->verts);
+ rmesa->verts = 0;
}
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * rvb->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
+ if (rmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE(rmesa->UbyteSecondaryColor.Ptr);
+ rmesa->UbyteSecondaryColor.Ptr = 0;
}
- VB->driver_data = rvb;
-}
-
-void radeonDDUnregisterVB( struct vertex_buffer *VB )
-{
- radeonVertexBufferPtr rvb = RADEON_DRIVER_DATA(VB);
-
- if ( rvb ) {
- if ( rvb->vert_store ) ALIGN_FREE( rvb->vert_store );
- gl_vector1ui_free( &rvb->clipped_elements );
- FREE( rvb );
- VB->driver_data = 0;
+ if (rmesa->UbyteColor.Ptr) {
+ ALIGN_FREE(rmesa->UbyteColor.Ptr);
+ rmesa->UbyteColor.Ptr = 0;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h
index bd809efbb..78337fae8 100644
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vb.h,v 1.1 2001/01/08 01:07:29 martin Exp $ */
+/* $XFree86$ */
/**************************************************************************
Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
@@ -29,108 +29,46 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
-#ifndef __RADEON_VB_H__
-#define __RADEON_VB_H__
+#ifndef RADEONVB_INC
+#define RADEONVB_INC
-#ifdef GLX_DIRECT_RENDERING
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "radeon_context.h"
-/* FIXME: This is endian-specific */
-typedef struct {
- GLubyte red;
- GLubyte green;
- GLubyte blue;
- GLubyte alpha;
-} radeon_color_t;
+#define _RADEON_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _NEW_TEXTURE | \
+ _NEW_FOG)
-/* The vertex structure. The final tu1/tv1 values are only used in
- * multitexture modes, and the rhw2 value is currently never used.
- */
-typedef struct {
- GLfloat x, y, z; /* Coordinates in screen space */
- GLfloat rhw; /* Reciprocal homogeneous w */
- radeon_color_t color; /* Diffuse color */
- radeon_color_t specular; /* Specular color (alpha is fog) */
- GLfloat tu0, tv0; /* Texture 0 coordinates */
- GLfloat tu1, tv1; /* Texture 1 coordinates */
- GLfloat rhw2; /* Reciprocal homogeneous w2 */
-} radeon_vertex;
-
-/* Format of vertices in radeon_vertex struct:
- */
-#define RADEON_TEX0_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
- RADEON_CP_VC_FRMT_Z | \
- RADEON_CP_VC_FRMT_W0 | \
- RADEON_CP_VC_FRMT_PKCOLOR | \
- RADEON_CP_VC_FRMT_PKSPEC | \
- RADEON_CP_VC_FRMT_ST0)
-
-#define RADEON_TEX1_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
- RADEON_CP_VC_FRMT_Z | \
- RADEON_CP_VC_FRMT_W0 | \
- RADEON_CP_VC_FRMT_PKCOLOR | \
- RADEON_CP_VC_FRMT_PKSPEC | \
- RADEON_CP_VC_FRMT_ST0 | \
- RADEON_CP_VC_FRMT_ST1)
-
-#if 0
-#define RADEON_PROJ_TEX1_VERTEX_FORMAT (RADEON_CP_VC_FRMT_XY | \
- RADEON_CP_VC_FRMT_Z | \
- RADEON_CP_VC_FRMT_W0 | \
- RADEON_CP_VC_FRMT_PKCOLOR | \
- RADEON_CP_VC_FRMT_PKSPEC | \
- RADEON_CP_VC_FRMT_ST0 | \
- RADEON_CP_VC_FRMT_ST1 | \
- RADEON_CP_VC_FRMT_Q1)
-#endif
+extern void radeonCheckTexSizes( GLcontext *ctx );
+extern void radeonChooseVertexState( GLcontext *ctx );
+extern void radeonBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
-/* The fastpath code still expects a 16-float stride vertex.
- */
-union radeon_vertex_t {
- radeon_vertex v;
- GLfloat f[16];
- GLuint ui[16];
-};
-
-typedef union radeon_vertex_t radeonVertex;
-typedef union radeon_vertex_t *radeonVertexPtr;
-
-typedef struct {
- radeonVertexPtr verts;
- GLvector1ui clipped_elements;
- GLint last_vert;
- void *vert_store;
- GLuint size;
-} *radeonVertexBufferPtr;
-
-#define RADEON_DRIVER_DATA(vb) ((radeonVertexBufferPtr)((vb)->driver_data))
-
-#define RADEON_WIN_BIT 0x01
-#define RADEON_RGBA_BIT 0x02
-#define RADEON_FOG_BIT 0x04
-#define RADEON_SPEC_BIT 0x08
-#define RADEON_TEX0_BIT 0x10
-#define RADEON_TEX1_BIT 0x20
-#define RADEON_MAX_SETUPFUNC 0x40
-
-extern void radeonDDChooseRasterSetupFunc( GLcontext *ctx );
-extern void radeonPrintSetupFlags( char *msg, GLuint flags );
-
-extern void radeonDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *s );
-extern void radeonDDPartialRasterSetup( struct vertex_buffer *VB );
-extern void radeonDDDoRasterSetup( struct vertex_buffer *VB );
-
-extern void radeonDDResizeVB( struct vertex_buffer *VB, GLuint size );
-extern void radeonDDRegisterVB( struct vertex_buffer *VB );
-extern void radeonDDUnregisterVB( struct vertex_buffer *VB );
-
-extern void radeonDDSetupInit( void );
+extern void radeonPrintSetupFlags(char *msg, GLuint flags );
+
+extern void radeonInitVB( GLcontext *ctx );
+extern void radeonFreeVB( GLcontext *ctx );
+
+extern void radeon_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void radeon_emit_indexed_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void radeon_translate_vertex( GLcontext *ctx,
+ const radeonVertex *src,
+ SWvertex *dst );
+
+extern void radeon_print_vertex( GLcontext *ctx, const radeonVertex *v );
#endif
-#endif /* __RADEON_VB_H__ */
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c
new file mode 100644
index 000000000..414dc072d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c
@@ -0,0 +1,785 @@
+/* $XFree86$ */
+/*
+ * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California.
+ *
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to 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
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION 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:
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+
+#include "glheader.h"
+#include "api_noop.h"
+#include "colormac.h"
+#include "context.h"
+#include "light.h"
+#include "macros.h"
+#include "mem.h"
+#include "mmath.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "vtxfmt.h"
+
+#include "math/m_xform.h"
+#include "tnl/tnl.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_vb.h"
+#include "radeon_vtxfmt.h"
+
+
+struct radeon_imm_vertex {
+ /* The immediate mode vertex cache.
+ */
+ radeonTnlVertex vertices[8];
+
+ /* Current vertices out of the cache. This makes the state machine
+ * a lot simpler, and avoids the need to swap lots of function
+ * pointers around.
+ */
+ radeonTnlVertex *v0;
+ radeonTnlVertex *v1;
+ radeonTnlVertex *v2;
+ radeonTnlVertex *v3;
+
+ radeon_flush_func *flush_tab;
+
+ void (*save_vertex)( GLcontext *ctx, radeonTnlVertex *v );
+ void (*flush_vertex)( GLcontext *ctx, radeonTnlVertex *v );
+
+ radeon_interp_func interp;
+
+ GLuint prim;
+ GLuint format;
+
+ GLvertexformat vtxfmt;
+};
+
+
+#define VERTEX radeonVertex
+#define TNL_VERTEX radeonTnlVertex
+
+
+#define LINTERP( T, A, B ) ((A) + (T) * ((B) - (A)))
+
+#define INTERP_RGBA( t, out, a, b ) \
+do { \
+ GLint i; \
+ for ( i = 0 ; i < 4 ; i++ ) { \
+ GLfloat fa = UBYTE_TO_FLOAT( a[i] ); \
+ GLfloat fb = UBYTE_TO_FLOAT( b[i] ); \
+ GLfloat fo = LINTERP( t, fa, fb ); \
+ UNCLAMPED_FLOAT_TO_UBYTE( out[i], fo ); \
+ } \
+} while (0)
+
+
+
+
+/* ================================================================
+ * Color functions: Always update ctx->Current.*
+ */
+
+/* ================================================================
+ * Material functions:
+ */
+
+static __inline void radeon_recalc_base_color( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_light *light;
+
+ COPY_3V( rmesa->state.light.base_color, ctx->Light._BaseColor[0] );
+ foreach ( light, &ctx->Light.EnabledList ) {
+ ACC_3V( rmesa->state.light.base_color, light->_MatAmbient[0] );
+ }
+
+ UNCLAMPED_FLOAT_TO_UBYTE( rmesa->state.light.base_alpha,
+ ctx->Light.Material[0].Diffuse[3] );
+}
+
+
+/* ================================================================
+ * Normal functions:
+ */
+
+struct radeon_norm_tab {
+ void (*normal3f_multi)( GLfloat x, GLfloat y, GLfloat z );
+ void (*normal3fv_multi)( const GLfloat *v );
+ void (*normal3f_single)( GLfloat x, GLfloat y, GLfloat z );
+ void (*normal3fv_single)( const GLfloat *v );
+};
+
+static struct radeon_norm_tab norm_tab[0x4];
+
+
+#define HAVE_HW_LIGHTING 0
+
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ radeonTnlVertexPtr v = rmesa->imm.v0
+
+#define CURRENT_NORMAL rmesa->state.current.normal
+#define BASE_COLOR rmesa->state.light.base_color
+#define BASE_ALPHA rmesa->state.light.base_alpha
+
+#define VERT_COLOR( COMP ) v->color[COMP]
+
+
+#define IND (0)
+#define TAG(x) radeon_##x
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_RESCALE)
+#define TAG(x) radeon_##x##_rescale
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_NORMALIZE)
+#define TAG(x) radeon_##x##_normalize
+#include "tnl_dd/t_dd_imm_napi.h"
+
+
+static void radeon_init_norm_funcs( void )
+{
+ radeon_init_norm();
+ radeon_init_norm_rescale();
+ radeon_init_norm_normalize();
+}
+
+static void radeon_choose_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint index;
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Transform.Normalize ) {
+ index = NORM_NORMALIZE;
+ }
+ else if ( !ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0 ) {
+ index = NORM_RESCALE;
+ }
+ else {
+ index = 0;
+ }
+
+ if ( ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev ) {
+ ctx->Exec->Normal3f = norm_tab[index].normal3f_single;
+ } else {
+ ctx->Exec->Normal3f = norm_tab[index].normal3f_multi;
+ }
+ } else {
+ ctx->Exec->Normal3f = _mesa_noop_Normal3f;
+ }
+
+ glNormal3f( x, y, z );
+}
+
+static void radeon_choose_Normal3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint index;
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Transform.Normalize ) {
+ index = NORM_NORMALIZE;
+ }
+ else if ( !ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0 ) {
+ index = NORM_RESCALE;
+ }
+ else {
+ index = 0;
+ }
+
+ if ( ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev ) {
+ ctx->Exec->Normal3fv = norm_tab[index].normal3fv_single;
+ } else {
+ ctx->Exec->Normal3fv = norm_tab[index].normal3fv_multi;
+ }
+ } else {
+ ctx->Exec->Normal3fv = _mesa_noop_Normal3fv;
+ }
+
+ glNormal3fv( v );
+}
+
+
+
+
+/* ================================================================
+ * Texture functions:
+ */
+
+#define GET_CURRENT \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+
+#define NUM_TEXTURE_UNITS RADEON_MAX_TEXTURE_UNITS
+#define DO_PROJ_TEX
+
+#define CURRENT_TEXTURE( unit ) rmesa->state.current.texture[unit]
+
+#define TAG(x) radeon_##x
+#include "tnl_dd/t_dd_imm_tapi.h"
+
+
+
+/* ================================================================
+ * Vertex functions:
+ */
+
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ radeonTnlVertexPtr v = rmesa->imm.v0
+
+#define CURRENT_VERTEX v->obj
+#define SAVE_VERTEX rmesa->imm.save_vertex( ctx, v )
+
+#define TAG(x) radeon_##x
+#include "tnl_dd/t_dd_imm_vapi.h"
+
+
+
+
+struct radeon_vert_tab {
+ void (*save_vertex)( GLcontext *ctx, radeonTnlVertexPtr v );
+ void (*interpolate_vertex)( GLfloat t,
+ radeonTnlVertex *O,
+ const radeonTnlVertex *I,
+ const radeonTnlVertex *J );
+};
+
+static struct radeon_vert_tab vert_tab[0xf];
+
+#define VTX_NORMAL 0x0
+#define VTX_RGBA 0x1
+#define VTX_SPEC 0x2
+#define VTX_TEX0 0x4
+#define VTX_TEX1 0x8
+
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+
+#define CURRENT_COLOR rmesa->state.current.color
+#define CURRENT_SPECULAR rmesa->state.current.specular
+
+#define CURRENT_NORMAL( COMP ) rmesa->state.current.normal[COMP]
+#define CURRENT_TEXTURE( U, COMP ) rmesa->state.current.texture[U][COMP]
+
+#define FLUSH_VERTEX rmesa->imm.flush_vertex( ctx, v );
+
+
+#define IND (VTX_NORMAL)
+#define TAG(x) radeon_##x##_NORMAL
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_NORMAL|VTX_TEX0)
+#define TAG(x) radeon_##x##_NORMAL_TEX0
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_NORMAL|VTX_TEX0|VTX_TEX1)
+#define TAG(x) radeon_##x##_NORMAL_TEX0_TEX1
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_RGBA)
+#define TAG(x) radeon_##x##_RGBA
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_RGBA|VTX_TEX0)
+#define TAG(x) radeon_##x##_RGBA_TEX0
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_RGBA|VTX_TEX1)
+#define TAG(x) radeon_##x##_RGBA_TEX0_TEX1
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+
+static void radeon_init_vert_funcs( void )
+{
+ radeon_init_vert_NORMAL();
+ radeon_init_vert_NORMAL_TEX0();
+ radeon_init_vert_NORMAL_TEX0_TEX1();
+ radeon_init_vert_RGBA();
+ radeon_init_vert_RGBA_TEX0();
+ radeon_init_vert_RGBA_TEX0_TEX1();
+}
+
+
+
+
+
+
+
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+
+#define GET_INTERP_FUNC \
+ radeon_interp_func interp = rmesa->imm.interp
+
+#define FLUSH_VERTEX rmesa->imm.flush_vertex
+
+#define IMM_VERTEX( V ) rmesa->imm.V
+#define IMM_VERTICES( n ) rmesa->imm.vertices[n]
+
+
+/* TINY_VERTEX_FORMAT:
+ */
+#define GET_VERTEX_SPACE( n ) radeonAllocDmaLow( rmesa, n * 16, __FUNCTION__ )
+
+#define EMIT_VERTEX( vb, v ) \
+do { \
+ vb[0] = *(GLuint *)&(v->clip[0]); \
+ vb[1] = *(GLuint *)&(v->clip[1]); \
+ vb[2] = *(GLuint *)&(v->clip[2]); \
+ vb[3] = *(GLuint *)&(v->color); \
+ vb += 4; \
+} while (0)
+
+#define TAG(x) radeon_##x##_tiny
+#define PRESERVE_PRIM_DEFS
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+
+/* NOTEX_VERTEX_FORMAT:
+ */
+#define GET_VERTEX_SPACE( n ) radeonAllocDmaLow( rmesa, n * 24, __FUNCTION__ )
+
+#define EMIT_VERTEX( vb, v ) \
+do { \
+ vb[0] = *(GLuint *)&(v->clip[0]); \
+ vb[1] = *(GLuint *)&(v->clip[1]); \
+ vb[2] = *(GLuint *)&(v->clip[2]); \
+ vb[3] = *(GLuint *)&(v->clip[3]); \
+ vb[4] = *(GLuint *)&(v->color); \
+ vb[5] = *(GLuint *)&(v->specular); \
+ vb += 6; \
+} while (0)
+
+#define TAG(x) radeon_##x##_notex
+#define PRESERVE_PRIM_DEFS
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+
+/* TEX0_VERTEX_FORMAT:
+ */
+#define GET_VERTEX_SPACE( n ) radeonAllocDmaLow( rmesa, n * 32, __FUNCTION__ )
+
+#define EMIT_VERTEX( vb, v ) \
+do { \
+ vb[0] = *(GLuint *)&(v->clip[0]); \
+ vb[1] = *(GLuint *)&(v->clip[1]); \
+ vb[2] = *(GLuint *)&(v->clip[2]); \
+ vb[3] = *(GLuint *)&(v->clip[3]); \
+ vb[4] = *(GLuint *)&(v->color); \
+ vb[5] = *(GLuint *)&(v->specular); \
+ vb[6] = *(GLuint *)&(v->texture[0][0]); \
+ vb[7] = *(GLuint *)&(v->texture[0][1]); \
+ vb += 8; \
+} while (0)
+
+#define TAG(x) radeon_##x##_tex0
+#define PRESERVE_PRIM_DEFS
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+
+/* TEX1_VERTEX_FORMAT:
+ */
+#define GET_VERTEX_SPACE( n ) radeonAllocDmaLow( rmesa, n * 40, __FUNCTION__ )
+
+#define EMIT_VERTEX( vb, v ) \
+do { \
+ vb[0] = *(GLuint *)&(v->clip[0]); \
+ vb[1] = *(GLuint *)&(v->clip[1]); \
+ vb[2] = *(GLuint *)&(v->clip[2]); \
+ vb[3] = *(GLuint *)&(v->clip[3]); \
+ vb[4] = *(GLuint *)&(v->color); \
+ vb[5] = *(GLuint *)&(v->specular); \
+ vb[6] = *(GLuint *)&(v->texture[0][0]); \
+ vb[7] = *(GLuint *)&(v->texture[0][1]); \
+ vb[8] = *(GLuint *)&(v->texture[1][0]); \
+ vb[9] = *(GLuint *)&(v->texture[1][1]); \
+ vb += 10; \
+} while (0)
+
+#define TAG(x) radeon_##x##_tex1
+#define PRESERVE_PRIM_DEFS
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+
+
+
+
+
+
+/* Bzzt: Material changes are lost on fallback.
+ */
+static void radeon_Materialfv( GLenum face, GLenum pname,
+ const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ _mesa_noop_Materialfv( face, pname, params );
+ radeon_recalc_base_color( ctx );
+}
+
+
+
+
+
+/* ================================================================
+ * Fallback functions:
+ */
+
+static void radeon_do_fallback( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct radeon_current_state *current = &rmesa->state.current;
+
+ /* Tell tnl to restore its exec vtxfmt, rehook its driver callbacks
+ * and revive internal state that depended on those callbacks:
+ */
+ _tnl_wakeup_exec( ctx );
+
+ /* Replay enough vertices that the current primitive is continued
+ * correctly:
+ */
+ if ( rmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END ) {
+ glBegin( rmesa->imm.prim );
+ /*rmesa->fire_on_fallback( ctx );*/
+ }
+
+ /* Replay the current, partially complete vertex:
+ */
+ if ( current->texture[0][3] == 1.0 ) {
+ glMultiTexCoord3fvARB( GL_TEXTURE0_ARB, current->texture[0] );
+ } else {
+ glMultiTexCoord4fvARB( GL_TEXTURE0_ARB, current->texture[0] );
+ }
+
+ if ( current->texture[1][3] == 1.0 ) {
+ glMultiTexCoord3fvARB( GL_TEXTURE1_ARB, current->texture[1] );
+ } else {
+ glMultiTexCoord4fvARB( GL_TEXTURE1_ARB, current->texture[1] );
+ }
+
+ /* FIXME: Secondary color, fog coord...
+ */
+
+ if ( ctx->Light.Enabled ) {
+ glColor4fv( ctx->Current.Color ); /* Catch ColorMaterial */
+ glNormal3fv( current->normal );
+ } else {
+ glColor4ubv( current->color );
+ }
+}
+
+#define PRE_LOOPBACK( FUNC ) do { \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeon_do_fallback( ctx ); \
+} while (0)
+
+#define TAG(x) radeon_fallback_##x
+#include "vtxfmt_tmp.h"
+
+
+
+
+
+
+static void radeon_Begin( GLenum prim )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( prim > GL_POLYGON ) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+ if ( rmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END ) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ ctx->Driver.NeedFlush |= (FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+
+
+ radeonChooseVertexState( ctx );
+
+
+ rmesa->imm.prim = prim;
+ rmesa->imm.v0 = &rmesa->imm.vertices[0];
+
+ rmesa->imm.save_vertex = radeon_save_vertex_RGBA;
+ rmesa->imm.flush_vertex = rmesa->imm.flush_tab[prim];
+}
+
+static void radeon_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( rmesa->imm.prim == PRIM_OUTSIDE_BEGIN_END ) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ rmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ ctx->Driver.NeedFlush &= ~(FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+}
+
+
+
+
+
+
+void radeonInitTnlModule( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLvertexformat *vfmt = &(rmesa->imm.vtxfmt);
+
+ return;
+
+ radeon_init_norm_funcs();
+ radeon_init_vert_funcs();
+
+ MEMSET( vfmt, 0, sizeof(GLvertexformat) );
+
+ /* Handled fully in supported states:
+ */
+ vfmt->ArrayElement = NULL; /* FIXME: ... */
+ vfmt->Color3f = radeon_choose_Color3f;
+ vfmt->Color3fv = radeon_choose_Color3fv;
+ vfmt->Color3ub = radeon_choose_Color3ub;
+ vfmt->Color3ubv = radeon_choose_Color3ubv;
+ vfmt->Color4f = radeon_choose_Color4f;
+ vfmt->Color4fv = radeon_choose_Color4fv;
+ vfmt->Color4ub = radeon_choose_Color4ub;
+ vfmt->Color4ubv = radeon_choose_Color4ubv;
+ vfmt->FogCoordfvEXT = radeon_FogCoordfvEXT;
+ vfmt->FogCoordfEXT = radeon_FogCoordfEXT;
+ vfmt->Materialfv = radeon_Materialfv;
+ vfmt->MultiTexCoord1fARB = radeon_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = radeon_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = radeon_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = radeon_MultiTexCoord2fvARB;
+ vfmt->MultiTexCoord3fARB = radeon_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = radeon_MultiTexCoord3fvARB;
+ vfmt->MultiTexCoord4fARB = radeon_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = radeon_MultiTexCoord4fvARB;
+ vfmt->Normal3f = radeon_choose_Normal3f;
+ vfmt->Normal3fv = radeon_choose_Normal3fv;
+ vfmt->SecondaryColor3ubEXT = radeon_SecondaryColor3ubEXT;
+ vfmt->SecondaryColor3ubvEXT = radeon_SecondaryColor3ubvEXT;
+ vfmt->SecondaryColor3fEXT = radeon_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = radeon_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = radeon_TexCoord1f;
+ vfmt->TexCoord1fv = radeon_TexCoord1fv;
+ vfmt->TexCoord2f = radeon_TexCoord2f;
+ vfmt->TexCoord2fv = radeon_TexCoord2fv;
+ vfmt->TexCoord3f = radeon_TexCoord3f;
+ vfmt->TexCoord3fv = radeon_TexCoord3fv;
+ vfmt->TexCoord4f = radeon_TexCoord4f;
+ vfmt->TexCoord4fv = radeon_TexCoord4fv;
+ vfmt->Vertex2f = radeon_Vertex2f;
+ vfmt->Vertex2fv = radeon_Vertex2fv;
+ vfmt->Vertex3f = radeon_Vertex3f;
+ vfmt->Vertex3fv = radeon_Vertex3fv;
+ vfmt->Vertex4f = radeon_Vertex4f;
+ vfmt->Vertex4fv = radeon_Vertex4fv;
+
+ vfmt->Begin = radeon_Begin;
+ vfmt->End = radeon_End;
+
+ vfmt->Rectf = _mesa_noop_Rectf; /* generic helper */
+
+ vfmt->DrawArrays = NULL;
+ vfmt->DrawElements = NULL;
+ vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; /* discard range */
+
+
+ /* Not active in supported states; just keep ctx->Current uptodate:
+ */
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->Indexi = _mesa_noop_Indexi;
+ vfmt->Indexiv = _mesa_noop_Indexiv;
+
+
+ /* Active but unsupported -- fallback if we receive these:
+ *
+ * All of these fallbacks can be fixed with additional code, except
+ * CallList, unless we build a play_immediate_noop() command which
+ * turns an immediate back into glBegin/glEnd commands...
+ */
+ vfmt->CallList = radeon_fallback_CallList;
+ vfmt->EvalCoord1f = radeon_fallback_EvalCoord1f;
+ vfmt->EvalCoord1fv = radeon_fallback_EvalCoord1fv;
+ vfmt->EvalCoord2f = radeon_fallback_EvalCoord2f;
+ vfmt->EvalCoord2fv = radeon_fallback_EvalCoord2fv;
+ vfmt->EvalMesh1 = radeon_fallback_EvalMesh1;
+ vfmt->EvalMesh2 = radeon_fallback_EvalMesh2;
+ vfmt->EvalPoint1 = radeon_fallback_EvalPoint1;
+ vfmt->EvalPoint2 = radeon_fallback_EvalPoint2;
+
+
+ rmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ /* THIS IS A HACK!
+ */
+ _mesa_install_exec_vtxfmt( ctx, vfmt );
+}
+
+
+
+
+
+
+#if 0
+
+
+
+static void radeon_Begin( GLenum prim )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_prim *tab = &radeon_prim_tab[(int)prim];
+
+ if ( prim > GL_POLYGON ) {
+ gl_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if ( rmesa->prim != PRIM_OUTSIDE_BEGIN_END ) {
+ gl_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ if ( tab->fire_on_vertex ) {
+ rmesa->fire_on_vertex = tab->fire_on_vertex;
+ rmesa->fire_on_end = tab->fire_on_end;
+ rmesa->fire_on_fallback = tab->fire_on_fallback;
+ rmesa->vert = &(rmesa->cache[0]);
+ rmesa->prim = prim;
+ ctx->Driver.NeedFlush |= (FLUSH_INSIDE_BEGIN_END |
+ FLUSH_STORED_VERTICES);
+ } else {
+ radeon_fallback_vtxfmt( ctx );
+ }
+}
+
+static void radeon_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( rmesa->prim == PRIM_OUTSIDE_BEGIN_END ) {
+ gl_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ rmesa->fire_on_end( ctx );
+ rmesa->prim = PRIM_OUTSIDE_BEGIN_END;
+
+ ctx->Exec->Vertex3fv = radeon_noop_Vertex3fv;
+ ctx->Exec->Vertex3f = radeon_noop_Vertex3f;
+ ctx->Exec->Vertex2f = radeon_noop_Vertex2f;
+
+ ctx->Driver.NeedFlush &= ~(FLUSH_INSIDE_BEGIN_END |
+ FLUSH_STORED_VERTICES);
+}
+
+
+
+
+static GLboolean radeon_flush_vtxfmt( GLcontext *ctx, GLuint flags )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( fxMesa->prim != PRIM_OUTSIDE_BEGIN_END )
+ return GL_FALSE;
+
+ /* Outside begin/end. All vertices will already be flushed, just
+ * update ctx->Current.
+ */
+ if ( flags & FLUSH_UPDATE_CURRENT ) {
+ radeonClipVertexPtr v = &(RADEON_CONTEXT(ctx)->Current);
+ COPY_2FV( ctx->Current.Texcoord[0], v->texcoord[0] );
+ COPY_2FV( ctx->Current.Texcoord[1], v->texcoord[1] );
+ if ( rmesa->accel_light == ACCEL_LIGHT ) {
+ COPY_3FV( ctx->Current.Normal, v->normal );
+ } else {
+ ctx->Current.Color[RCOMP] = UBYTE_TO_CHAN( v->v.color.red );
+ ctx->Current.Color[GCOMP] = UBYTE_TO_CHAN( v->v.color.green );
+ ctx->Current.Color[BCOMP] = UBYTE_TO_CHAN( v->v.color.blue );
+ ctx->Current.Color[ACOMP] = UBYTE_TO_CHAN( v->v.color.alpha );
+
+ if ( ctx->Light.ColorMaterialEnabled )
+ _mesa_update_color_material( ctx, ctx->Current.Color );
+ }
+ }
+
+ /* Could clear this flag and set it from each 'choose' function,
+ * maybe, but there isn't much of a penalty for leaving it set:
+ */
+ ctx->Driver.NeedFlush = FLUSH_UPDATE_CURRENT;
+ return GL_TRUE;
+}
+
+void radeon_update_lighting( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( !ctx->Light.Enabled ) {
+ rmesa->accel_light = ACCEL_NO_LIGHT;
+ }
+ else if ( !ctx->Light._NeedVertices && !ctx->Light.Model.TwoSide ) {
+ rmesa->accel_light = ACCEL_LIGHT;
+ radeon_recalc_basecolor( ctx );
+ }
+ else {
+ radeon->accel_light = 0;
+ }
+}
+
+
+/* How to fallback:
+ * - install default vertex format
+ * - call glBegin
+ * - revive stalled vertices (may be reordered).
+ * - re-issue call that caused fallback.
+ */
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgapipeline.h b/xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.h
index ab961a895..d0bc1c04d 100644
--- a/xc/lib/GL/mesa/src/drv/mga/mgapipeline.h
+++ b/xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.h
@@ -1,6 +1,7 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapipeline.h,v 1.3 2001/04/10 16:07:50 dawes Exp $ */
+/* $XFree86$ */
/*
- * Copyright 2000-2001 VA Linux Systems, Inc.
+ * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, California.
+ *
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -16,31 +17,30 @@
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION 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@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
*/
-#ifndef _MGA_PIPELINE_H
-#define _MGA_PIPELINE_H
+#ifndef __RADEON_VTXFMT_H__
+#define __RADEON_VTXFMT_H__
+#ifdef GLX_DIRECT_RENDERING
-extern GLuint mgaDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
+#include "radeon_context.h"
-extern GLboolean mgaDDBuildImmediatePipeline( GLcontext *ctx );
-extern GLboolean mgaDDBuildPrecalcPipeline( GLcontext *ctx );
+extern void radeonInitTnlModule( GLcontext *ctx );
-extern void mgaDDFastPath( struct vertex_buffer *VB );
-extern void mgaDDFastPathInit( void );
-extern void mgaDDEltPath( struct vertex_buffer *VB );
-extern void mgaDDEltPathInit( void );
+extern radeon_flush_func radeon_flush_tab_tiny[GL_POLYGON+1];
+extern radeon_flush_func radeon_flush_tab_notex[GL_POLYGON+1];
+extern radeon_flush_func radeon_flush_tab_tex0[GL_POLYGON+1];
+extern radeon_flush_func radeon_flush_tab_tex1[GL_POLYGON+1];
#endif
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/radeon/radeon_xmesa.c b/xc/lib/GL/mesa/src/drv/radeon/radeon_xmesa.c
deleted file mode 100644
index 6db4d690a..000000000
--- a/xc/lib/GL/mesa/src/drv/radeon/radeon_xmesa.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_xmesa.c,v 1.4 2001/04/10 16:07:53 dawes Exp $ */
-/**************************************************************************
-
-Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
- VA Linux Systems Inc., Fremont, California.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <martin@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-/* Radeon Mesa driver includes */
-#include "radeon_context.h"
-#include "radeon_ioctl.h"
-#include "radeon_state.h"
-#include "radeon_tex.h"
-
-/* Mesa src includes */
-#include "context.h"
-#include "simple_list.h"
-#include "mmath.h"
-
-extern void __driRegisterExtensions( void );
-
-static radeonContextPtr radeonCtx = NULL;
-
-
-/* Initialize the driver specific screen private data.
- */
-GLboolean XMesaInitDriver( __DRIscreenPrivate *sPriv )
-{
- sPriv->private = (void *) radeonCreateScreen( sPriv );
-
- /* Check the DRI version */
- {
- int major, minor, patch;
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 || minor < 0 ) {
- char msg[128];
- sprintf( msg, "RADEON DRI driver expected DRI version 4.0.x but got version %d.%d.%d", major, minor, patch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
- }
- }
-
- /* Check that the DDX driver version is compatible */
- if ( sPriv->ddxMajor != 4 ||
- sPriv->ddxMinor < 0 ) {
- char msg[128];
- sprintf( msg, "RADEON DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- /* Check that the DRM driver version is compatible */
- if ( sPriv->drmMajor != 1 ||
- sPriv->drmMinor < 1 ) {
- char msg[128];
- sprintf( msg, "RADEON DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- if ( !sPriv->private ) {
- radeonDestroyScreen( sPriv );
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-/* Reset the driver specific screen private data.
- */
-void XMesaResetDriver( __DRIscreenPrivate *sPriv )
-{
- radeonDestroyScreen( sPriv );
-}
-
-/* Create and initialize the Mesa and driver specific visual data.
- */
-GLvisual *XMesaCreateVisual( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config )
-{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount( visinfo->red_mask ),
- _mesa_bitcount( visinfo->green_mask ),
- _mesa_bitcount( visinfo->blue_mask ),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */);
-}
-
-/* Create and initialize the Mesa and driver specific context data.
- */
-GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
-{
- return radeonCreateContext( dpy, mesaVis, driContextPriv );
-}
-
-/* Destroy the Mesa and driver specific context data.
- */
-void XMesaDestroyContext( __DRIcontextPrivate *driContextPriv )
-{
- radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
-
- if ( rmesa == (void *)radeonCtx) radeonCtx = NULL;
- radeonDestroyContext( rmesa );
-}
-
-/* Create and initialize the Mesa and driver specific pixmap buffer
- * data.
- */
-GLframebuffer *XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- GL_FALSE /* software alpha buffer? */ );
-}
-
-/* Create and initialize the Mesa and driver specific pixmap buffer
- * data.
- */
-GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0 );
-#else
- return NULL; /* not implemented yet */
-#endif
-}
-
-/* Copy the back color buffer to the front color buffer.
- */
-void XMesaSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
-{
- /* FIXME: This assumes buffer is currently bound to a context. This
- * needs to be able to swap buffers when not currently bound. Also,
- * this needs to swap according to buffer, and NOT according to
- * context!
- */
- if ( radeonCtx == NULL ) return;
-
- /* Only swap buffers when a back buffer exists.
- */
- if ( radeonCtx->glCtx->Visual->DBflag ) {
- FLUSH_VB( radeonCtx->glCtx, "swap buffers" );
- if ( !radeonCtx->doPageFlip ) {
- radeonSwapBuffers( radeonCtx );
- } else {
- radeonPageFlip( radeonCtx );
- }
- }
-}
-
-/* Force the context `c' to be the current context and associate with it
- * buffer `b'.
- */
-GLboolean XMesaMakeCurrent( __DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv )
-{
- if ( driContextPriv ) {
- radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
-
- radeonCtx = radeonMakeCurrent( radeonCtx, rmesa, driDrawPriv );
-
- gl_make_current2( radeonCtx->glCtx,
- driDrawPriv->mesaBuffer,
- driReadPriv->mesaBuffer );
-
- if ( radeonCtx->driDrawable != driDrawPriv ) {
- radeonCtx->driDrawable = driDrawPriv;
- radeonCtx->dirty = RADEON_UPLOAD_ALL;
- }
-
- /* GH: We need this to correctly calculate the window offset
- * and aux scissor rects.
- */
- radeonCtx->new_state = RADEON_NEW_WINDOW | RADEON_NEW_CLIP;
-
- if ( !radeonCtx->glCtx->Viewport.Width ) {
- gl_Viewport( radeonCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
- }
- } else {
- gl_make_current( 0, 0 );
- radeonCtx = NULL;
- }
-
- return GL_TRUE;
-}
-
-/* Force the context `c' to be unbound from its buffer.
- */
-GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
- return GL_TRUE;
-}
-
-/* This function is called by libGL.so as soon as libGL.so is loaded.
- * This is where we'd register new extension functions with the dispatcher.
- */
-void __driRegisterExtensions( void )
-{
-}
-
-/* Initialize the fullscreen mode.
- */
-GLboolean
-XMesaOpenFullScreen( __DRIcontextPrivate *driContextPriv )
-{
- radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
- GLint ret;
-
- /* FIXME: Do we need to check this?
- */
- if ( !radeonCtx->glCtx->Visual->DBflag )
- return GL_TRUE;
-
- LOCK_HARDWARE( rmesa );
- radeonWaitForIdleLocked( rmesa );
-
- /* Ignore errors. If this fails, we simply don't do page flipping.
- */
- ret = drmRadeonFullScreen( rmesa->driFd, GL_TRUE );
-
- UNLOCK_HARDWARE( rmesa );
-
- rmesa->doPageFlip = ( ret == 0 );
-
- return GL_TRUE;
-}
-
-/* Shut down the fullscreen mode.
- */
-GLboolean
-XMesaCloseFullScreen( __DRIcontextPrivate *driContextPriv )
-{
- radeonContextPtr rmesa = (radeonContextPtr)driContextPriv->driverPrivate;
-
- LOCK_HARDWARE( rmesa );
- radeonWaitForIdleLocked( rmesa );
-
- /* Don't care if this fails, we're not page flipping anymore.
- */
- drmRadeonFullScreen( rmesa->driFd, GL_FALSE );
-
- UNLOCK_HARDWARE( rmesa );
-
- rmesa->doPageFlip = GL_FALSE;
- rmesa->currentPage = 0;
-
- return GL_TRUE;
-}
-
-#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
index abb22e61a..7405bc18d 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
+++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile,v 1.28 2001/08/18 02:51:06 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile,v 1.25.2.1 2001/06/01 07:42:23 alanh Exp $
#include <Threads.tmpl>
@@ -22,13 +22,15 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile,v 1.28 2001/08/18 02:51:06
#ifdef i386Architecture
#include "../../X86/Imakefile.inc"
#endif
+#ifdef SparcArchitecture
+#include "../../SPARC/Imakefile.inc"
+#endif
DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(MESA_ASM_DEFINES)
INCLUDES = $(X_INCLUDES) $(MESA_INCLUDES) $(DRI_INCLUDES) \
-I$(GLIDE3INCDIR)
- DRIOBJS = $(GLXLIBSRC)/mesa/dri/dri_mesa.o \
- $(GLXLIBSRC)/dri/dri_tmm.o
+ DRIOBJS = $(GLXLIBSRC)/dri/dri_util.o
DRMOBJS = $(GLXLIBSRC)/dri/drm/xf86drm.o \
$(GLXLIBSRC)/dri/drm/xf86drmHash.o \
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc
index 0b7080a49..c3e85ff4a 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc
+++ b/xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc,v 1.3 2001/08/18 02:51:06 dawes Exp $
+XCOMM $XFree86: xc/lib/GL/mesa/src/drv/tdfx/Imakefile.inc,v 1.1 2001/03/23 19:18:44 dawes Exp $
#ifndef MesaDrvSrcDir
#define MesaDrvSrcDir $(GLXLIBSRC)/mesa/src/drv
@@ -16,26 +16,28 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
#endif
#if BuildXF86DRI
- DRI_DEFINES = GlxDefines
- DRI_INCLUDES = -I$(GLXLIBSRC)/dri -I$(GLXLIBSRC)/glx \
- -I$(INCLUDESRC) -I$(INCLUDESRC)/GL \
- -I$(GLXLIBSRC)/mesa/dri \
+ DRI_DEFINES = GlxDefines -DX_BYTE_ORDER=ByteOrder
+ DRI_INCLUDES = -I$(GLXLIBSRC)/dri \
+ -I$(GLXLIBSRC)/glx \
+ -I$(INCLUDESRC) \
+ -I$(INCLUDESRC)/GL \
-I$(SERVERSRC)/GL/dri \
-I$(XF86OSSRC) \
-I$(XF86DRIVERSRC)/tdfx \
- -I$(GLXLIBSRC)/dri/drm
+ -I$(XF86COMSRC) \
+ -I$(GLXLIBSRC)/dri/drm \
+ -I$(GLXLIBSRC)/include
#endif
-MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESADRVSRCDIR)/common \
-I$(MESADRVSRCDIR)/tdfx
X_INCLUDES = -I$(XINCLUDESRC) -I$(EXTINCSRC)
TDFXSRCS = $(MESADRVTDFXBUILDDIR)tdfx_context.c \
$(MESADRVTDFXBUILDDIR)tdfx_dd.c \
- $(MESADRVTDFXBUILDDIR)tdfx_pixels.c \
- $(MESADRVTDFXBUILDDIR)tdfx_fastpath.c \
$(MESADRVTDFXBUILDDIR)tdfx_lock.c \
- $(MESADRVTDFXBUILDDIR)tdfx_pipeline.c \
+ $(MESADRVTDFXBUILDDIR)tdfx_pixels.c \
$(MESADRVTDFXBUILDDIR)tdfx_render.c \
$(MESADRVTDFXBUILDDIR)tdfx_screen.c \
$(MESADRVTDFXBUILDDIR)tdfx_span.c \
@@ -44,16 +46,12 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
$(MESADRVTDFXBUILDDIR)tdfx_texman.c \
$(MESADRVTDFXBUILDDIR)tdfx_texstate.c \
$(MESADRVTDFXBUILDDIR)tdfx_tris.c \
- $(MESADRVTDFXBUILDDIR)tdfx_vb.c \
- $(MESADRVTDFXBUILDDIR)tdfx_wrapper.c \
- $(MESADRVTDFXBUILDDIR)tdfx_xmesa.c
+ $(MESADRVTDFXBUILDDIR)tdfx_vb.c
TDFXOBJS = $(MESADRVTDFXBUILDDIR)tdfx_context.o \
$(MESADRVTDFXBUILDDIR)tdfx_dd.o \
- $(MESADRVTDFXBUILDDIR)tdfx_pixels.o \
- $(MESADRVTDFXBUILDDIR)tdfx_fastpath.o \
$(MESADRVTDFXBUILDDIR)tdfx_lock.o \
- $(MESADRVTDFXBUILDDIR)tdfx_pipeline.o \
+ $(MESADRVTDFXBUILDDIR)tdfx_pixels.o \
$(MESADRVTDFXBUILDDIR)tdfx_render.o \
$(MESADRVTDFXBUILDDIR)tdfx_screen.o \
$(MESADRVTDFXBUILDDIR)tdfx_span.o \
@@ -62,16 +60,12 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
$(MESADRVTDFXBUILDDIR)tdfx_texman.o \
$(MESADRVTDFXBUILDDIR)tdfx_texstate.o \
$(MESADRVTDFXBUILDDIR)tdfx_tris.o \
- $(MESADRVTDFXBUILDDIR)tdfx_vb.o \
- $(MESADRVTDFXBUILDDIR)tdfx_wrapper.o \
- $(MESADRVTDFXBUILDDIR)tdfx_xmesa.o
+ $(MESADRVTDFXBUILDDIR)tdfx_vb.o
TDFXUOBJS = $(MESADRVTDFXBUILDDIR)unshared/tdfx_context.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_dd.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_pixels.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_fastpath.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_lock.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_pipeline.o \
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_pixels.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_render.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_screen.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_span.o \
@@ -80,16 +74,12 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_texman.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_texstate.o \
$(MESADRVTDFXBUILDDIR)unshared/tdfx_tris.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_vb.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_wrapper.o \
- $(MESADRVTDFXBUILDDIR)unshared/tdfx_xmesa.o
+ $(MESADRVTDFXBUILDDIR)unshared/tdfx_vb.o
TDFXDOBJS = $(MESADRVTDFXBUILDDIR)debugger/tdfx_context.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_dd.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_pixels.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_fastpath.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_lock.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_pipeline.o \
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_pixels.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_render.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_screen.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_span.o \
@@ -98,16 +88,12 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_texman.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_texstate.o \
$(MESADRVTDFXBUILDDIR)debugger/tdfx_tris.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_vb.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_wrapper.o \
- $(MESADRVTDFXBUILDDIR)debugger/tdfx_xmesa.o
+ $(MESADRVTDFXBUILDDIR)debugger/tdfx_vb.o
TDFXPOBJS = $(MESADRVTDFXBUILDDIR)profiled/tdfx_context.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_dd.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_pixels.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_fastpath.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_lock.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_pipeline.o \
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_pixels.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_render.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_screen.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_span.o \
@@ -116,17 +102,13 @@ MESA_INCLUDES = -I$(MESASRCDIR)/src -I$(MESADRVSRCDIR)/common \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_texman.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_texstate.o \
$(MESADRVTDFXBUILDDIR)profiled/tdfx_tris.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_vb.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_wrapper.o \
- $(MESADRVTDFXBUILDDIR)profiled/tdfx_xmesa.o
+ $(MESADRVTDFXBUILDDIR)profiled/tdfx_vb.o
#ifdef NeedToLinkMesaSrc
LinkSourceFile(tdfx_context.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_dd.c, $(MESADRVSRCDIR)/tdfx)
-LinkSourceFile(tdfx_pixels.c, $(MESADRVSRCDIR)/tdfx)
-LinkSourceFile(tdfx_fastpath.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_lock.c, $(MESADRVSRCDIR)/tdfx)
-LinkSourceFile(tdfx_pipeline.c, $(MESADRVSRCDIR)/tdfx)
+LinkSourceFile(tdfx_pixels.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_render.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_screen.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_span.c, $(MESADRVSRCDIR)/tdfx)
@@ -136,7 +118,4 @@ LinkSourceFile(tdfx_texman.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_texstate.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_tris.c, $(MESADRVSRCDIR)/tdfx)
LinkSourceFile(tdfx_vb.c, $(MESADRVSRCDIR)/tdfx)
-LinkSourceFile(tdfx_wrapper.c, $(MESADRVSRCDIR)/tdfx)
-LinkSourceFile(tdfx_xmesa.c, $(MESADRVSRCDIR)/tdfx)
#endif
-
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
index fa532ba36..faf4972d0 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c
@@ -36,30 +36,23 @@
*/
#include <dlfcn.h>
-#include "dri_glide.h"
#include "tdfx_context.h"
#include "tdfx_dd.h"
#include "tdfx_state.h"
#include "tdfx_vb.h"
+#include "tdfx_tris.h"
#include "tdfx_render.h"
-#include "tdfx_pipeline.h"
#include "tdfx_span.h"
-#include "tdfx_tex.h"
#include "tdfx_texman.h"
#include "extensions.h"
-#ifndef TDFX_DEBUG
-int TDFX_DEBUG = (0
-/* | DEBUG_ALWAYS_SYNC */
-/* | DEBUG_VERBOSE_API */
-/* | DEBUG_VERBOSE_MSG */
-/* | DEBUG_VERBOSE_LRU */
-/* | DEBUG_VERBOSE_DRI */
-/* | DEBUG_VERBOSE_IOCTL */
-/* | DEBUG_VERBOSE_2D */
-/* | DEBUG_VERBOSE_TEXTURE */
- );
-#endif
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
#if 0
@@ -79,27 +72,25 @@ static void tdfxDDInitExtensions( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" );
- gl_extensions_disable( ctx, "GL_EXT_blend_minmax" );
- gl_extensions_disable( ctx, "GL_EXT_blend_subtract" );
- gl_extensions_disable( ctx, "GL_EXT_blend_color" );
- gl_extensions_disable( ctx, "GL_EXT_blend_func_separate" );
- gl_extensions_disable( ctx, "GL_EXT_point_parameters" );
- gl_extensions_disable( ctx, "GL_EXT_shared_texture_palette" );
- gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" );
- gl_extensions_enable( ctx, "GL_HP_occlusion_test" );
-
- if ( fxMesa->numTMUs == 1 ) {
- gl_extensions_disable( ctx, "GL_EXT_texture_env_add" );
- gl_extensions_disable( ctx, "GL_ARB_multitexture" );
+ _mesa_enable_extension( ctx, "GL_HP_occlusion_test" );
+ _mesa_enable_extension( ctx, "GL_EXT_paletted_texture" );
+ _mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
+
+ if ( fxMesa->haveTwoTMUs ) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
}
if ( TDFX_IS_NAPALM( fxMesa ) ) {
- gl_extensions_enable( ctx, "GL_EXT_texture_env_combine" );
+#if 0
+ _mesa_enable_extension( ctx, "GL_ARB_texture_compression" );
+ _mesa_enable_extension( ctx, "GL_3DFX_texture_compression_FXT1" );
+#endif
+ _mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
}
if (fxMesa->haveHwStencil) {
- gl_extensions_enable( ctx, "GL_EXT_stencil_wrap" );
+ _mesa_enable_extension( ctx, "GL_EXT_stencil_wrap" );
}
/* Example of hooking in an extension function.
@@ -124,22 +115,46 @@ static void tdfxDDInitExtensions( GLcontext *ctx )
-GLboolean tdfxCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
+static const struct gl_pipeline_stage *tdfx_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage, /* REMOVE: fog coord stage */
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+ &_tnl_render_stage,
+ 0,
+};
+
+
+GLboolean tdfxCreateContext( Display *dpy, const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
{
tdfxContextPtr fxMesa;
- GLcontext *ctx = driContextPriv->mesaContext;
+ GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
- fxScreen->sarea_priv_offset);
+ sizeof(XF86DRISAREARec));
- fxMesa = (tdfxContextPtr) MALLOC( sizeof(tdfxContextRec) );
- if ( !fxMesa ) {
+ /* Allocate tdfx context */
+ fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
+ if (!fxMesa)
+ return GL_FALSE;
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx, fxMesa, GL_TRUE);
+ if (!fxMesa->glCtx) {
+ FREE(fxMesa);
return GL_FALSE;
}
- BZERO(fxMesa, sizeof(tdfxContextRec));
+ driContextPriv->driverPrivate = fxMesa;
/* Mirror some important DRI state
*/
@@ -152,25 +167,19 @@ GLboolean tdfxCreateContext( Display *dpy, GLvisual *mesaVis,
fxMesa->fxScreen = fxScreen;
fxMesa->sarea = saPriv;
-
-
fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) &&
- mesaVis->StencilBits &&
- mesaVis->DepthBits == 24 );
+ mesaVis->stencilBits &&
+ mesaVis->depthBits == 24 );
fxMesa->screen_width = fxScreen->width;
fxMesa->screen_height = fxScreen->height;
+ fxMesa->new_gl_state = ~0;
fxMesa->new_state = ~0;
fxMesa->dirty = ~0;
- fxMesa->vertexFormat = 0;
-
- fxMesa->glCtx = driContextPriv->mesaContext;
- fxMesa->glVis = mesaVis;
-
- /* NOTE: This MUST be called before any Glide functions are called! */
- if (!tdfxInitGlide(fxMesa)) {
+ /* NOTE: This must be here before any Glide calls! */
+ if (!tdfxInitGlide( fxMesa )) {
FREE(fxMesa);
return GL_FALSE;
}
@@ -196,10 +205,16 @@ GLboolean tdfxCreateContext( Display *dpy, GLvisual *mesaVis,
fxMesa->Glide.Initialized = GL_FALSE;
fxMesa->Glide.Board = 0;
- if ( getenv( "FX_EMULATE_SINGLE_TMU" ) || TDFX_IS_BANSHEE( fxMesa ) ) {
- fxMesa->numTMUs = 1;
- } else {
- fxMesa->numTMUs = 2;
+
+ if (getenv("FX_EMULATE_SINGLE_TMU")) {
+ fxMesa->haveTwoTMUs = GL_FALSE;
+ }
+ else {
+ if ( TDFX_IS_BANSHEE( fxMesa ) ) {
+ fxMesa->haveTwoTMUs = GL_FALSE;
+ } else {
+ fxMesa->haveTwoTMUs = GL_TRUE;
+ }
}
fxMesa->stats.swapBuffer = 0;
@@ -209,61 +224,58 @@ GLboolean tdfxCreateContext( Display *dpy, GLvisual *mesaVis,
fxMesa->tmuSrc = TDFX_TMU_NONE;
+ ctx = fxMesa->glCtx;
if ( TDFX_IS_NAPALM( fxMesa ) ) {
ctx->Const.MaxTextureLevels = 12;
- ctx->Const.MaxTextureSize = 2048;
ctx->Const.NumCompressedTextureFormats = 1;
} else {
ctx->Const.MaxTextureLevels = 9;
- ctx->Const.MaxTextureSize = 256;
ctx->Const.NumCompressedTextureFormats = 0;
}
ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2;
- ctx->NewState |= NEW_DRVSTATE1;
-
- ctx->DriverCtx = (void *) fxMesa;
-
- tdfxDDInitExtensions( ctx );
-
- tdfxDDInitDriverFuncs( ctx );
- tdfxDDInitStateFuncs( ctx );
- tdfxDDInitRenderFuncs( ctx );
- tdfxDDInitSpanFuncs( ctx );
- tdfxDDInitTextureFuncs( ctx );
-
- ctx->Driver.TriangleCaps = (DD_TRI_CULL |
- DD_TRI_LIGHT_TWOSIDE |
- DD_TRI_STIPPLE |
- DD_TRI_OFFSET);
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
- if ( ctx->VB )
- tdfxDDRegisterVB( ctx->VB );
+ /* Disable wide lines as we can't antialias them correctly in
+ * hardware.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
- if ( ctx->NrPipelineStages )
- ctx->NrPipelineStages =
- tdfxDDRegisterPipelineStages( ctx->PipelineStage,
- ctx->PipelineStage,
- ctx->NrPipelineStages );
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
- /* Run the config file */
- gl_context_initialize( ctx );
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, tdfx_pipeline );
-#if 0
- /* HACK: Allocate buffer for vertex data.
+ /* Configure swrast to match hardware characteristics:
*/
- if ( fxMesa->buffer ) {
- ALIGN_FREE( fxMesa->buffer );
- }
- fxMesa->buffer = ALIGN_MALLOC( 2048, 32 );
- fxMesa->buffer_total = 2048;
- fxMesa->buffer_used = 0;
-#endif
+ _swrast_allow_pixel_fog( ctx, GL_TRUE );
+ _swrast_allow_vertex_fog( ctx, GL_FALSE );
+ tdfxDDInitExtensions( ctx );
+ tdfxDDInitDriverFuncs( ctx );
+ tdfxDDInitStateFuncs( ctx );
+ tdfxDDInitRenderFuncs( ctx );
+ tdfxDDInitSpanFuncs( ctx );
+ tdfxDDInitTriFuncs( ctx );
+ tdfxInitVB( ctx );
tdfxInitState( fxMesa );
- driContextPriv->driverPrivate = (void *) fxMesa;
-
return GL_TRUE;
}
@@ -284,26 +296,40 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
}
}
- /* Single textured vertex format - 32 bytes.
+ /* Tiny vertex format - 16 bytes.
*/
fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] );
+ /* Non textured vertex format - 24 bytes (Need w for table fog)
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
- fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
-#if 0
- fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );
-#endif
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_NOTEX] );
+ /* Single textured vertex format - 32 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
+ /*grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] );
/* Multitextured vertex format - 40 bytes.
*/
fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
-
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
@@ -311,29 +337,22 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
-#if 0
- fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );
-#endif
-
+ /*fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] );
/* Projected texture vertex format - 48 bytes.
*/
fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
-
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
- fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE );
-#if 0
- fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );
-#endif
-
+ /*fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJECT] );
UNLOCK_HARDWARE( fxMesa );
@@ -345,8 +364,8 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
/*
* Initialize the state in an tdfxContextPtr struct.
*/
-GLboolean tdfxInitContext( __DRIdrawablePrivate *driDrawPriv,
- tdfxContextPtr fxMesa )
+static GLboolean
+tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
{
/* KW: Would be nice to make one of these a member of the other.
*/
@@ -397,7 +416,7 @@ GLboolean tdfxInitContext( __DRIdrawablePrivate *driDrawPriv,
LOCK_HARDWARE( fxMesa );
- if ( fxMesa->glVis->DepthBits > 0 ) {
+ if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
} else {
fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE);
@@ -444,6 +463,14 @@ GLboolean tdfxInitContext( __DRIdrawablePrivate *driDrawPriv,
UNLOCK_HARDWARE( fxMesa );
+ {
+ const char *debug = getenv("LIBGL_DEBUG");
+ if (debug && strstr(debug, "fallbacks")) {
+ fxMesa->debugFallbacks = GL_TRUE;
+ }
+ }
+
+
fxMesa->numClipRects = 0;
fxMesa->pClipRects = NULL;
fxMesa->scissoredClipRects = GL_FALSE;
@@ -454,37 +481,223 @@ GLboolean tdfxInitContext( __DRIdrawablePrivate *driDrawPriv,
}
-void tdfxDestroyContext( tdfxContextPtr fxMesa )
+void
+tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
{
+ tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
+
if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
fprintf( stderr, "%s( %p )\n", __FUNCTION__, fxMesa );
}
if ( fxMesa ) {
- GLcontext *ctx = fxMesa->glCtx;
- struct gl_texture_object *tObj;
-
- if ( ctx->Shared->RefCount == 1 && fxMesa->driDrawable ) {
+ if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
/* This share group is about to go away, free our private
* texture object data.
*/
- LOCK_HARDWARE( fxMesa );
- for ( tObj = ctx->Shared->TexObjectList ; tObj ; tObj = tObj->Next ) {
- tdfxTMFreeTextureLocked( fxMesa, tObj );
+ struct gl_texture_object *tObj;
+ tObj = fxMesa->glCtx->Shared->TexObjectList;
+ while (tObj) {
+ tdfxTMFreeTexture(fxMesa, tObj);
+ tObj = tObj->Next;
}
- UNLOCK_HARDWARE( fxMesa );
}
- tdfxTMClose( fxMesa ); /* free texture memory */
- FREE( fxMesa );
+ tdfxTMClose(fxMesa); /* free texture memory */
+
+ _swsetup_DestroyContext( fxMesa->glCtx );
+ _tnl_DestroyContext( fxMesa->glCtx );
+ _ac_DestroyContext( fxMesa->glCtx );
+ _swrast_DestroyContext( fxMesa->glCtx );
+
+ tdfxFreeVB( fxMesa->glCtx );
+
+ /* Free Mesa context */
+ fxMesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(fxMesa->glCtx);
+
+ /* free the tdfx context */
+ XFree( fxMesa );
+ }
+}
+
+
+GLboolean
+tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
+ }
+
+ if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) {
+ LOCK_HARDWARE(fxMesa);
+ fxMesa->Glide.grGlideGetState(fxMesa->Glide.State);
+ UNLOCK_HARDWARE(fxMesa);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
+ }
+
+ if ( driContextPriv ) {
+ tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate;
+ GLcontext *newCtx = newFx->glCtx;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if ( newFx->driDrawable != driDrawPriv ) {
+ newFx->driDrawable = driDrawPriv;
+ newFx->dirty = ~0;
+ }
+ else if (curCtx == newCtx) {
+ /* same drawable, same context -> no-op */
+ /* Need to call _mesa_make_current2() in order to make sure API
+ * dispatch is set correctly.
+ */
+ _mesa_make_current2( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+ return GL_TRUE;
+ }
+
+ if ( !newFx->Glide.Initialized ) {
+ if ( !tdfxInitContext( driDrawPriv, newFx ) )
+ return GL_FALSE;
+
+ LOCK_HARDWARE( newFx );
+
+ /* FIXME: Force loading of window information */
+ newFx->width = 0;
+ tdfxUpdateClipping(newCtx);
+ tdfxUploadClipping(newFx);
+
+ UNLOCK_HARDWARE( newFx );
+ } else {
+ LOCK_HARDWARE( newFx );
+
+ newFx->Glide.grSstSelect( newFx->Glide.Board );
+ newFx->Glide.grGlideSetState( newFx->Glide.State );
+
+ tdfxUpdateClipping(newCtx);
+ tdfxUploadClipping(newFx);
+
+ UNLOCK_HARDWARE( newFx );
+ }
+
+ _mesa_make_current2( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if ( !newCtx->Viewport.Width ) {
+ _mesa_set_viewport( newCtx, 0, 0, driDrawPriv->w, driDrawPriv->h );
+ }
+ } else {
+ _mesa_make_current( 0, 0 );
}
-#if 0
- glx_fini_prof();
-#endif
+ return GL_TRUE;
}
+/*
+ * Enable this to trace calls to various Glide functions.
+ */
+/*#define DEBUG_TRAP*/
+#ifdef DEBUG_TRAP
+static void (*real_grDrawTriangle)( const void *a, const void *b, const void *c );
+static void (*real_grDrawPoint)( const void *a );
+static void (*real_grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers);
+static void (*real_grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count,
+ void *pointers, FxU32 stride);
+static void (*real_grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
+
+static void (*real_grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode);
+static void (*real_grGlideGetVertexLayout)( void *layout );
+static void (*real_grGlideSetVertexLayout)( const void *layout );
+
+static void (*real_grTexDownloadMipMapLevel)( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data );
+
+
+static void debug_grDrawTriangle( const void *a, const void *b, const void *c )
+{
+ printf("%s\n", __FUNCTION__);
+ (*real_grDrawTriangle)(a, b, c);
+}
+
+static void debug_grDrawPoint( const void *a )
+{
+ const float *f = (const float *) a;
+ printf("%s %g %g\n", __FUNCTION__, f[0], f[1]);
+ (*real_grDrawPoint)(a);
+}
+
+static void debug_grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers)
+{
+ printf("%s count=%d\n", __FUNCTION__, (int) Count);
+ (*real_grDrawVertexArray)(mode, Count, pointers);
+}
+
+static void debug_grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count,
+ void *pointers, FxU32 stride)
+{
+ printf("%s mode=0x%x count=%d\n", __FUNCTION__, (int) mode, (int) Count);
+ (*real_grDrawVertexArrayContiguous)(mode, Count, pointers, stride);
+}
+
+static void debug_grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
+{
+ printf("%s %d,%d .. %d,%d\n", __FUNCTION__,
+ (int) minx, (int) miny, (int) maxx, (int) maxy);
+ (*real_grClipWindow)(minx, miny, maxx, maxy);
+}
+
+static void debug_grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
+{
+ (*real_grVertexLayout)(param, offset, mode);
+}
+
+static void debug_grGlideGetVertexLayout( void *layout )
+{
+ (*real_grGlideGetVertexLayout)(layout);
+}
+
+static void debug_grGlideSetVertexLayout( const void *layout )
+{
+ (*real_grGlideSetVertexLayout)(layout);
+}
+
+static void debug_grTexDownloadMipMapLevel( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data )
+{
+ (*real_grTexDownloadMipMapLevel)(tmu, startAddress, thisLod, largeLod,
+ aspectRatio, format, evenOdd, data);
+}
+
+#endif
+
/*
* Examine the context's deviceID to determine what kind of 3dfx hardware
@@ -513,10 +726,8 @@ GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
break;
default:
{
- char err[1000];
- sprintf(err, "unrecognized 3dfx deviceID: 0x%x",
+ __driUtilMessage("unrecognized 3dfx deviceID: 0x%x",
tmesa->fxScreen->deviceID);
- __driMesaMessage(err);
}
return GL_FALSE;
}
@@ -528,13 +739,10 @@ GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
*/
libHandle = dlopen(defaultGlide, RTLD_NOW);
if (!libHandle) {
- char err[1000];
- sprintf(err,
+ __driUtilMessage(
"can't find Glide library, dlopen(%s) and dlopen(%s) both failed.",
libName, defaultGlide);
- __driMesaMessage(err);
- sprintf(err, "dlerror() message: %s", dlerror());
- __driMesaMessage(err);
+ __driUtilMessage("dlerror() message: %s", dlerror());
return GL_FALSE;
}
libName = defaultGlide;
@@ -550,10 +758,8 @@ GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
#define GET_FUNCTION(PTR, NAME) \
tmesa->Glide.PTR = dlsym(libHandle, NAME); \
if (!tmesa->Glide.PTR) { \
- char err[1000]; \
- sprintf(err, "couldn't find Glide function %s in %s.", \
+ __driUtilMessage("couldn't find Glide function %s in %s.", \
NAME, libName); \
- __driMesaMessage(err); \
}
GET_FUNCTION(grDrawPoint, "grDrawPoint");
@@ -609,10 +815,10 @@ GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
GET_FUNCTION(grDisable, "grDisable");
GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace");
GET_FUNCTION(grDepthRange, "grDepthRange");
-#if defined(__linux__) || defined(__FreeBSD__)
+#ifdef __linux__
GET_FUNCTION(grStippleMode, "grStippleMode");
GET_FUNCTION(grStipplePattern, "grStipplePattern");
-#endif /* __linux__ || __FreeBSD__ */
+#endif /* __linux__ */
GET_FUNCTION(grViewport, "grViewport");
GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired");
GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired");
@@ -685,5 +891,35 @@ GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
tmesa->Glide.txImgDequantizeFXT1 = dlsym(libHandle, "_txImgDequantizeFXT1");
tmesa->Glide.txErrorSetCallback = dlsym(libHandle, "txErrorSetCallback");
+#ifdef DEBUG_TRAP
+ /* wrap the drawing functions so we can trap them */
+ real_grDrawTriangle = tmesa->Glide.grDrawTriangle;
+ tmesa->Glide.grDrawTriangle = debug_grDrawTriangle;
+
+ real_grDrawPoint = tmesa->Glide.grDrawPoint;
+ tmesa->Glide.grDrawPoint = debug_grDrawPoint;
+
+ real_grDrawVertexArray = tmesa->Glide.grDrawVertexArray;
+ tmesa->Glide.grDrawVertexArray = debug_grDrawVertexArray;
+
+ real_grDrawVertexArrayContiguous = tmesa->Glide.grDrawVertexArrayContiguous;
+ tmesa->Glide.grDrawVertexArrayContiguous = debug_grDrawVertexArrayContiguous;
+
+ real_grClipWindow = tmesa->Glide.grClipWindow;
+ tmesa->Glide.grClipWindow = debug_grClipWindow;
+
+ real_grVertexLayout = tmesa->Glide.grVertexLayout;
+ tmesa->Glide.grVertexLayout = debug_grVertexLayout;
+
+ real_grGlideGetVertexLayout = tmesa->Glide.grGlideGetVertexLayout;
+ tmesa->Glide.grGlideGetVertexLayout = debug_grGlideGetVertexLayout;
+
+ real_grGlideSetVertexLayout = tmesa->Glide.grGlideSetVertexLayout;
+ tmesa->Glide.grGlideSetVertexLayout = debug_grGlideSetVertexLayout;
+
+ real_grTexDownloadMipMapLevel = tmesa->Glide.grTexDownloadMipMapLevel;
+ tmesa->Glide.grTexDownloadMipMapLevel = debug_grTexDownloadMipMapLevel;
+
+#endif
return GL_TRUE;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
index 39069f061..baee1125c 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h
@@ -40,10 +40,7 @@
#ifdef GLX_DIRECT_RENDERING
#include <sys/time.h>
-#include "dri_tmm.h"
-#include "dri_mesaint.h"
-#include "dri_mesa.h"
-#include "dri_xmesaapi.h"
+#include "dri_util.h"
#ifdef XFree86Server
#include "GL/xf86glx.h"
#else
@@ -52,35 +49,21 @@
#if defined(__linux__)
#include <signal.h>
#endif
+
+#include "glide.h"
+#include "g3ext.h"
+
#include "clip.h"
#include "context.h"
-
#include "macros.h"
#include "matrix.h"
#include "mem.h"
-#include "texture.h"
-#include "types.h"
-#include "vb.h"
-#include "vbrender.h"
-#include "xform.h"
+#include "mtypes.h"
-#include "tdfx_wrapper.h"
#include "tdfx_screen.h"
-#include "tdfx_lock.h"
-/* Mergable items first
- */
-#define SETUP_RGBA 0x1
-#define SETUP_TMU0 0x2
-#define SETUP_TMU1 0x4
-#define SETUP_XY 0x8
-#define SETUP_Z 0x10
-#define SETUP_W 0x20
-
-#define MAX_MERGABLE 0x8
-
#define TDFX_TMU0 GR_TMU0
#define TDFX_TMU1 GR_TMU1
@@ -129,7 +112,6 @@
#define TDFX_UPLOAD_CULL 0x00004000
#define TDFX_UPLOAD_VERTEX_LAYOUT 0x00008000
#define TDFX_UPLOAD_COLOR_MASK 0x00010000
-#define TDFX_UPLOAD_CONSTANT_COLOR 0x00020000
#define TDFX_UPLOAD_DITHER 0x00040000
#define TDFX_UPLOAD_STENCIL 0x00080000
@@ -143,27 +125,28 @@
#define TDFX_UPLOAD_STIPPLE 0x04000000
-/* Flags for software fallback cases
- */
-#define TDFX_FALLBACK_TEXTURE 0x0001
-#define TDFX_FALLBACK_BUFFER 0x0002
+/* Flags for software fallback cases */
+/* See correponding strings in tdfx_tris.c */
+#define TDFX_FALLBACK_TEXTURE_1D_3D 0x0001
+#define TDFX_FALLBACK_DRAW_BUFFER 0x0002
#define TDFX_FALLBACK_SPECULAR 0x0004
#define TDFX_FALLBACK_STENCIL 0x0008
#define TDFX_FALLBACK_RENDER_MODE 0x0010
-#define TDFX_FALLBACK_MULTIDRAW 0x0020
-#define TDFX_FALLBACK_LOGICOP 0x0040
-#define TDFX_FALLBACK_WIDE_AA_LINE 0x0080
-#define TDFX_FALLBACK_TEXTURE_ENV 0x0100
-#define TDFX_FALLBACK_TEXTURE_BORDER 0x0200
-#define TDFX_FALLBACK_COLORMASK 0x0400
-#define TDFX_FALLBACK_BLEND 0x0800
+#define TDFX_FALLBACK_LOGICOP 0x0020
+#define TDFX_FALLBACK_TEXTURE_ENV 0x0040
+#define TDFX_FALLBACK_TEXTURE_BORDER 0x0080
+#define TDFX_FALLBACK_COLORMASK 0x0100
+#define TDFX_FALLBACK_BLEND 0x0200
+#define TDFX_FALLBACK_LINE_STIPPLE 0x0400
/* Different Glide vertex layouts
*/
-#define TDFX_LAYOUT_SINGLE 0
-#define TDFX_LAYOUT_MULTI 1
-#define TDFX_LAYOUT_PROJECT 2
-#define TDFX_NUM_LAYOUTS 3
+#define TDFX_LAYOUT_TINY 0
+#define TDFX_LAYOUT_NOTEX 1
+#define TDFX_LAYOUT_SINGLE 2
+#define TDFX_LAYOUT_MULTI 3
+#define TDFX_LAYOUT_PROJECT 4
+#define TDFX_NUM_LAYOUTS 5
#define TDFX_XY_OFFSET 0
#define TDFX_Z_OFFSET 8
@@ -260,18 +243,15 @@
(((GLuint) (G) & 0xF8) << 2) | \
(((GLuint) (R) & 0xF8) >> 3))
-typedef void (*tdfxRenderEltsFunc)( struct vertex_buffer * );
-
/* Used in calls to grColorMaskv()...
*/
extern const GLboolean false4[4];
extern const GLboolean true4[4];
-typedef void (*tdfx_interp_func)( GLfloat t,
- GLfloat *result,
- const GLfloat *in,
- const GLfloat *out );
+typedef struct tdfx_context tdfxContextRec;
+typedef struct tdfx_context *tdfxContextPtr;
+
typedef struct {
volatile int fifoPtr;
@@ -279,7 +259,9 @@ typedef struct {
volatile int fifoOwner;
volatile int ctxOwner;
volatile int texOwner;
-} TDFXSAREAPriv;
+}
+TDFXSAREAPriv;
+
typedef struct {
GLuint swapBuffer;
@@ -289,75 +271,122 @@ typedef struct {
GLuint texSwaps;
} tdfxStats;
+
+
/*
* Memory range from startAddr to endAddr-1
*/
typedef struct mem_range {
struct mem_range *next;
FxU32 startAddr, endAddr;
-} tdfxMemRange;
+}
+tdfxMemRange;
-typedef struct {
- GLvoid *data;
- GLsizei width, height;
- FxU32 size;
-} tdfxTexRawData;
typedef struct {
- tdfxTexRawData original; /* Mesa-formatted texture image */
- tdfxTexRawData rescaled; /* Only needed if aspect ratio > 8:1 */
-
- GLvoid *data; /* Final version of texture image */
- FxU32 size; /* image size in bytes */
-
- GrTextureFormat_t glideFormat; /* Glide image format */
- GLint wScale, hScale; /* Broken hardware... */
-} tdfxTexImage, *tdfxTexImagePtr;
+ GLsizei width, height; /* image size */
+ GLint wScale, hScale; /* scale factors */
+ GrTextureFormat_t glideFormat; /* Glide image format */
+}
+tdfxMipMapLevel;
#define TDFX_NUM_TMU 2
-typedef struct {
+typedef struct tdfxTexInfo_t
+{
GLboolean isInTM;
GLboolean reloadImages; /* if true, resend images to Glide */
GLuint lastTimeUsed;
FxU32 whichTMU;
GrTexInfo info;
- tdfxTexImage image[MAX_TEXTURE_LEVELS];
- tdfxMemRange *range[TDFX_NUM_TMU];
+ GrAspectRatio_t aspectRatio;
+ tdfxMemRange *tm[TDFX_NUM_TMU];
GLint minLevel, maxLevel;
- GrMipMapMode_t mmMode;
- GrAspectRatio_t aspectRatio;
- FxBool LODblend;
GrTextureFilterMode_t minFilt;
GrTextureFilterMode_t magFilt;
GrTextureClampMode_t sClamp;
GrTextureClampMode_t tClamp;
+ FxBool LODblend;
+ GrMipMapMode_t mmMode;
- GLfloat sScale, tScale; /* texcoord scale factor */
+ GLfloat sScale, tScale; /* texcoord scale factor */
GuTexPalette palette;
-} tdfxTexObj, *tdfxTexObjPtr;
+}
+tdfxTexInfo;
+
+
+#define TDFX_TEXTURE_DATA(mesaObj) ((tdfxTexInfo *)((mesaObj)->DriverData))
+
+#define TDFX_TEXIMAGE_DATA(mesaImg) ((tdfxMipMapLevel *)((mesaImg)->DriverData))
-#define TDFX_TEXTURE_DATA(tObj) ((tdfxTexObjPtr)((tObj)->DriverData))
-/* This is state which may be shared by several tdfx contexts.
+/*
+ * This is state which may be shared by several tdfx contexts.
* It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData).
*/
-typedef struct tdfx_shared_state {
+struct tdfxSharedState {
GLboolean umaTexMemory;
- GLuint totalTexMem[TDFX_NUM_TMU]; /* constant */
- GLuint freeTexMem[TDFX_NUM_TMU]; /* changes as we go */
- tdfxMemRange *rangePool;
- tdfxMemRange *freeRanges[TDFX_NUM_TMU];
-} tdfxSharedState, *tdfxSharedStatePtr;
+ GLuint totalTexMem[TDFX_NUM_TMU]; /* constant */
+ GLuint freeTexMem[TDFX_NUM_TMU]; /* changes as we go */
+ tdfxMemRange *tmPool;
+ tdfxMemRange *tmFree[TDFX_NUM_TMU];
+};
+/* ================================================================
+ * The vertex structures.
+ */
+typedef struct {
+ GLubyte blue;
+ GLubyte green;
+ GLubyte red;
+ GLubyte alpha;
+} tdfx_color_t;
+
+typedef struct {
+ GLfloat x, y, z; /* Coordinates in screen space */
+ GLfloat rhw; /* Reciprocal homogeneous w */
+ tdfx_color_t color; /* Diffuse color */
+ GLuint pad;
+ GLfloat tu0, tv0; /* Texture 0 coordinates */
+ GLfloat tu1, tv1; /* Texture 1 coordinates */
+} tdfx_vertex;
+
+typedef struct {
+ GLfloat x, y, z; /* Coordinates in screen space */
+ GLfloat rhw; /* Reciprocal homogeneous w */
+ tdfx_color_t color; /* Diffuse color */
+ GLuint pad;
+ GLfloat tu0, tv0; /* Texture 0 coordinates */
+ GLfloat tu1, tv1; /* Texture 1 coordinates */
+ GLfloat tq0, tq1; /* Texture 0/1 q coords */
+} tdfx_ptex_vertex;
+
+typedef struct {
+ GLfloat x, y, z; /* Coordinates in screen space */
+ tdfx_color_t color; /* Diffuse color */
+} tdfx_tiny_vertex;
+
+/* The size of this union is not of relevence:
+ */
+union tdfx_vertex_t {
+ tdfx_vertex v;
+ tdfx_tiny_vertex tv;
+ tdfx_ptex_vertex pv;
+ GLfloat f[16];
+ GLuint ui[16];
+ GLubyte ub4[16][4];
+};
+
+typedef union tdfx_vertex_t tdfxVertex, *tdfxVertexPtr;
+
/* ================================================================
*
@@ -512,11 +541,6 @@ struct tdfx_depth {
FxBool Mask; /* Write enable flag */
};
-#ifndef GR_STIPPLE_PATTERN
-#error You MUST upgrade your Glide3 libraries and headers.
-#error Get the latest from http://dri.sourceforge.net/res.phtml
-#endif
-
struct tdfx_stipple {
GrStippleMode_t Mode; /* Stipple enable/disable */
FxU32 Pattern; /* 8x4 Stipple Pattern */
@@ -650,10 +674,10 @@ struct tdfx_glide {
void (*grDisable)( GrEnableMode_t mode );
void (*grCoordinateSpace)( GrCoordinateSpaceMode_t mode );
void (*grDepthRange)( FxFloat n, FxFloat f );
-#if defined(__linux__) || defined (__FreeBSD__)
+#ifdef __linux__
void (*grStippleMode)( GrStippleMode_t mode );
void (*grStipplePattern)( GrStipplePattern_t mode );
-#endif /* __linux__ || __FreeBSD__ */
+#endif /* __linux__ */
void (*grViewport)( FxI32 x, FxI32 y, FxI32 width, FxI32 height );
FxU32 (*grTexCalcMemRequired)(GrLOD_t lodmin, GrLOD_t lodmax,
GrAspectRatio_t aspect, GrTextureFormat_t fmt);
@@ -799,13 +823,17 @@ struct tdfx_glide {
void (*txErrorSetCallback)( void *fnc );
};
+typedef void (*tdfx_tri_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex *,
+ tdfxVertex * );
+typedef void (*tdfx_line_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex * );
+typedef void (*tdfx_point_func)( tdfxContextPtr, tdfxVertex * );
struct tdfx_context {
/* Set once and never changed:
*/
GLcontext *glCtx; /* The core Mesa context */
- GLvisual *glVis; /* Describes the color buffer */
+ GLuint new_gl_state;
GLuint new_state;
GLuint dirty;
@@ -843,37 +871,51 @@ struct tdfx_context {
struct tdfx_glide Glide;
+
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array UbyteColor;
+
+ /* Fallback rasterization functions
+ */
+ tdfx_point_func draw_point;
+ tdfx_line_func draw_line;
+ tdfx_tri_func draw_triangle;
+
+
/* Variable-size Glide vertex formats
*/
- GLuint vertsize; /* bytes per vertex */
GLuint vertexFormat; /* the current format */
+ GLuint vertex_stride_shift;
void *layout[TDFX_NUM_LAYOUTS];
-
- GLuint tmu_source[TDFX_NUM_TMU];
- GLuint tex_dest[MAX_TEXTURE_UNITS];
- GLuint numTMUs;
-
+ char *verts; /* tdfxVertices, arbitarily packed */
+
+ GLfloat hw_viewport[16];
+
GLuint SetupIndex;
- GLuint SetupDone;
+ GLuint SetupNewInputs;
GLuint RenderIndex;
-
- GLuint IndirectTriangles;
GLuint Fallback;
+ GLenum render_primitive; /* what GL thinks */
+ GLenum raster_primitive; /* what the hardware thinks */
GLfloat sScale0, tScale0;
GLfloat sScale1, tScale1;
- GLuint using_fast_path, passes, multipass;
GLuint texBindNumber;
GLint tmuSrc;
int screen_width;
int screen_height;
+ GLboolean haveTwoTMUs; /* True if we have 2 tmu's */
GLboolean haveHwStencil;
+ GLboolean haveHwStipple;
GLint maxPendingSwapBuffers;
+ char rendererString[100];
+
/* stuff added for DRI */
__DRIscreenPrivate *driScreen;
__DRIcontextPrivate *driContext;
@@ -897,39 +939,41 @@ struct tdfx_context {
XF86DRIClipRectPtr pClipRects;
GLboolean scissoredClipRects; /* if true, pClipRects is private storage */
-
GuTexPalette glbPalette; /* global texture palette */
- tdfx_interp_func interp;
-
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
- render_func *RenderVBRawTab;
- tdfxRenderEltsFunc RenderElementsRaw;
-
-
tdfxStats stats;
- /* HACK: Let's get some buffering of vertices happening...
- */
- GLuint *buffer;
- GLuint buffer_total;
- GLuint buffer_used;
+ GLboolean debugFallbacks;
};
#define TDFX_CONTEXT(ctx) ((tdfxContextPtr)((ctx)->DriverCtx))
-extern GLboolean tdfxCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv );
-extern void tdfxDestroyContext( tdfxContextPtr fxMesa );
+extern GLboolean
+tdfxCreateContext( Display *dpy,
+ const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void
+tdfxDestroyContext( __DRIcontextPrivate *driContextPriv );
+
+extern GLboolean
+tdfxUnbindContext( __DRIcontextPrivate *driContextPriv );
+
+extern GLboolean
+tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean
+tdfxInitGlide( tdfxContextPtr tmesa );
-extern GLboolean tdfxInitContext( __DRIdrawablePrivate *driDrawPriv,
- tdfxContextPtr fxMesa );
+extern void
+FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]);
-extern GLboolean tdfxInitGlide(tdfxContextPtr tmesa);
+extern void
+FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
/* Color packing utilities
@@ -981,7 +1025,6 @@ extern int TDFX_DEBUG;
#define DEBUG_VERBOSE_DRI 0x10
#define DEBUG_VERBOSE_IOCTL 0x20
#define DEBUG_VERBOSE_2D 0x40
-#define DEBUG_VERBOSE_TEXTURE 0x80
#endif /* GLX_DIRECT_RENDERING */
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c
index b783b1ea9..451dcd8c2 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c,v 1.5 2001/08/18 02:51:06 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -37,17 +37,18 @@
#include "tdfx_context.h"
#include "tdfx_dd.h"
+#include "tdfx_lock.h"
#include "tdfx_vb.h"
-#include "tdfx_pipeline.h"
#include "tdfx_pixels.h"
#include "enums.h"
-#include "pb.h"
-#if defined(USE_X86_ASM) || defined(USE_3DNOW_ASM) || defined(USE_KATMAI_ASM)
+#include "swrast/swrast.h"
+#if defined(USE_X86_ASM)
#include "X86/common_x86_asm.h"
#endif
-#define TDFX_DATE "20010501"
+
+#define TDFX_DATE "20010624"
/* These are used in calls to FX_grColorMaskv() */
@@ -65,42 +66,48 @@ static const GLubyte *tdfxDDGetString( GLcontext *ctx, GLenum name )
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
switch ( name ) {
- case GL_VENDOR:
- return (GLubyte *)"VA Linux Systems, Inc.";
+ case GL_RENDERER:
+ {
+ /* The renderer string must be per-context state to handle
+ * multihead correctly.
+ */
+ char *buffer = fxMesa->rendererString;
+ char hardware[100];
- case GL_RENDERER: {
- static char buffer[128];
- char hardware[128];
+ LOCK_HARDWARE(fxMesa);
+ strcpy( hardware, fxMesa->Glide.grGetString(GR_HARDWARE) );
+ UNLOCK_HARDWARE(fxMesa);
- strcpy( hardware, FX_grGetString( fxMesa, GR_HARDWARE ) );
+ strcpy( buffer, "Mesa DRI " );
+ strcat( buffer, TDFX_DATE );
+ strcat( buffer, " " );
if ( strcmp( hardware, "Voodoo3 (tm)" ) == 0 ) {
- strcpy( hardware, "Voodoo3" );
+ strcat( buffer, "Voodoo3" );
}
else if ( strcmp( hardware, "Voodoo Banshee (tm)" ) == 0 ) {
- strcpy( hardware, "VoodooBanshee" );
+ strcat( buffer, "VoodooBanshee" );
}
else if ( strcmp( hardware, "Voodoo4 (tm)" ) == 0 ) {
- strcpy( hardware, "Voodoo4" );
+ strcat( buffer, "Voodoo4" );
}
else if ( strcmp( hardware, "Voodoo5 (tm)" ) == 0 ) {
- strcpy( hardware, "Voodoo5" );
+ strcat( buffer, "Voodoo5" );
}
else {
- /* Unexpected result: replace spaces with hyphens */
+ /* unexpected result: replace spaces with hyphens */
int i;
- for ( i = 0 ; hardware[i] ; i++ ) {
+ for ( i = 0 ; hardware[i] && i < 60 ; i++ ) {
if ( hardware[i] == ' ' || hardware[i] == '\t' )
hardware[i] = '-';
}
+ strcat( buffer, hardware );
}
- /* Now make the GL_RENDERER string */
- sprintf( buffer, "Mesa DRI %s " TDFX_DATE, hardware );
/* Append any CPU-specific information.
*/
#ifdef USE_X86_ASM
- if ( gl_x86_cpu_features ) {
+ if ( _mesa_x86_cpu_features ) {
strncat( buffer, " x86", 4 );
}
#endif
@@ -114,41 +121,35 @@ static const GLubyte *tdfxDDGetString( GLcontext *ctx, GLenum name )
strncat( buffer, "/3DNow!", 7 );
}
#endif
-#ifdef USE_KATMAI_ASM
+#ifdef USE_SSE_ASM
if ( cpu_has_xmm ) {
strncat( buffer, "/SSE", 4 );
}
#endif
- return (GLubyte *)buffer;
+ return (const GLubyte *) buffer;
}
-
+ case GL_VENDOR:
+ return "VA Linux Systems, Inc.";
default:
return NULL;
}
}
-/* Return buffer size information.
+/* Return uptodate buffer size information.
*/
static void tdfxDDGetBufferSize( GLcontext *ctx,
GLuint *width, GLuint *height )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE( fxMesa );
*width = fxMesa->width;
*height = fxMesa->height;
+ UNLOCK_HARDWARE( fxMesa );
}
-static GLint tdfxDDGetParameteri( const GLcontext *ctx, GLint param )
-{
- switch ( param ) {
- case DD_HAVE_HARDWARE_FOG:
- return 1;
- default:
- return 0;
- }
-}
/*
* Return the current value of the occlusion test flag and
@@ -240,10 +241,10 @@ static GLboolean tdfxDDGetIntegerv( GLcontext *ctx, GLenum pname,
#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
- ((vis->RedBits == r) && \
- (vis->GreenBits == g) && \
- (vis->BlueBits == b) && \
- (vis->AlphaBits == a))
+ ((vis.redBits == r) && \
+ (vis.greenBits == g) && \
+ (vis.blueBits == b) && \
+ (vis.alphaBits == a))
void tdfxDDInitDriverFuncs( GLcontext *ctx )
{
@@ -254,48 +255,74 @@ void tdfxDDInitDriverFuncs( GLcontext *ctx )
ctx->Driver.GetString = tdfxDDGetString;
ctx->Driver.GetBufferSize = tdfxDDGetBufferSize;
ctx->Driver.Error = NULL;
- ctx->Driver.GetParameteri = tdfxDDGetParameteri;
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffersMESA = _swrast_alloc_buffers;
+
+ /* Accelerated paths
+ */
if ( VISUAL_EQUALS_RGBA(ctx->Visual, 8, 8, 8, 8) )
{
ctx->Driver.DrawPixels = tdfx_drawpixels_R8G8B8A8;
ctx->Driver.ReadPixels = tdfx_readpixels_R8G8B8A8;
- ctx->Driver.CopyPixels = NULL;
- ctx->Driver.Bitmap = NULL;
}
else if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
{
- ctx->Driver.DrawPixels = NULL;
ctx->Driver.ReadPixels = tdfx_readpixels_R5G6B5;
- ctx->Driver.CopyPixels = NULL;
- ctx->Driver.Bitmap = NULL;
- }
- else
- {
- ctx->Driver.DrawPixels = NULL;
- ctx->Driver.ReadPixels = NULL;
- ctx->Driver.CopyPixels = NULL;
- ctx->Driver.Bitmap = NULL;
}
- ctx->Driver.RegisterVB = tdfxDDRegisterVB;
- ctx->Driver.UnregisterVB = tdfxDDUnregisterVB;
- ctx->Driver.ResetVB = NULL;
- ctx->Driver.ResetCvaVB = NULL;
-
- if ( !getenv( "TDFX_NO_FAST" ) ) {
- ctx->Driver.BuildPrecalcPipeline = tdfxDDBuildPrecalcPipeline;
- } else {
- ctx->Driver.BuildPrecalcPipeline = NULL;
- }
- ctx->Driver.BuildEltPipeline = NULL;
-
- ctx->Driver.OptimizeImmediatePipeline = NULL;
- ctx->Driver.OptimizePrecalcPipeline = NULL;
-
ctx->Driver.GetBooleanv = tdfxDDGetBooleanv;
ctx->Driver.GetDoublev = tdfxDDGetDoublev;
ctx->Driver.GetFloatv = tdfxDDGetFloatv;
ctx->Driver.GetIntegerv = tdfxDDGetIntegerv;
ctx->Driver.GetPointerv = NULL;
}
+
+
+/*
+ * These are here for lack of a better place.
+ */
+
+void
+FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4])
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE(fxMesa);
+ if (ctx->Visual.redBits == 8) {
+ /* 32bpp mode */
+ ASSERT( fxMesa->Glide.grColorMaskExt );
+ fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
+ rgba[BCOMP], rgba[ACOMP]);
+ }
+ else {
+ /* 16 bpp mode */
+ /* we never have an alpha buffer */
+ fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
+ GL_FALSE);
+ }
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+void
+FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4])
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (ctx->Visual.redBits == 8) {
+ /* 32bpp mode */
+ ASSERT( fxMesa->Glide.grColorMaskExt );
+ fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
+ rgba[BCOMP], rgba[ACOMP]);
+ }
+ else {
+ /* 16 bpp mode */
+ /* we never have an alpha buffer */
+ fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
+ GL_FALSE);
+ }
+}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fastpath.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fastpath.c
deleted file mode 100644
index d448ad581..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fastpath.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_fastpath.c,v 1.2 2001/08/18 02:51:06 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-#include "types.h"
-#include "enums.h"
-#include "cva.h"
-#include "vertices.h"
-#include "mmath.h"
-
-#include "tdfx_context.h"
-#include "tdfx_state.h"
-#include "tdfx_vb.h"
-#include "tdfx_tris.h"
-#include "tdfx_pipeline.h"
-
-
-struct tdfx_fast_tab {
- void (*build_vertices)( struct vertex_buffer *VB, GLuint do_cliptest );
- void (*interp)( GLfloat t, GLfloat *O, const GLfloat *I, const GLfloat *J );
- void (*project_vertices)( struct vertex_buffer *VB );
- void (*project_clipped_vertices)( struct vertex_buffer *VB );
-};
-
-
-#define POINT(x) tdfx_draw_point( fxMesa, &vert[x], psize )
-#define LINE(x,y) tdfx_draw_line( fxMesa, &vert[x], &vert[y], lwidth )
-#define TRI(x,y,z) fxMesa->Glide.grDrawTriangle( &vert[x], &vert[y], &vert[z] );
-
-
-#define INDIRECT_TRI(x,y,z) \
-do { \
- out[next_elt + 0] = &vert[x]; \
- out[next_elt + 1] = &vert[y]; \
- out[next_elt + 2] = &vert[z]; \
- next_elt += 3; \
-} while (0)
-
-
-
-/* Direct, and no clipping required. The clip funcs have not been
- * written yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for ( e = start ; e < count ; e++ ) \
- POINT( elt[e] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if ( parity ) { \
- GLuint tmp = e2; e2 = e1; e1 = tmp; \
- } \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI( e3, e2, e ); \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define LOCAL_VARS \
- tdfxVertexPtr vert = TDFX_DRIVER_DATA(VB)->verts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
- const GLfloat lwidth = ctx->Line.Width; \
- const GLfloat psize = ctx->Point.Size; \
- (void) lwidth; (void) psize; (void) vert; (void) fxMesa;
-
-#define TAG(x) tdfx_##x##_smooth_direct
-#include "render_tmp.h"
-
-
-
-/* Indirect, and no clipping required. The clip funcs have not been
- * written yet, so this is only useful for the fast path.
- */
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint e; \
- for ( e = start ; e < count ; e++ ) \
- POINT( elt[e] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i ) \
-do { \
- GLuint e1 = elt[i1], e = elt[i]; \
- LINE( e1, e ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- if ( parity ) { \
- GLuint tmp = e2; e2 = e1; e1 = tmp; \
- } \
- INDIRECT_TRI( e2, e1, e ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
-do { \
- GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \
- TRI( e3, e2, e ); \
- TRI( e2, e1, e ); \
-} while (0)
-
-#define LOCAL_VARS \
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB); \
- tdfxVertexPtr vert = fxVB->verts; \
- GLuint next_elt = fxVB->last_elt; \
- tdfxVertexPtr *out = fxVB->elts; \
- const GLuint *elt = VB->EltPtr->data; \
- GLcontext *ctx = VB->ctx; \
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
- const GLfloat lwidth = ctx->Line.Width; \
- const GLfloat psize = ctx->Point.Size; \
- (void) lwidth; (void) psize; (void) vert; (void) out; (void) fxMesa;
-
-#define POSTFIX \
- fxVB->last_elt = next_elt;
-
-#define TAG(x) tdfx_##x##_smooth_indirect
-#include "render_tmp.h"
-
-
-
-#define NEGATIVE(f) (f < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#define LINTERP(T, A, B) ((A) + (T) * ((B) - (A)))
-
-#define INTERP_RGBA( t, out, a, b ) \
-do { \
- int i; \
- for ( i = 0 ; i < 4 ; i++ ) { \
- GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR( a[i] ); \
- GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR( b[i] ); \
- GLfloat fo = LINTERP( t, fa, fb ); \
- FLOAT_COLOR_TO_UBYTE_COLOR( out[i], fo ); \
- } \
-} while (0)
-
-#define CLIP( SGN, V, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLuint *indata = inlist[in]; \
- GLuint *outdata = inlist[in ^= 1]; \
- GLuint nr = n; \
- GLfloat *J = verts[indata[nr-1]].f; \
- GLfloat dpJ = (SGN J[V]) + J[3]; \
- \
- inlist[0] = vlist1; \
- for ( i = n = 0 ; i < nr ; i++ ) { \
- GLuint elt_i = indata[i]; \
- GLfloat *I = verts[elt_i].f; \
- GLfloat dpI = (SGN I[V]) + I[3]; \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t, *in, *out; \
- \
- if ( NEGATIVE( dpI ) ) { \
- t = dpI / (dpI - dpJ); \
- in = I; \
- out = J; \
- } else { \
- t = dpJ / (dpJ - dpI); \
- in = J; \
- out = I; \
- } \
- \
- interp( t, O, in, out ); \
- \
- clipmask[next_vert] = 0; \
- outdata[n++] = next_vert++; \
- } \
- \
- clipmask[elt_i] |= PLANE; /* don't set up */ \
- \
- if ( !NEGATIVE( dpI ) ) { \
- outdata[n++] = elt_i; \
- clipmask[elt_i] &= ~PLANE; /* set up after all */ \
- } \
- \
- J = I; \
- dpJ = dpI; \
- } \
- \
- if ( n < 3 ) return; \
- } \
-} while (0)
-
-#define LINE_CLIP( x, y, z, w, PLANE ) \
-do { \
- if ( mask & PLANE ) { \
- GLfloat dpI = DOT4V( I, x, y, z, w ); \
- GLfloat dpJ = DOT4V( J, x, y, z, w ); \
- \
- if ( DIFFERENT_SIGNS( dpI, dpJ ) ) { \
- GLfloat *O = verts[next_vert].f; \
- GLfloat t = dpI / (dpI - dpJ); \
- \
- interp( t, O, I, J ); \
- \
- clipmask[next_vert] = 0; \
- \
- if ( NEGATIVE( dpI ) ) { \
- clipmask[elts[0]] |= PLANE; \
- I = O; \
- elts[0] = next_vert++; \
- } else { \
- clipmask[elts[1]] |= PLANE; \
- J = O; \
- elts[1] = next_vert++; \
- } \
- } else if ( NEGATIVE( dpI ) ) { \
- return; \
- } \
- } \
-} while (0)
-
-
-static __inline void tdfx_tri_clip( GLuint **p_elts,
- tdfxVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- tdfx_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLuint next_vert = *p_next_vert;
- GLuint in = 0;
- GLuint n = 3;
- GLuint vlist1[VB_MAX_CLIPPED_VERTS];
- GLuint vlist2[VB_MAX_CLIPPED_VERTS];
- GLuint *inlist[2];
- GLuint *out;
- GLuint i;
-
- inlist[0] = elts;
- inlist[1] = vlist2;
-
- CLIP( -, 0, CLIP_RIGHT_BIT );
- CLIP( +, 0, CLIP_LEFT_BIT );
- CLIP( -, 1, CLIP_TOP_BIT );
- CLIP( +, 1, CLIP_BOTTOM_BIT );
- CLIP( -, 2, CLIP_FAR_BIT );
- CLIP( +, 2, CLIP_NEAR_BIT );
-
- /* Convert the planar polygon to a list of triangles */
- out = inlist[in];
-
- for ( i = 2 ; i < n ; i++ ) {
- elts[0] = out[0];
- elts[1] = out[i-1];
- elts[2] = out[i];
- elts += 3;
- }
-
- *p_next_vert = next_vert;
- *p_elts = elts;
-}
-
-
-static __inline void tdfx_line_clip( GLuint **p_elts,
- tdfxVertex *verts,
- GLubyte *clipmask,
- GLuint *p_next_vert,
- GLubyte mask,
- tdfx_interp_func interp )
-{
- GLuint *elts = *p_elts;
- GLfloat *I = verts[elts[0]].f;
- GLfloat *J = verts[elts[1]].f;
- GLuint next_vert = *p_next_vert;
-
- LINE_CLIP( 1, 0, 0, -1, CLIP_LEFT_BIT );
- LINE_CLIP( -1, 0, 0, 1, CLIP_RIGHT_BIT );
- LINE_CLIP( 0, 1, 0, -1, CLIP_TOP_BIT );
- LINE_CLIP( 0, -1, 0, 1, CLIP_BOTTOM_BIT );
- LINE_CLIP( 0, 0, 1, -1, CLIP_FAR_BIT );
- LINE_CLIP( 0, 0, -1, 1, CLIP_NEAR_BIT );
-
- *p_next_vert = next_vert;
- *p_elts += 2;
-}
-
-
-#define CLIP_POINT( e ) \
-do { \
- if ( mask[e] ) *out++ = e; \
-} while (0)
-
-#define CLIP_LINE( e1, e0 ) \
-do { \
- GLubyte ormask = mask[e0] | mask[e1]; \
- out[0] = e1; \
- out[1] = e0; \
- out += 2; \
- if ( ormask ) { \
- out-=2; \
- if ( !(mask[e0] & mask[e1]) ) { \
- tdfx_line_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-#define CLIP_TRIANGLE( e2, e1, e0 ) \
-do { \
- GLubyte ormask; \
- out[0] = e2; \
- out[1] = e1; \
- out[2] = e0; \
- out += 3; \
- ormask = mask[e2] | mask[e1] | mask[e0]; \
- if ( ormask ) { \
- out -= 3; \
- if ( !(mask[e2] & mask[e1] & mask[e0]) ) { \
- tdfx_tri_clip( &out, verts, mask, \
- &next_vert, ormask, interp ); \
- } \
- } \
-} while (0)
-
-
-
-/* Build a table of functions to clip each primitive type. These
- * produce a list of elements in the appropriate 'reduced' primitive,
- * ie (points, lines, triangles) containing all the clipped and
- * unclipped primitives from the original list.
- */
-#define LOCAL_VARS \
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx); \
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB); \
- GLuint *elt = VB->EltPtr->data; \
- tdfxVertexPtr verts = fxVB->verts; \
- GLuint next_vert = fxVB->last_vert; \
- GLuint *out = fxVB->clipped_elements.data; \
- GLubyte *mask = VB->ClipMask; \
- tdfx_interp_func interp = fxMesa->interp; \
- (void) interp; (void) verts;
-
-#define POSTFIX \
- fxVB->clipped_elements.count = out - fxVB->clipped_elements.data; \
- fxVB->last_vert = next_vert;
-
-
-#define INIT( x )
-
-#define RENDER_POINTS( start, count ) \
-do { \
- GLuint i; \
- for ( i = start ; i < count ; i++ ) \
- CLIP_POINT( elt[i] ); \
-} while (0)
-
-#define RENDER_LINE( i1, i0 ) \
-do { \
- CLIP_LINE( elt[i1], elt[i0] ); \
-} while (0)
-
-#define RENDER_TRI( i2, i1, i0, pv, parity ) \
-do { \
- GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \
- if ( parity ) e2 = elt[i1], e1 = elt[i2]; \
- CLIP_TRIANGLE( e2, e1, e0 ); \
-} while (0)
-
-#define RENDER_QUAD( i3, i2, i1, i0, pv ) \
-do { \
- CLIP_TRIANGLE( elt[i3], elt[i2], elt[i0] ); \
- CLIP_TRIANGLE( elt[i2], elt[i1], elt[i0] ); \
-} while (0)
-
-#define TAG(x) tdfx_##x##_clip_elt
-#include "render_tmp.h"
-
-
-
-
-/* Pack rgba and/or texture into the remaining half of a 32 byte vertex.
- */
-#define CLIP_UBYTE_COLOR 4
-#define CLIP_UBYTE_B 0
-#define CLIP_UBYTE_G 1
-#define CLIP_UBYTE_R 2
-#define CLIP_UBYTE_A 3
-#define CLIP_S0 6
-#define CLIP_T0 7
-#define CLIP_S1 8
-#define CLIP_T1 9
-
-#define TYPE (0)
-#define TAG(x) x
-#include "tdfx_fasttmp.h"
-
-#define TYPE (TDFX_RGBA_BIT)
-#define TAG(x) x##_RGBA
-#include "tdfx_fasttmp.h"
-
-#define TYPE (TDFX_TEX0_BIT)
-#define TAG(x) x##_TEX0
-#include "tdfx_fasttmp.h"
-
-#define TYPE (TDFX_RGBA_BIT | TDFX_TEX0_BIT)
-#define TAG(x) x##_RGBA_TEX0
-#include "tdfx_fasttmp.h"
-
-#define TYPE (TDFX_RGBA_BIT | TDFX_TEX0_BIT | TDFX_TEX1_BIT)
-#define TAG(x) x##_RGBA_TEX0_TEX1
-#include "tdfx_fasttmp.h"
-
-/* This one *could* get away with sneaking TEX1 into the color and
- * specular slots, thus fitting inside a cache line. Would be even
- * better to switch to a smaller vertex.
- */
-#define TYPE (TDFX_TEX0_BIT | TDFX_TEX1_BIT)
-#define TAG(x) x##_TEX0_TEX1
-#include "tdfx_fasttmp.h"
-
-
-
-/* Render elements directly from original list of vertices.
- */
-static void tdfx_render_elements_direct( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = tdfx_render_tab_smooth_direct[prim];
- GLuint p = 0;
-
- if ( fxMesa->new_state )
- tdfxDDUpdateHwState( ctx );
-
- BEGIN_CLIP_LOOP( fxMesa );
- do {
- func( VB, 0, nr, 0 );
- } while ( ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ) );
- END_CLIP_LOOP( fxMesa );
-}
-
-/* Render elements indirectly from original list of vertices.
- */
-#if 0
-static void tdfx_render_elements_indirect( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = tdfx_render_tab_smooth_indirect[prim];
- GLuint p = 0;
-
- if ( fxMesa->new_state )
- tdfxDDUpdateHwState( ctx );
-
- do {
- func( VB, 0, nr, 0 );
- } while ( ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ) );
-
- BEGIN_CLIP_LOOP( fxMesa );
- fxMesa->Glide.grDrawVertexArray( GR_TRIANGLES, fxVB->last_elt, fxVB->elts );
- END_CLIP_LOOP( fxMesa );
-
- fxVB->last_elt = 0;
-}
-#endif
-
-/* Very sparsely popluated array - fix the indices.
- */
-static struct tdfx_fast_tab fxFastTab[0x80];
-
-void tdfxDDFastPathInit( void )
-{
- tdfx_render_init_clip_elt();
- tdfx_render_init_smooth_direct();
- tdfx_render_init_smooth_indirect();
-
- tdfx_init_fastpath( &fxFastTab[0] );
- tdfx_init_fastpath_RGBA( &fxFastTab[TDFX_RGBA_BIT] );
- tdfx_init_fastpath_TEX0( &fxFastTab[TDFX_TEX0_BIT] );
- tdfx_init_fastpath_RGBA_TEX0( &fxFastTab[TDFX_RGBA_BIT|TDFX_TEX0_BIT] );
- tdfx_init_fastpath_TEX0_TEX1( &fxFastTab[TDFX_TEX0_BIT|TDFX_TEX1_BIT] );
- tdfx_init_fastpath_RGBA_TEX0_TEX1( &fxFastTab[TDFX_RGBA_BIT|TDFX_TEX0_BIT|
- TDFX_TEX1_BIT] );
-}
-
-
-#define VALID_SETUP (TDFX_RGBA_BIT | TDFX_TEX0_BIT | TDFX_TEX1_BIT)
-
-
-void tdfxDDFastPath( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLenum prim = ctx->CVA.elt_mode;
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
- struct tdfx_fast_tab *tab = &fxFastTab[fxMesa->SetupIndex & VALID_SETUP];
-
- if ( fxMesa->new_state ) {
- tdfxDDUpdateHwState( ctx );
- }
- else if ( fxMesa->dirty & TDFX_UPLOAD_VERTEX_LAYOUT ) {
- /* After extensive debugging I discovered that the vertex layout
- * may need to be updated at this point. Not sure how this works
- * in the other drivers. -BP
- */
- LOCK_HARDWARE( fxMesa );
- fxMesa->Glide.grGlideSetVertexLayout( fxMesa->layout[fxMesa->vertexFormat] );
- fxMesa->dirty &= ~TDFX_UPLOAD_VERTEX_LAYOUT;
- UNLOCK_HARDWARE( fxMesa );
- }
-
- gl_prepare_arrays_cva( VB ); /* still need this */
-
- /* Reserve enough space for the pathological case */
- if ( VB->EltPtr->count * 12 > fxVB->size )
- tdfxDDResizeVB( VB, VB->EltPtr->count * 12 );
-
- tab->build_vertices( VB, 1 ); /* object->clip space */
-
- if ( VB->ClipOrMask ) {
- if ( !VB->ClipAndMask ) {
- render_func *clip = tdfx_render_tab_clip_elt;
-
- fxMesa->interp = tab->interp;
-
- clip[prim]( VB, 0, VB->EltPtr->count, 0 ); /* build new elts */
-
- ctx->CVA.elt_mode = gl_reduce_prim[prim];
- VB->EltPtr = &(fxVB->clipped_elements);
-
- tab->project_clipped_vertices( VB ); /* clip->device space */
- tdfx_render_elements_direct( VB ); /* render using new list */
- }
- } else {
- tab->project_vertices( VB ); /* clip->device space */
- tdfx_render_elements_direct( VB ); /* render using orig list */
- }
-
- /* This indicates that there is no cached data to reuse */
- VB->pipeline->data_valid = 0;
- VB->pipeline->new_state = 0;
-}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fasttmp.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fasttmp.h
deleted file mode 100644
index ab97a3895..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_fasttmp.h
+++ /dev/null
@@ -1,293 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_fasttmp.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-/* The first part of setup is applied to all vertices, clipped or
- * unclipped. This data will be used for clipping, and then all
- * vertices with a zero clipmask will be projected to device space.
- *
- * This could be split into several loops, but - it seems that the
- * large stride of the fxVertices makes cache issues the big
- * performance factor, and that multiple loops mean multiple cache
- * misses....
- */
-
-static void TAG(tdfx_setup_full)( struct vertex_buffer *VB,
- GLuint do_cliptest )
-{
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
- GLcontext *ctx = VB->ctx;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- const GLfloat * const m = ctx->ModelProjectMatrix.m;
- GLuint start = VB->CopyStart;
- GLuint count = VB->Count;
-
- if (0) fprintf(stderr, "%s\n", __FUNCTION__);
-
- gl_xform_points3_v16_general( TDFX_DRIVER_DATA(VB)->verts[start].f,
- m,
- VB->ObjPtr->start,
- VB->ObjPtr->stride,
- count - start );
-
- if ( do_cliptest ) {
- VB->ClipAndMask = ~0;
- VB->ClipOrMask = 0;
- gl_cliptest_points4_v16( fxVB->verts[start].f,
- fxVB->verts[count].f,
- &(VB->ClipOrMask),
- &(VB->ClipAndMask),
- VB->ClipMask + start );
- }
-
- /* These branches are all resolved at compile time. Hopefully all
- * the pointers are valid addresses even when not enabled.
- */
- if ( TYPE ) {
- GLubyte *color = VB->ColorPtr->start;
- GLfloat *tex0_data = VB->TexCoordPtr[fxMesa->tmu_source[0]]->start;
- GLfloat *tex1_data = VB->TexCoordPtr[fxMesa->tmu_source[1]]->start;
-
- const GLuint color_stride = VB->ColorPtr->stride;
- const GLuint tex0_stride = VB->TexCoordPtr[fxMesa->tmu_source[0]]->stride;
- const GLuint tex1_stride = VB->TexCoordPtr[fxMesa->tmu_source[1]]->stride;
-
- GLfloat *f = fxVB->verts[start].f;
- GLfloat *end = f + (16 * (count - start));
-
- while ( f != end ) {
- if ( TYPE & TDFX_RGBA_BIT ) {
-#if defined(USE_X86_ASM)
- __asm__ (
- "movl (%%edx),%%eax \n"
- "bswap %%eax \n"
- "rorl $8,%%eax \n"
- "movl %%eax,16(%%edi) \n"
- :
- : "d" (color), "D" (f)
- : "%eax" );
-#else
- GLubyte *col = color;
- GLubyte *b = (GLubyte *)&f[CLIP_UBYTE_COLOR];
- b[CLIP_UBYTE_B] = col[2];
- b[CLIP_UBYTE_G] = col[1];
- b[CLIP_UBYTE_R] = col[0];
- b[CLIP_UBYTE_A] = col[3];
-#endif
- }
- if (TYPE & TDFX_TEX0_BIT) {
-#if defined (USE_X86_ASM)
- __asm__ (
- "movl (%%ecx), %%eax \n"
- "movl %%eax, 24(%%edi) \n"
- "movl 4(%%ecx), %%eax \n"
- "movl %%eax, 28(%%edi)"
- :
- : "c" (tex0_data), "D" (f)
- : "%eax");
-#else
- *(unsigned int *)(f+CLIP_S0) = *(unsigned int *)tex0_data;
- *(unsigned int *)(f+CLIP_T0) = *(unsigned int *)(tex0_data+1);
-#endif
- }
- if (TYPE & TDFX_TEX1_BIT) {
- /* Hits a second cache line.
- */
-#if defined (USE_X86_ASM)
- __asm__ (
- "movl (%%esi), %%eax \n"
- "movl %%eax, 32(%%edi) \n"
- "movl 4(%%esi), %%eax \n"
- "movl %%eax, 36(%%edi)"
- :
- : "S" (tex1_data), "D" (f)
- : "%eax");
-#else
- *(unsigned int *)(f+CLIP_S1) = *(unsigned int *)tex1_data;
- *(unsigned int *)(f+CLIP_T1) = *(unsigned int *)(tex1_data+1);
-#endif
- }
- if ( TYPE & TDFX_RGBA_BIT ) color += color_stride;
- if ( TYPE & TDFX_TEX0_BIT ) STRIDE_F( tex0_data, tex0_stride );
- if ( TYPE & TDFX_TEX1_BIT ) STRIDE_F( tex1_data, tex1_stride );
- f += 16;
- }
- }
-
- fxVB->clipped_elements.count = start;
- fxVB->last_vert = count;
-}
-
-
-/* Changed to just put the interp func instead of the whole clip
- * routine into the header. Less code and better chance of doing some
- * of this stuff in assembly.
- */
-static void TAG(tdfx_interp_vert)( GLfloat t,
- GLfloat *O,
- const GLfloat *I,
- const GLfloat *J )
-{
- O[0] = LINTERP( t, I[0], J[0] );
- O[1] = LINTERP( t, I[1], J[1] );
- O[2] = LINTERP( t, I[2], J[2] );
- O[3] = LINTERP( t, I[3], J[3] );
-
- if ( TYPE & TDFX_RGBA_BIT ) {
- INTERP_RGBA( t,
- ((GLubyte *)&(O[4])),
- ((GLubyte *)&(I[4])),
- ((GLubyte *)&(J[4])) );
- }
-
- if ( TYPE & TDFX_TEX0_BIT ) {
- O[6] = LINTERP( t, I[6], J[6] );
- O[7] = LINTERP( t, I[7], J[7] );
- }
-
- if ( TYPE & TDFX_TEX1_BIT ) {
- O[8] = LINTERP( t, I[8], J[8] );
- O[9] = LINTERP( t, I[9], J[9] );
- }
-}
-
-
-
-static void TAG(tdfx_project_vertices)( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
- GLfloat *first = fxVB->verts[VB->CopyStart].f;
- GLfloat *last = fxVB->verts[fxVB->last_vert].f;
- GLfloat m[16];
- GLfloat *f;
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] + fxMesa->x_offset + TRI_X_OFFSET;
- m[MAT_SY] = mat->m[MAT_SY];
- m[MAT_TY] = mat->m[MAT_TY] + fxMesa->y_delta + TRI_Y_OFFSET;
- m[MAT_SZ] = mat->m[MAT_SZ];
- m[MAT_TZ] = mat->m[MAT_TZ];
-
- gl_project_v16( first, last, m, 16 * 4 );
-
- /* V3 at least requires texcoords to be multiplied by 1/w:
- */
- if ( TYPE & (TDFX_TEX0_BIT|TDFX_TEX1_BIT) ) {
-
- const GLfloat sScale0 = fxMesa->sScale0;
- const GLfloat tScale0 = fxMesa->tScale0;
- const GLfloat sScale1 = fxMesa->sScale1;
- const GLfloat tScale1 = fxMesa->tScale1;
-
-
- for ( f = first ; f != last ; f += 16) {
- const GLfloat oow = f[3];
-
- if (TYPE & TDFX_TEX0_BIT) {
- f[CLIP_S0] *= sScale0 * oow;
- f[CLIP_T0] *= tScale0 * oow;
- }
-
- if (TYPE & TDFX_TEX1_BIT) {
- f[CLIP_S1] *= sScale1 * oow;
- f[CLIP_T1] *= tScale1 * oow;
- }
- }
- }
-}
-
-static void TAG(tdfx_project_clipped_vertices)( struct vertex_buffer *VB )
-{
- GLfloat *f;
-
- GLcontext *ctx = VB->ctx;
- GLmatrix *mat = &ctx->Viewport.WindowMap;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
- GLfloat *first = fxVB->verts[VB->CopyStart].f;
- GLfloat *last = fxVB->verts[fxVB->last_vert].f;
- const GLubyte *mask = VB->ClipMask + VB->CopyStart;
- GLfloat m[16];
-
- m[MAT_SX] = mat->m[MAT_SX];
- m[MAT_TX] = mat->m[MAT_TX] + fxMesa->x_offset + TRI_X_OFFSET;
- m[MAT_SY] = mat->m[MAT_SY];
- m[MAT_TY] = mat->m[MAT_TY] + fxMesa->y_delta + TRI_Y_OFFSET;
- m[MAT_SZ] = mat->m[MAT_SZ];
- m[MAT_TZ] = mat->m[MAT_TZ];
-
- gl_project_clipped_v16( first, last, m, 16 * 4, mask );
-
- /* V3 at least requires texcoords to be multiplied by 1/w:
- */
- if ( TYPE & (TDFX_TEX0_BIT|TDFX_TEX1_BIT) ) {
-
- const GLfloat sScale0 = fxMesa->sScale0;
- const GLfloat tScale0 = fxMesa->tScale0;
- const GLfloat sScale1 = fxMesa->sScale1;
- const GLfloat tScale1 = fxMesa->tScale1;
-
- for ( f = first ; f != last ; f += 16, mask++) {
- if (!*mask) {
- const GLfloat oow = f[3];
- if (TYPE & TDFX_TEX0_BIT) {
- f[CLIP_S0] *= sScale0 * oow;
- f[CLIP_T0] *= tScale0 * oow;
- }
-
- if (TYPE & TDFX_TEX1_BIT) {
- f[CLIP_S1] *= sScale1 * oow;
- f[CLIP_T1] *= tScale1 * oow;
- }
- }
- }
- }
-}
-
-static void TAG(tdfx_init_fastpath)( struct tdfx_fast_tab *tab )
-{
- tab->build_vertices = TAG(tdfx_setup_full);
- tab->interp = TAG(tdfx_interp_vert);
- tab->project_vertices = TAG(tdfx_project_vertices);
- tab->project_clipped_vertices = TAG(tdfx_project_clipped_vertices);
-}
-
-#undef TYPE
-#undef TAG
-#undef SIZE
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
index 729349a24..40f097476 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c
@@ -34,11 +34,10 @@
*
*/
-#include "dri_glide.h"
-
#include "tdfx_context.h"
#include "tdfx_lock.h"
#include "tdfx_state.h"
+#include "tdfx_render.h"
#include "tdfx_texman.h"
#include "tdfx_tris.h"
@@ -51,15 +50,14 @@ void tdfxGetLock( tdfxContextPtr fxMesa )
TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
fxMesa->fxScreen->sarea_priv_offset);
int stamp = dPriv->lastStamp;
- int one_rect = (fxMesa->numClipRects <= 1);
drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 );
/* This macro will update dPriv's cliprects if needed */
- XMESA_VALIDATE_DRAWABLE_INFO( cPriv->display, sPriv, dPriv );
+ DRI_VALIDATE_DRAWABLE_INFO( cPriv->display, sPriv, dPriv );
if ( saPriv->fifoOwner != fxMesa->hHWContext ) {
- fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead );
+ fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead );
}
if ( saPriv->ctxOwner != fxMesa->hHWContext ) {
@@ -69,11 +67,11 @@ void tdfxGetLock( tdfxContextPtr fxMesa )
* that state onto the hardware when you set the state.
*/
void *state;
- FxI32 size;
- fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, 4, &size );
- state = malloc( size );
- FX_grGlideGetState_NoLock( state );
- FX_grGlideSetState_NoLock( state );
+ FxI32 stateSize;
+ fxMesa->Glide.grGet(GR_GLIDE_STATE_SIZE, 4, &stateSize);
+ state = malloc(stateSize);
+ fxMesa->Glide.grGlideGetState( state );
+ fxMesa->Glide.grGlideSetState( state );
free( state );
}
@@ -88,11 +86,5 @@ void tdfxGetLock( tdfxContextPtr fxMesa )
tdfxUploadClipping(fxMesa);
}
- /* Detect if we have swapped between 1 and >1 cliprects, and change
- * triangle funcs if necessary.
- */
- if (one_rect != (fxMesa->numClipRects <= 1))
- tdfxDDToggleTriCliprects( fxMesa->glCtx );
-
DEBUG_LOCK();
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h
index 8f258f57b..249384f81 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h,v 1.2 2001/08/18 02:51:06 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
/*
* Original rewrite:
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.c
deleted file mode 100644
index 370ed51f2..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.c,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-#include "tdfx_context.h"
-#include "tdfx_pipeline.h"
-#include "tdfx_vb.h"
-#include "tdfx_tris.h"
-
-#include "vbindirect.h"
-
-static struct gl_pipeline_stage tdfx_fast_stage = {
- "TDFX Fast Path",
- (PIPE_OP_VERT_XFORM |
- PIPE_OP_RAST_SETUP_0 |
- PIPE_OP_RAST_SETUP_1 |
- PIPE_OP_RENDER),
- PIPE_PRECALC,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- tdfxDDFastPath
-};
-
-#define ILLEGAL_ENABLES (TEXTURE0_3D | \
- TEXTURE1_3D | \
- ENABLE_TEXMAT0 | \
- ENABLE_TEXMAT1 | \
- ENABLE_TEXGEN0 | \
- ENABLE_TEXGEN1 | \
- ENABLE_USERCLIP | \
- ENABLE_LIGHT | \
- ENABLE_FOG)
-
-/* Build the PRECALC pipeline with our stage, if possible. Otherwise,
- * return GL_FALSE.
- */
-GLboolean tdfxDDBuildPrecalcPipeline( GLcontext *ctx )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- struct gl_pipeline *pipe = &ctx->CVA.pre;
-
- if ( (fxMesa->RenderIndex & ~TDFX_CLIPRECT_BIT) == 0 &&
- (ctx->Enabled & ILLEGAL_ENABLES) == 0 &&
-#ifdef VAO
- (ctx->Array.Current->Flags & (VERT_OBJ_234 |
-#else
- (ctx->Array.Flags & (VERT_OBJ_234 |
-#endif
- VERT_TEX0_4 |
- VERT_TEX1_4 |
- VERT_ELT)) == (VERT_OBJ_23 | VERT_ELT) )
- {
- pipe->stages[0] = &tdfx_fast_stage;
- pipe->stages[1] = 0;
- pipe->new_inputs = ctx->RenderFlags & VERT_DATA;
- pipe->ops = pipe->stages[0]->ops;
-
- fxMesa->using_fast_path = GL_TRUE;
- return GL_TRUE;
- }
-
- if ( fxMesa->using_fast_path ) {
- fxMesa->using_fast_path = GL_FALSE;
-
- ctx->CVA.VB->ClipOrMask = 0;
- ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS;
-#ifdef VAO
- ctx->Array.NewArrayState |= ctx->Array.Current->Summary;
-#else
- ctx->Array.NewArrayState |= ctx->Array.Summary;
-#endif
- }
-
- return GL_FALSE;
-}
-
-
-static void tdfxDDCheckRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d )
-{
- d->type = PIPE_IMMEDIATE | PIPE_PRECALC;
- d->inputs = ctx->RenderFlags;
-
- d->outputs = VERT_SETUP_FULL;
-
- if ( ctx->IndirectTriangles & DD_SW_SETUP )
- d->type = PIPE_IMMEDIATE;
-}
-
-
-static void tdfxDDRenderElements(struct vertex_buffer *VB)
-{
- if (VB->ClipOrMask) {
- gl_render_elts( VB );
- } else {
- GLcontext *ctx = VB->ctx;
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- fxMesa->RenderElementsRaw( VB );
- }
-}
-
-
-/* Register the pipeline with our stages included */
-GLuint tdfxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr )
-{
- int i, o;
-
- for ( i = o = 0 ; i < nr ; i++ ) {
- switch ( in[i].ops ) {
-
- case PIPE_OP_RAST_SETUP_0:
- out[o] = in[i];
- out[o].cva_state_change = (NEW_LIGHTING |
- NEW_TEXTURING |
- NEW_RASTER_OPS);
- out[o].state_change = ~0;
- out[o].check = tdfxDDCheckPartialRasterSetup;
- out[o].run = tdfxDDPartialRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RAST_SETUP_0 | PIPE_OP_RAST_SETUP_1:
- out[o] = in[i];
- out[o].check = tdfxDDCheckRasterSetup;
- out[o].run = tdfxDDDoRasterSetup;
- o++;
- break;
-
- case PIPE_OP_RENDER:
- out[o] = in[i];
- if (in[i].type == PIPE_PRECALC)
- out[o].run = tdfxDDRenderElements;
- o++;
- break;
-
- default:
- out[o++] = in[i];
- break;
- }
- }
-
- return o;
-}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
index 9be3edf44..dc9b01e0f 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c,v 1.3 2001/08/18 02:51:06 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -38,13 +38,56 @@
#include "tdfx_context.h"
#include "tdfx_dd.h"
+#include "tdfx_lock.h"
#include "tdfx_vb.h"
-#include "tdfx_pipeline.h"
#include "tdfx_pixels.h"
#include "tdfx_render.h"
+#include "swrast/swrast.h"
+
#include "image.h"
+
+#define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while(0)
+
+
+#define FX_grLfbReadRegion(fxMesa,src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while (0);
+
+
+static FxBool
+FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
+ FxBool pixelPipeline, GrLfbInfo_t * info)
+{
+ FxBool result;
+
+ LOCK_HARDWARE(fxMesa);
+ result = fxMesa->Glide.grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
+ UNLOCK_HARDWARE(fxMesa);
+ return result;
+}
+
+
+
+#define FX_grLfbUnlock(fxMesa, t, b) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbUnlock(t, b); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while (0)
+
+
+
#if 0
/* test if window coord (px,py) is visible */
static GLboolean
@@ -432,25 +475,26 @@ tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
}
#endif
-GLboolean
+void
tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
GLvoid * dstImage)
{
- if (!(format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5)) {
- return GL_FALSE; /* format/type not recognised */
- }
-
- if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
- return GL_FALSE; /* can't do this */
+ if (format != GL_RGB ||
+ type != GL_UNSIGNED_SHORT_5_6_5 ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)))
+ {
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing,
+ dstImage );
+ return;
}
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
- GLboolean result = GL_FALSE;
const GLint winX = fxMesa->x_offset;
const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
@@ -460,9 +504,9 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
LOCK_HARDWARE( fxMesa );
info.size = sizeof(info);
if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->ReadBuffer,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ fxMesa->ReadBuffer,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer ==
GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2);
const GLushort *src = (const GLushort *) info.lfbPtr
@@ -472,45 +516,43 @@ tdfx_readpixels_R5G6B5(GLcontext * ctx, GLint x, GLint y,
const GLint dstStride = _mesa_image_row_stride(packing,
width, format, type);
- if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
- /* directly memcpy 5R6G5B pixels into client's buffer */
- const GLint widthInBytes = width * 2;
- GLint row;
- for (row = 0; row < height; row++) {
- MEMCPY(dst, src, widthInBytes);
- dst += dstStride;
- src -= srcStride;
- }
- result = GL_TRUE;
+ /* directly memcpy 5R6G5B pixels into client's buffer */
+ const GLint widthInBytes = width * 2;
+ GLint row;
+ for (row = 0; row < height; row++) {
+ MEMCPY(dst, src, widthInBytes);
+ dst += dstStride;
+ src -= srcStride;
}
fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer);
}
UNLOCK_HARDWARE( fxMesa );
- return result;
+ return;
}
}
-GLboolean
+void
tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
GLvoid * dstImage)
{
- if (!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
- !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
- return GL_FALSE; /* format/type not optimised */
+ if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
+ !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)))
+ {
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing,
+ dstImage );
+ return;
}
- if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
- return GL_FALSE; /* can't do this */
- }
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrLfbInfo_t info;
- GLboolean result = GL_FALSE;
const GLint winX = fxMesa->x_offset;
const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
@@ -520,9 +562,9 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
LOCK_HARDWARE(fxMesa);
info.size = sizeof(info);
if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY,
- fxMesa->ReadBuffer,
- GR_LFBWRITEMODE_ANY,
- GR_ORIGIN_UPPER_LEFT, FXFALSE, &info))
+ fxMesa->ReadBuffer,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info))
{
const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
? (fxMesa->screen_width) : (info.strideInBytes / 4);
@@ -534,46 +576,53 @@ tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
dstImage, width, height, format, type, 0, 0, 0);
const GLint widthInBytes = width * 4;
- if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) ||
- (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+ {
GLint row;
for (row = 0; row < height; row++) {
MEMCPY(dst, src, widthInBytes);
dst += dstStride;
src -= srcStride;
}
- result = GL_TRUE;
}
fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer);
}
UNLOCK_HARDWARE(fxMesa);
- return result;
}
}
-GLboolean
+void
tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid * pixels)
{
- if (!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
- !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
- return GL_FALSE; /* format/type not optimised */
- }
-
- if (ctx->Pixel.ZoomX!=1.0F || ctx->Pixel.ZoomY!=1.0F) {
- return GL_FALSE; /* can't scale pixels */
- }
-
- if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) {
- return GL_FALSE; /* can't do this */
- }
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- if (ctx->RasterMask & (~BLEND_BIT)) {
- return GL_FALSE; /* can't do any raster ops, except blend */
+ if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
+ !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) ||
+ ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._ReallyEnabled ||
+ ctx->Depth.OcclusionTest ||
+ fxMesa->Fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
}
{
@@ -590,7 +639,7 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
LOCK_HARDWARE(fxMesa);
/* make sure hardware has latest blend funcs */
- if (ctx->RasterMask & BLEND_BIT) {
+ if (ctx->Color.BlendEnabled) {
fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC;
tdfxEmitHwStateLocked( fxMesa );
}
@@ -599,15 +648,17 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) {
if (!inClipRects_Region(fxMesa, scrX, scrY, width, height)) {
UNLOCK_HARDWARE(fxMesa);
- return GL_FALSE;
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
}
}
info.size = sizeof(info);
if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY,
- fxMesa->DrawBuffer,
- GR_LFBWRITEMODE_8888,
- GR_ORIGIN_UPPER_LEFT, FXTRUE, &info))
+ fxMesa->DrawBuffer,
+ GR_LFBWRITEMODE_8888,
+ GR_ORIGIN_UPPER_LEFT, FXTRUE, &info))
{
const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT)
? (fxMesa->screen_width * 4) : (info.strideInBytes);
@@ -633,6 +684,5 @@ tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer);
}
UNLOCK_HARDWARE(fxMesa);
- return result;
}
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h
index bb409d6fa..d565ca496 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h
@@ -43,33 +43,33 @@
#include "context.h"
-extern GLboolean
+extern void
tdfx_bitmap_R5G6B5( GLcontext *ctx, GLint px, GLint py,
GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap );
-extern GLboolean
+extern void
tdfx_bitmap_R8G8B8A8( GLcontext *ctx, GLint px, GLint py,
GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap );
-extern GLboolean
+extern void
tdfx_readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
GLvoid *dstImage );
-extern GLboolean
+extern void
tdfx_readpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
GLvoid *dstImage );
-extern GLboolean
+extern void
tdfx_drawpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c
index d97549f0a..e3afab10d 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c
@@ -35,91 +35,22 @@
*
*/
-#include "dri_glide.h"
#include "tdfx_context.h"
#include "tdfx_render.h"
#include "tdfx_state.h"
#include "tdfx_texman.h"
+#include "swrast/swrast.h"
/* Clear the color and/or depth buffers.
*/
-static GLbitfield tdfxDDClear( GLcontext *ctx,
- GLbitfield mask, GLboolean all,
- GLint x, GLint y, GLint width, GLint height )
+static void tdfxDDClear( GLcontext *ctx,
+ GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
{
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
- const GLuint stencil_size = fxMesa->haveHwStencil ? fxMesa->glVis->StencilBits : 0;
- GLbitfield softwareMask = 0;
-
-#if 0
- GLuint flags;
-
- FLUSH_BATCH( fxMesa );
-
- if ( mask & DD_FRONT_LEFT_BIT ) {
- flags |= TDFX_FRONT;
- mask &= ~DD_FRONT_LEFT_BIT;
- }
-
- if ( mask & DD_BACK_LEFT_BIT ) {
- flags |= TDFX_BACK;
- mask &= ~DD_BACK_LEFT_BIT;
- }
-
- if ( (mask & DD_DEPTH_BIT) && ctx->Depth.Mask ) {
- flags |= TDFX_DEPTH;
- mask &= ~DD_DEPTH_BIT;
- }
-
- if ( (mask & DD_STENCIL_BIT) && fxMesa->haveHwStencil ) {
- clear.flags |= TDFX_STENCIL;
- mask &= ~DD_STENCIL_BIT;
- }
-
- if ( !flags )
- return mask;
-
- LOCK_HARDWARE( fxMesa );
-
-
- if ( flags & TDFX_FRONT ) {
-
- }
-
- if ( flags & TDFX_BACK ) {
-
- }
-
- if ( flags & TDFX_DEPTH ) {
-
- }
-
- if ( flags & TDFX_STENCIL ) {
- fxMesa->Glide.grStencilMask( fxMesa->Stencil.WriteMask );
- /* set stencil ref value = desired clear value */
- fxMesa->Glide.grStencilFunc( GR_CMP_ALWAYS, fxMesa->Stencil.Clear, 0xff );
- fxMesa->Glide.grStencilOp( GR_STENCILOP_REPLACE,
- GR_STENCILOP_REPLACE,
- GR_STENCILOP_REPLACE );
- fxMesa->Glide.grEnable( GR_STENCIL_MODE_EXT );
-
- if ( ctx->Stencil.Enabled ) {
- fxMesa->Glide.grStencilOp( fxMesa->Stencil.FailFunc,
- fxMesa->Stencil.ZFailFunc,
- fxMesa->Stencil.ZPassFunc );
- fxMesa->Glide.grStencilMask( fxMesa->Stencil.WriteMask );
- fxMesa->Glide.grStencilFunc( fxMesa->Stencil.Function,
- fxMesa->Stencil.RefValue,
- fxMesa->Stencil.ValueMask );
- fxMesa->Glide.grEnable_NoLock( GR_STENCIL_MODE_EXT );
- } else {
- fxMesa->Glide.grDisable( GR_STENCIL_MODE_EXT );
- }
-
- }
- UNLOCK_HARDWARE( fxMesa );
-
-#else
+ GLbitfield softwareMask = mask & (DD_ACCUM_BIT);
+ const GLuint stencil_size =
+ fxMesa->haveHwStencil ? fxMesa->glCtx->Visual.stencilBits : 0;
if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s( %d, %d, %d, %d )\n",
@@ -133,10 +64,7 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
}
/* we can't clear accum buffers */
- if (mask & DD_ACCUM_BIT) {
- mask &= ~(DD_ACCUM_BIT);
- softwareMask |= DD_ACCUM_BIT;
- }
+ mask &= ~(DD_ACCUM_BIT);
if (mask & DD_STENCIL_BIT) {
if (!fxMesa->haveHwStencil || ctx->Stencil.WriteMask != 0xff) {
@@ -147,10 +75,10 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
}
}
- if (fxMesa->glVis->RedBits != 8) {
+ if (fxMesa->glCtx->Visual.redBits != 8) {
/* can only do color masking if running in 24/32bpp on Napalm */
- if ((ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP]) ||
- (ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP])) {
+ if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
+ ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT));
mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
}
@@ -166,7 +94,8 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
if (mask & DD_STENCIL_BIT) {
fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff);
/* set stencil ref value = desired clear value */
- fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS, ctx->Stencil.Clear, 0xff);
+ fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS,
+ ctx->Stencil.Clear, 0xff);
fxMesa->Glide.grStencilOp(GR_STENCILOP_REPLACE,
GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE);
fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT);
@@ -178,7 +107,8 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
}
/*
- * FIXME: This is just plain ugly...
+ * This may be ugly, but it's needed in order to work around a number
+ * of Glide bugs.
*/
BEGIN_CLIP_LOOP(fxMesa);
{
@@ -277,8 +207,7 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT:
/* front and back */
fxMesa->Glide.grDepthMask(FXFALSE);
- fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grColorMaskv_NoLock(ctx, true4);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
if (stencil_size > 0)
fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
fxMesa->Color.ClearAlpha,
@@ -288,7 +217,7 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
fxMesa->Color.ClearAlpha,
fxMesa->Depth.Clear);
- fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
if (stencil_size > 0)
fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
fxMesa->Color.ClearAlpha,
@@ -306,7 +235,6 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
/* clear front */
fxMesa->Glide.grDepthMask(FXFALSE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
- FX_grColorMaskv_NoLock(ctx, true4);
if (stencil_size > 0)
fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
fxMesa->Color.ClearAlpha,
@@ -319,7 +247,7 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
/* clear back and depth */
fxMesa->Glide.grDepthMask(FXTRUE);
fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
- if (stencil_size > 0)
+ if (stencil_size > 0)
fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
fxMesa->Color.ClearAlpha,
fxMesa->Depth.Clear,
@@ -381,8 +309,8 @@ static GLbitfield tdfxDDClear( GLcontext *ctx,
fxMesa->dirty |= TDFX_UPLOAD_STENCIL;
}
-#endif
- return softwareMask;
+ if (softwareMask)
+ _swrast_Clear( ctx, softwareMask, all, x, y, width, height );
}
@@ -410,7 +338,7 @@ static void tdfxDDFlush( GLcontext *ctx )
}
-
+#if 0
static const char *texSource(int k)
{
switch (k) {
@@ -454,7 +382,9 @@ static const char *texSource(int k)
return "";
}
}
+#endif
+#if 0
static const char *texMode(int k)
{
switch (k) {
@@ -472,11 +402,14 @@ static const char *texMode(int k)
return "";
}
}
+#endif
+#if 0
static const char *texInvert(int k)
{
return k ? "FXTRUE" : "FXFALSE";
}
+#endif
static void uploadTextureEnv( tdfxContextPtr fxMesa )
{
@@ -530,7 +463,7 @@ static void uploadTextureEnv( tdfxContextPtr fxMesa )
fxMesa->TexCombineExt[unit].Alpha.Shift,
fxMesa->TexCombineExt[unit].Alpha.Invert);
fxMesa->Glide.grConstantColorValueExt(TDFX_TMU0 + unit,
- fxMesa->TexCombineExt[unit].EnvColor);
+ fxMesa->TexCombineExt[unit].EnvColor);
}
}
else {
@@ -598,13 +531,16 @@ static void uploadTextureImages( tdfxContextPtr fxMesa )
{
GLcontext *ctx = fxMesa->glCtx;
int unit;
- for ( unit = 0 ; unit < TDFX_NUM_TMU ; unit++ ) {
- if ( ctx->Texture.Unit[unit].ReallyEnabled == TEXTURE0_2D ) {
- struct gl_texture_object *tObj = ctx->Texture.Unit[unit].CurrentD[2];
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- if ( t && t->reloadImages ) {
- tdfxTMDownloadTextureLocked( fxMesa, tObj );
- t->reloadImages = GL_FALSE;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled == TEXTURE0_2D) {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit].Current2D;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti && ti->reloadImages && ti->whichTMU != TDFX_TMU_NONE) {
+ /*
+ printf("download texture image on unit %d\n", unit);
+ */
+ tdfxTMDownloadTexture(fxMesa, tObj);
+ ti->reloadImages = GL_FALSE;
}
}
}
@@ -631,9 +567,9 @@ void tdfxUploadClipping( tdfxContextPtr fxMesa )
}
else if (fxMesa->numClipRects == 1) {
fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1,
- fxMesa->screen_height - fxMesa->pClipRects[0].y2,
- fxMesa->pClipRects[0].x2,
- fxMesa->screen_height - fxMesa->pClipRects[0].y1);
+ fxMesa->screen_height - fxMesa->pClipRects[0].y2,
+ fxMesa->pClipRects[0].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y1);
}
/* else, we'll do a cliprect loop around all drawing */
@@ -650,23 +586,23 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_COMBINE ) {
if (TDFX_IS_NAPALM(fxMesa)) {
fxMesa->Glide.grColorCombineExt(fxMesa->ColorCombineExt.SourceA,
- fxMesa->ColorCombineExt.ModeA,
- fxMesa->ColorCombineExt.SourceB,
- fxMesa->ColorCombineExt.ModeB,
- fxMesa->ColorCombineExt.SourceC,
- fxMesa->ColorCombineExt.InvertC,
- fxMesa->ColorCombineExt.SourceD,
- fxMesa->ColorCombineExt.InvertD,
- fxMesa->ColorCombineExt.Shift,
- fxMesa->ColorCombineExt.Invert);
+ fxMesa->ColorCombineExt.ModeA,
+ fxMesa->ColorCombineExt.SourceB,
+ fxMesa->ColorCombineExt.ModeB,
+ fxMesa->ColorCombineExt.SourceC,
+ fxMesa->ColorCombineExt.InvertC,
+ fxMesa->ColorCombineExt.SourceD,
+ fxMesa->ColorCombineExt.InvertD,
+ fxMesa->ColorCombineExt.Shift,
+ fxMesa->ColorCombineExt.Invert);
}
else {
/* Voodoo 3 */
- fxMesa->Glide.grColorCombine(fxMesa->ColorCombine.Function,
- fxMesa->ColorCombine.Factor,
- fxMesa->ColorCombine.Local,
- fxMesa->ColorCombine.Other,
- fxMesa->ColorCombine.Invert);
+ fxMesa->Glide.grColorCombine( fxMesa->ColorCombine.Function,
+ fxMesa->ColorCombine.Factor,
+ fxMesa->ColorCombine.Local,
+ fxMesa->ColorCombine.Other,
+ fxMesa->ColorCombine.Invert );
}
fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_COMBINE;
}
@@ -699,13 +635,11 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
fxMesa->dirty &= ~TDFX_UPLOAD_RENDER_BUFFER;
}
-#if defined(__linux__) || defined(__FreeBSD__)
if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE) {
fxMesa->Glide.grStipplePattern( fxMesa->Stipple.Pattern );
fxMesa->Glide.grStippleMode( fxMesa->Stipple.Mode );
fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE;
}
-#endif /* __linux__ || __FreeBSD__ */
if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_TEST ) {
fxMesa->Glide.grAlphaTestFunction( fxMesa->Color.AlphaFunc );
@@ -779,7 +713,7 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK ) {
if ( fxMesa->Glide.grColorMaskExt
- && fxMesa->glCtx->Visual->RedBits == 8) {
+ && fxMesa->glCtx->Visual.redBits == 8) {
fxMesa->Glide.grColorMaskExt( fxMesa->Color.ColorMask[RCOMP],
fxMesa->Color.ColorMask[GCOMP],
fxMesa->Color.ColorMask[BCOMP],
@@ -793,10 +727,10 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK;
}
- if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) {
- fxMesa->Glide.grConstantColorValue( fxMesa->Color.MonoColor );
- fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR;
- }
+/* if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) { */
+/* grConstantColorValue( fxMesa->Color.MonoColor ); */
+/* fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR; */
+/* } */
if ( fxMesa->dirty & TDFX_UPLOAD_LINE ) {
if (fxMesa->glCtx->Line.SmoothFlag && fxMesa->glCtx->Line.Width == 1.0)
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
index 5d47e948a..61a3b4dea 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c,v 1.2 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
/*
* Original rewrite:
@@ -38,9 +38,9 @@
#include "tdfx_dri.h"
#include "tdfx_context.h"
+#include "tdfx_lock.h"
#include "tdfx_vb.h"
#include "tdfx_tris.h"
-#include "tdfx_pipeline.h"
#ifdef DEBUG_LOCKING
@@ -48,8 +48,22 @@ char *prevLockFile = 0;
int prevLockLine = 0;
#endif
+#ifndef TDFX_DEBUG
+int TDFX_DEBUG = (0
+/* | DEBUG_ALWAYS_SYNC */
+/* | DEBUG_VERBOSE_API */
+/* | DEBUG_VERBOSE_MSG */
+/* | DEBUG_VERBOSE_LRU */
+/* | DEBUG_VERBOSE_DRI */
+/* | DEBUG_VERBOSE_IOCTL */
+/* | DEBUG_VERBOSE_2D */
+ );
+#endif
+
+
-GLboolean tdfxCreateScreen( __DRIscreenPrivate *sPriv )
+static GLboolean
+tdfxCreateScreen( __DRIscreenPrivate *sPriv )
{
tdfxScreenPrivate *fxScreen;
TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv;
@@ -84,17 +98,12 @@ GLboolean tdfxCreateScreen( __DRIscreenPrivate *sPriv )
return GL_FALSE;
}
- tdfxDDSetupInit();
- tdfxDDTriangleFuncsInit();
- tdfxDDFastPathInit();
-
- /***
- tdfxDDGlideExtensionsInit();
- **/
return GL_TRUE;
}
-void tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
+
+static void
+tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
{
tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
@@ -105,3 +114,258 @@ void tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
sPriv->private = NULL;
}
}
+
+
+static GLboolean
+tdfxInitDriver( __DRIscreenPrivate *sPriv )
+{
+ int major, minor, patch;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, sPriv );
+ }
+
+ /* Check the DRI version */
+ if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
+ if ( major != 4 ||
+ minor < 0 ) {
+ __driUtilMessage(
+ "3dfx DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ major, minor, patch );
+ return GL_FALSE;
+ }
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( sPriv->ddxMajor != 1 ||
+ sPriv->ddxMinor < 0 ) {
+ __driUtilMessage(
+ "3dfx DRI driver expected DDX driver version 1.0.x "
+ "but got version %d.%d.%d",
+ sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( sPriv->drmMajor != 1 ||
+ sPriv->drmMinor < 0 ) {
+ __driUtilMessage(
+ "3dfx DRI driver expected DRM driver version 1.0.x "
+ "but got version %d.%d.%d",
+ sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
+ return GL_FALSE;
+ }
+
+ if ( !tdfxCreateScreen( sPriv ) ) {
+ tdfxDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+tdfxCreateBuffer( Display *dpy,
+ __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* software alpha channel? */ );
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+static void
+tdfxSwapBuffers(Display *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *driDrawPriv = (__DRIdrawablePrivate*) drawablePrivate;
+ GET_CURRENT_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = 0;
+ GLframebuffer *mesaBuffer;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, driDrawPriv );
+ }
+
+ mesaBuffer = (GLframebuffer *) driDrawPriv->driverPrivate;
+ if ( !mesaBuffer->Visual.doubleBufferMode )
+ return; /* can't swap a single-buffered window */
+
+ /* If the current context's drawable matches the given drawable
+ * we have to do a glFinish (per the GLX spec).
+ */
+ if ( ctx ) {
+ __DRIdrawablePrivate *curDrawPriv;
+ fxMesa = TDFX_CONTEXT(ctx);
+ curDrawPriv = fxMesa->driContext->driDrawablePriv;
+
+ if ( curDrawPriv == driDrawPriv ) {
+ /* swapping window bound to current context, flush first */
+ _mesa_swapbuffers( ctx );
+ LOCK_HARDWARE( fxMesa );
+ }
+ else {
+ /* find the fxMesa context previously bound to the window */
+ fxMesa = (tdfxContextPtr) driDrawPriv->driContextPriv->driverPrivate;
+ if (!fxMesa)
+ return;
+ LOCK_HARDWARE( fxMesa );
+ fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
+ printf("SwapBuf SetState 1\n");
+ fxMesa->Glide.grGlideSetState(fxMesa->Glide.State );
+ }
+ }
+
+#ifdef STATS
+ {
+ int stalls;
+ static int prevStalls = 0;
+
+ stalls = fxMesa->Glide.grFifoGetStalls();
+
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ if ( stalls != prevStalls ) {
+ fprintf( stderr, " %d stalls occurred\n",
+ stalls - prevStalls );
+ prevStalls = stalls;
+ }
+ if ( fxMesa && fxMesa->texSwaps ) {
+ fprintf( stderr, " %d texture swaps occurred\n",
+ fxMesa->texSwaps );
+ fxMesa->texSwaps = 0;
+ }
+ }
+#endif
+
+ if (fxMesa->scissoredClipRects) {
+ /* restore clip rects without scissor box */
+ fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
+ driDrawPriv->w, driDrawPriv->h,
+ driDrawPriv->numClipRects,
+ driDrawPriv->pClipRects );
+ }
+
+ fxMesa->Glide.grDRIBufferSwap( fxMesa->Glide.SwapInterval );
+
+ if (fxMesa->scissoredClipRects) {
+ /* restore clip rects WITH scissor box */
+ fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
+ driDrawPriv->w, driDrawPriv->h,
+ fxMesa->numClipRects, fxMesa->pClipRects );
+ }
+
+
+#if 0
+ {
+ FxI32 result;
+ do {
+ FxI32 result;
+ fxMesa->Glide.grGet(GR_PENDING_BUFFERSWAPS, 4, &result);
+ } while ( result > fxMesa->maxPendingSwapBuffers );
+ }
+#endif
+
+ fxMesa->stats.swapBuffer++;
+
+ if (ctx) {
+ if (ctx->DriverCtx != fxMesa) {
+ fxMesa = TDFX_CONTEXT(ctx);
+ fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
+ printf("SwapBuf SetState 2\n");
+ fxMesa->Glide.grGlideSetState(fxMesa->Glide.State );
+ }
+ UNLOCK_HARDWARE( fxMesa );
+ }
+}
+
+
+
+/* This function is called by libGL.so as soon as libGL.so is loaded.
+ * This is where we'd register new extension functions with the dispatcher.
+ */
+void __driRegisterExtensions( void )
+{
+#if 0
+ /* Example. Also look in tdfx_dd.c for more details. */
+ {
+ const int _gloffset_FooBarEXT = 555; /* just an example number! */
+ if ( _glapi_add_entrypoint( "glFooBarEXT", _gloffset_FooBarEXT ) ) {
+ void *f = glXGetProcAddressARB( "glFooBarEXT" );
+ assert( f );
+ }
+ }
+#endif
+}
+
+static GLboolean
+tdfxOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+ fprintf(stderr,"***** XMesaOpenFullScreen *****\n");
+#if 0 /* When new glide3 calls exist */
+ return((GLboolean)grDRISetupFullScreen(GL_TRUE));
+#else
+ return GL_TRUE;
+#endif
+}
+
+
+static GLboolean
+tdfxCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+ fprintf(stderr,"***** XMesaCloseFullScreen *****\n");
+#if 0 /* When new glide3 calls exist */
+ return((GLboolean)grDRISetupFullScreen(GL_FALSE));
+#else
+ return GL_TRUE;
+#endif
+}
+
+
+
+static struct __DriverAPIRec tdfxAPI = {
+ tdfxInitDriver,
+ tdfxDestroyScreen,
+ tdfxCreateContext,
+ tdfxDestroyContext,
+ tdfxCreateBuffer,
+ tdfxDestroyBuffer,
+ tdfxSwapBuffers,
+ tdfxMakeCurrent,
+ tdfxUnbindContext,
+ tdfxOpenFullScreen,
+ tdfxCloseFullScreen
+};
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &tdfxAPI);
+ return (void *) psp;
+}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h
index 9c41933d8..2391417e9 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h
@@ -39,8 +39,6 @@
#ifdef GLX_DIRECT_RENDERING
-#include "dri_mesaint.h"
-
typedef struct {
drmHandle handle;
drmSize size;
@@ -71,8 +69,5 @@ typedef struct {
} tdfxScreenPrivate;
-extern GLboolean tdfxCreateScreen( __DRIscreenPrivate *driScrnPriv );
-extern void tdfxDestroyScreen( __DRIscreenPrivate *driScrnPriv );
-
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c
index 06bd0022f..6b9a49b57 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c,v 1.3 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
/*
* Original rewrite:
@@ -37,8 +37,10 @@
*/
#include "tdfx_context.h"
+#include "tdfx_lock.h"
#include "tdfx_span.h"
#include "tdfx_render.h"
+#include "swrast/swrast.h"
#define DBG 0
@@ -58,8 +60,6 @@
(void) buf; (void) p;
-#define INIT_MONO_PIXEL( p ) p = fxMesa->Color.MonoColor;
-
#define CLIPPIXEL( _x, _y ) ( _x >= minx && _x < maxx && \
_y >= miny && _y < maxy )
@@ -83,8 +83,9 @@
UNLOCK_HARDWARE( fxMesa ); \
LOCK_HARDWARE( fxMesa ); \
info.size = sizeof(GrLfbInfo_t); \
- if ( fxMesa->Glide.grLfbLock( GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer, \
- LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
+ if ( fxMesa->Glide.grLfbLock( GR_LFB_WRITE_ONLY, \
+ fxMesa->DrawBuffer, LFB_MODE, \
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
{
#define HW_WRITE_UNLOCK() \
@@ -100,7 +101,7 @@
LOCK_HARDWARE( fxMesa ); \
info.size = sizeof(GrLfbInfo_t); \
if ( fxMesa->Glide.grLfbLock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer, \
- LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
+ LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
{
#define HW_READ_UNLOCK() \
@@ -140,6 +141,11 @@
/* 16 bit, RGB565 color spanline and pixel functions */ \
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR565( color[0], color[1], color[2] )
+
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \
(((int)g & 0xfc) << 3) | \
@@ -195,6 +201,10 @@
/* 24 bit, RGB888 color spanline and pixel functions */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR888( color[0], color[1], color[2] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLuint *)(buf + _x*3 + _y*pitch) = ((b << 0) | \
(g << 8) | \
@@ -223,6 +233,10 @@ do { \
/* 32 bit, ARGB8888 color spanline and pixel functions */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR8888( color[0], color[1], color[2], color[3] )
+
#define WRITE_RGBA( _x, _y, r, g, b, a ) \
*(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
(g << 8) | \
@@ -557,10 +571,6 @@ GetFbParams(tdfxContextPtr fxMesa,
* it's better in the macro or in the call.
*
* Recall that x and y are screen coordinates.
- *
- * Note: ANSI C doesn't allow conditional expressions or cast expressions
- * as lvalues. Some of these macros violate that.
- *
*/
#define GET_FB_DATA(ReadParamsp, type, x, y) \
(((x) < (ReadParamsp)->firstWrappedX) \
@@ -592,8 +602,8 @@ tdfxDDWriteDepthSpan(GLcontext * ctx,
{
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->y_offset + fxMesa->height - 1;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
GrLfbInfo_t info;
GLubyte visMask[MAX_WIDTH];
@@ -828,7 +838,7 @@ tdfxDDReadDepthSpan(GLcontext * ctx,
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
GrLfbInfo_t info;
if (MESA_VERBOSE & VERBOSE_DRIVER) {
@@ -883,7 +893,7 @@ tdfxDDReadDepthSpan(GLcontext * ctx,
LFBParameters ReadParams;
GrLfbInfo_t backBufferInfo;
int wrappedPartStart;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
GetBackBufferInfo(fxMesa, &backBufferInfo);
/*
* Note that the _LOCK macro adds a curly brace,
@@ -934,8 +944,8 @@ tdfxDDWriteDepthPixels(GLcontext * ctx,
GLuint i;
GLushort d16;
GLuint d32;
- GLuint depth_size = fxMesa->glVis->DepthBits;
- GLuint stencil_size = fxMesa->glVis->StencilBits;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
GrLfbInfo_t info;
int xpos;
int ypos;
@@ -1013,7 +1023,7 @@ tdfxDDReadDepthPixels(GLcontext * ctx, GLuint n,
tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- GLuint depth_size = fxMesa->glVis->DepthBits;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
GLushort d16;
int xpos;
int ypos;
@@ -1058,7 +1068,7 @@ tdfxDDReadDepthPixels(GLcontext * ctx, GLuint n,
* and the UNLOCK macro removes it.
*/
READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
- stencil_size = fxMesa->glVis->StencilBits;
+ stencil_size = fxMesa->glCtx->Visual.stencilBits;
{
LFBParameters ReadParams;
GetFbParams(fxMesa, &info, &backBufferInfo,
@@ -1270,47 +1280,96 @@ read_stencil_pixels(GLcontext * ctx, GLuint n, const GLint x[],
}
#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
- ((vis->RedBits == r) && \
- (vis->GreenBits == g) && \
- (vis->BlueBits == b) && \
- (vis->AlphaBits == a))
+ ((vis.redBits == r) && \
+ (vis.greenBits == g) && \
+ (vis.blueBits == b) && \
+ (vis.alphaBits == a))
+
+
+
+
+/**********************************************************************/
+/* Locking for swrast */
+/**********************************************************************/
+
+
+static void tdfxSpanRenderStart( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE(fxMesa);
+}
+
+static void tdfxSpanRenderFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+/* Set the buffer used for reading */
+static void tdfxDDSetReadBuffer( GLcontext *ctx,
+ GLframebuffer *buffer, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ (void) buffer;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
+ break;
+
+ case GL_BACK_LEFT:
+ fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**********************************************************************/
+/* Initialize swrast device driver */
+/**********************************************************************/
void tdfxDDInitSpanFuncs( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
+
+ swdd->SetReadBuffer = tdfxDDSetReadBuffer;
if ( VISUAL_EQUALS_RGBA(ctx->Visual, 5, 6, 5, 0) )
{
/* 16bpp mode */
- ctx->Driver.WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
- ctx->Driver.WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
- ctx->Driver.WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
- ctx->Driver.WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
- ctx->Driver.WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
- ctx->Driver.ReadRGBASpan = tdfxReadRGBASpan_RGB565;
- ctx->Driver.ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = tdfxReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
}
else if ( VISUAL_EQUALS_RGBA(ctx->Visual, 8, 8, 8, 0) )
{
/* 24bpp mode */
- ctx->Driver.WriteRGBASpan = tdfxWriteRGBASpan_RGB888;
- ctx->Driver.WriteRGBSpan = tdfxWriteRGBSpan_RGB888;
- ctx->Driver.WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB888;
- ctx->Driver.WriteRGBAPixels = tdfxWriteRGBAPixels_RGB888;
- ctx->Driver.WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB888;
- ctx->Driver.ReadRGBASpan = tdfxReadRGBASpan_RGB888;
- ctx->Driver.ReadRGBAPixels = tdfxReadRGBAPixels_RGB888;
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB888;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB888;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB888;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB888;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB888;
+ swdd->ReadRGBASpan = tdfxReadRGBASpan_RGB888;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB888;
}
else if ( VISUAL_EQUALS_RGBA(ctx->Visual, 8, 8, 8, 8) )
{
/* 32bpp mode */
- ctx->Driver.WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
- ctx->Driver.WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
- ctx->Driver.WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
- ctx->Driver.ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
- ctx->Driver.ReadRGBASpan = tdfxReadRGBASpan_ARGB8888;
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
+ swdd->ReadRGBASpan = tdfxReadRGBASpan_ARGB8888;
}
else
{
@@ -1318,22 +1377,25 @@ void tdfxDDInitSpanFuncs( GLcontext *ctx )
}
if ( fxMesa->haveHwStencil ) {
- ctx->Driver.WriteStencilSpan = write_stencil_span;
- ctx->Driver.ReadStencilSpan = read_stencil_span;
- ctx->Driver.WriteStencilPixels = write_stencil_pixels;
- ctx->Driver.ReadStencilPixels = read_stencil_pixels;
+ swdd->WriteStencilSpan = write_stencil_span;
+ swdd->ReadStencilSpan = read_stencil_span;
+ swdd->WriteStencilPixels = write_stencil_pixels;
+ swdd->ReadStencilPixels = read_stencil_pixels;
}
- ctx->Driver.WriteDepthSpan = tdfxDDWriteDepthSpan;
- ctx->Driver.WriteDepthPixels = tdfxDDWriteDepthPixels;
- ctx->Driver.ReadDepthSpan = tdfxDDReadDepthSpan;
- ctx->Driver.ReadDepthPixels = tdfxDDReadDepthPixels;
-
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
+ swdd->WriteDepthSpan = tdfxDDWriteDepthSpan;
+ swdd->WriteDepthPixels = tdfxDDWriteDepthPixels;
+ swdd->ReadDepthSpan = tdfxDDReadDepthSpan;
+ swdd->ReadDepthPixels = tdfxDDReadDepthPixels;
+
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
+
+ swdd->SpanRenderStart = tdfxSpanRenderStart;
+ swdd->SpanRenderFinish = tdfxSpanRenderFinish;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c
index 7485f6ea1..cd321720b 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c
@@ -32,19 +32,26 @@
* Authors:
* Gareth Hughes <gareth@valinux.com>
* Brian Paul <brianp@valinux.com>
+ * Keith Whitwell <keithw@valinux.com> (port to 3.5)
*
*/
-#include "types.h"
-#include "pb.h"
+#include "mtypes.h"
+#include "texformat.h"
+#include "texstore.h"
-#include "dri_glide.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
#include "tdfx_context.h"
#include "tdfx_state.h"
#include "tdfx_vb.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
+#include "tdfx_texstate.h"
#include "tdfx_tris.h"
#include "tdfx_render.h"
@@ -60,7 +67,6 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
GrCmpFnc_t func;
GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA;
GrAlpha_t ref = ctx->Color.AlphaRef;
- const int hasAlpha = ctx->Visual->AlphaBits > 0;
if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
fprintf( stderr, "%s()\n", __FUNCTION__ );
@@ -120,13 +126,13 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
break;
case GL_DST_ALPHA:
- srcRGB = hasAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE;
+ srcRGB = GR_BLEND_DST_ALPHA;
break;
case GL_ONE_MINUS_DST_ALPHA:
- srcRGB = hasAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO;
+ srcRGB = GR_BLEND_ONE_MINUS_DST_ALPHA;
break;
case GL_SRC_ALPHA_SATURATE:
- srcRGB = hasAlpha ? GR_BLEND_ALPHA_SATURATE : GR_BLEND_ZERO;
+ srcRGB = GR_BLEND_ALPHA_SATURATE;
break;
default:
srcRGB = GR_BLEND_ONE;
@@ -139,23 +145,23 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
case GL_ONE:
srcA = GR_BLEND_ONE;
break;
- case GL_DST_COLOR: /* Napalm only */
- srcA = hasAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE;
+ case GL_DST_COLOR:
+ srcA = GR_BLEND_DST_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_DST_COLOR: /* Napalm only */
- srcA = hasAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO;
+ case GL_ONE_MINUS_DST_COLOR:
+ srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
break;
- case GL_SRC_ALPHA: /* Napalm only */
- srcA = GR_BLEND_SRC_ALPHA;
+ case GL_SRC_ALPHA:
+ srcA = GR_BLEND_SRC_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_SRC_ALPHA: /* Napalm only */
- srcA = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ srcA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
break;
- case GL_DST_ALPHA: /* Napalm only */
- srcA = hasAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE;
+ case GL_DST_ALPHA:
+ srcA = GR_BLEND_DST_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_DST_ALPHA: /* Napalm only */
- srcA = hasAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO;
+ case GL_ONE_MINUS_DST_ALPHA:
+ srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
break;
case GL_SRC_ALPHA_SATURATE:
srcA = GR_BLEND_ONE;
@@ -184,10 +190,10 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
break;
case GL_DST_ALPHA:
- dstRGB = hasAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE;
+ dstRGB = GR_BLEND_DST_ALPHA;
break;
case GL_ONE_MINUS_DST_ALPHA:
- dstRGB = hasAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO;
+ dstRGB = GR_BLEND_ONE_MINUS_DST_ALPHA;
break;
default:
dstRGB = GR_BLEND_ZERO;
@@ -200,23 +206,23 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
case GL_ONE:
dstA = GR_BLEND_ONE;
break;
- case GL_SRC_COLOR: /* Napalm only */
- dstA = GR_BLEND_SRC_ALPHA;
+ case GL_SRC_COLOR:
+ dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_SRC_COLOR: /* Napalm only */
- dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
break;
- case GL_SRC_ALPHA: /* Napalm only */
- dstA = GR_BLEND_SRC_ALPHA;
+ case GL_SRC_ALPHA:
+ dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_SRC_ALPHA: /* Napalm only */
- dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
break;
- case GL_DST_ALPHA: /* Napalm only */
- dstA = hasAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE;
+ case GL_DST_ALPHA:
+ dstA = GR_BLEND_DST_ALPHA; /* Napalm only */
break;
- case GL_ONE_MINUS_DST_ALPHA: /* Napalm only */
- dstA = hasAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dstA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
break;
default:
dstA = GR_BLEND_ZERO;
@@ -251,7 +257,7 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
}
}
-static void tdfxDDAlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
+static void tdfxDDAlphaFunc( GLcontext *ctx, GLenum func, GLchan ref )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
@@ -265,11 +271,6 @@ static void tdfxDDBlendEquation( GLcontext *ctx, GLenum mode )
FLUSH_BATCH( fxMesa );
fxMesa->new_state |= TDFX_NEW_ALPHA;
-
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- fxMesa->Fallback |= TDFX_FALLBACK_LOGICOP;
- else
- fxMesa->Fallback &= ~TDFX_FALLBACK_LOGICOP;
}
static void tdfxDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
@@ -300,7 +301,7 @@ static void tdfxDDBlendFuncSeparate( GLcontext *ctx,
* Stipple
*/
-static void tdfxUpdateStipple( GLcontext *ctx )
+void tdfxUpdateStipple( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
GrStippleMode_t mode = GR_STIPPLE_DISABLE;
@@ -333,9 +334,9 @@ static void tdfxUpdateZMode( GLcontext *ctx )
FxI32 bias;
FxBool mask;
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API )
fprintf( stderr, "%s()\n", __FUNCTION__ );
- }
+
bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE);
@@ -381,7 +382,7 @@ static void tdfxUpdateZMode( GLcontext *ctx )
mask = FXFALSE; /* zbuffer is not touched */
}
- fxMesa->Depth.Clear = (FxU32) (((1 << fxMesa->glVis->DepthBits) - 1)
+ fxMesa->Depth.Clear = (FxU32) (((1 << fxMesa->glCtx->Visual.depthBits) - 1)
* ctx->Depth.Clear);
if ( fxMesa->Depth.Bias != bias ) {
@@ -451,7 +452,7 @@ static GrStencil_t convertGLStencilOp( GLenum op )
case GL_DECR_WRAP_EXT:
return GR_STENCILOP_DECR_WRAP;
default:
- gl_problem( NULL, "bad stencil op in convertGLStencilOp" );
+ _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" );
}
return GR_STENCILOP_KEEP; /* never get, silence compiler warning */
}
@@ -547,14 +548,14 @@ static void tdfxUpdateFogAttrib( GLcontext *ctx )
{
switch( ctx->Fog.Mode ) {
case GL_EXP:
- fxMesa->Glide.guFogGenerateExp(fxMesa->Fog.Table, ctx->Fog.Density);
+ fxMesa->Glide.guFogGenerateExp( fxMesa->Fog.Table, ctx->Fog.Density );
break;
case GL_EXP2:
- fxMesa->Glide.guFogGenerateExp2(fxMesa->Fog.Table, ctx->Fog.Density);
+ fxMesa->Glide.guFogGenerateExp2( fxMesa->Fog.Table, ctx->Fog.Density);
break;
case GL_LINEAR:
- fxMesa->Glide.guFogGenerateLinear(fxMesa->Fog.Table,
- ctx->Fog.Start, ctx->Fog.End);
+ fxMesa->Glide.guFogGenerateLinear( fxMesa->Fog.Table,
+ ctx->Fog.Start, ctx->Fog.End );
break;
}
@@ -619,6 +620,7 @@ void tdfxUpdateClipping( GLcontext *ctx )
fxMesa->height = dPriv->h;
fxMesa->y_delta =
fxMesa->screen_height - fxMesa->y_offset - fxMesa->height;
+ tdfxUpdateViewport( ctx );
}
if (fxMesa->scissoredClipRects && fxMesa->pClipRects) {
@@ -678,18 +680,15 @@ void tdfxUpdateClipping( GLcontext *ctx )
* Culling
*/
-static void tdfxUpdateCull( GLcontext *ctx )
+void tdfxUpdateCull( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
GrCullMode_t mode = GR_CULL_DISABLE;
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s()\n", __FUNCTION__ );
- }
-
- if ( ctx->Polygon.CullFlag &&
- (ctx->PB->primitive == GL_POLYGON ||
- ctx->PB->primitive == GL_BITMAP) ) {
+ /* KW: don't need to check raster_primitive here as we don't
+ * attempt to draw lines or points with triangles.
+ */
+ if ( ctx->Polygon.CullFlag ) {
switch ( ctx->Polygon.CullFaceMode ) {
case GL_FRONT:
if ( ctx->Polygon.FrontFace == GL_CCW ) {
@@ -708,8 +707,11 @@ static void tdfxUpdateCull( GLcontext *ctx )
break;
case GL_FRONT_AND_BACK:
+ /* Handled as a fallback on triangles in tdfx_tris.c */
+ return;
+
default:
- mode = GR_CULL_DISABLE;
+ ASSERT(0);
break;
}
}
@@ -762,32 +764,13 @@ static void tdfxDDLineWidth( GLcontext *ctx, GLfloat width )
}
-
/* =============================================================
* Color Attributes
*/
-static void tdfxDDLogicOp( GLcontext *ctx, GLenum opcode )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-
- if (ctx->Color.ColorLogicOpEnabled)
- {
- FLUSH_BATCH( fxMesa );
-
- if (opcode == GL_COPY)
- fxMesa->Fallback &= ~TDFX_FALLBACK_LOGICOP;
- else
- fxMesa->Fallback |= TDFX_FALLBACK_LOGICOP;
- }
- else
- fxMesa->Fallback &= ~TDFX_FALLBACK_LOGICOP;
-}
-
-
-static GLboolean tdfxDDColorMask( GLcontext *ctx,
- GLboolean r, GLboolean g,
- GLboolean b, GLboolean a )
+static void tdfxDDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
@@ -803,48 +786,22 @@ static GLboolean tdfxDDColorMask( GLcontext *ctx,
fxMesa->Color.ColorMask[ACOMP] = a;
fxMesa->dirty |= TDFX_UPLOAD_COLOR_MASK;
- if (ctx->Visual->RedBits < 8) {
+ if (ctx->Visual.redBits < 8) {
/* Can't do RGB colormasking in 16bpp mode. */
/* We can completely ignore the alpha mask. */
- if (r != g || g != b) {
- fxMesa->Fallback |= TDFX_FALLBACK_COLORMASK;
- }
- else {
- fxMesa->Fallback &= ~TDFX_FALLBACK_COLORMASK;
- }
+ FALLBACK( fxMesa, TDFX_FALLBACK_COLORMASK, (r != g || g != b) );
}
}
-
- return GL_FALSE; /* This forces the software paths to do colormasking. */
- /* This function will return void when we use Mesa 3.5 */
}
-static void tdfxDDColor( GLcontext *ctx,
- GLubyte r, GLubyte g, GLubyte b, GLubyte a )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- GrColor_t color;
-
- FLUSH_BATCH( fxMesa );
-
- color = tdfxPackColor( fxMesa->fxScreen->cpp, r, g, b, a );
-
- if ( fxMesa->Color.MonoColor != color ) {
- fxMesa->Color.MonoColor = color;
- fxMesa->dirty |= TDFX_UPLOAD_CONSTANT_COLOR;
- }
-}
static void tdfxDDClearColor( GLcontext *ctx,
- GLubyte red, GLubyte green,
- GLubyte blue, GLubyte alpha )
+ const GLchan color[4] )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-
FLUSH_BATCH( fxMesa );
-
- fxMesa->Color.ClearColor = TDFXPACKCOLOR888( red, green, blue );
- fxMesa->Color.ClearAlpha = alpha;
+ fxMesa->Color.ClearColor = TDFXPACKCOLOR888( color[0], color[1], color[2] );
+ fxMesa->Color.ClearAlpha = color[3];
}
@@ -858,14 +815,9 @@ static void tdfxDDLightModelfv( GLcontext *ctx, GLenum pname,
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
- FLUSH_BATCH( fxMesa );
-
- fxMesa->Fallback &= ~TDFX_FALLBACK_SPECULAR;
-
- if ( ctx->Light.Enabled &&
- ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ) {
- fxMesa->Fallback |= TDFX_FALLBACK_SPECULAR;
- }
+ FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ));
}
}
@@ -906,12 +858,20 @@ static void tdfxUpdateRenderAttrib( GLcontext *ctx )
* Viewport
*/
-static void tdfxUpdateViewport( GLcontext *ctx )
+void tdfxUpdateViewport( GLcontext *ctx )
{
- /* XXX: Implement this when we're doing clip coordinates */
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s()\n", __FUNCTION__ );
- }
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = fxMesa->hw_viewport;
+
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + fxMesa->x_offset + TRI_X_OFFSET;
+ m[MAT_SY] = v[MAT_SY];
+ m[MAT_TY] = v[MAT_TY] + fxMesa->y_delta + TRI_Y_OFFSET;
+ m[MAT_SZ] = v[MAT_SZ];
+ m[MAT_TZ] = v[MAT_TZ];
+
+ fxMesa->SetupNewInputs |= VERT_CLIP;
}
@@ -924,7 +884,7 @@ static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y,
}
-static void tdfxDDNearFar( GLcontext *ctx, GLfloat nearVal, GLfloat farVal )
+static void tdfxDDDepthRange( GLcontext *ctx, GLclampd nearVal, GLclampd farVal )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
FLUSH_BATCH( fxMesa );
@@ -949,11 +909,9 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_BLEND:
FLUSH_BATCH( fxMesa );
fxMesa->new_state |= TDFX_NEW_ALPHA;
-
- if (ctx->Color.ColorLogicOpEnabled && ctx->Color.LogicOp != GL_COPY)
- fxMesa->Fallback |= TDFX_FALLBACK_LOGICOP;
- else
- fxMesa->Fallback &= ~TDFX_FALLBACK_LOGICOP;
+ FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
break;
case GL_CULL_FACE:
@@ -982,12 +940,15 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_COLOR_LOGIC_OP:
- FLUSH_BATCH( fxMesa );
- if ( state && ctx->Color.LogicOp != GL_COPY ) {
- fxMesa->Fallback |= TDFX_FALLBACK_LOGICOP;
- } else {
- fxMesa->Fallback &= ~TDFX_FALLBACK_LOGICOP;
- }
+ FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+
+ case GL_LIGHTING:
+ FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ));
break;
case GL_LINE_SMOOTH:
@@ -995,6 +956,10 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
fxMesa->new_state |= TDFX_NEW_LINE;
break;
+ case GL_LINE_STIPPLE:
+ FALLBACK(fxMesa, TDFX_FALLBACK_LINE_STIPPLE, state);
+ break;
+
case GL_POLYGON_STIPPLE:
FLUSH_BATCH(fxMesa);
fxMesa->new_state |= TDFX_NEW_STIPPLE;
@@ -1007,20 +972,13 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
case GL_STENCIL_TEST:
FLUSH_BATCH( fxMesa );
- if (fxMesa->haveHwStencil)
- fxMesa->new_state |= TDFX_NEW_STENCIL;
- else if (state)
- fxMesa->Fallback |= TDFX_FALLBACK_STENCIL;
- else
- fxMesa->Fallback &= ~TDFX_FALLBACK_STENCIL;
+ FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil);
break;
case GL_TEXTURE_1D:
case GL_TEXTURE_3D:
- if (state)
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE;
- else
- fxMesa->Fallback &= ~TDFX_FALLBACK_TEXTURE;
+ FLUSH_BATCH( fxMesa );
+ FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_1D_3D, state); /* wrong */
fxMesa->new_state |= TDFX_NEW_TEXTURE;
break;
@@ -1048,56 +1006,31 @@ static GLboolean tdfxDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
FLUSH_BATCH( fxMesa );
- fxMesa->Fallback &= ~TDFX_FALLBACK_BUFFER;
-
- switch ( mode ) {
+ switch( mode) {
case GL_FRONT_LEFT:
fxMesa->DrawBuffer = GR_BUFFER_FRONTBUFFER;
fxMesa->new_state |= TDFX_NEW_RENDER;
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
case GL_BACK_LEFT:
fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER;
fxMesa->new_state |= TDFX_NEW_RENDER;
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
case GL_NONE:
FX_grColorMaskv( ctx, false4 );
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
return GL_TRUE;
default:
- fxMesa->Fallback |= TDFX_FALLBACK_BUFFER;
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
return GL_FALSE;
}
}
-/* Set the buffer used for reading */
-/* XXX support for separate read/draw buffers hasn't been tested */
-static void tdfxDDSetReadBuffer( GLcontext *ctx,
- GLframebuffer *buffer, GLenum mode )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- (void) buffer;
-
- FLUSH_BATCH( fxMesa );
-
- fxMesa->Fallback &= ~TDFX_FALLBACK_BUFFER;
-
- switch ( mode ) {
- case GL_FRONT_LEFT:
- fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
- break;
-
- case GL_BACK_LEFT:
- fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
- break;
-
- default:
- fxMesa->Fallback |= TDFX_FALLBACK_BUFFER;
- break;
- }
-}
/* =============================================================
* Polygon stipple
@@ -1109,12 +1042,30 @@ static void tdfxDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
const GLubyte *m = mask;
GLubyte q[4];
int i,j,k;
- int active = (ctx->Polygon.StippleFlag && ctx->PB->primitive == GL_POLYGON);
+ GLboolean allBitsSet;
+
+/* int active = (ctx->Polygon.StippleFlag && */
+/* fxMesa->reduced_prim == GL_TRIANGLES); */
FLUSH_BATCH(fxMesa);
+ fxMesa->Stipple.Pattern = 0xffffffff;
+ fxMesa->dirty |= TDFX_UPLOAD_STIPPLE;
+ fxMesa->new_state |= TDFX_NEW_STIPPLE;
- if (active) {
- ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
+ /* Check if the stipple pattern is fully opaque. If so, use software
+ * rendering. This basically a trick to make sure the OpenGL conformance
+ * test passes.
+ */
+ allBitsSet = GL_TRUE;
+ for (i = 0; i < 32; i++) {
+ if (((GLuint *) mask)[i] != 0xffffffff) {
+ allBitsSet = GL_FALSE;
+ break;
+ }
+ }
+ if (allBitsSet) {
+ fxMesa->haveHwStipple = GL_FALSE;
+ return;
}
q[0] = mask[0];
@@ -1126,43 +1077,24 @@ static void tdfxDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
for (j = 0 ; j < 4; j++)
for (i = 0 ; i < 4 ; i++,m++) {
if (*m != q[j]) {
- ctx->Driver.TriangleCaps &= ~DD_TRI_STIPPLE;
- fxMesa->Stipple.Pattern = 0xffffffff; /* ensure all pixels on */
+ fxMesa->haveHwStipple = GL_FALSE;
return;
}
}
- /* We can do it, so flag an upload of the stipple pattern */
+ fxMesa->haveHwStipple = GL_TRUE;
fxMesa->Stipple.Pattern = ( (q[0] << 0) |
(q[1] << 8) |
(q[2] << 16) |
(q[3] << 24) );
- fxMesa->dirty |= TDFX_UPLOAD_STIPPLE;
}
-/* Always called between RenderStart and RenderFinish --> We already
- * hold the lock.
- */
-static void tdfxDDReducedPrimitiveChange( GLcontext *ctx, GLenum prim )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
-
- FLUSH_BATCH( fxMesa );
- tdfxUpdateCull(ctx);
- if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) {
- fxMesa->Glide.grCullMode( fxMesa->CullMode );
- fxMesa->dirty &= ~TDFX_UPLOAD_CULL;
- }
-#if defined(__linux__) || defined(__FreeBSD__)
- tdfxUpdateStipple(ctx);
- if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE ) {
- fxMesa->Glide.grStipplePattern ( fxMesa->Stipple.Pattern );
- fxMesa->Glide.grStippleMode ( fxMesa->Stipple.Mode );
- fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE;
- }
-#endif /* __linux__ || __FreeBSD__ */
+static void tdfxDDRenderMode( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ FALLBACK( fxMesa, TDFX_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
}
@@ -1266,65 +1198,13 @@ void tdfxDDUpdateHwState( GLcontext *ctx )
}
-static void tdfxDDRenderStart( GLcontext *ctx )
-{
- tdfxDDUpdateHwState( ctx );
- LOCK_HARDWARE( TDFX_CONTEXT(ctx) );
-}
-
-static void tdfxDDRenderFinish( GLcontext *ctx )
-{
- UNLOCK_HARDWARE( TDFX_CONTEXT(ctx) );
-}
-
-#define INTERESTED (~(NEW_MODELVIEW | \
- NEW_PROJECTION | \
- NEW_TEXTURE_MATRIX | \
- NEW_USER_CLIP | \
- NEW_CLIENT_STATE | \
- NEW_TEXTURE_ENABLE))
-
-static void tdfxDDUpdateState( GLcontext *ctx )
+static void tdfxDDInvalidateState( GLcontext *ctx, GLuint new_state )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, "%s()\n", __FUNCTION__ );
- }
-
- /* Have to do this here to detect texture, line fallbacks in time:
- */
- if ( fxMesa->new_state & (TDFX_NEW_TEXTURE | TDFX_NEW_LINE) )
- tdfxDDUpdateHwState( ctx );
-
- if ( ctx->NewState & INTERESTED ) {
- tdfxDDChooseRenderState( ctx );
- }
-
- /* The choise of vertex setup function only depends on whether fog
- * and/or texturing is enabled.
- */
- if ( ctx->NewState & (NEW_FOG | NEW_TEXTURE_ENABLE | NEW_TEXTURING)) {
- tdfxDDChooseRasterSetupFunc( ctx );
- }
-
- if ( 0 )
- fprintf( stderr, "fallback %x indirect %x\n",
- fxMesa->Fallback, fxMesa->IndirectTriangles );
-
- if ( fxMesa->Fallback ) {
- ctx->IndirectTriangles |= ctx->TriangleCaps;
- }
- else {
- ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
- ctx->IndirectTriangles |= fxMesa->IndirectTriangles;
-
- ctx->Driver.PointsFunc = fxMesa->PointsFunc;
- ctx->Driver.LineFunc = fxMesa->LineFunc;
- ctx->Driver.TriangleFunc = fxMesa->TriangleFunc;
- ctx->Driver.QuadFunc = fxMesa->QuadFunc;
- ctx->Driver.RenderVBRawTab = fxMesa->RenderVBRawTab;
- }
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ TDFX_CONTEXT(ctx)->new_gl_state |= new_state;
}
@@ -1405,7 +1285,7 @@ void tdfxInitState( tdfxContextPtr fxMesa )
fxMesa->TexState.Enabled = 0;
}
- if ( ctx->Visual->DBflag) {
+ if ( ctx->Visual.doubleBufferMode) {
fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER;
fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
} else {
@@ -1430,7 +1310,7 @@ void tdfxInitState( tdfxContextPtr fxMesa )
fxMesa->Color.Dither = GR_DITHER_2x2;
- if ( fxMesa->glVis->DepthBits > 0 ) {
+ if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
fxMesa->Depth.Mode = GR_DEPTHBUFFER_ZBUFFER;
} else {
fxMesa->Depth.Mode = GR_DEPTHBUFFER_DISABLE;
@@ -1486,31 +1366,18 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- ctx->Driver.UpdateState = tdfxDDUpdateState;
+ ctx->Driver.UpdateState = tdfxDDInvalidateState;
+
+ /* State notification callbacks:
+ */
ctx->Driver.ClearIndex = NULL;
ctx->Driver.ClearColor = tdfxDDClearColor;
- ctx->Driver.Index = NULL;
- ctx->Driver.Color = tdfxDDColor;
ctx->Driver.SetDrawBuffer = tdfxDDSetDrawBuffer;
- ctx->Driver.SetReadBuffer = tdfxDDSetReadBuffer;
ctx->Driver.IndexMask = NULL;
ctx->Driver.ColorMask = tdfxDDColorMask;
- ctx->Driver.NearFar = tdfxDDNearFar;
-
- ctx->Driver.RenderStart = tdfxDDRenderStart;
- ctx->Driver.RenderFinish = tdfxDDRenderFinish;
- ctx->Driver.RasterSetup = NULL;
-
- ctx->Driver.RenderVBClippedTab = NULL;
- ctx->Driver.RenderVBCulledTab = NULL;
- ctx->Driver.RenderVBRawTab = NULL;
-
- ctx->Driver.ReducedPrimitiveChange = tdfxDDReducedPrimitiveChange;
- ctx->Driver.MultipassFunc = NULL;
-
ctx->Driver.AlphaFunc = tdfxDDAlphaFunc;
ctx->Driver.BlendEquation = tdfxDDBlendEquation;
ctx->Driver.BlendFunc = tdfxDDBlendFunc;
@@ -1521,7 +1388,7 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.FrontFace = tdfxDDFrontFace;
ctx->Driver.DepthFunc = tdfxDDDepthFunc;
ctx->Driver.DepthMask = tdfxDDDepthMask;
- ctx->Driver.DepthRange = NULL;
+ ctx->Driver.DepthRange = tdfxDDDepthRange;
ctx->Driver.Enable = tdfxDDEnable;
ctx->Driver.Fogfv = tdfxDDFogfv;
ctx->Driver.Hint = NULL;
@@ -1529,14 +1396,37 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
ctx->Driver.LightModelfv = tdfxDDLightModelfv;
ctx->Driver.LineStipple = NULL;
ctx->Driver.LineWidth = tdfxDDLineWidth;
- ctx->Driver.LogicOpcode = tdfxDDLogicOp;
-#if 0
- ctx->Driver.PolygonMode = NULL;
-#endif
ctx->Driver.PolygonStipple = tdfxDDPolygonStipple;
+ ctx->Driver.RenderMode = tdfxDDRenderMode;
ctx->Driver.Scissor = tdfxDDScissor;
ctx->Driver.ShadeModel = tdfxDDShadeModel;
+ ctx->Driver.BindTexture = tdfxDDBindTexture;
+ ctx->Driver.DeleteTexture = tdfxDDDeleteTexture;
+ ctx->Driver.TexEnv = tdfxDDTexEnv;
+ ctx->Driver.TexParameter = tdfxDDTexParameter;
+ ctx->Driver.ChooseTextureFormat = tdfxDDChooseTextureFormat;
+ ctx->Driver.TexImage2D = tdfxDDTexImage2D;
+ ctx->Driver.TexSubImage2D = tdfxDDTexSubImage2D;
+ /*
+ ctx->Driver.TexImage2D = _mesa_store_teximage2d;
+ ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
+ */
+
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
+/* ctx->Driver.GetTexImage = tdfxDDGetTexImage; */
+ ctx->Driver.UpdateTexturePalette = tdfxDDTexturePalette;
+
if ( fxMesa->haveHwStencil ) {
ctx->Driver.StencilFunc = tdfxDDStencilFunc;
ctx->Driver.StencilMask = tdfxDDStencilMask;
@@ -1548,4 +1438,12 @@ void tdfxDDInitStateFuncs( GLcontext *ctx )
}
ctx->Driver.Viewport = tdfxDDViewport;
+
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h
index d2ad058d2..e4fdcb44f 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h
@@ -51,5 +51,14 @@ extern void tdfxInitState( tdfxContextPtr fxMesa );
extern void tdfxUpdateClipping( GLcontext *ctx );
+
+extern void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) tdfxFallback( rmesa->glCtx, bit, mode )
+
+extern void tdfxUpdateCull( GLcontext *ctx );
+extern void tdfxUpdateStipple( GLcontext *ctx );
+extern void tdfxUpdateViewport( GLcontext *ctx );
+
+
#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c
index 3b9a40d3f..e204498ea 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c,v 1.3 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -35,37 +35,42 @@
*
*/
+#include "image.h"
+#include "texutil.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstore.h"
#include "tdfx_context.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
-#include "enums.h"
-#include "image.h"
-#include "texutil.h"
-
-#define TX_DITHER_NONE 0x00000000
-static int logbase2( int n )
+static int
+logbase2(int n)
{
- GLint i = 1;
- GLint log2 = 0;
-
- if ( n < 0 )
- return -1;
-
- while ( n > i ) {
- i *= 2;
- log2++;
- }
- if ( i != n ) {
- return -1;
- } else {
- return log2;
- }
+ GLint i = 1;
+ GLint log2 = 0;
+
+ if (n < 0) {
+ return -1;
+ }
+
+ while (n > i) {
+ i *= 2;
+ log2++;
+ }
+ if (i != n) {
+ return -1;
+ }
+ else {
+ return log2;
+ }
}
-/* Compute various texture image parameters.
+
+/*
+ * Compute various texture image parameters.
* Input: w, h - source texture width and height
* Output: lodlevel - Glide lod level token for the larger texture dimension
* aspectratio - Glide aspect ratio token
@@ -82,282 +87,524 @@ static int logbase2( int n )
* 32 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x2 (=-1)
* 32 32 GR_LOD_LOG2_32 (=5) GR_ASPECT_LOG2_1x1 (=0)
*/
-static void tdfxTexGetInfo( const GLcontext *ctx, int w, int h,
- GrLOD_t *lodlevel, GrAspectRatio_t *aspectratio,
- float *sscale, float *tscale,
- int *wscale, int *hscale )
+static void
+tdfxTexGetInfo(const GLcontext *ctx, int w, int h,
+ GrLOD_t *lodlevel, GrAspectRatio_t *aspectratio,
+ float *sscale, float *tscale,
+ int *wscale, int *hscale)
{
- int logw, logh, ar, lod, ws, hs;
- float s, t;
+ int logw, logh, ar, lod, ws, hs;
+ float s, t;
+
+ ASSERT(w >= 1);
+ ASSERT(h >= 1);
+
+ logw = logbase2(w);
+ logh = logbase2(h);
+ ar = logw - logh; /* aspect ratio = difference in log dimensions */
+
+ /* Hardware only allows a maximum aspect ratio of 8x1, so handle
+ |ar| > 3 by scaling the image and using an 8x1 aspect ratio */
+ if (ar >= 0) {
+ ASSERT(width >= height);
+ lod = logw;
+ s = 256.0;
+ ws = 1;
+ if (ar <= GR_ASPECT_LOG2_8x1) {
+ t = 256 >> ar;
+ hs = 1;
+ }
+ else {
+ /* have to stretch image height */
+ t = 32.0;
+ hs = 1 << (ar - 3);
+ }
+ }
+ else {
+ ASSERT(width < height);
+ lod = logh;
+ t = 256.0;
+ hs = 1;
+ if (ar >= GR_ASPECT_LOG2_1x8) {
+ s = 256 >> -ar;
+ ws = 1;
+ }
+ else {
+ /* have to stretch image width */
+ s = 32.0;
+ ws = 1 << (-ar - 3);
+ }
+ }
+
+ if (ar < GR_ASPECT_LOG2_1x8)
+ ar = GR_ASPECT_LOG2_1x8;
+ else if (ar > GR_ASPECT_LOG2_8x1)
+ ar = GR_ASPECT_LOG2_8x1;
+
+ if (lodlevel)
+ *lodlevel = (GrLOD_t) lod;
+ if (aspectratio)
+ *aspectratio = (GrAspectRatio_t) ar;
+ if (sscale)
+ *sscale = s;
+ if (tscale)
+ *tscale = t;
+ if (wscale)
+ *wscale = ws;
+ if (hscale)
+ *hscale = hs;
+}
- ASSERT( w >= 1 );
- ASSERT( h >= 1 );
- logw = logbase2( w );
- logh = logbase2( h );
- ar = logw - logh; /* aspect ratio = difference in log dimensions */
+/*
+ * We need to call this when a texture object's minification filter
+ * or texture image sizes change.
+ */
+static void RevalidateTexture(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ GLint minl, maxl;
+
+ if (!ti)
+ return;
+
+ minl = maxl = tObj->BaseLevel;
+
+ if (tObj->Image[minl]) {
+ maxl = MIN2(tObj->MaxLevel, tObj->Image[minl]->MaxLog2);
+
+ /* compute largeLodLog2, aspect ratio and texcoord scale factors */
+ tdfxTexGetInfo(ctx, tObj->Image[minl]->Width, tObj->Image[minl]->Height,
+ &ti->info.largeLodLog2,
+ &ti->info.aspectRatioLog2,
+ &(ti->sScale), &(ti->tScale), NULL, NULL);
+ }
+
+ if (tObj->Image[maxl] && (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) {
+ /* mipmapping: need to compute smallLodLog2 */
+ tdfxTexGetInfo(ctx, tObj->Image[maxl]->Width,
+ tObj->Image[maxl]->Height,
+ &ti->info.smallLodLog2, NULL,
+ NULL, NULL, NULL, NULL);
+ }
+ else {
+ /* not mipmapping: smallLodLog2 = largeLodLog2 */
+ ti->info.smallLodLog2 = ti->info.largeLodLog2;
+ maxl = minl;
+ }
+
+ ti->minLevel = minl;
+ ti->maxLevel = maxl;
+ ti->info.data = NULL;
+}
- /* Hardware only allows a maximum aspect ratio of 8x1, so handle
- * |ar| > 3 by scaling the image and using an 8x1 aspect ratio.
- */
- if ( ar >= 0 ) {
- ASSERT( w >= h );
- lod = logw;
- s = 256.0;
- ws = 1;
- if ( ar <= GR_ASPECT_LOG2_8x1 ) {
- t = 256 >> ar;
- hs = 1;
- } else {
- /* have to stretch image height */
- t = 32.0;
- hs = 1 << (ar - 3);
- }
- } else {
- ASSERT( w < h );
- lod = logh;
- t = 256.0;
- hs = 1;
- if ( ar >= GR_ASPECT_LOG2_1x8 ) {
- s = 256 >> -ar;
- ws = 1;
- } else {
- /* have to stretch image width */
- s = 32.0;
- ws = 1 << (-ar - 3);
- }
- }
- if ( ar < GR_ASPECT_LOG2_1x8 ) {
- ar = GR_ASPECT_LOG2_1x8;
- } else if ( ar > GR_ASPECT_LOG2_8x1 ) {
- ar = GR_ASPECT_LOG2_8x1;
- }
+static tdfxTexInfo *
+fxAllocTexObjData(tdfxContextPtr fxMesa)
+{
+ tdfxTexInfo *ti;
+
+ if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
+ _mesa_problem(NULL, "tdfx driver: out of memory");
+ return NULL;
+ }
+
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ ti->tm[TDFX_TMU0] = NULL;
+ ti->tm[TDFX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
- if ( lodlevel )
- *lodlevel = (GrLOD_t)lod;
- if ( aspectratio )
- *aspectratio = (GrAspectRatio_t)ar;
- if ( sscale )
- *sscale = s;
- if ( tscale )
- *tscale = t;
- if ( wscale )
- *wscale = ws;
- if ( hscale )
- *hscale = hs;
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ return ti;
}
-/* We need to call this when a texture object's minification filter
- * or texture image sizes change.
+/*
+ * Called via glBindTexture.
*/
-static void tdfxRevalidateTexture( GLcontext *ctx,
- struct gl_texture_object *tObj )
-{
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- GLint minl, maxl;
- if ( !t )
- return;
+void
+tdfxDDBindTexture(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
- minl = maxl = tObj->BaseLevel;
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexBind(%d,%p)\n", tObj->Name,
+ tObj->DriverData);
+ }
- if ( tObj->Image[minl] ) {
- maxl = MIN2( tObj->MaxLevel, tObj->Image[minl]->MaxLog2 );
+ if (target != GL_TEXTURE_2D)
+ return;
- /* Compute largeLodLog2, aspect ratio and texcoord scale factors.
- */
- tdfxTexGetInfo( ctx,
- tObj->Image[minl]->Width, tObj->Image[minl]->Height,
- &t->info.largeLodLog2, &t->info.aspectRatioLog2,
- &t->sScale, &t->tScale, NULL, NULL );
- }
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
- if ( tObj->Image[maxl] &&
- tObj->MinFilter != GL_NEAREST &&
- tObj->MinFilter != GL_LINEAR ) {
- /* Mipmapping: need to compute smallLodLog2 */
- tdfxTexGetInfo( ctx,
- tObj->Image[maxl]->Width, tObj->Image[maxl]->Height,
- &t->info.smallLodLog2,
- NULL, NULL, NULL, NULL, NULL );
- } else {
- /* Not mipmapping: smallLodLog2 = largeLodLog2 */
- t->info.smallLodLog2 = t->info.largeLodLog2;
- }
+ ti = TDFX_TEXTURE_DATA(tObj);
+ ti->lastTimeUsed = fxMesa->texBindNumber++;
- t->minLevel = minl;
- t->maxLevel = maxl;
- t->info.data = NULL;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
}
-static tdfxTexObjPtr tdfxAllocTexObj( tdfxContextPtr fxMesa )
+/*
+ * Called via glTexEnv.
+ */
+void
+tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+ const GLfloat * param)
{
- tdfxTexObjPtr t;
- int i;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ if (param)
+ fprintf(stderr, "fxmesa: texenv(%x,%x)\n", pname,
+ (GLint) (*param));
+ else
+ fprintf(stderr, "fxmesa: texenv(%x)\n", pname);
+ }
+
+ /* XXX this is a bit of a hack to force the Glide texture
+ * state to be updated.
+ */
+ fxMesa->TexState.EnvMode[ctx->Texture.CurrentUnit] = 0;
+
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
- t = CALLOC( sizeof(tdfxTexObj) );
- if ( !t ) {
- gl_problem( NULL, "tdfx driver: out of memory" );
- return NULL;
- }
- t->isInTM = GL_FALSE;
+/*
+ * Called via glTexParameter.
+ */
+void
+tdfxDDTexParameter(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLenum param = (GLenum) (GLint) params[0];
+ tdfxTexInfo *ti;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexParam(%d,%p,%x,%x)\n", tObj->Name,
+ tObj->DriverData, pname, param);
+ }
+
+ if (target != GL_TEXTURE_2D)
+ return;
+
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+
+ ti = TDFX_TEXTURE_DATA(tObj);
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ }
+ /* XXX Voodoo3/Banshee mipmap blending seems to produce
+ * incorrectly filtered colors for the smallest mipmap levels.
+ * To work-around we fall-through here and use a different filter.
+ */
+ case GL_NEAREST_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ }
+ /* XXX Voodoo3/Banshee mipmap blending seems to produce
+ * incorrectly filtered colors for the smallest mipmap levels.
+ * To work-around we fall-through here and use a different filter.
+ */
+ case GL_LINEAR_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ default:
+ break;
+ }
+ RevalidateTexture(ctx, tObj);
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_MAG_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->magFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ case GL_LINEAR:
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ switch (param) {
+ case GL_CLAMP:
+ ti->sClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_WRAP_T:
+ switch (param) {
+ case GL_CLAMP:
+ ti->tClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_MIN_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ RevalidateTexture(ctx, tObj);
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ RevalidateTexture(ctx, tObj);
+ break;
+
+ default:
+ break;
+ }
+}
- t->whichTMU = TDFX_TMU_NONE;
- t->range[TDFX_TMU0] = NULL;
- t->range[TDFX_TMU1] = NULL;
+/*
+ * Called via glDeleteTextures to delete a texture object.
+ * Here, we delete the Glide data associated with the texture.
+ */
+void
+tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ if (ctx && ctx->DriverCtx) {
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTMFreeTexture(fxMesa, tObj);
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ }
+}
- t->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- t->magFilt = GR_TEXTUREFILTER_BILINEAR;
- t->sClamp = GR_TEXTURECLAMP_WRAP;
- t->tClamp = GR_TEXTURECLAMP_WRAP;
+/*
+ * Return true if texture is resident, false otherwise.
+ */
+GLboolean
+tdfxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ return (GLboolean) (ti && ti->isInTM);
+}
- t->mmMode = GR_MIPMAP_NEAREST;
- t->LODblend = FXFALSE;
- for ( i = 0 ; i < MAX_TEXTURE_LEVELS ; i++ ) {
- t->image[i].original.data = NULL;
- t->image[i].rescaled.data = NULL;
- }
- return t;
+/*
+ * Convert a gl_color_table texture palette to Glide's format.
+ */
+static void
+convertPalette(FxU32 data[256], const struct gl_color_table *table)
+{
+ const GLubyte *tableUB = (const GLubyte *) table->Table;
+ GLint width = table->Size;
+ FxU32 r, g, b, a;
+ GLint i;
+
+ ASSERT(table->TableType == GL_UNSIGNED_BYTE);
+
+ switch (table->Format) {
+ case GL_INTENSITY:
+ for (i = 0; i < width; i++) {
+ r = tableUB[i];
+ g = tableUB[i];
+ b = tableUB[i];
+ a = tableUB[i];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i = 0; i < width; i++) {
+ r = tableUB[i];
+ g = tableUB[i];
+ b = tableUB[i];
+ a = 255;
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ case GL_ALPHA:
+ for (i = 0; i < width; i++) {
+ r = g = b = 255;
+ a = tableUB[i];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < width; i++) {
+ r = g = b = tableUB[i * 2 + 0];
+ a = tableUB[i * 2 + 1];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ case GL_RGB:
+ for (i = 0; i < width; i++) {
+ r = tableUB[i * 3 + 0];
+ g = tableUB[i * 3 + 1];
+ b = tableUB[i * 3 + 2];
+ a = 255;
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ case GL_RGBA:
+ for (i = 0; i < width; i++) {
+ r = tableUB[i * 4 + 0];
+ g = tableUB[i * 4 + 1];
+ b = tableUB[i * 4 + 2];
+ a = tableUB[i * 4 + 3];
+ data[i] = (a << 24) | (r << 16) | (g << 8) | b;
+ }
+ break;
+ }
}
-/* Given an OpenGL internal texture format, return the corresponding
- * Glide internal texture format and MesaIntTexFormat.
- * If allow32bpp is true, we'll return 32-bit texel formats when
- * appropriate.
- */
-static GrTextureFormat_t
-tdfxTexGetFormat( tdfxContextPtr fxMesa, struct gl_texture_image *texImage,
- GLenum format, GLenum type )
+
+void
+tdfxDDTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
{
- const GLboolean allow32bpp = TDFX_IS_NAPALM(fxMesa);
- const GLboolean is32bpp = ( fxMesa->fxScreen->cpp == 4 );
- const struct gl_texture_format *texFormat;
- GrTextureFormat_t ret;
-
- if ( 0 )
- fprintf( stderr, "internal=%s format=%s type=%s\n",
- texImage->IntFormat == 3 ? "GL_RGB (3)" :
- texImage->IntFormat == 4 ? "GL_RGBA (4)" :
- gl_lookup_enum_by_nr( texImage->IntFormat ),
- gl_lookup_enum_by_nr( format ),
- gl_lookup_enum_by_nr( type ) );
-
-#define SET_FORMAT( gr, gl ) \
- do { \
- ret = (gr); \
- texFormat = &(gl); \
- } while (0)
-
-#define SET_FORMAT_32BPP( gr32, gl32, gr16, gl16 ) \
- do { \
- if ( allow32bpp ) { \
- ret = (gr32); \
- texFormat = &(gl32); \
- } else { \
- ret = (gr16); \
- texFormat = &(gl16); \
- } \
- } while (0)
-
- switch ( texImage->IntFormat ) {
- /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
- * got to be better than sticking them way down the end of this
- * huge list.
- */
- case GL_RGBA:
- case 4:
- if ( format == GL_BGRA ) {
- if ( type == GL_UNSIGNED_INT_8_8_8_8_REV && allow32bpp ) {
- SET_FORMAT( GR_TEXFMT_ARGB_8888, _mesa_texformat_argb8888 );
- break;
- } else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
- SET_FORMAT( GR_TEXFMT_ARGB_4444, _mesa_texformat_argb4444 );
- break;
- } else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
- SET_FORMAT( GR_TEXFMT_ARGB_1555, _mesa_texformat_argb1555 );
- break;
- }
- }
- if ( allow32bpp && is32bpp ) {
- SET_FORMAT( GR_TEXFMT_ARGB_8888, _mesa_texformat_argb8888 );
- } else {
- SET_FORMAT( GR_TEXFMT_ARGB_4444, _mesa_texformat_argb4444 );
- }
- break;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (tObj) {
+ /* per-texture palette */
+ tdfxTexInfo *ti;
+
+ /* This might be a proxy texture. */
+ if (!tObj->Palette.Table)
+ return;
+
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = TDFX_TEXTURE_DATA(tObj);
+ convertPalette(ti->palette.data, &tObj->Palette);
+ /*tdfxTexInvalidate(ctx, tObj);*/
+ }
+ else {
+ /* global texture palette */
+ convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */
+}
- case GL_RGB:
- case 3:
- if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
- SET_FORMAT( GR_TEXFMT_RGB_565, _mesa_texformat_rgb565 );
- break;
- }
- if ( allow32bpp && is32bpp ) {
- SET_FORMAT( GR_TEXFMT_ARGB_8888, _mesa_texformat_argb8888 );
- } else {
- SET_FORMAT( GR_TEXFMT_RGB_565, _mesa_texformat_rgb565 );
- }
- break;
- /* GH: Okay, keep checking as normal. Still test for GL_RGB,
- * GL_RGBA formats first.
- */
- case GL_RGBA8:
- case GL_RGB10_A2:
- case GL_RGBA12:
- case GL_RGBA16:
- SET_FORMAT_32BPP( GR_TEXFMT_ARGB_8888, _mesa_texformat_argb8888,
- GR_TEXFMT_ARGB_4444, _mesa_texformat_argb4444 );
- break;
+/**********************************************************************/
+/**** NEW TEXTURE IMAGE FUNCTIONS ****/
+/**********************************************************************/
- case GL_RGBA4:
- case GL_RGBA2:
- SET_FORMAT( GR_TEXFMT_ARGB_4444, _mesa_texformat_argb4444 );
- break;
+static FxBool TexusFatalError = FXFALSE;
+static FxBool TexusError = FXFALSE;
- case GL_RGB5_A1:
- SET_FORMAT( GR_TEXFMT_ARGB_1555, _mesa_texformat_argb1555 );
- break;
+#define TX_DITHER_NONE 0x00000000
- case GL_RGB8:
- case GL_RGB10:
- case GL_RGB12:
- case GL_RGB16:
- SET_FORMAT_32BPP( GR_TEXFMT_ARGB_8888, _mesa_texformat_argb8888,
- GR_TEXFMT_RGB_565, _mesa_texformat_rgb565 );
- break;
+#if 000
+static void
+fxTexusError(const char *string, FxBool fatal)
+{
+ _mesa_problem(NULL, string);
+ /*
+ * Just propagate the fatal value up.
+ */
+ TexusError = FXTRUE;
+ TexusFatalError = fatal;
+}
+#endif
- case GL_RGB5:
- case GL_RGB4:
- case GL_R3_G3_B2:
- SET_FORMAT( GR_TEXFMT_RGB_565, _mesa_texformat_rgb565 );
- break;
+const struct gl_texture_format *
+tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLboolean allow32bpt = TDFX_IS_NAPALM(fxMesa);
+
+ switch (internalFormat) {
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA8:
case GL_ALPHA12:
case GL_ALPHA16:
- SET_FORMAT( GR_TEXFMT_ALPHA_8, _mesa_texformat_a8 );
- break;
-
+ return &_mesa_texformat_a8;
case 1:
case GL_LUMINANCE:
case GL_LUMINANCE4:
case GL_LUMINANCE8:
case GL_LUMINANCE12:
case GL_LUMINANCE16:
- SET_FORMAT( GR_TEXFMT_INTENSITY_8, _mesa_texformat_l8 );
- break;
-
+ return &_mesa_texformat_l8;
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
@@ -366,17 +613,39 @@ tdfxTexGetFormat( tdfxContextPtr fxMesa, struct gl_texture_image *texImage,
case GL_LUMINANCE12_ALPHA4:
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
- SET_FORMAT( GR_TEXFMT_ALPHA_INTENSITY_88, _mesa_texformat_al88 );
- break;
-
+ return &_mesa_texformat_al88;
case GL_INTENSITY:
case GL_INTENSITY4:
case GL_INTENSITY8:
case GL_INTENSITY12:
case GL_INTENSITY16:
- SET_FORMAT( GR_TEXFMT_ALPHA_8, _mesa_texformat_i8 );
+ return &_mesa_texformat_i8;
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+ case 3:
+ case GL_RGB:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return (allow32bpt) ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_rgb565;
break;
-
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+ case 4:
+ case GL_RGBA:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return allow32bpt ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_argb4444;
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
case GL_COLOR_INDEX:
case GL_COLOR_INDEX1_EXT:
case GL_COLOR_INDEX2_EXT:
@@ -384,677 +653,821 @@ tdfxTexGetFormat( tdfxContextPtr fxMesa, struct gl_texture_image *texImage,
case GL_COLOR_INDEX8_EXT:
case GL_COLOR_INDEX12_EXT:
case GL_COLOR_INDEX16_EXT:
- SET_FORMAT( GR_TEXFMT_P_8, _mesa_texformat_ci8 );
- break;
-
+ return &_mesa_texformat_ci8;
default:
- fprintf( stderr, "bad texture format in fxTexGetFormat() %d",
- texImage->IntFormat );
- return -1;
+ _mesa_problem(ctx, "unexpected format in tdfxDDChooseTextureFormat");
+ return NULL;
}
-
- texImage->TexFormat = texFormat;
-
- return ret;
}
-static GLboolean
-tdfxDDTexImage2D( GLcontext *ctx, GLenum target, GLint level,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLboolean *retainInternalCopy )
+/*
+ * Return the Glide format for the given mesa texture format.
+ */
+static GrTextureFormat_t
+fxGlideFormat(GLint mesaFormat)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- const struct gl_texture_format *texFormat;
- GrTextureFormat_t glideFormat;
- tdfxTexObjPtr t;
- tdfxTexImagePtr image;
- GLint dstWidth, dstHeight, wScale, hScale;
- GLint size;
- void *data;
-
- if ( 0 ) {
- printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
- texObj->Name, texImage->IntFormat, format, type,
- texImage->Width, texImage->Height);
- }
-
- if ( target != GL_TEXTURE_2D || texImage->Border > 0 )
- return GL_FALSE;
-
- if ( !texObj->DriverData )
- texObj->DriverData = tdfxAllocTexObj( fxMesa );
-
- t = TDFX_TEXTURE_DATA(texObj);
- image = &t->image[level];
-
- /* Determine the appropriate GL internal texel format, Mesa internal
- * texel format, and texelSize (bytes) given the user's internal
- * texture format hint.
- */
- glideFormat = tdfxTexGetFormat( fxMesa, texImage, format, type );
-
- /* Get the destination internal format.
- */
- texFormat = texImage->TexFormat;
-
- /* Determine width and height scale factors for texture. Remember,
- * Glide is limited to 8:1 aspect ratios.
- */
- tdfxTexGetInfo( ctx,
- texImage->Width, texImage->Height,
- NULL, NULL, NULL, NULL,
- &wScale, &hScale );
- dstWidth = texImage->Width * wScale;
- dstHeight = texImage->Height * hScale;
-
- /* Allocate new storage for texture image, if needed. This
- * conditional wants to set uncompressedImage to point to the
- * uncompressed image, and mml->data to the texture data. If the
- * image is uncompressed, these are identical. If the image is not
- * compressed, these are different.
- */
- if ( !image->original.data || image->glideFormat != glideFormat ||
- image->original.width != texImage->Width ||
- image->original.height != texImage->Height )
- {
- if ( image->original.data ) {
- FREE( image->original.data );
- image->original.data = NULL;
- }
- if ( image->rescaled.data ) {
- FREE( image->rescaled.data );
- image->rescaled.data = NULL;
- }
-
- size = texImage->Width * texImage->Height * texFormat->TexelBytes;
- image->original.data = (void *) MALLOC( size );
- if ( !image->original.data )
- return GL_FALSE;
-
- image->original.width = texImage->Width;
- image->original.height = texImage->Height;
- image->original.size = size;
-
- image->glideFormat = glideFormat;
- image->wScale = wScale;
- image->hScale = hScale;
-
- t->info.format = glideFormat;
- tdfxTMMoveOutTM( fxMesa, texObj );
- }
-
- /* Store the texture image into the 'original' space.
- */
- if ( !_mesa_convert_texsubimage2d( texFormat->IntFormat,
- 0, 0, texImage->Width,
- texImage->Height, texImage->Width,
- format, type, packing, pixels,
- image->original.data ) ) {
- return GL_FALSE;
- }
-
- data = image->original.data;
- size = image->original.size;
-
- /* GH: Sigh...
- */
- if ( wScale > 1 || hScale > 1 ) {
- if ( image->rescaled.data ) {
- FREE( image->rescaled.data );
- image->rescaled.data = NULL;
- }
-
- size = dstWidth * dstHeight * texFormat->TexelBytes;
- image->rescaled.data = (void *) MALLOC( size );
- if ( !image->rescaled.data )
- return GL_FALSE;
-
- image->rescaled.width = dstWidth;
- image->rescaled.height = dstHeight;
- image->rescaled.size = size;
-
- _mesa_rescale_teximage2d( texFormat->TexelBytes,
- texImage->Width, texImage->Height,
- dstWidth, dstHeight,
- image->original.data, image->rescaled.data );
-
- data = image->rescaled.data;
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_A8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_L8:
+ return GR_TEXFMT_INTENSITY_8;
+ case MESA_FORMAT_CI8:
+ return GR_TEXFMT_P_8;
+ case MESA_FORMAT_AL88:
+ return GR_TEXFMT_ALPHA_INTENSITY_88;
+ case MESA_FORMAT_RGB565:
+ return GR_TEXFMT_RGB_565;
+ case MESA_FORMAT_ARGB4444:
+ return GR_TEXFMT_ARGB_4444;
+ case MESA_FORMAT_ARGB1555:
+ return GR_TEXFMT_ARGB_1555;
+ case MESA_FORMAT_ARGB8888:
+ return GR_TEXFMT_ARGB_8888;
+ default:
+ _mesa_problem(NULL, "Unexpected format in fxGlideFormat");
+ return 0;
}
+}
- image->data = data;
- image->size = size;
-
- tdfxRevalidateTexture( ctx, texObj );
- t->reloadImages = GL_TRUE;
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
+/* Texel-fetch functions for software texturing and glGetTexImage().
+ * We should have been able to use some "standard" fetch functions (which
+ * may get defined in texutil.c) but we have to account for scaled texture
+ * images on tdfx hardware (the 8:1 aspect ratio limit).
+ * Hence, we need special functions here.
+ */
- *retainInternalCopy = GL_FALSE;
- return GL_TRUE;
+static void
+fetch_intensity8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = *texel;
}
-static GLboolean
-tdfxDDTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLenum type, const GLvoid *pixels,
- const struct gl_pixelstore_attrib *packing,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage )
+static void
+fetch_luminance8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
- tdfxTexImagePtr image;
-
- if ( target != GL_TEXTURE_2D )
- return GL_FALSE;
-
- if ( !t )
- return GL_FALSE;
-
- if ( 0 ) {
- fprintf( stderr, "TexSubImage id=%d lvl=%d int=0x%x format=0x%x type=0x%x x=%d y=%d w=%d h=%d fullW=%d fullH=%d\n",
- texObj->Name, level, texImage->IntFormat, format, type,
- xoffset, yoffset, width, height,
- texImage->Width, texImage->Height );
- }
-
- image = &t->image[level];
-
- /* Must have an existing texture image!
- */
- assert( image->original.data );
-
- if ( !_mesa_convert_texsubimage2d( texImage->TexFormat->IntFormat,
- xoffset, yoffset, width, height,
- texImage->Width,
- format, type, packing,
- pixels, image->original.data ) ) {
- return GL_FALSE;
- }
-
- /* Rescale the original image again if we have to.
- */
- if ( image->wScale > 1 || image->hScale > 1 ) {
- assert( image->rescaled.data );
- _mesa_rescale_teximage2d( texImage->TexFormat->TexelBytes,
- image->original.width, image->original.height,
- image->rescaled.width, image->rescaled.height,
- image->original.data, image->rescaled.data );
- }
-
- t->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
- fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX this might be a bit much */
-
- return GL_TRUE;
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = 255;
}
+static void
+fetch_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+ i = i * mml->width / texImage->Width;
+ j = j * mml->height / texImage->Height;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = 255;
+ rgba[GCOMP] = 255;
+ rgba[BCOMP] = 255;
+ rgba[ACOMP] = *texel;
+}
-/* ================================================================
- *
- */
-static void tdfxDDTexEnv( GLcontext *ctx, GLenum target,
- GLenum pname, const GLfloat *param )
+static void
+fetch_index8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ (void) mml;
+ /* XXX todo */
+}
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- if ( param ) {
- fprintf( stderr, __FUNCTION__"( %x, %x )\n", pname, (GLint)(*param) );
- } else {
- fprintf( stderr, __FUNCTION__"( %x )\n", pname );
- }
- }
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
+static void
+fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2;
+ rgba[RCOMP] = texel[0];
+ rgba[GCOMP] = texel[0];
+ rgba[BCOMP] = texel[0];
+ rgba[ACOMP] = texel[1];
}
-static void tdfxDDTexParameter( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
- GLenum pname, const GLfloat *params )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- GLenum param = (GLenum) (GLint) params[0];
- tdfxTexObjPtr t;
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, __FUNCTION__ "( %d, %p, %x, %x )\n",
- tObj->Name, tObj->DriverData, pname, param );
- }
+static void
+fetch_r5g6b5(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
+ rgba[GCOMP] = (((*texel) >> 5) & 0x3f) * 255 / 63;
+ rgba[BCOMP] = (((*texel) >> 0) & 0x1f) * 255 / 31;
+ rgba[ACOMP] = 255;
+}
- if ( target != GL_TEXTURE_2D )
- return;
-
- if ( !tObj->DriverData )
- tObj->DriverData = tdfxAllocTexObj( fxMesa );
-
- t = TDFX_TEXTURE_DATA(tObj);
-
- switch ( pname ) {
- case GL_TEXTURE_MIN_FILTER:
- switch ( param ) {
- case GL_NEAREST:
- t->mmMode = GR_MIPMAP_DISABLE;
- t->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- t->LODblend = FXFALSE;
- break;
-
- case GL_LINEAR:
- t->mmMode = GR_MIPMAP_DISABLE;
- t->minFilt = GR_TEXTUREFILTER_BILINEAR;
- t->LODblend = FXFALSE;
- break;
-
- case GL_NEAREST_MIPMAP_LINEAR:
- if ( TDFX_IS_NAPALM(fxMesa) ) {
- if ( fxMesa->numTMUs > 1 ) {
- t->mmMode = GR_MIPMAP_NEAREST;
- t->LODblend = FXTRUE;
- } else {
- t->mmMode = GR_MIPMAP_NEAREST_DITHER;
- t->LODblend = FXFALSE;
- }
- t->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- break;
- }
- /* XXX Voodoo3/Banshee mipmap blending seems to produce
- * incorrectly filtered colors for the smallest mipmap levels.
- * To work-around we fall-through here and use a different filter.
- */
- case GL_NEAREST_MIPMAP_NEAREST:
- t->mmMode = GR_MIPMAP_NEAREST;
- t->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- t->LODblend = FXFALSE;
- break;
-
- case GL_LINEAR_MIPMAP_LINEAR:
- if ( TDFX_IS_NAPALM(fxMesa) ) {
- if ( fxMesa->numTMUs > 1 ) {
- t->mmMode = GR_MIPMAP_NEAREST;
- t->LODblend = FXTRUE;
- } else {
- t->mmMode = GR_MIPMAP_NEAREST_DITHER;
- t->LODblend = FXFALSE;
- }
- t->minFilt = GR_TEXTUREFILTER_BILINEAR;
- break;
- }
- /* XXX Voodoo3/Banshee mipmap blending seems to produce
- * incorrectly filtered colors for the smallest mipmap levels.
- * To work-around we fall-through here and use a different filter.
- */
- case GL_LINEAR_MIPMAP_NEAREST:
- t->mmMode = GR_MIPMAP_NEAREST;
- t->minFilt = GR_TEXTUREFILTER_BILINEAR;
- t->LODblend = FXFALSE;
- break;
- default:
- break;
- }
- tdfxRevalidateTexture( ctx, tObj );
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
- break;
- case GL_TEXTURE_MAG_FILTER:
- switch ( param ) {
- case GL_NEAREST:
- t->magFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
- break;
- case GL_LINEAR:
- t->magFilt = GR_TEXTUREFILTER_BILINEAR;
- break;
- default:
- break;
- }
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
- break;
+static void
+fetch_r4g4b4a4(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 12) & 0xf) * 255 / 15;
+ rgba[GCOMP] = (((*texel) >> 8) & 0xf) * 255 / 15;
+ rgba[BCOMP] = (((*texel) >> 4) & 0xf) * 255 / 15;
+ rgba[ACOMP] = (((*texel) >> 0) & 0xf) * 255 / 15;
+}
- case GL_TEXTURE_WRAP_S:
- switch ( param ) {
- case GL_CLAMP:
- t->sClamp = GR_TEXTURECLAMP_CLAMP;
- break;
- case GL_REPEAT:
- t->sClamp = GR_TEXTURECLAMP_WRAP;
- break;
- default:
- break;
- }
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
- break;
- case GL_TEXTURE_WRAP_T:
- switch ( param ) {
- case GL_CLAMP:
- t->tClamp = GR_TEXTURECLAMP_CLAMP;
- break;
- case GL_REPEAT:
- t->tClamp = GR_TEXTURECLAMP_WRAP;
- break;
- default:
- break;
- }
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
- break;
+static void
+fetch_r5g5b5a1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
+ rgba[GCOMP] = (((*texel) >> 6) & 0x1f) * 255 / 31;
+ rgba[BCOMP] = (((*texel) >> 1) & 0x1f) * 255 / 31;
+ rgba[ACOMP] = (((*texel) >> 0) & 0x01) * 255;
+}
- case GL_TEXTURE_BASE_LEVEL:
- tdfxRevalidateTexture( ctx, tObj );
- break;
- case GL_TEXTURE_MAX_LEVEL:
- tdfxRevalidateTexture( ctx, tObj );
- break;
+static void
+fetch_a8r8g8b8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLvoid * texelOut)
+{
+ GLchan *rgba = (GLchan *) texelOut;
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLuint *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLuint *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 16) & 0xff);
+ rgba[GCOMP] = (((*texel) >> 8) & 0xff);
+ rgba[BCOMP] = (((*texel) ) & 0xff);
+ rgba[ACOMP] = (((*texel) >> 24) & 0xff);
+}
- case GL_TEXTURE_BORDER_COLOR:
- /* TO DO */
- break;
- case GL_TEXTURE_MIN_LOD:
- /* TO DO */
- break;
- case GL_TEXTURE_MAX_LOD:
- /* TO DO */
- break;
+static FetchTexelFunc
+fxFetchFunction(GLint mesaFormat)
+{
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return fetch_intensity8;
+ case MESA_FORMAT_A8:
+ return fetch_alpha8;
+ case MESA_FORMAT_L8:
+ return fetch_luminance8;
+ case MESA_FORMAT_CI8:
+ return fetch_index8;
+ case MESA_FORMAT_AL88:
+ return fetch_luminance8_alpha8;
+ case MESA_FORMAT_RGB565:
+ return fetch_r5g6b5;
+ case MESA_FORMAT_ARGB4444:
+ return fetch_r4g4b4a4;
+ case MESA_FORMAT_ARGB1555:
+ return fetch_r5g5b5a1;
+ case MESA_FORMAT_ARGB8888:
+ return fetch_a8r8g8b8;
default:
- break;
+ _mesa_problem(NULL, "Unexpected format in fxFetchFunction");
+ printf("%d\n", mesaFormat);
+ return NULL;
}
}
-static void tdfxDDBindTexture( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexObjPtr t;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
- fprintf( stderr, __FUNCTION__ "( %d, %p )\n",
- tObj->Name, tObj->DriverData );
- }
-
- if ( target != GL_TEXTURE_2D )
- return;
- if ( !tObj->DriverData )
- tObj->DriverData = tdfxAllocTexObj( fxMesa );
-
- t = TDFX_TEXTURE_DATA(tObj);
- t->lastTimeUsed = fxMesa->texBindNumber++;
-
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
-}
-
-static void tdfxDDDeleteTexture( GLcontext *ctx,
- struct gl_texture_object *tObj )
+void
+tdfxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
-
- if ( fxMesa->driDrawable ) {
- LOCK_HARDWARE( fxMesa );
- tdfxTMFreeTextureLocked( fxMesa, tObj );
- UNLOCK_HARDWARE( fxMesa );
- }
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint texelBytes;
+
+ /*
+ printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
+ texObj->Name, texImage->IntFormat, format, type,
+ texImage->Width, texImage->Height);
+ */
- fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ ti = TDFX_TEXTURE_DATA(texObj);
+ if (!ti) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ ti = TDFX_TEXTURE_DATA(texObj);
+ }
+
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ if (!mml) {
+ texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel));
+ if (!texImage->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ }
+
+ /* Determine width and height scale factors for texture.
+ * Remember, Glide is limited to 8:1 aspect ratios.
+ */
+ tdfxTexGetInfo(ctx,
+ texImage->Width, texImage->Height,
+ NULL, /* lod level */
+ NULL, /* aspect ratio */
+ NULL, NULL, /* sscale, tscale */
+ &mml->wScale, &mml->hScale);
+
+ /* rescaled size: */
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexel = fxFetchFunction(texImage->TexFormat->MesaFormat);
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ if (mml->width != width || mml->height != height) {
+ /* rescale the image to overcome 1:8 aspect limitation */
+ GLvoid *tempImage;
+ tempImage = MALLOC(width * height * texelBytes);
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ /* unpack image, apply transfer ops and store in tempImage */
+ _mesa_transfer_teximage(ctx, 2, texImage->Format,
+ texImage->TexFormat,
+ tempImage,
+ width, height, 1, 0, 0, 0,
+ width * texelBytes,
+ 0, /* dstImageStride */
+ format, type, pixels, packing);
+ assert(!texImage->Data);
+ texImage->Data = MALLOC(mml->width * mml->height * texelBytes);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ FREE(tempImage);
+ return;
+ }
+ _mesa_rescale_teximage2d(texelBytes,
+ mml->width * texelBytes, /* dst stride */
+ width, height,
+ mml->width, mml->height,
+ tempImage /*src*/, texImage->Data /*dst*/ );
+ FREE(tempImage);
+ }
+ else {
+ /* no rescaling needed */
+ assert(!texImage->Data);
+ texImage->Data = MALLOC(mml->width * mml->height * texelBytes);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ _mesa_transfer_teximage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ width, height, 1, 0, 0, 0,
+ texImage->Width * texelBytes,
+ 0, /* dstImageStride */
+ format, type, pixels, packing);
+ }
+
+ RevalidateTexture(ctx, texObj);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
}
-static GLboolean tdfxDDIsTextureResident( GLcontext *ctx,
- struct gl_texture_object *tObj )
-{
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- return ( t && t->isInTM );
+void
+tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint texelBytes;
+
+ if (!texObj->DriverData) {
+ _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
+ return;
+ }
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ assert(mml);
+
+ assert(texImage->Data); /* must have an existing texture image! */
+ assert(texImage->Format);
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* need to rescale subimage to match mipmap level's rescale factors */
+ const GLint newWidth = width * mml->wScale;
+ const GLint newHeight = height * mml->hScale;
+ GLvoid *scaledImage, *tempImage;
+ GLubyte *destAddr;
+ tempImage = MALLOC(width * height * texelBytes);
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+
+ _mesa_transfer_teximage(ctx, 2, texImage->Format,/* Tex int format */
+ texImage->TexFormat, /* dest format */
+ (GLubyte *) tempImage, /* dest */
+ width, height, 1, /* subimage size */
+ 0, 0, 0, /* subimage pos */
+ width * texelBytes, /* dest row stride */
+ 0, /* dst image stride */
+ format, type, pixels, packing);
+
+ /* now rescale */
+ scaledImage = MALLOC(newWidth * newHeight * texelBytes);
+ if (!scaledImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ FREE(tempImage);
+ return;
+ }
+
+ /* compute address of dest subimage within the overal tex image */
+ destAddr = (GLubyte *) texImage->Data
+ + (yoffset * mml->hScale * mml->width
+ + xoffset * mml->wScale) * texelBytes;
+
+ _mesa_rescale_teximage2d(texelBytes,
+ mml->width * texelBytes, /* dst stride */
+ width, height,
+ newWidth, newHeight,
+ tempImage, destAddr);
+
+ FREE(tempImage);
+ FREE(scaledImage);
+ }
+ else {
+ /* no rescaling needed */
+ _mesa_transfer_teximage(ctx, 2, texImage->Format, /* Tex int format */
+ texImage->TexFormat, /* dest format */
+ (GLubyte *) texImage->Data,/* dest */
+ width, height, 1, /* subimage size */
+ xoffset, yoffset, 0, /* subimage pos */
+ mml->width * texelBytes, /* dest row stride */
+ 0, /* dst image stride */
+ format, type, pixels, packing);
+ }
+
+ ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
+ fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX this might be a bit much */
}
-/* Convert a gl_color_table texture palette to Glide's format.
- */
-static void
-tdfxConvertPalette( FxU32 data[256], const struct gl_color_table *table )
-{
- const GLubyte *tableUB = (const GLubyte *) table->Table;
- GLint width = table->Size;
- FxU32 r, g, b, a;
- GLint i;
- ASSERT( table->TableType == GL_UNSIGNED_BYTE );
+/**********************************************************************/
+/**** COMPRESSED TEXTURE IMAGE FUNCTIONS ****/
+/**********************************************************************/
- switch ( table->Format ) {
- case GL_RGBA:
- for ( i = 0 ; i < width ; i++ ) {
- r = tableUB[i * 4 + 0];
- g = tableUB[i * 4 + 1];
- b = tableUB[i * 4 + 2];
- a = tableUB[i * 4 + 3];
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- case GL_RGB:
- for ( i = 0 ; i < width ; i++ ) {
- r = tableUB[i * 3 + 0];
- g = tableUB[i * 3 + 1];
- b = tableUB[i * 3 + 2];
- a = 255;
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- case GL_LUMINANCE:
- for ( i = 0 ; i < width ; i++ ) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = 255;
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- case GL_ALPHA:
- for ( i = 0 ; i < width ; i++ ) {
- r = g = b = 255;
- a = tableUB[i];
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- case GL_LUMINANCE_ALPHA:
- for ( i = 0 ; i < width ; i++ ) {
- r = g = b = tableUB[i * 2 + 0];
- a = tableUB[i * 2 + 1];
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- case GL_INTENSITY:
- for ( i = 0 ; i < width ; i++ ) {
- r = tableUB[i];
- g = tableUB[i];
- b = tableUB[i];
- a = tableUB[i];
- data[i] = PACK_COLOR_8888( a, r, g, b );
- }
- break;
- }
+#if 0000
+GLboolean
+tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+ GLint level, GLsizei imageSize,
+ const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLboolean *retainInternalCopy)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLboolean allow32bpt = TDFX_IS_NAPALM(fxMesa);
+ GrTextureFormat_t gldformat;
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint dstWidth, dstHeight, wScale, hScale, texelSize;
+ MesaIntTexFormat intFormat;
+ GLboolean isCompressedFormat;
+ GLsizei texSize;
+
+ if (target != GL_TEXTURE_2D || texImage->Border > 0)
+ return GL_FALSE;
+
+ if (!texObj->DriverData)
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ mml = &ti->mipmapLevel[level];
+
+ isCompressedFormat = tdfxDDIsCompressedGlideFormatMacro(texImage->IntFormat);
+ if (!isCompressedFormat) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(format)");
+ return GL_FALSE;
+ }
+ /* Determine the apporpriate GL internal texel format, Mesa internal
+ * texel format, and texelSize (bytes) given the user's internal
+ * texture format hint.
+ */
+ tdfxTexGetFormat(texImage->IntFormat, allow32bpt,
+ &gldformat, &intFormat, &texelSize);
+
+ /* Determine width and height scale factors for texture.
+ * Remember, Glide is limited to 8:1 aspect ratios.
+ */
+ tdfxTexGetInfo(ctx,
+ texImage->Width, texImage->Height,
+ NULL, /* lod level */
+ NULL, /* aspect ratio */
+ NULL, NULL, /* sscale, tscale */
+ &wScale, &hScale);
+ dstWidth = texImage->Width * wScale;
+ dstHeight = texImage->Height * hScale;
+ /* housekeeping */
+ _mesa_set_teximage_component_sizes(intFormat, texImage);
+
+ texSize = tdfxDDCompressedImageSize(ctx,
+ texImage->IntFormat,
+ 2,
+ texImage->Width,
+ texImage->Height,
+ 1);
+ if (texSize != imageSize) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexImage2D(texSize)");
+ return GL_FALSE;
+ }
+
+ /* allocate new storage for texture image, if needed */
+ if (!mml->data || mml->glideFormat != gldformat ||
+ mml->width != dstWidth || mml->height != dstHeight ||
+ texSize != mml->dataSize) {
+ if (mml->data) {
+ FREE(mml->data);
+ }
+ mml->data = MALLOC(texSize);
+ if (!mml->data) {
+ return GL_FALSE;
+ }
+ mml->texelSize = texelSize;
+ mml->glideFormat = gldformat;
+ mml->width = dstWidth;
+ mml->height = dstHeight;
+ tdfxTMMoveOutTM(fxMesa, texObj);
+ /*tdfxTexInvalidate(ctx, texObj);*/
+ }
+
+ /* save the texture data */
+ MEMCPY(mml->data, data, imageSize);
+
+ RevalidateTexture(ctx, texObj);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+
+ *retainInternalCopy = GL_FALSE;
+ return GL_TRUE;
}
-static void
-tdfxDDTexturePalette( GLcontext *ctx, struct gl_texture_object *tObj )
+GLboolean
+tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+ GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width,
+ GLint height, GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexObjPtr t;
-
- if ( tObj ) {
- /* Per-texture palette */
- if ( !tObj->DriverData )
- tObj->DriverData = tdfxAllocTexObj(fxMesa);
-
- t = TDFX_TEXTURE_DATA(tObj);
- tdfxConvertPalette( t->palette.data, &tObj->Palette );
- /*tdfxTexInvalidate( ctx, tObj );*/
- } else {
- /* Global texture palette */
- tdfxConvertPalette( fxMesa->glbPalette.data, &ctx->Texture.Palette );
- }
-
- fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+
+ /*
+ * We punt if we are not replacing the entire image. This
+ * is allowed by the spec.
+ */
+ if ((xoffset != 0) && (yoffset != 0)
+ && (width != texImage->Width)
+ && (height != texImage->Height)) {
+ return GL_FALSE;
+ }
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ mml = &ti->mipmapLevel[level];
+ if (imageSize != mml->dataSize) {
+ return GL_FALSE;
+ }
+ MEMCPY(data, mml->data, imageSize);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+
+ return GL_TRUE;
}
+#endif
-
-/**********************************************************************/
-/**** NEW TEXTURE IMAGE FUNCTIONS ****/
-/**********************************************************************/
-
-
-
-#if 0
+#if 0
static void
PrintTexture(int w, int h, int c, const GLubyte * data)
{
- int i, j;
- for (i = 0; i < h; i++) {
- for (j = 0; j < w; j++) {
- if (c == 2)
- printf("%02x %02x ", data[0], data[1]);
- else if (c == 3)
- printf("%02x %02x %02x ", data[0], data[1], data[2]);
- data += c;
- }
- printf("\n");
- }
+ int i, j;
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++) {
+ if (c == 2)
+ printf("%02x %02x ", data[0], data[1]);
+ else if (c == 3)
+ printf("%02x %02x %02x ", data[0], data[1], data[2]);
+ data += c;
+ }
+ printf("\n");
+ }
}
#endif
-static GLboolean
-tdfxDDTestProxyTexImage( GLcontext *ctx, GLenum target,
- GLint level, GLint internalFormat,
- GLenum format, GLenum type,
- GLint width, GLint height,
- GLint depth, GLint border )
+GLboolean
+tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
-
- switch (target) {
- case GL_PROXY_TEXTURE_1D:
- return GL_TRUE; /* software rendering */
- case GL_PROXY_TEXTURE_2D:
- {
- struct gl_texture_object *tObj;
- tdfxTexObjPtr t;
- int memNeeded;
-
- tObj = ctx->Texture.Proxy2D;
- if (!tObj->DriverData)
- tObj->DriverData = tdfxAllocTexObj(fxMesa);
- t = TDFX_TEXTURE_DATA(tObj);
-
- /* assign the parameters to test against */
- tObj->Image[level]->Width = width;
- tObj->Image[level]->Height = height;
- tObj->Image[level]->Border = border;
- tObj->Image[level]->IntFormat = internalFormat;
- if (level == 0) {
- /* don't use mipmap levels > 0 */
- tObj->MinFilter = tObj->MagFilter = GL_NEAREST;
- }
- else {
- /* test with all mipmap levels */
- tObj->MinFilter = GL_LINEAR_MIPMAP_LINEAR;
- tObj->MagFilter = GL_NEAREST;
- }
- tdfxRevalidateTexture(ctx, tObj);
-
- /*
- printf("small lodlog2 0x%x\n", t->info.smallLodLog2);
- printf("large lodlog2 0x%x\n", t->info.largeLodLog2);
- printf("aspect ratio 0x%x\n", t->info.aspectRatioLog2);
- printf("glide format 0x%x\n", t->info.format);
- printf("data %p\n", t->info.data);
- printf("lodblend %d\n", (int) t->LODblend);
- */
-
- /* determine where texture will reside */
- if (t->LODblend && !tss->umaTexMemory) {
- /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
- memNeeded = fxMesa->Glide.grTexTextureMemRequired(
- GR_MIPMAPLEVELMASK_BOTH, &(t->info));
- }
- else {
- /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
- memNeeded = fxMesa->Glide.grTexTextureMemRequired(
- GR_MIPMAPLEVELMASK_BOTH, &(t->info));
- }
- /*
- printf("Proxy test %d > %d\n", memNeeded, tss->totalTexMem[0]);
- */
- if (memNeeded > tss->totalTexMem[0])
- return GL_FALSE;
- else
- return GL_TRUE;
- }
- case GL_PROXY_TEXTURE_3D:
- return GL_TRUE; /* software rendering */
- default:
- return GL_TRUE; /* never happens, silence compiler */
- }
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ return GL_TRUE; /* software rendering */
+ case GL_PROXY_TEXTURE_2D:
+ {
+ struct gl_texture_object *tObj;
+ tdfxTexInfo *ti;
+ int memNeeded;
+
+ tObj = ctx->Texture.Proxy2D;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = TDFX_TEXTURE_DATA(tObj);
+
+ /* assign the parameters to test against */
+ tObj->Image[level]->Width = width;
+ tObj->Image[level]->Height = height;
+ tObj->Image[level]->Border = border;
+#if 0
+ tObj->Image[level]->IntFormat = internalFormat;
+#endif
+ if (level == 0) {
+ /* don't use mipmap levels > 0 */
+ tObj->MinFilter = tObj->MagFilter = GL_NEAREST;
+ }
+ else {
+ /* test with all mipmap levels */
+ tObj->MinFilter = GL_LINEAR_MIPMAP_LINEAR;
+ tObj->MagFilter = GL_NEAREST;
+ }
+ RevalidateTexture(ctx, tObj);
+
+ /*
+ printf("small lodlog2 0x%x\n", ti->info.smallLodLog2);
+ printf("large lodlog2 0x%x\n", ti->info.largeLodLog2);
+ printf("aspect ratio 0x%x\n", ti->info.aspectRatioLog2);
+ printf("glide format 0x%x\n", ti->info.format);
+ printf("data %p\n", ti->info.data);
+ printf("lodblend %d\n", (int) ti->LODblend);
+ */
+
+ /* determine where texture will reside */
+ if (ti->LODblend && !shared->umaTexMemory) {
+ /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+ memNeeded = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
+ else {
+ /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+ memNeeded = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
+ /*
+ printf("Proxy test %d > %d\n", memNeeded, shared->totalTexMem[0]);
+ */
+ if (memNeeded > shared->totalTexMem[0])
+ return GL_FALSE;
+ else
+ return GL_TRUE;
+ }
+ case GL_PROXY_TEXTURE_3D:
+ return GL_TRUE; /* software rendering */
+ default:
+ return GL_TRUE; /* never happens, silence compiler */
+ }
}
-/* Return a texture image to Mesa. This is either to satisfy
- * a glGetTexImage() call or to prepare for software texturing.
+#if 000
+/*
+ * This is called from _mesa_GetCompressedTexImage. We just
+ * copy out the compressed data.
*/
-static GLvoid *
-tdfxDDGetTexImage( GLcontext *ctx, GLenum target, GLint level,
- const struct gl_texture_object *texObj,
- GLenum *formatOut, GLenum *typeOut,
- GLboolean *freeImageOut )
+void
+tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+ GLint lod, void *image,
+ const struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
{
- const struct gl_texture_image *texImage = texObj->Image[level];
- const struct gl_texture_format *texFormat = texImage->TexFormat;
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
- tdfxTexImagePtr image;
- GLubyte *data;
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
- if ( target != GL_TEXTURE_2D )
- return NULL;
- if ( !t )
- return NULL;
+ if (target != GL_TEXTURE_2D)
+ return;
- image = &t->image[level];
- if ( !image->original.data )
- return NULL;
+ if (!texObj->DriverData)
+ return;
- data = (GLubyte *) MALLOC( texImage->Width * texImage->Height * 4 );
- if ( !data )
- return NULL;
+ ti = TDFX_TEXTURE_DATA(texObj);
+ mml = &ti->mipmapLevel[lod];
+ if (mml->data) {
+ MEMCPY(image, mml->data, mml->dataSize);
+ }
+}
+#endif
- _mesa_unconvert_teximage2d( texFormat->IntFormat, texImage->Format,
- texImage->Width, texImage->Height,
- image->original.data, data );
+/*
+ * Calculate a specific texture format given a generic
+ * texture format.
+ */
+GLint
+tdfxDDSpecificCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat,
+ GLint numDimensions)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (numDimensions != 2) {
+ return internalFormat;
+ }
+ /*
+ * If we don't have pointers to the functions, then
+ * we drop back to uncompressed format. The logic
+ * in Mesa proper handles this for us.
+ *
+ * This is just to ease the transition to a Glide with
+ * the texus2 library.
+ */
+ if (!fxMesa->Glide.txImgQuantize || !fxMesa->Glide.txImgDequantizeFXT1) {
+ return internalFormat;
+ }
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_ARB:
+ return GL_COMPRESSED_RGB_FXT1_3DFX;
+ case GL_COMPRESSED_RGBA_ARB:
+ return GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ return internalFormat;
+}
- *formatOut = texImage->Format;
- *typeOut = GL_UNSIGNED_BYTE;
- *freeImageOut = GL_TRUE;
+/*
+ * Calculate a specific texture format given a generic
+ * texture format.
+ */
+GLint
+tdfxDDBaseCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat)
+{
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return GL_RGB;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return GL_RGBA;
+ }
+ return -1;
+}
- return data;
+/*
+ * Tell us if an image is compressed. The real work is done
+ * in a macro, but we need to have a function to create a
+ * function pointer.
+ */
+GLboolean
+tdfxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat)
+{
+ return tdfxDDIsCompressedFormatMacro(internalFormat);
}
-void tdfxDDInitTextureFuncs( GLcontext *ctx )
+/*
+ * Calculate the image size of a compressed texture.
+ *
+ * The current compressed format, the FXT1 family, all
+ * map 8x32 texel blocks into 128 bits.
+ *
+ * We return 0 if we can't calculate the size.
+ *
+ * Glide would report this out to us, but we don't have
+ * exactly the right parameters.
+ */
+GLsizei
+tdfxDDCompressedImageSize(GLcontext *ctx,
+ GLenum intFormat,
+ GLuint numDimensions,
+ GLuint width,
+ GLuint height,
+ GLuint depth)
{
- ctx->Driver.TexImage2D = tdfxDDTexImage2D;
- ctx->Driver.TexSubImage2D = tdfxDDTexSubImage2D;
- ctx->Driver.GetTexImage = tdfxDDGetTexImage;
- ctx->Driver.TexEnv = tdfxDDTexEnv;
- ctx->Driver.TexParameter = tdfxDDTexParameter;
- ctx->Driver.BindTexture = tdfxDDBindTexture;
- ctx->Driver.DeleteTexture = tdfxDDDeleteTexture;
- ctx->Driver.IsTextureResident = tdfxDDIsTextureResident;
- ctx->Driver.UpdateTexturePalette = tdfxDDTexturePalette;
+ if (numDimensions != 2) {
+ return 0;
+ }
+ switch (intFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ /*
+ * Round height and width to multiples of 4 and 8,
+ * divide the resulting product by 32 to get the number
+ * of blocks, and multiply by 32 = 128/8 to get the.
+ * number of bytes required. That is to say, just
+ * return the product. Remember that we are returning
+ * bytes, not texels, so we have shrunk the texture
+ * by a factor of the texel size.
+ */
+ width = (width + 0x7) &~ 0x7;
+ height = (height + 0x3) &~ 0x3;
+ return width * height;
+ }
+ return 0;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h
index 3de4285a9..f6fcb6d3a 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -35,12 +35,131 @@
*
*/
-#ifndef __TDFX_TEX_H__
-#define __TDFX_TEX_H__
+#ifndef _TDFX_TEX_H_
+#define _TDFX_TEX_H_
-extern void tdfxUpdateTextureState( GLcontext *ctx );
-extern void tdfxUpdateTextureBinding( GLcontext *ctx );
-extern void tdfxDDInitTextureFuncs( GLcontext *ctx );
+#include "texutil.h"
+
+
+#define tdfxDDIsCompressedFormatMacro(internalFormat) \
+ (((internalFormat) == GL_COMPRESSED_RGB_FXT1_3DFX) || \
+ ((internalFormat) == GL_COMPRESSED_RGBA_FXT1_3DFX))
+#define tdfxDDIsCompressedGlideFormatMacro(internalFormat) \
+ ((internalFormat) == GR_TEXFMT_ARGB_CMP_FXT1)
+
+
+
+extern void
+tdfxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj);
+
+extern void
+tdfxDDBindTexture(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj);
+
+extern void
+tdfxDDDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj);
+
+extern GLboolean
+tdfxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj);
+
+extern void
+tdfxDDTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj);
+
+#if 000 /* DEAD? */
+extern void
+fxDDTexUseGlobalPalette(GLcontext * ctx, GLboolean state);
+#endif
+
+extern void
+tdfxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+ const GLfloat * param);
+
+extern void
+tdfxDDTexParameter(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params);
+
+extern const struct gl_texture_format *
+tdfxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType );
+
+extern void
+tdfxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height,
+ GLint border,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib * packing,
+ struct gl_texture_object * texObj,
+ struct gl_texture_image * texImage);
+
+extern void
+tdfxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+
+#if 000
+extern GLboolean
+tdfxDDCompressedTexImage2D( GLcontext *ctx, GLenum target,
+ GLint level, GLsizei imageSize,
+ const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLboolean *retainInternalCopy);
+
+extern GLboolean
+tdfxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
+ GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width,
+ GLint height, GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+#endif
+
+extern GLboolean
+tdfxDDTestProxyTexImage(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border);
+
+extern GLvoid *
+tdfxDDGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+ const struct gl_texture_object *texObj,
+ GLenum * formatOut, GLenum * typeOut,
+ GLboolean * freeImageOut);
+
+extern void
+tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+ GLint lod, void *image,
+ const struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+
+extern GLint
+tdfxDDSpecificCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat,
+ GLint numDimensions);
+
+extern GLint
+tdfxDDBaseCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat);
+
+extern GLboolean
+tdfxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat);
+
+extern GLsizei
+tdfxDDCompressedImageSize(GLcontext *ctx,
+ GLenum intFormat,
+ GLuint numDimensions,
+ GLuint width,
+ GLuint height,
+ GLuint depth);
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c
index 273fd3169..6fc3484a3 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c,v 1.4 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -39,871 +39,934 @@
#include "tdfx_tex.h"
#include "tdfx_texman.h"
-#define BAD_ADDRESS ((FxU32) -1)
-/* Verify the consistancy of the texture memory manager.
+#define BAD_ADDRESS ((FxU32) -1)
+
+
+#if 0 /* DEBUG use */
+/*
+ * Verify the consistancy of the texture memory manager.
* This involves:
* Traversing all texture objects and computing total memory used.
* Traverse the free block list and computing total memory free.
* Compare the total free and total used amounts to the total memory size.
* Make various assertions about the results.
*/
-static void tdfxTMVerifyFreeList( tdfxContextPtr fxMesa, FxU32 unit )
+static void
+VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu)
{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- struct gl_texture_object *texObj;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- tdfxMemRange *block;
- int prevStart = -1, prevEnd = -1;
- int totalFree = 0;
- int numObj = 0, numRes = 0;
- int totalUsed = 0;
-
- for ( block = tss->freeRanges[unit] ; block ; block = block->next ) {
- assert( block->endAddr > 0 );
- assert( block->startAddr <= tss->totalTexMem[unit] );
- assert( block->endAddr <= tss->totalTexMem[unit] );
- assert( (int) block->startAddr > prevStart );
- assert( (int) block->startAddr >= prevEnd );
- prevStart = (int) block->startAddr;
- prevEnd = (int) block->endAddr;
- totalFree += (block->endAddr - block->startAddr);
- }
- assert( totalFree == tss->freeTexMem[unit] );
-
- for ( texObj = ss->TexObjectList ; texObj ; texObj = texObj->Next ) {
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
- numObj++;
- if ( t ) {
- if ( t->isInTM ) {
- numRes++;
- assert( t->range[0] );
- if ( t->range[unit] )
- totalUsed += (t->range[unit]->endAddr - t->range[unit]->startAddr);
- } else {
- assert(!t->range[0]);
- }
- }
- }
-
- fprintf( stderr,
- "totalFree: %d totalUsed: %d totalMem: %d #objs=%d #res=%d\n",
- tss->freeTexMem[unit], totalUsed, tss->totalTexMem[unit],
- numObj, numRes );
-
- assert( totalUsed + totalFree == tss->totalTexMem[unit] );
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *block;
+ int prevStart = -1, prevEnd = -1;
+ int totalFree = 0;
+ int numObj = 0, numRes = 0;
+ int totalUsed = 0;
+
+ for (block = shared->tmFree[tmu]; block; block = block->next) {
+ assert( block->endAddr > 0 );
+ assert( block->startAddr <= shared->totalTexMem[tmu] );
+ assert( block->endAddr <= shared->totalTexMem[tmu] );
+ assert( (int) block->startAddr > prevStart );
+ assert( (int) block->startAddr >= prevEnd );
+ prevStart = (int) block->startAddr;
+ prevEnd = (int) block->endAddr;
+ totalFree += (block->endAddr - block->startAddr);
+ }
+ assert(totalFree == shared->freeTexMem[tmu]);
+
+ {
+ struct gl_texture_object *obj;
+ for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) {
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(obj);
+ numObj++;
+ if (ti) {
+ if (ti->isInTM) {
+ numRes++;
+ assert(ti->tm[0]);
+ if (ti->tm[tmu])
+ totalUsed += (ti->tm[tmu]->endAddr - ti->tm[tmu]->startAddr);
+ }
+ else {
+ assert(!ti->tm[0]);
+ }
+ }
+ }
+ }
+
+ printf("totalFree: %d totalUsed: %d totalMem: %d #objs=%d #res=%d\n",
+ shared->freeTexMem[tmu], totalUsed, shared->totalTexMem[tmu],
+ numObj, numRes);
+
+ assert(totalUsed + totalFree == shared->totalTexMem[tmu]);
}
-static void tdfxTMDumpTexMem( tdfxContextPtr fxMesa )
-{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- struct gl_texture_object *texObj;
- tdfxMemRange *r;
- FxU32 prev;
-
- printf( "DUMP Objects:\n" );
- for ( texObj = ss->TexObjectList ; texObj ; texObj = texObj->Next ) {
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
-
- if ( t && t->isInTM ) {
- printf( "Obj %8p: %4d info = %p\n", texObj, texObj->Name, t );
-
- printf( " isInTM=%d whichTMU=%ld lastTimeUsed=%d\n",
- t->isInTM, t->whichTMU, t->lastTimeUsed );
- printf( " tm[0] = %p", t->range[0] );
- assert( t->range[0] );
- if ( t->range[0] ) {
- printf( " tm startAddr = %ld endAddr = %ld",
- t->range[0]->startAddr,
- t->range[0]->endAddr );
- }
- printf( "\n" );
- printf( " tm[1] = %p", t->range[1] );
- if ( t->range[1] ) {
- printf( " tm startAddr = %ld endAddr = %ld",
- t->range[1]->startAddr,
- t->range[1]->endAddr );
- }
- printf( "\n" );
- }
- }
-
- tdfxTMVerifyFreeList( fxMesa, 0 );
- tdfxTMVerifyFreeList( fxMesa, 1 );
- printf( "Free memory unit 0: %d bytes\n", tss->freeTexMem[0] );
- prev = 0;
- for ( r = tss->freeRanges[0] ; r ; r = r->next ) {
- printf( "%8p: start %8ld end %8ld size %8ld gap %8ld\n",
- r, r->startAddr, r->endAddr, r->endAddr - r->startAddr,
- r->startAddr - prev );
- prev = r->endAddr;
- }
+static void
+dump_texmem(tdfxContextPtr fxMesa)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ struct gl_texture_object *oldestObj, *obj, *lowestPriorityObj;
+ tdfxMemRange *r;
+ FxU32 prev;
+
+ printf("DUMP Objects:\n");
+ for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) {
+ tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj);
+
+ if (info && info->isInTM) {
+ printf("Obj %8p: %4d info = %p\n", obj, obj->Name, info);
+
+ printf(" isInTM=%d whichTMU=%d lastTimeUsed=%d\n",
+ info->isInTM, info->whichTMU, info->lastTimeUsed);
+ printf(" tm[0] = %p", info->tm[0]);
+ assert(info->tm[0]);
+ if (info->tm[0]) {
+ printf(" tm startAddr = %d endAddr = %d",
+ info->tm[0]->startAddr,
+ info->tm[0]->endAddr);
+ }
+ printf("\n");
+ printf(" tm[1] = %p", info->tm[1]);
+ if (info->tm[1]) {
+ printf(" tm startAddr = %d endAddr = %d",
+ info->tm[1]->startAddr,
+ info->tm[1]->endAddr);
+ }
+ printf("\n");
+ }
+ }
+
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+
+ printf("Free memory unit 0: %d bytes\n", shared->freeTexMem[0]);
+ prev = 0;
+ for (r = shared->tmFree[0]; r; r = r->next) {
+ printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev);
+ prev = r->endAddr;
+ }
+
+ printf("Free memory unit 1: %d bytes\n", shared->freeTexMem[1]);
+ prev = 0;
+ for (r = shared->tmFree[1]; r; r = r->next) {
+ printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev);
+ prev = r->endAddr;
+ }
- printf( "Free memory unit 1: %d bytes\n", tss->freeTexMem[1] );
- prev = 0;
- for ( r = tss->freeRanges[1] ; r ; r = r->next ) {
- printf( "%8p: start %8ld end %8ld size %8ld gap %8ld\n",
- r, r->startAddr, r->endAddr, r->endAddr - r->startAddr,
- r->startAddr - prev );
- prev = r->endAddr;
- }
}
+#endif
+
#ifdef TEXSANITY
-static void fubar( void )
+static void
+fubar(void)
{
- /* GH: What am I meant to do??? */
}
-/* Sanity Check
+/*
+ * Sanity Check
*/
-static void sanity( tdfxContextPtr fxMesa )
+static void
+sanity(tdfxContextPtr fxMesa)
{
- tdfxMemRange *tmp, *prev, *pos;
-
- prev = 0;
- tmp = fxMesa->freeRanges[0];
- while ( tmp ) {
- if ( !tmp->startAddr && !tmp->endAddr ) {
- fprintf( stderr, "Textures fubar\n" );
- fubar();
- }
- if ( tmp->startAddr >= tmp->endAddr ) {
- fprintf( stderr, "Node fubar\n" );
- fubar();
- }
- if ( prev && ( prev->startAddr >= tmp->startAddr ||
- prev->endAddr > tmp->startAddr ) ) {
- fprintf( stderr, "Sorting fubar\n" );
- fubar();
- }
- prev = tmp;
- tmp = tmp->next;
- }
-
- prev = 0;
- tmp = fxMesa->freeRanges[1];
- while ( tmp ) {
- if ( !tmp->startAddr && !tmp->endAddr ) {
- fprintf( stderr, "Textures fubar\n" );
- fubar();
- }
- if ( tmp->startAddr >= tmp->endAddr ) {
- fprintf( stderr, "Node fubar\n" );
- fubar();
- }
- if ( prev && ( prev->startAddr >= tmp->startAddr ||
- prev->endAddr > tmp->startAddr ) ) {
- fprintf( stderr, "Sorting fubar\n" );
- fubar();
- }
- prev = tmp;
- tmp = tmp->next;
- }
+ tdfxMemRange *tmp, *prev, *pos;
+
+ prev = 0;
+ tmp = fxMesa->tmFree[0];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ prev = 0;
+ tmp = fxMesa->tmFree[1];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
}
#endif
-/* Allocate and initialize a new MemRange struct. Try to allocate it
- * from the pool of free MemRange nodes rather than malloc.
- */
-static tdfxMemRange *
-tdfxTMNewRangeNode( tdfxContextPtr fxMesa, FxU32 start, FxU32 end )
-{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- tdfxMemRange *range;
-
- _glthread_LOCK_MUTEX( ss->Mutex );
- if ( tss && tss->rangePool ) {
- range = tss->rangePool;
- tss->rangePool = tss->rangePool->next;
- } else {
- range = MALLOC( sizeof(tdfxMemRange) );
- }
- _glthread_UNLOCK_MUTEX( ss->Mutex );
- if ( !range ) {
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, __FUNCTION__ ": out of memory!\n" );
- return NULL;
- }
- range->startAddr = start;
- range->endAddr = end;
- range->next = NULL;
- return range;
+/*
+ * Allocate and initialize a new MemRange struct.
+ * Try to allocate it from the pool of free MemRange nodes rather than malloc.
+ */
+static tdfxMemRange *
+NewRangeNode(tdfxContextPtr fxMesa, FxU32 start, FxU32 end)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *result;
+
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ if (shared && shared->tmPool) {
+ result = shared->tmPool;
+ shared->tmPool = shared->tmPool->next;
+ }
+ else {
+ result = MALLOC(sizeof(tdfxMemRange));
+
+ }
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+
+ if (!result) {
+ /*fprintf(stderr, "fxDriver: out of memory!\n");*/
+ return NULL;
+ }
+
+ result->startAddr = start;
+ result->endAddr = end;
+ result->next = NULL;
+
+ return result;
}
-/* Initialize texture memory. We take care of one or both TMU's here.
+/*
+ * Initialize texture memory.
+ * We take care of one or both TMU's here.
*/
-void tdfxTMInit( tdfxContextPtr fxMesa )
+void
+tdfxTMInit(tdfxContextPtr fxMesa)
{
- GLcontext *ctx = fxMesa->glCtx;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, __FUNCTION__ "\n" );
-
- if ( !ctx->Shared->DriverData ) {
- const char *extensions;
- tdfxSharedStatePtr tss = CALLOC_STRUCT( tdfx_shared_state );
-
- if ( !tss )
- return;
-
- LOCK_HARDWARE( fxMesa );
-
- extensions = fxMesa->Glide.grGetString( GR_EXTENSION );
-
- if ( strstr( extensions, " TEXUMA " ) ) {
- FxU32 start, end;
-
- tss->umaTexMemory = GL_TRUE;
-
- fxMesa->Glide.grEnable( GR_TEXTURE_UMA_EXT );
-
- start = fxMesa->Glide.grTexMinAddress( 0 );
- end = fxMesa->Glide.grTexMaxAddress( 0 );
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, " UMA tex memory: %d\n", (int)(end - start) );
-
- tss->totalTexMem[0] = end - start;
- tss->totalTexMem[1] = 0;
- tss->freeTexMem[0] = end - start;
- tss->freeTexMem[1] = 0;
- tss->freeRanges[0] = tdfxTMNewRangeNode( fxMesa, start, end );
- tss->freeRanges[1] = NULL;
- } else {
- int unit;
-
- tss->umaTexMemory = GL_FALSE;
-
- for ( unit = 0 ; unit < fxMesa->numTMUs ; unit++ ) {
- FxU32 start, end;
-
- start = fxMesa->Glide.grTexMinAddress( unit );
- end = fxMesa->Glide.grTexMaxAddress( unit );
-
- tss->totalTexMem[unit] = end - start;
- tss->freeTexMem[unit] = end - start;
- tss->freeRanges[unit] = tdfxTMNewRangeNode( fxMesa, start, end );
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, " Split tex memory: %d\n",
- (int)(end - start) );
- }
- }
-
- UNLOCK_HARDWARE( fxMesa );
-
- tss->rangePool = NULL;
- ctx->Shared->DriverData = tss;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, " init UMA: %d\n", tss->umaTexMemory );
- }
+ if (!fxMesa->glCtx->Shared->DriverData) {
+ const char *extensions;
+ struct tdfxSharedState *shared = CALLOC_STRUCT(tdfxSharedState);
+ if (!shared)
+ return;
+
+ LOCK_HARDWARE(fxMesa);
+ extensions = fxMesa->Glide.grGetString(GR_EXTENSION);
+ UNLOCK_HARDWARE(fxMesa);
+ if (strstr(extensions, "TEXUMA")) {
+ FxU32 start, end;
+ shared->umaTexMemory = GL_TRUE;
+ LOCK_HARDWARE(fxMesa);
+ fxMesa->Glide.grEnable(GR_TEXTURE_UMA_EXT);
+ start = fxMesa->Glide.grTexMinAddress(0);
+ end = fxMesa->Glide.grTexMaxAddress(0);
+ UNLOCK_HARDWARE(fxMesa);
+ shared->totalTexMem[0] = end - start;
+ shared->totalTexMem[1] = 0;
+ shared->freeTexMem[0] = end - start;
+ shared->freeTexMem[1] = 0;
+ shared->tmFree[0] = NewRangeNode(fxMesa, start, end);
+ shared->tmFree[1] = NULL;
+ /*printf("UMA tex memory: %d\n", (int) (end - start));*/
+ }
+ else {
+ const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+ int tmu;
+ shared->umaTexMemory = GL_FALSE;
+ LOCK_HARDWARE(fxMesa);
+ for (tmu = 0; tmu < numTMUs; tmu++) {
+ FxU32 start = fxMesa->Glide.grTexMinAddress(tmu);
+ FxU32 end = fxMesa->Glide.grTexMaxAddress(tmu);
+ shared->totalTexMem[tmu] = end - start;
+ shared->freeTexMem[tmu] = end - start;
+ shared->tmFree[tmu] = NewRangeNode(fxMesa, start, end);
+ /*printf("Split tex memory: %d\n", (int) (end - start));*/
+ }
+ UNLOCK_HARDWARE(fxMesa);
+ }
+
+ shared->tmPool = NULL;
+ fxMesa->glCtx->Shared->DriverData = shared;
+ /*printf("Texture memory init UMA: %d\n", shared->umaTexMemory);*/
+ }
}
-/* Clean-up texture memory before destroying context.
+/*
+ * Clean-up texture memory before destroying context.
*/
-void tdfxTMClose( tdfxContextPtr fxMesa )
+void
+tdfxTMClose(tdfxContextPtr fxMesa)
{
- GLcontext *ctx = fxMesa->glCtx;
-
- if ( ctx->Shared->RefCount == 1 && fxMesa->driDrawable ) {
- /* RefCount will soon go to zero, free our 3dfx stuff */
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ctx->Shared->DriverData;
- int unit;
- tdfxMemRange *tmp, *next;
-
- /* Deallocate the pool of free tdfxMemRange nodes */
- tmp = tss->rangePool;
- while ( tmp ) {
- next = tmp->next;
- FREE( tmp );
- tmp = next;
- }
-
- /* Delete the texture memory block tdfxMemRange nodes */
- for ( unit = 0 ; unit < fxMesa->numTMUs ; unit++ ) {
- tmp = tss->freeRanges[unit];
- while ( tmp ) {
- next = tmp->next;
- FREE( tmp );
- tmp = next;
- }
- }
-
- FREE( tss );
- ctx->Shared->DriverData = NULL;
- }
+ if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
+ /* refcount will soon go to zero, free our 3dfx stuff */
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+
+ const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+ int tmu;
+ tdfxMemRange *tmp, *next;
+
+ /* Deallocate the pool of free tdfxMemRange nodes */
+ tmp = shared->tmPool;
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+
+ /* Delete the texture memory block tdfxMemRange nodes */
+ for (tmu = 0; tmu < numTMUs; tmu++) {
+ tmp = shared->tmFree[tmu];
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ }
+
+ FREE(shared);
+ fxMesa->glCtx->Shared->DriverData = NULL;
+ }
}
-/* Delete a tdfxMemRange struct.
+/*
+ * Delete a tdfxMemRange struct.
* We keep a linked list of free/available tdfxMemRange structs to
* avoid extra malloc/free calls.
*/
-#define DELETE_RANGE_NODE( tss, range ) \
-do { \
- (range)->next = (tss)->rangePool; \
- (tss)->rangePool = (range); \
-} while (0)
+#if 0
+static void
+DeleteRangeNode_NoLock(struct TdfxSharedState *shared, tdfxMemRange *range)
+{
+ /* insert at head of list */
+ range->next = shared->tmPool;
+ shared->tmPool = range;
+}
+#endif
+
+#define DELETE_RANGE_NODE(shared, range) \
+ (range)->next = (shared)->tmPool; \
+ (shared)->tmPool = (range)
+
-/* When we've run out of texture memory we have to throw out an
+
+/*
+ * When we've run out of texture memory we have to throw out an
* existing texture to make room for the new one. This function
* determins the texture to throw out.
*/
static struct gl_texture_object *
-tdfxTMFindOldestObject( tdfxContextPtr fxMesa, FxU32 unit )
+FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu)
{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- const GLuint bindNumber = fxMesa->texBindNumber;
- struct gl_texture_object *oldestObj, *texObj, *lowestPriorityObj;
- GLfloat lowestPriority;
- GLuint oldestAge;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, __FUNCTION__ "\n" );
-
- oldestObj = NULL;
- oldestAge = 0;
-
- lowestPriority = 1.0F;
- lowestPriorityObj = NULL;
-
- for ( texObj = ss->TexObjectList ; texObj ; texObj = texObj->Next ) {
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(texObj);
-
- if ( t && t->isInTM &&
- ( ( t->whichTMU == unit ) ||
- ( t->whichTMU == TDFX_TMU_BOTH ) ||
- ( t->whichTMU == TDFX_TMU_SPLIT ) ) ) {
- GLuint age, lastTime;
-
- assert( t->range[0] );
- lastTime = t->lastTimeUsed;
-
- if ( lastTime > bindNumber ) {
- /* TODO: check wrap around */
- age = bindNumber + (UINT_MAX - lastTime + 1);
- } else {
- age = bindNumber - lastTime;
- }
- if ( age >= oldestAge ) {
- oldestAge = age;
- oldestObj = texObj;
- }
+ const GLuint bindnumber = fxMesa->texBindNumber;
+ struct gl_texture_object *oldestObj, *obj, *lowestPriorityObj;
+ GLfloat lowestPriority;
+ GLuint oldestAge;
+
+ oldestObj = NULL;
+ oldestAge = 0;
+
+ lowestPriority = 1.0F;
+ lowestPriorityObj = NULL;
+
+ for (obj = fxMesa->glCtx->Shared->TexObjectList; obj; obj = obj->Next) {
+ tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj);
+
+ if (info && info->isInTM &&
+ ((info->whichTMU == tmu) || (info->whichTMU == TDFX_TMU_BOTH) ||
+ (info->whichTMU == TDFX_TMU_SPLIT))) {
+ GLuint age, lasttime;
+
+ assert(info->tm[0]);
+ lasttime = info->lastTimeUsed;
+
+ if (lasttime > bindnumber)
+ age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
+ else
+ age = bindnumber - lasttime;
+
+ if (age >= oldestAge) {
+ oldestAge = age;
+ oldestObj = obj;
+ }
+
+ /* examine priority */
+ if (obj->Priority < lowestPriority) {
+ lowestPriority = obj->Priority;
+ lowestPriorityObj = obj;
+ }
+ }
+ }
+
+ if (lowestPriority < 1.0) {
+ ASSERT(lowestPriorityObj);
+ /*
+ printf("discard %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
+ */
+ return lowestPriorityObj;
+ }
+ else {
+ /*
+ printf("discard %d age=%d\n", oldestObj->Name, oldestAge);
+ */
+ return oldestObj;
+ }
+}
- /* examine priority */
- if ( texObj->Priority < lowestPriority ) {
- lowestPriority = texObj->Priority;
- lowestPriorityObj = texObj;
- }
- }
- }
- if ( lowestPriority < 1.0 ) {
- ASSERT( lowestPriorityObj );
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, "discard %d pri=%f\n",
- lowestPriorityObj->Name, lowestPriority );
- return lowestPriorityObj;
- } else {
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE )
- fprintf( stderr, "discard %d age=%d\n",
- oldestObj->Name, oldestAge );
- return oldestObj;
- }
+#if 0
+static void
+FlushTexMemory(tdfxContextPtr fxMesa)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ struct gl_texture_object *obj;
+
+ for (obj = mesaShared->TexObjectList; obj; obj = obj->Next) {
+ if (obj->RefCount < 2) {
+ /* don't flush currently bound textures */
+ tdfxTMMoveOutTM_NoLock(fxMesa, obj);
+ }
+ }
}
+#endif
-/* Find the address (offset?) at which we can store a new texture.
- * <unit> is the texture unit.
+/*
+ * Find the address (offset?) at which we can store a new texture.
+ * <tmu> is the texture unit.
* <size> is the texture size in bytes.
*/
-static FxU32 tdfxTMFindStartAddr( tdfxContextPtr fxMesa,
- FxU32 unit, FxU32 size )
+static FxU32
+FindStartAddr(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 size)
{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- struct gl_texture_object *texObj;
- tdfxMemRange *prev, *block;
- FxU32 result;
-
- if ( tss->umaTexMemory ) {
- assert( unit == TDFX_TMU0 );
- }
-
- _glthread_LOCK_MUTEX( ss->Mutex );
- while ( 1 ) {
- prev = NULL;
- block = tss->freeRanges[unit];
-
- while ( block ) {
- if ( block->endAddr - block->startAddr >= size ) {
- /* The texture will fit here */
- result = block->startAddr;
- block->startAddr += size;
- if ( block->startAddr == block->endAddr ) {
- /* Remove this node since it's empty */
- if ( prev ) {
- prev->next = block->next;
- } else {
- tss->freeRanges[unit] = block->next;
- }
- DELETE_RANGE_NODE( tss, block );
- }
- tss->freeTexMem[unit] -= size;
- _glthread_UNLOCK_MUTEX( ss->Mutex );
- return result;
- }
- prev = block;
- block = block->next;
- }
-
- /* We failed to find a block large enough to accomodate <size> bytes.
- * Find the oldest texObject and free it.
- */
- texObj = tdfxTMFindOldestObject( fxMesa, unit );
- if ( texObj ) {
- tdfxTMMoveOutTMLocked( fxMesa, texObj );
- fxMesa->stats.texSwaps++;
- } else {
- gl_problem( NULL, "tdfx driver: extreme texmem fragmentation" );
- _glthread_UNLOCK_MUTEX( ss->Mutex );
- return BAD_ADDRESS;
- }
- }
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *prev, *block;
+ FxU32 result;
+#if 0
+ int discardedCount = 0;
+#define MAX_DISCARDS 10
+#endif
- /* never get here, but play it safe */
- _glthread_UNLOCK_MUTEX( ss->Mutex );
- return BAD_ADDRESS;
+ if (shared->umaTexMemory) {
+ assert(tmu == TDFX_TMU0);
+ }
+
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ while (1) {
+ prev = NULL;
+ block = shared->tmFree[tmu];
+ while (block) {
+ if (block->endAddr - block->startAddr >= size) {
+ /* The texture will fit here */
+ result = block->startAddr;
+ block->startAddr += size;
+ if (block->startAddr == block->endAddr) {
+ /* Remove this node since it's empty */
+ if (prev) {
+ prev->next = block->next;
+ }
+ else {
+ shared->tmFree[tmu] = block->next;
+ }
+ DELETE_RANGE_NODE(shared, block);
+ }
+ shared->freeTexMem[tmu] -= size;
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return result;
+ }
+ prev = block;
+ block = block->next;
+ }
+ /* We failed to find a block large enough to accomodate <size> bytes.
+ * Find the oldest texObject and free it.
+ */
+#if 0
+ discardedCount++;
+ if (discardedCount > MAX_DISCARDS + 1) {
+ _mesa_problem(NULL, "tdfx driver: extreme texmem fragmentation");
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
+ }
+ else if (discardedCount > MAX_DISCARDS) {
+ /* texture memory is probably really fragmented, flush it */
+ FlushTexMemory(fxMesa);
+ }
+ else
+#endif
+ {
+ struct gl_texture_object *obj = FindOldestObject(fxMesa, tmu);
+ if (obj) {
+ tdfxTMMoveOutTM_NoLock(fxMesa, obj);
+ fxMesa->stats.texSwaps++;
+ }
+ else {
+ _mesa_problem(NULL, "tdfx driver: extreme texmem fragmentation");
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
+ }
+ }
+ }
+
+ /* never get here, but play it safe */
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
}
-/* Remove the given tdfxMemRange node from hardware texture memory.
+/*
+ * Remove the given tdfxMemRange node from hardware texture memory.
*/
-static void tdfxTMRemoveRangeLocked( tdfxContextPtr fxMesa,
- FxU32 unit, tdfxMemRange *range )
+static void
+RemoveRange_NoLock(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range)
{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- tdfxMemRange *block, *prev;
-
- if ( tss->umaTexMemory ) {
- assert( unit == TDFX_TMU0 );
- }
-
- if ( !range )
- return;
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *block, *prev;
+
+ if (shared->umaTexMemory) {
+ assert(tmu == TDFX_TMU0);
+ }
+
+ if (!range)
+ return;
+
+ if (range->startAddr == range->endAddr) {
+ DELETE_RANGE_NODE(shared, range);
+ return;
+ }
+ shared->freeTexMem[tmu] += range->endAddr - range->startAddr;
+
+ /* find position in linked list to insert this tdfxMemRange node */
+ prev = NULL;
+ block = shared->tmFree[tmu];
+ while (block) {
+ assert(range->startAddr != block->startAddr);
+ if (range->startAddr > block->startAddr) {
+ prev = block;
+ block = block->next;
+ }
+ else {
+ break;
+ }
+ }
+
+ /* Insert the free block, combine with adjacent blocks when possible */
+ range->next = block;
+ if (block) {
+ if (range->endAddr == block->startAddr) {
+ /* Combine */
+ block->startAddr = range->startAddr;
+ DELETE_RANGE_NODE(shared, range);
+ range = block;
+ }
+ }
+ if (prev) {
+ if (prev->endAddr == range->startAddr) {
+ /* Combine */
+ prev->endAddr = range->endAddr;
+ prev->next = range->next;
+ DELETE_RANGE_NODE(shared, range);
+ }
+ else {
+ prev->next = range;
+ }
+ }
+ else {
+ shared->tmFree[tmu] = range;
+ }
+}
- if ( range->startAddr == range->endAddr ) {
- DELETE_RANGE_NODE( tss, range );
- return;
- }
- tss->freeTexMem[unit] += range->endAddr - range->startAddr;
-
- /* find position in linked list to insert this tdfxMemRange node */
- prev = NULL;
- block = tss->freeRanges[unit];
- while ( block ) {
- assert( range->startAddr != block->startAddr );
- if ( range->startAddr > block->startAddr ) {
- prev = block;
- block = block->next;
- } else {
- break;
- }
- }
- /* Insert the free block, combine with adjacent blocks when possible */
- range->next = block;
- if ( block ) {
- if ( range->endAddr == block->startAddr ) {
- /* Combine */
- block->startAddr = range->startAddr;
- DELETE_RANGE_NODE( tss, range );
- range = block;
- }
- }
- if ( prev ) {
- if ( prev->endAddr == range->startAddr ) {
- /* Combine */
- prev->endAddr = range->endAddr;
- prev->next = range->next;
- DELETE_RANGE_NODE( tss, range );
- } else {
- prev->next = range;
- }
- } else {
- tss->freeRanges[unit] = range;
- }
+#if 0 /* NOT USED */
+static void
+RemoveRange(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ RemoveRange_NoLock(fxMesa, tmu, range);
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
}
+#endif
-/* Allocate space for a texture image.
+/*
+ * Allocate space for a texture image.
* <tmu> is the texture unit
* <texmemsize> is the number of bytes to allocate
*/
static tdfxMemRange *
-tdfxTMAllocTexMem( tdfxContextPtr fxMesa, FxU32 unit, FxU32 size )
+AllocTexMem(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 texmemsize)
{
- tdfxMemRange *range = NULL;
- FxU32 start;
-
- start = tdfxTMFindStartAddr( fxMesa, unit, size );
-
- if ( start != BAD_ADDRESS ) {
- range = tdfxTMNewRangeNode( fxMesa, start, start + size );
- } else {
- fprintf( stderr,
- "tdfxTMAllocTexMem returned NULL! unit=%ld size=%ld\n",
- unit, size );
- }
- return range;
+ FxU32 startAddr;
+ startAddr = FindStartAddr(fxMesa, tmu, texmemsize);
+ if (startAddr == BAD_ADDRESS) {
+ char err[100];
+ sprintf(err, "AllocTexMem returned NULL! tmu=%d texmemsize=%d\n",
+ (int) tmu, (int) texmemsize);
+ _mesa_problem(fxMesa->glCtx, err);
+ return NULL;
+ }
+ else {
+ tdfxMemRange *range;
+ range = NewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
+ return range;
+ }
}
-/* Download (copy) the given texture data (all mipmap levels) into the
- * Voodoo's texture memory. The texture memory must have already been
- * allocated.
+/*
+ * Download (copy) the given texture data (all mipmap levels) into the
+ * Voodoo's texture memory.
+ * The texture memory must have already been allocated.
*/
-void tdfxTMDownloadTextureLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj )
+void
+tdfxTMDownloadTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
{
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- FxU32 targetTMU;
- GLint l;
-
- assert( tObj );
- assert( t );
-
- targetTMU = t->whichTMU;
-
- switch ( targetTMU ) {
- case TDFX_TMU0:
- case TDFX_TMU1:
- if ( t->range[targetTMU] ) {
- for ( l = t->minLevel ; l <= t->maxLevel && t->image[l].data ; l++ ) {
- GrLOD_t glideLod = t->info.largeLodLog2 - l + tObj->BaseLevel;
-
- fxMesa->Glide.grTexDownloadMipMapLevel( targetTMU,
- t->range[targetTMU]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[l].data );
- }
- }
- break;
-
- case TDFX_TMU_SPLIT:
- if ( t->range[TDFX_TMU0] && t->range[TDFX_TMU1] ) {
- for ( l = t->minLevel ; l <= t->maxLevel && t->image[l].data ; l++ ) {
- GrLOD_t glideLod = t->info.largeLodLog2 - l + tObj->BaseLevel;
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU0,
- t->range[TDFX_TMU0]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- t->image[l].data );
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU1,
- t->range[TDFX_TMU1]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- t->image[l].data );
- }
- }
- break;
-
- case TDFX_TMU_BOTH:
- if ( t->range[TDFX_TMU0] && t->range[TDFX_TMU1] ) {
- for ( l = t->minLevel ; l <= t->maxLevel && t->image[l].data ; l++ ) {
- GrLOD_t glideLod = t->info.largeLodLog2 - l + tObj->BaseLevel;
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU0,
- t->range[TDFX_TMU0]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[l].data );
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU1,
- t->range[TDFX_TMU1]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[l].data );
- }
- }
- break;
-
- default:
- gl_problem( NULL, "error in tdfxTMDownloadTexture: bad unit" );
- return;
- }
+ tdfxTexInfo *ti;
+ GLint l;
+ FxU32 targetTMU;
+
+ assert(tObj);
+ ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
+ targetTMU = ti->whichTMU;
+
+ switch (targetTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ if (ti->tm[targetTMU]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(targetTMU,
+ ti->tm[targetTMU]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[l]->Data);
+ }
+ }
+ break;
+ case TDFX_TMU_SPLIT:
+ if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[TDFX_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ tObj->Image[l]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[TDFX_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ tObj->Image[l]->Data);
+ }
+ }
+ break;
+ case TDFX_TMU_BOTH:
+ if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[TDFX_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[l]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[TDFX_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[l]->Data);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "error in tdfxTMDownloadTexture: bad tmu");
+ return;
+ }
}
-void tdfxTMReloadMipMapLevelLocked( GLcontext *ctx,
- struct gl_texture_object *tObj,
- GLint level )
+void
+tdfxTMReloadMipMapLevel(GLcontext *ctx, struct gl_texture_object *tObj,
+ GLint level)
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- GrLOD_t glideLod;
- FxU32 unit;
-
- ASSERT( t->isInTM );
-
- unit = t->whichTMU;
- glideLod = t->info.largeLodLog2 - level + tObj->BaseLevel;
-
- switch ( unit ) {
- case TDFX_TMU0:
- case TDFX_TMU1:
- fxMesa->Glide.grTexDownloadMipMapLevel( unit,
- t->range[unit]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[level].data );
- break;
-
- case TDFX_TMU_SPLIT:
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU0,
- t->range[GR_TMU0]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_ODD,
- t->image[level].data );
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU1,
- t->range[GR_TMU1]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_EVEN,
- t->image[level].data );
- break;
-
- case TDFX_TMU_BOTH:
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU0,
- t->range[GR_TMU0]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[level].data );
-
- fxMesa->Glide.grTexDownloadMipMapLevel( GR_TMU1,
- t->range[GR_TMU1]->startAddr,
- glideLod,
- t->info.largeLodLog2,
- t->info.aspectRatioLog2,
- t->info.format,
- GR_MIPMAPLEVELMASK_BOTH,
- t->image[level].data );
- break;
-
- default:
- gl_problem( ctx, "error in tdfxTMReloadMipMapLevel(): wrong unit" );
- break;
- }
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ GrLOD_t glideLod;
+ FxU32 tmu;
+
+ tmu = ti->whichTMU;
+ glideLod = ti->info.largeLodLog2 - level + tObj->BaseLevel;
+ ASSERT(ti->isInTM);
+
+ LOCK_HARDWARE(fxMesa);
+
+ switch (tmu) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ fxMesa->Glide.grTexDownloadMipMapLevel(tmu,
+ ti->tm[tmu]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[level]->Data);
+ break;
+ case TDFX_TMU_SPLIT:
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ tObj->Image[level]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ tObj->Image[level]->Data);
+ break;
+ case TDFX_TMU_BOTH:
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[level]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[level]->Data);
+ break;
+
+ default:
+ _mesa_problem(ctx, "error in tdfxTMReloadMipMapLevel(): wrong tmu");
+ break;
+ }
+ UNLOCK_HARDWARE(fxMesa);
}
-/* Allocate space for the given texture in texture memory then
+/*
+ * Allocate space for the given texture in texture memory then
* download (copy) it into that space.
*/
-void tdfxTMMoveInTMLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj, FxU32 targetTMU )
+void
+tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj,
+ FxU32 targetTMU )
{
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
- FxU32 size;
-
- fxMesa->stats.reqTexUpload++;
-
- if ( t->isInTM ) {
- if ( t->whichTMU == targetTMU )
- return;
-
- if ( targetTMU == TDFX_TMU_SPLIT || t->whichTMU == TDFX_TMU_SPLIT ) {
- tdfxTMMoveOutTMLocked( fxMesa, tObj );
- } else {
- if ( t->whichTMU == TDFX_TMU_BOTH )
- return;
- targetTMU = TDFX_TMU_BOTH;
- }
- }
-
- t->whichTMU = targetTMU;
-
- switch ( targetTMU ) {
- case TDFX_TMU0:
- case TDFX_TMU1:
- size = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &t->info );
- t->range[targetTMU] = tdfxTMAllocTexMem(fxMesa, targetTMU, size);
- break;
-
- case TDFX_TMU_SPLIT:
- size = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_ODD, &t->info );
- t->range[TDFX_TMU0] = tdfxTMAllocTexMem( fxMesa, TDFX_TMU0, size );
- if ( t->range[TDFX_TMU0] )
- fxMesa->stats.memTexUpload += size;
-
- size = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_EVEN, &t->info );
- t->range[TDFX_TMU1] = tdfxTMAllocTexMem( fxMesa, TDFX_TMU1, size );
- break;
-
- case TDFX_TMU_BOTH:
- size = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &t->info );
- t->range[TDFX_TMU0] = tdfxTMAllocTexMem( fxMesa, TDFX_TMU0, size );
- if ( t->range[TDFX_TMU0] )
- fxMesa->stats.memTexUpload += size;
-
- size = fxMesa->Glide.grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &t->info );
- t->range[TDFX_TMU1] = tdfxTMAllocTexMem( fxMesa, TDFX_TMU1, size );
- break;
-
- default:
- gl_problem( NULL, "error in tdfxTMMoveInTM() -> bad unit (%d)" );
- return;
- }
-
- t->reloadImages = GL_TRUE;
- t->isInTM = GL_TRUE;
-
- fxMesa->stats.texUpload++;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ FxU32 texmemsize;
+
+ fxMesa->stats.reqTexUpload++;
+
+ if (ti->isInTM) {
+ if (ti->whichTMU == targetTMU)
+ return;
+ if (targetTMU == TDFX_TMU_SPLIT || ti->whichTMU == TDFX_TMU_SPLIT) {
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ }
+ else {
+ if (ti->whichTMU == TDFX_TMU_BOTH)
+ return;
+ targetTMU = TDFX_TMU_BOTH;
+ }
+ }
+
+ ti->whichTMU = targetTMU;
+
+ switch (targetTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[targetTMU] = AllocTexMem(fxMesa, targetTMU, texmemsize);
+ break;
+ case TDFX_TMU_SPLIT:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD,
+ &(ti->info));
+ ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize);
+ if (ti->tm[TDFX_TMU0])
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN,
+ &(ti->info));
+ ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize);
+ break;
+ case TDFX_TMU_BOTH:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize);
+ if (ti->tm[TDFX_TMU0])
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize);
+ break;
+ default:
+ _mesa_problem(NULL, "error in tdfxTMMoveInTM() -> bad tmu (%d)");
+ return;
+ }
+
+ ti->reloadImages = GL_TRUE;
+ ti->isInTM = GL_TRUE;
+
+ fxMesa->stats.texUpload++;
}
-/* Move the given texture out of hardware texture memory.
+/*
+ * Move the given texture out of hardware texture memory.
* This deallocates the texture's memory space.
*/
-void tdfxTMMoveOutTMLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj )
+void
+tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj )
{
- struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- fprintf( stderr, __FUNCTION__ "( %p (%d) )\n", tObj, tObj->Name );
- tdfxTMVerifyFreeList( fxMesa, 0 );
- tdfxTMVerifyFreeList( fxMesa, 1 );
- }
-
- if ( !t || !t->isInTM )
- return;
-
- switch ( t->whichTMU ) {
- case TDFX_TMU0:
- case TDFX_TMU1:
- tdfxTMRemoveRangeLocked( fxMesa, t->whichTMU, t->range[t->whichTMU] );
- break;
-
- case TDFX_TMU_SPLIT:
- case TDFX_TMU_BOTH:
- assert( !tss->umaTexMemory );
- tdfxTMRemoveRangeLocked( fxMesa, TDFX_TMU0, t->range[TDFX_TMU0] );
- tdfxTMRemoveRangeLocked( fxMesa, TDFX_TMU1, t->range[TDFX_TMU1] );
- break;
-
- default:
- gl_problem( NULL, "tdfx driver: bad unit in tdfxTMMOveOutTM()" );
- return;
- }
-
- t->isInTM = GL_FALSE;
- t->range[0] = NULL;
- t->range[1] = NULL;
- t->whichTMU = TDFX_TMU_NONE;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- tdfxTMVerifyFreeList( fxMesa, 0 );
- tdfxTMVerifyFreeList( fxMesa, 1 );
- }
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxTMMoveOutTM(%p (%d))\n", tObj, tObj->Name);
+ }
+
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
+
+ if (!ti || !ti->isInTM)
+ return;
+
+ switch (ti->whichTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ RemoveRange_NoLock(fxMesa, ti->whichTMU, ti->tm[ti->whichTMU]);
+ break;
+ case TDFX_TMU_SPLIT:
+ case TDFX_TMU_BOTH:
+ assert(!shared->umaTexMemory);
+ RemoveRange_NoLock(fxMesa, TDFX_TMU0, ti->tm[TDFX_TMU0]);
+ RemoveRange_NoLock(fxMesa, TDFX_TMU1, ti->tm[TDFX_TMU1]);
+ break;
+ default:
+ _mesa_problem(NULL, "tdfx driver: bad tmu in tdfxTMMOveOutTM()");
+ return;
+ }
+
+ ti->isInTM = GL_FALSE;
+ ti->tm[0] = NULL;
+ ti->tm[1] = NULL;
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
}
-void tdfxTMFreeTextureLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj )
+/*
+ * Called via glDeleteTexture to delete a texture object.
+ */
+void
+tdfxTMFreeTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
{
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
-
- if ( t ) {
- int i;
- tdfxTMMoveOutTMLocked( fxMesa, tObj );
- for ( i = 0 ; i < MAX_TEXTURE_LEVELS ; i++ ) {
- if ( t->image[i].original.data ) FREE( t->image[i].original.data );
- if ( t->image[i].rescaled.data ) FREE( t->image[i].rescaled.data );
- }
- FREE( t );
- tObj->DriverData = NULL;
- }
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- tdfxTMVerifyFreeList( fxMesa, 0 );
- tdfxTMVerifyFreeList( fxMesa, 1 );
- }
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti) {
+ tdfxTMMoveOutTM(fxMesa, tObj);
+ FREE(ti);
+ tObj->DriverData = NULL;
+ }
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
}
-/* After a context switch this function will be called to restore
+
+/*
+ * After a context switch this function will be called to restore
* texture memory for the new context.
*/
-void tdfxTMRestoreTexturesLocked( tdfxContextPtr fxMesa )
+void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa )
{
GLcontext *ctx = fxMesa->glCtx;
struct gl_texture_object *tObj;
int i;
for ( tObj = ctx->Shared->TexObjectList ; tObj ; tObj = tObj->Next ) {
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA( tObj );
- if ( t && t->isInTM ) {
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj );
+ if ( ti && ti->isInTM ) {
for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) {
- if ( ctx->Texture.Unit[i].Current == tObj ) {
- tdfxTMDownloadTextureLocked( fxMesa, tObj );
+ if ( ctx->Texture.Unit[i]._Current == tObj ) {
+ tdfxTMDownloadTexture( fxMesa, tObj );
break;
}
}
if ( i == MAX_TEXTURE_UNITS ) {
- tdfxTMMoveOutTMLocked( fxMesa, tObj );
+ tdfxTMMoveOutTM_NoLock( fxMesa, tObj );
}
}
}
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_TEXTURE ) {
- tdfxTMVerifyFreeList( fxMesa, 0 );
- tdfxTMVerifyFreeList( fxMesa, 1 );
- }
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h
index 485d8cf3b..1965aaa84 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -38,39 +38,47 @@
#ifndef __TDFX_TEXMAN_H__
#define __TDFX_TEXMAN_H__
+
#include "tdfx_lock.h"
+
extern void tdfxTMInit( tdfxContextPtr fxMesa );
+
extern void tdfxTMClose( tdfxContextPtr fxMesa );
-extern void tdfxTMDownloadTextureLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj );
-extern void tdfxTMReloadMipMapLevelLocked( GLcontext *ctx,
- struct gl_texture_object *tObj,
- GLint level );
-extern void tdfxTMMoveInTMLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj,
- FxU32 targetTMU );
-extern void tdfxTMMoveOutTMLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj );
-extern void tdfxTMRestoreTexturesLocked( tdfxContextPtr fxMesa );
-
-extern void tdfxTMFreeTextureLocked( tdfxContextPtr fxMesa,
- struct gl_texture_object *tObj );
-
-
-#define tdfxTMMoveInTM( fxMesa, tObj, targetTMU ) \
-do { \
- LOCK_HARDWARE( fxMesa ); \
- tdfxTMMoveInTMLocked( fxMesa, tObj, targetTMU ); \
- UNLOCK_HARDWARE( fxMesa ); \
-} while (0)
-
-#define tdfxTMMoveOutTM( fxMesa, tObj ) \
-do { \
- LOCK_HARDWARE( fxMesa ); \
- tdfxTMMoveOutTMLocked( fxMesa, tObj ); \
- UNLOCK_HARDWARE( fxMesa ); \
-} while (0)
+extern void tdfxTMDownloadTexture(tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj);
+
+extern void tdfxTMReloadMipMapLevel( GLcontext *ctx,
+ struct gl_texture_object *tObj,
+ GLint level );
+
+extern void tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj,
+ FxU32 targetTMU );
+
+extern void tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj );
+
+extern void tdfxTMFreeTexture( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj );
+
+extern void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa );
+
+
+#define tdfxTMMoveInTM( fxMesa, tObj, targetTMU ) \
+ do { \
+ LOCK_HARDWARE( fxMesa ); \
+ tdfxTMMoveInTM_NoLock( fxMesa, tObj, targetTMU ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ } while (0)
+
+#define tdfxTMMoveOutTM( fxMesa, tObj ) \
+ do { \
+ LOCK_HARDWARE( fxMesa ); \
+ tdfxTMMoveOutTM_NoLock( fxMesa, tObj ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ } while (0)
+
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
index a32dd431d..ccffeff5e 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -38,6 +38,7 @@
#include "tdfx_state.h"
#include "tdfx_tex.h"
#include "tdfx_texman.h"
+#include "tdfx_texstate.h"
/* =============================================================
@@ -656,7 +657,7 @@ SetupTexEnvNapalm(GLcontext *ctx, GLboolean useIteratedRGBA,
texUnit->CombineOperandA[1],
incomingAlpha);
TEXENV_SETUP_MODE_A(Bmode_A,
- texUnit->CombineOperandA[0]);
+ texUnit->CombineOperandA[1]);
C_A = D_A = GR_CMBX_ZERO;
Cinv_A = FXTRUE;
Dinv_A = Ginv_A = FXFALSE;
@@ -751,7 +752,7 @@ SetupTexEnvNapalm(GLcontext *ctx, GLboolean useIteratedRGBA,
texUnit->CombineOperandA[2],
incomingAlpha);
Cinv_A = FXFALSE;
- D_A = GR_CMBX_ZERO;
+ D_A = GR_CMBX_B;
Dinv_A = Ginv_A = FXFALSE;
break;
default:
@@ -798,7 +799,7 @@ SetupTexEnvNapalm(GLcontext *ctx, GLboolean useIteratedRGBA,
break;
default:
- gl_problem(ctx, "Bad envMode in SetupTexEnvNapalm");
+ _mesa_problem(ctx, "Bad envMode in SetupTexEnvNapalm");
}
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV;
@@ -1008,7 +1009,7 @@ SetupSingleTexEnvVoodoo3(GLcontext *ctx, int unit,
break;
default:
- gl_problem(NULL, "bad texture env mode in SetupSingleTexEnvVoodoo3");
+ _mesa_problem(NULL, "bad texture env mode in SetupSingleTexEnvVoodoo3");
}
if (colorComb.Function != fxMesa->ColorCombine.Function ||
@@ -1250,7 +1251,7 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
fxMesa->AlphaCombine.Invert = FXFALSE;
}
else {
- /*gl_problem(ctx, "Unexpected dual texture mode encountered\n");*/
+ /*_mesa_problem(ctx, "Unexpected dual texture mode encountered\n");*/
return GL_FALSE;
}
@@ -1269,105 +1270,105 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
static void
setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
{
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
const GLcontext *ctx = fxMesa->glCtx;
- tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ctx->Shared->DriverData;
- tdfxTexObjPtr t = TDFX_TEXTURE_DATA(tObj);
/* Make sure we're not loaded incorrectly */
- if (t->isInTM && !tss->umaTexMemory) {
+ if (ti->isInTM && !shared->umaTexMemory) {
/* if doing filtering between mipmap levels, alternate mipmap levels
* must be in alternate TMUs.
*/
- if (t->LODblend) {
- if (t->whichTMU != TDFX_TMU_SPLIT)
- tdfxTMMoveOutTMLocked(fxMesa, tObj);
+ if (ti->LODblend) {
+ if (ti->whichTMU != TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
}
else {
- if (t->whichTMU == TDFX_TMU_SPLIT)
- tdfxTMMoveOutTMLocked(fxMesa, tObj);
+ if (ti->whichTMU == TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
}
}
/* Make sure we're loaded correctly */
- if (!t->isInTM) {
+ if (!ti->isInTM) {
/* Have to download the texture */
- if (tss->umaTexMemory) {
- tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU0);
+ if (shared->umaTexMemory) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
}
else {
/* Voodoo3 (split texture memory) */
- if (t->LODblend) {
- tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU_SPLIT);
+ if (ti->LODblend) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU_SPLIT);
}
else {
#if 0
/* XXX putting textures into the second memory bank when the
* first bank is full is not working at this time.
*/
- if (fxMesa->numTMUs > 1) {
- GLint memReq =
- grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &t->info );
- if (tss->freeTexMem[TDFX_TMU0] > memReq) {
- tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU0);
+ if (fxMesa->haveTwoTMUs) {
+ GLint memReq = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ if (shared->freeTexMem[TDFX_TMU0] > memReq) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
}
else {
- tdfxTMMoveInTMLocked(fxMesa, tObj, TDFX_TMU1);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1);
}
}
else
#endif
{
- tdfxTMMoveInTMLocked( fxMesa, tObj, TDFX_TMU0 );
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
}
}
}
}
- if (t->LODblend && t->whichTMU == TDFX_TMU_SPLIT) {
+ if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) {
/* mipmap levels split between texture banks */
GLint u;
- if (t->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(t->palette);
+ fxMesa->TexPalette.Data = &(ti->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
for (u = 0; u < 2; u++) {
- fxMesa->TexParams[u].sClamp = t->sClamp;
- fxMesa->TexParams[u].tClamp = t->tClamp;
- fxMesa->TexParams[u].minFilt = t->minFilt;
- fxMesa->TexParams[u].magFilt = t->magFilt;
- fxMesa->TexParams[u].mmMode = t->mmMode;
- fxMesa->TexParams[u].LODblend = t->LODblend;
+ fxMesa->TexParams[u].sClamp = ti->sClamp;
+ fxMesa->TexParams[u].tClamp = ti->tClamp;
+ fxMesa->TexParams[u].minFilt = ti->minFilt;
+ fxMesa->TexParams[u].magFilt = ti->magFilt;
+ fxMesa->TexParams[u].mmMode = ti->mmMode;
+ fxMesa->TexParams[u].LODblend = ti->LODblend;
fxMesa->TexParams[u].LodBias = ctx->Texture.Unit[u].LodBias;
}
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
- fxMesa->TexSource[0].StartAddress = t->range[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].StartAddress = ti->tm[TDFX_TMU0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
- fxMesa->TexSource[0].Info = &(t->info);
- fxMesa->TexSource[1].StartAddress = t->range[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[0].Info = &(ti->info);
+ fxMesa->TexSource[1].StartAddress = ti->tm[TDFX_TMU1]->startAddr;
fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
- fxMesa->TexSource[1].Info = &(t->info);
+ fxMesa->TexSource[1].Info = &(ti->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}
else {
FxU32 tmu;
- if (t->whichTMU == TDFX_TMU_BOTH)
+ if (ti->whichTMU == TDFX_TMU_BOTH)
tmu = TDFX_TMU0;
else
- tmu = t->whichTMU;
+ tmu = ti->whichTMU;
- if (tss->umaTexMemory) {
- assert(t->whichTMU == TDFX_TMU0);
+ if (shared->umaTexMemory) {
+ assert(ti->whichTMU == TDFX_TMU0);
assert(tmu == TDFX_TMU0);
}
- if (t->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(t->palette);
+ fxMesa->TexPalette.Data = &(ti->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
@@ -1376,18 +1377,18 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
* texture memory, so perhaps it's not a good idea.
*/
- if (fxMesa->TexParams[tmu].sClamp != t->sClamp ||
- fxMesa->TexParams[tmu].tClamp != t->tClamp ||
- fxMesa->TexParams[tmu].minFilt != t->minFilt ||
- fxMesa->TexParams[tmu].magFilt != t->magFilt ||
- fxMesa->TexParams[tmu].mmMode != t->mmMode ||
+ if (fxMesa->TexParams[tmu].sClamp != ti->sClamp ||
+ fxMesa->TexParams[tmu].tClamp != ti->tClamp ||
+ fxMesa->TexParams[tmu].minFilt != ti->minFilt ||
+ fxMesa->TexParams[tmu].magFilt != ti->magFilt ||
+ fxMesa->TexParams[tmu].mmMode != ti->mmMode ||
fxMesa->TexParams[tmu].LODblend != FXFALSE ||
fxMesa->TexParams[tmu].LodBias != ctx->Texture.Unit[tmu].LodBias) {
- fxMesa->TexParams[tmu].sClamp = t->sClamp;
- fxMesa->TexParams[tmu].tClamp = t->tClamp;
- fxMesa->TexParams[tmu].minFilt = t->minFilt;
- fxMesa->TexParams[tmu].magFilt = t->magFilt;
- fxMesa->TexParams[tmu].mmMode = t->mmMode;
+ fxMesa->TexParams[tmu].sClamp = ti->sClamp;
+ fxMesa->TexParams[tmu].tClamp = ti->tClamp;
+ fxMesa->TexParams[tmu].minFilt = ti->minFilt;
+ fxMesa->TexParams[tmu].magFilt = ti->magFilt;
+ fxMesa->TexParams[tmu].mmMode = ti->mmMode;
fxMesa->TexParams[tmu].LODblend = FXFALSE;
fxMesa->TexParams[tmu].LodBias = ctx->Texture.Unit[tmu].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
@@ -1396,16 +1397,16 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
/* Glide texture source info */
fxMesa->TexSource[0].Info = NULL;
fxMesa->TexSource[1].Info = NULL;
- if (t->range[tmu]) {
- fxMesa->TexSource[tmu].StartAddress = t->range[tmu]->startAddr;
+ if (ti->tm[tmu]) {
+ fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr;
fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu].Info = &(t->info);
+ fxMesa->TexSource[tmu].Info = &(ti->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}
}
- fxMesa->sScale0 = t->sScale;
- fxMesa->tScale0 = t->tScale;
+ fxMesa->sScale0 = ti->sScale;
+ fxMesa->tScale0 = ti->tScale;
}
static void
@@ -1419,12 +1420,12 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
- if ( fxMesa->numTMUs > 1 ) {
- const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
+ if (fxMesa->haveTwoTMUs) {
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
int tmu;
- if (tss->umaTexMemory)
+ if (shared->umaTexMemory)
tmu = GR_TMU0;
else
tmu = GR_TMU1;
@@ -1446,7 +1447,7 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE;
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
- if ( fxMesa->numTMUs > 1 ) {
+ if (fxMesa->haveTwoTMUs) {
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
@@ -1480,19 +1481,19 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
static void print_state(tdfxContextPtr fxMesa)
{
GLcontext *ctx = fxMesa->glCtx;
- struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
- struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
GLenum base0 = tObj0->Image[tObj0->BaseLevel] ? tObj0->Image[tObj0->BaseLevel]->Format : 99;
GLenum base1 = tObj1->Image[tObj1->BaseLevel] ? tObj1->Image[tObj1->BaseLevel]->Format : 99;
- printf("Unit 0: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[0].ReallyEnabled,
+ printf("Unit 0: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[0]._ReallyEnabled,
fxMesa->TexState.Enabled);
printf(" EnvMode: GL=0x%x Gr=0x%x\n", ctx->Texture.Unit[0].EnvMode,
fxMesa->TexState.EnvMode[0]);
printf(" BaseFmt: GL=0x%x Gr=0x%x\n", base0, fxMesa->TexState.TexFormat[0]);
- printf("Unit 1: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[1].ReallyEnabled,
+ printf("Unit 1: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[1]._ReallyEnabled,
fxMesa->TexState.Enabled);
printf(" EnvMode: GL=0x%x Gr:0x%x\n", ctx->Texture.Unit[1].EnvMode,
fxMesa->TexState.EnvMode[1]);
@@ -1510,48 +1511,39 @@ static void print_state(tdfxContextPtr fxMesa)
static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxTexObjPtr t;
+ tdfxTexInfo *ti;
struct gl_texture_object *tObj;
int tmu;
GLenum envMode, baseFormat;
- tObj = ctx->Texture.Unit[unit].CurrentD[2];
-
- if (!tObj->Image[tObj->BaseLevel]) {
- fprintf(stderr, "tObj->Image[BaseLevel] is nil, how did this happen?!?\n");
- return;
- }
-
+ tObj = ctx->Texture.Unit[unit].Current2D;
if (tObj->Image[tObj->BaseLevel]->Border > 0) {
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_BORDER;
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE);
return;
}
setupSingleTMU(fxMesa, tObj);
- t = TDFX_TEXTURE_DATA(tObj);
- if (t->whichTMU == TDFX_TMU_BOTH)
+ ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti->whichTMU == TDFX_TMU_BOTH)
tmu = TDFX_TMU0;
else
- tmu = t->whichTMU;
+ tmu = ti->whichTMU;
if (fxMesa->tmuSrc != tmu) {
- selectSingleTMUSrc(fxMesa, tmu, t->LODblend);
+ selectSingleTMUSrc(fxMesa, tmu, ti->LODblend);
}
- if (t->reloadImages)
+ if (ti->reloadImages)
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
- /* Some texture environments not supported */
- fxMesa->Fallback &= ~TDFX_FALLBACK_TEXTURE_ENV;
-
/* Check if we really need to update the texenv state */
envMode = ctx->Texture.Unit[unit].EnvMode;
baseFormat = tObj->Image[tObj->BaseLevel]->Format;
if (TDFX_IS_NAPALM(fxMesa)) {
/* see if we really need to update the unit */
- if (fxMesa->TexState.Enabled != ctx->Texture.ReallyEnabled ||
+ if (fxMesa->TexState.Enabled != ctx->Texture._ReallyEnabled ||
envMode != fxMesa->TexState.EnvMode[0] ||
envMode == GL_COMBINE_EXT ||
baseFormat != fxMesa->TexState.TexFormat[0]) {
@@ -1560,7 +1552,7 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
&ctx->Texture.Unit[unit], baseFormat,
&fxMesa->TexCombineExt[0])) {
/* software fallback */
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_ENV;
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
}
/* disable other unit */
otherEnv = &fxMesa->TexCombineExt[1];
@@ -1585,7 +1577,7 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
otherEnv->Alpha.Shift = 0;
otherEnv->Alpha.Invert = FXFALSE;
- fxMesa->TexState.Enabled = ctx->Texture.ReallyEnabled;
+ fxMesa->TexState.Enabled = ctx->Texture._ReallyEnabled;
fxMesa->TexState.EnvMode[0] = envMode;
fxMesa->TexState.TexFormat[0] = baseFormat;
fxMesa->TexState.EnvMode[1] = 0;
@@ -1596,15 +1588,15 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
/* Voodoo3 */
/* see if we really need to update the unit */
- if (fxMesa->TexState.Enabled != ctx->Texture.ReallyEnabled ||
+ if (fxMesa->TexState.Enabled != ctx->Texture._ReallyEnabled ||
envMode != fxMesa->TexState.EnvMode[0] ||
envMode == GL_COMBINE_EXT ||
baseFormat != fxMesa->TexState.TexFormat[0]) {
if (!SetupSingleTexEnvVoodoo3(ctx, tmu, envMode, baseFormat)) {
/* software fallback */
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_ENV;
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
}
- fxMesa->TexState.Enabled = ctx->Texture.ReallyEnabled;
+ fxMesa->TexState.Enabled = ctx->Texture._ReallyEnabled;
fxMesa->TexState.EnvMode[0] = envMode;
fxMesa->TexState.TexFormat[0] = baseFormat;
fxMesa->TexState.EnvMode[1] = 0;
@@ -1626,35 +1618,35 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
#define T0_IN_TMU1 0x10
#define T1_IN_TMU1 0x20
- const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
const GLcontext *ctx = fxMesa->glCtx;
- tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
GLuint tstate = 0;
int tmu0 = 0, tmu1 = 1;
- if (tss->umaTexMemory) {
- if (!t0->isInTM) {
- tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
- assert(t0->isInTM);
+ if (shared->umaTexMemory) {
+ if (!ti0->isInTM) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ assert(ti0->isInTM);
}
- if (!t1->isInTM) {
- tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU0);
- assert(t1->isInTM);
+ if (!ti1->isInTM) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
+ assert(ti1->isInTM);
}
}
else {
/* We shouldn't need to do this. There is something wrong with
multitexturing when the TMUs are swapped. So, we're forcing
them to always be loaded correctly. !!! */
- if (t0->whichTMU == TDFX_TMU1)
- tdfxTMMoveOutTMLocked(fxMesa, tObj0);
- if (t1->whichTMU == TDFX_TMU0)
- tdfxTMMoveOutTMLocked(fxMesa, tObj1);
+ if (ti0->whichTMU == TDFX_TMU1)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj0);
+ if (ti1->whichTMU == TDFX_TMU0)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj1);
- if (t0->isInTM) {
- switch (t0->whichTMU) {
+ if (ti0->isInTM) {
+ switch (ti0->whichTMU) {
case TDFX_TMU0:
tstate |= T0_IN_TMU0;
break;
@@ -1672,8 +1664,8 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
else
tstate |= T0_NOT_IN_TMU;
- if (t1->isInTM) {
- switch (t1->whichTMU) {
+ if (ti1->isInTM) {
+ switch (ti1->whichTMU) {
case TDFX_TMU0:
tstate |= T1_IN_TMU0;
break;
@@ -1696,7 +1688,7 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
if (tObj0 == tObj1) {
- tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU_BOTH);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU_BOTH);
}
else {
/* Find the minimal way to correct the situation */
@@ -1704,10 +1696,10 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/* We have one in the standard order, setup the other */
if (tstate & T0_IN_TMU0) {
/* T0 is in TMU0, put T1 in TMU1 */
- tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU1);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
}
else {
- tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
}
/* tmu0 and tmu1 are setup */
}
@@ -1715,36 +1707,36 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/* we have one in the reverse order, setup the other */
if (tstate & T1_IN_TMU0) {
/* T1 is in TMU0, put T0 in TMU1 */
- tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU1);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU1);
}
else {
- tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU0);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
}
tmu0 = 1;
tmu1 = 0;
}
else { /* Nothing is loaded */
- tdfxTMMoveInTMLocked(fxMesa, tObj0, TDFX_TMU0);
- tdfxTMMoveInTMLocked(fxMesa, tObj1, TDFX_TMU1);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
/* tmu0 and tmu1 are setup */
}
}
}
}
- t0->lastTimeUsed = fxMesa->texBindNumber;
- t1->lastTimeUsed = fxMesa->texBindNumber;
+ ti0->lastTimeUsed = fxMesa->texBindNumber;
+ ti1->lastTimeUsed = fxMesa->texBindNumber;
if (!ctx->Texture.SharedPalette) {
- if (t0->info.format == GR_TEXFMT_P_8) {
+ if (ti0->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(t0->palette);
+ fxMesa->TexPalette.Data = &(ti0->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
- else if (t1->info.format == GR_TEXFMT_P_8) {
+ else if (ti1->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &(t1->palette);
+ fxMesa->TexPalette.Data = &(ti1->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
else {
@@ -1755,25 +1747,25 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/*
* Setup Unit 0
*/
- assert(t0->isInTM);
- assert(t0->range[tmu0]);
- fxMesa->TexSource[tmu0].StartAddress = t0->range[tmu0]->startAddr;
+ assert(ti0->isInTM);
+ assert(ti0->tm[tmu0]);
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &(t0->info);
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
- if (fxMesa->TexParams[tmu0].sClamp != t0->sClamp ||
- fxMesa->TexParams[tmu0].tClamp != t0->tClamp ||
- fxMesa->TexParams[tmu0].minFilt != t0->minFilt ||
- fxMesa->TexParams[tmu0].magFilt != t0->magFilt ||
- fxMesa->TexParams[tmu0].mmMode != t0->mmMode ||
+ if (fxMesa->TexParams[tmu0].sClamp != ti0->sClamp ||
+ fxMesa->TexParams[tmu0].tClamp != ti0->tClamp ||
+ fxMesa->TexParams[tmu0].minFilt != ti0->minFilt ||
+ fxMesa->TexParams[tmu0].magFilt != ti0->magFilt ||
+ fxMesa->TexParams[tmu0].mmMode != ti0->mmMode ||
fxMesa->TexParams[tmu0].LODblend != FXFALSE ||
fxMesa->TexParams[tmu0].LodBias != ctx->Texture.Unit[tmu0].LodBias) {
- fxMesa->TexParams[tmu0].sClamp = t0->sClamp;
- fxMesa->TexParams[tmu0].tClamp = t0->tClamp;
- fxMesa->TexParams[tmu0].minFilt = t0->minFilt;
- fxMesa->TexParams[tmu0].magFilt = t0->magFilt;
- fxMesa->TexParams[tmu0].mmMode = t0->mmMode;
+ fxMesa->TexParams[tmu0].sClamp = ti0->sClamp;
+ fxMesa->TexParams[tmu0].tClamp = ti0->tClamp;
+ fxMesa->TexParams[tmu0].minFilt = ti0->minFilt;
+ fxMesa->TexParams[tmu0].magFilt = ti0->magFilt;
+ fxMesa->TexParams[tmu0].mmMode = ti0->mmMode;
fxMesa->TexParams[tmu0].LODblend = FXFALSE;
fxMesa->TexParams[tmu0].LodBias = ctx->Texture.Unit[tmu0].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
@@ -1782,42 +1774,42 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
/*
* Setup Unit 1
*/
- if (tss->umaTexMemory) {
- ASSERT(t1->isInTM);
- ASSERT(t1->range[0]);
- fxMesa->TexSource[tmu1].StartAddress = t1->range[0]->startAddr;
+ if (shared->umaTexMemory) {
+ ASSERT(ti1->isInTM);
+ ASSERT(ti1->tm[0]);
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(t1->info);
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
}
else {
- ASSERT(t1->isInTM);
- ASSERT(t1->range[tmu1]);
- fxMesa->TexSource[tmu1].StartAddress = t1->range[tmu1]->startAddr;
+ ASSERT(ti1->isInTM);
+ ASSERT(ti1->tm[tmu1]);
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &(t1->info);
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
}
- if (fxMesa->TexParams[tmu1].sClamp != t1->sClamp ||
- fxMesa->TexParams[tmu1].tClamp != t1->tClamp ||
- fxMesa->TexParams[tmu1].minFilt != t1->minFilt ||
- fxMesa->TexParams[tmu1].magFilt != t1->magFilt ||
- fxMesa->TexParams[tmu1].mmMode != t1->mmMode ||
+ if (fxMesa->TexParams[tmu1].sClamp != ti1->sClamp ||
+ fxMesa->TexParams[tmu1].tClamp != ti1->tClamp ||
+ fxMesa->TexParams[tmu1].minFilt != ti1->minFilt ||
+ fxMesa->TexParams[tmu1].magFilt != ti1->magFilt ||
+ fxMesa->TexParams[tmu1].mmMode != ti1->mmMode ||
fxMesa->TexParams[tmu1].LODblend != FXFALSE ||
fxMesa->TexParams[tmu1].LodBias != ctx->Texture.Unit[tmu1].LodBias) {
- fxMesa->TexParams[tmu1].sClamp = t1->sClamp;
- fxMesa->TexParams[tmu1].tClamp = t1->tClamp;
- fxMesa->TexParams[tmu1].minFilt = t1->minFilt;
- fxMesa->TexParams[tmu1].magFilt = t1->magFilt;
- fxMesa->TexParams[tmu1].mmMode = t1->mmMode;
+ fxMesa->TexParams[tmu1].sClamp = ti1->sClamp;
+ fxMesa->TexParams[tmu1].tClamp = ti1->tClamp;
+ fxMesa->TexParams[tmu1].minFilt = ti1->minFilt;
+ fxMesa->TexParams[tmu1].magFilt = ti1->magFilt;
+ fxMesa->TexParams[tmu1].mmMode = ti1->mmMode;
fxMesa->TexParams[tmu1].LODblend = FXFALSE;
fxMesa->TexParams[tmu1].LodBias = ctx->Texture.Unit[tmu1].LodBias;
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
}
- fxMesa->sScale0 = t0->sScale;
- fxMesa->tScale0 = t0->tScale;
- fxMesa->sScale1 = t1->sScale;
- fxMesa->tScale1 = t1->tScale;
+ fxMesa->sScale0 = ti0->sScale;
+ fxMesa->tScale0 = ti0->tScale;
+ fxMesa->sScale1 = ti1->sScale;
+ fxMesa->tScale1 = ti1->tScale;
#undef T0_NOT_IN_TMU
#undef T1_NOT_IN_TMU
@@ -1830,30 +1822,27 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
static void setupTextureDoubleTMU(GLcontext * ctx)
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
- struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
- tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
struct gl_texture_image *baseImage0 = tObj0->Image[tObj0->BaseLevel];
struct gl_texture_image *baseImage1 = tObj1->Image[tObj1->BaseLevel];
const GLenum envMode0 = ctx->Texture.Unit[0].EnvMode;
const GLenum envMode1 = ctx->Texture.Unit[1].EnvMode;
- if (baseImage0->Border > 0 || baseImage1->Border >0) {
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_BORDER;
+ if (baseImage0->Border > 0 || baseImage1->Border > 0) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE);
return;
}
setupDoubleTMU(fxMesa, tObj0, tObj1);
- if (t0->reloadImages || t1->reloadImages)
+ if (ti0->reloadImages || ti1->reloadImages)
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
fxMesa->tmuSrc = TDFX_TMU_BOTH;
- /* Some texture environments not supported */
- fxMesa->Fallback &= ~TDFX_FALLBACK_TEXTURE_ENV;
-
if (TDFX_IS_NAPALM(fxMesa)) {
/* Remember, Glide has its texture units numbered in backward
* order compared to OpenGL.
@@ -1861,7 +1850,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
GLboolean hw1 = GL_TRUE, hw2 = GL_TRUE;
/* check if we really need to update glide unit 1 */
- if (fxMesa->TexState.Enabled != ctx->Texture.ReallyEnabled ||
+ if (fxMesa->TexState.Enabled != ctx->Texture._ReallyEnabled ||
envMode0 != fxMesa->TexState.EnvMode[1] ||
envMode0 == GL_COMBINE_EXT ||
baseImage0->Format != fxMesa->TexState.TexFormat[1] ||
@@ -1873,7 +1862,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
}
/* check if we really need to update glide unit 0 */
- if (fxMesa->TexState.Enabled != ctx->Texture.ReallyEnabled ||
+ if (fxMesa->TexState.Enabled != ctx->Texture._ReallyEnabled ||
envMode1 != fxMesa->TexState.EnvMode[0] ||
envMode1 == GL_COMBINE_EXT ||
baseImage1->Format != fxMesa->TexState.TexFormat[0] ||
@@ -1884,21 +1873,21 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
fxMesa->TexState.TexFormat[0] = baseImage1->Format;
}
- fxMesa->TexState.Enabled = ctx->Texture.ReallyEnabled;
+ fxMesa->TexState.Enabled = ctx->Texture._ReallyEnabled;
if (!hw1 || !hw2) {
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_ENV;
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
}
}
else {
int unit0, unit1;
- if ((t0->whichTMU == TDFX_TMU1) || (t1->whichTMU == TDFX_TMU0))
+ if ((ti0->whichTMU == TDFX_TMU1) || (ti1->whichTMU == TDFX_TMU0))
unit0 = 1;
else
unit0 = 0;
unit1 = 1 - unit0;
- if (fxMesa->TexState.Enabled != ctx->Texture.ReallyEnabled ||
+ if (fxMesa->TexState.Enabled != ctx->Texture._ReallyEnabled ||
envMode0 != fxMesa->TexState.EnvMode[unit0] ||
envMode0 == GL_COMBINE_EXT ||
envMode1 != fxMesa->TexState.EnvMode[unit1] ||
@@ -1910,47 +1899,50 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
if (!SetupDoubleTexEnvVoodoo3(ctx, unit0,
ctx->Texture.Unit[0].EnvMode, baseImage0->Format,
ctx->Texture.Unit[1].EnvMode, baseImage1->Format)) {
- fxMesa->Fallback |= TDFX_FALLBACK_TEXTURE_ENV;
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
}
fxMesa->TexState.EnvMode[unit0] = envMode0;
fxMesa->TexState.TexFormat[unit0] = baseImage0->Format;
fxMesa->TexState.EnvMode[unit1] = envMode1;
fxMesa->TexState.TexFormat[unit1] = baseImage1->Format;
- fxMesa->TexState.Enabled = ctx->Texture.ReallyEnabled;
+ fxMesa->TexState.Enabled = ctx->Texture._ReallyEnabled;
}
}
}
-void tdfxUpdateTextureState( GLcontext *ctx )
+void
+tdfxUpdateTextureState( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- GLuint enabled = ctx->Texture.ReallyEnabled;
+ GLuint tex2Denabled = ctx->Texture._ReallyEnabled;
- if ( fxMesa->numTMUs == 1 )
- enabled &= TEXTURE0_2D;
+ if (!fxMesa->haveTwoTMUs)
+ tex2Denabled &= TEXTURE0_2D;
- switch ( enabled ) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_FALSE);
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_FALSE);
+
+ switch (tex2Denabled) {
case TEXTURE0_2D:
LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */
- setupTextureSingleTMU( ctx, 0 );
+ setupTextureSingleTMU(ctx, 0);
UNLOCK_HARDWARE( fxMesa );
break;
case TEXTURE1_2D:
LOCK_HARDWARE( fxMesa );
- setupTextureSingleTMU( ctx, 1 );
+ setupTextureSingleTMU(ctx, 1);
UNLOCK_HARDWARE( fxMesa );
break;
- case TEXTURE0_2D | TEXTURE1_2D:
+ case (TEXTURE0_2D | TEXTURE1_2D):
LOCK_HARDWARE( fxMesa );
- setupTextureDoubleTMU( ctx );
+ setupTextureDoubleTMU(ctx);
UNLOCK_HARDWARE( fxMesa );
break;
-
default:
- /* Disable hardware texturing */
- if ( TDFX_IS_NAPALM( fxMesa ) ) {
+ /* disable hardware texturing */
+ if (TDFX_IS_NAPALM(fxMesa)) {
fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB;
fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X;
fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO;
@@ -1971,8 +1963,9 @@ void tdfxUpdateTextureState( GLcontext *ctx )
fxMesa->AlphaCombineExt.InvertD = FXFALSE;
fxMesa->AlphaCombineExt.Shift = 0;
fxMesa->AlphaCombineExt.Invert = FXFALSE;
- } else {
- /* Voodoo 3 */
+ }
+ else {
+ /* Voodoo 3*/
fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED;
@@ -1995,103 +1988,106 @@ void tdfxUpdateTextureState( GLcontext *ctx )
}
-/* This is a special case of texture state update.
+
+/*
+ * This is a special case of texture state update.
* It's used when we've simply bound a new texture to a texture
* unit and the new texture has the exact same attributes as the
* previously bound texture.
* This is very common in Quake3.
*/
-void tdfxUpdateTextureBinding( GLcontext *ctx )
+void
+tdfxUpdateTextureBinding( GLcontext *ctx )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- const struct gl_shared_state *ss = fxMesa->glCtx->Shared;
- const tdfxSharedStatePtr tss = (tdfxSharedStatePtr)ss->DriverData;
- struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].CurrentD[2];
- struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].CurrentD[2];
- tdfxTexObjPtr t0 = TDFX_TEXTURE_DATA(tObj0);
- tdfxTexObjPtr t1 = TDFX_TEXTURE_DATA(tObj1);
-
- if ( t0 ) {
- fxMesa->sScale0 = t0->sScale;
- fxMesa->tScale0 = t0->tScale;
- if ( t0->info.format == GR_TEXFMT_P_8 ) {
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+
+ if (ti0) {
+ fxMesa->sScale0 = ti0->sScale;
+ fxMesa->tScale0 = ti0->tScale;
+ if (ti0->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &t0->palette;
+ fxMesa->TexPalette.Data = &(ti0->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
- } else if ( t1 && t1->info.format == GR_TEXFMT_P_8 ) {
+ }
+ else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) {
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
- fxMesa->TexPalette.Data = &t1->palette;
+ fxMesa->TexPalette.Data = &(ti1->palette);
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
}
}
- if ( t1 ) {
- fxMesa->sScale1 = t1->sScale;
- fxMesa->tScale1 = t1->tScale;
+ if (ti1) {
+ fxMesa->sScale1 = ti1->sScale;
+ fxMesa->tScale1 = ti1->tScale;
}
- switch ( ctx->Texture.ReallyEnabled ) {
- case TEXTURE0_2D:
- if ( tss->umaTexMemory ) {
- fxMesa->TexSource[0].StartAddress = t0->range[0]->startAddr;
+ if (ctx->Texture._ReallyEnabled == TEXTURE0_2D) {
+ if (shared->umaTexMemory) {
+ fxMesa->TexSource[0].StartAddress = ti0->tm[0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[0].Info = &(t0->info);
- } else {
- if ( t0->LODblend && t0->whichTMU == TDFX_TMU_SPLIT ) {
- fxMesa->TexSource[0].StartAddress = t0->range[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].Info = &(ti0->info);
+ }
+ else {
+ if (ti0->LODblend && ti0->whichTMU == TDFX_TMU_SPLIT) {
+ fxMesa->TexSource[0].StartAddress = ti0->tm[TDFX_TMU0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
- fxMesa->TexSource[0].Info = &t0->info;
- fxMesa->TexSource[1].StartAddress = t0->range[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[0].Info = &(ti0->info);
+ fxMesa->TexSource[1].StartAddress = ti0->tm[TDFX_TMU1]->startAddr;
fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
- fxMesa->TexSource[1].Info = &t0->info;
- } else {
- FxU32 unit;
- if ( t0->whichTMU == TDFX_TMU_BOTH ) {
- unit = TDFX_TMU0;
- } else {
- unit = t0->whichTMU;
- }
+ fxMesa->TexSource[1].Info = &(ti0->info);
+ }
+ else {
+ FxU32 tmu;
+ if (ti0->whichTMU == TDFX_TMU_BOTH)
+ tmu = TDFX_TMU0;
+ else
+ tmu = ti0->whichTMU;
fxMesa->TexSource[0].Info = NULL;
fxMesa->TexSource[1].Info = NULL;
- if ( t0->range[unit] ) {
- fxMesa->TexSource[unit].StartAddress = t0->range[unit]->startAddr;
- fxMesa->TexSource[unit].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[unit].Info = &t0->info;
+ if (ti0->tm[tmu]) {
+ fxMesa->TexSource[tmu].StartAddress = ti0->tm[tmu]->startAddr;
+ fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu].Info = &(ti0->info);
}
}
}
- break;
-
- case TEXTURE1_2D:
- if ( tss->umaTexMemory ) {
- fxMesa->TexSource[0].StartAddress = t1->range[0]->startAddr;
+ }
+ else if (ctx->Texture._ReallyEnabled == TEXTURE1_2D) {
+ if (shared->umaTexMemory) {
+ fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr;
fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[0].Info = &t1->info;
+ fxMesa->TexSource[0].Info = &(ti1->info);
}
- break;
-
- case TEXTURE0_2D | TEXTURE1_2D:
- if ( tss->umaTexMemory ) {
+ }
+ else if (ctx->Texture._ReallyEnabled == (TEXTURE0_2D | TEXTURE1_2D)) {
+ if (shared->umaTexMemory) {
const FxU32 tmu0 = 0, tmu1 = 1;
- fxMesa->TexSource[tmu0].StartAddress = t0->range[0]->startAddr;
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &t0->info;
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
- fxMesa->TexSource[tmu1].StartAddress = t1->range[0]->startAddr;
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &t1->info;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
}
else {
const FxU32 tmu0 = 0, tmu1 = 1;
- fxMesa->TexSource[tmu0].StartAddress = t0->range[tmu0]->startAddr;
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu0].Info = &t0->info;
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
- fxMesa->TexSource[tmu1].StartAddress = t1->range[tmu1]->startAddr;
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
- fxMesa->TexSource[tmu1].Info = &t1->info;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
}
- break;
}
+
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.h
index 2f199a007..0c0d4adcb 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.h
@@ -23,7 +23,7 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pipeline.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+/* $XFree86$ */
/*
* Original rewrite:
@@ -31,24 +31,14 @@
*
* Authors:
* Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
+ * Brian Paul <brianp@valinux.com>
*
*/
-#ifndef __TDFX_PIPELINE_H__
-#define __TDFX_PIPELINE_H__
+#ifndef __TDFX_TEXSTATE_H__
+#define __TDFX_TEXSTATE_H__
-#ifdef GLX_DIRECT_RENDERING
+extern void tdfxUpdateTextureState( GLcontext *ctx );
+extern void tdfxUpdateTextureBinding( GLcontext *ctx );
-#include "context.h"
-
-extern GLboolean tdfxDDBuildPrecalcPipeline( GLcontext *ctx );
-extern GLuint tdfxDDRegisterPipelineStages( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
-
-extern void tdfxDDFastPathInit( void );
-extern void tdfxDDFastPath( struct vertex_buffer *VB );
-
-#endif
#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
index 2afe815b2..2a8270dbd 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c
@@ -23,493 +23,1262 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c,v 1.2 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfxtris.c,v 1.5 2000/09/24 13:51:04 alanh Exp $ */
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
+/* Authors:
+ * Keith Whitwell <keithw@valinux.com>
*/
-#include "tdfx_context.h"
+#include <stdio.h>
+#include <math.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast_setup/ss_context.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
#include "tdfx_tris.h"
+#include "tdfx_state.h"
+#include "tdfx_vb.h"
+#include "tdfx_lock.h"
+#include "tdfx_render.h"
+
+
+static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim );
+static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_triangle( fxMesa, a, b, c ); \
+ else \
+ fxMesa->Glide.grDrawTriangle( a, b, c ); \
+} while (0) \
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ fxMesa->draw_triangle( fxMesa, a, b, d ); \
+ fxMesa->draw_triangle( fxMesa, b, c, d ); \
+ } else { \
+ fxMesa->Glide.grDrawTriangle( a, b, d ); \
+ fxMesa->Glide.grDrawTriangle( b, c, d ); \
+ } \
+} while (0)
-#include "pipeline.h"
-#include "vbindirect.h"
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_line( fxMesa, v0, v1 ); \
+ else { \
+ v0->v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ fxMesa->Glide.grDrawLine( v0, v1 ); \
+ v0->v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_point( fxMesa, v0 ); \
+ else { \
+ v0->v.x += PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ fxMesa->Glide.grDrawPoint( v0 ); \
+ v0->v.x -= PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* Build an SWvertex from a hardware vertex.
+ *
+ * This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) {
+ dst->win[0] = src->tv.x - fxMesa->x_offset;
+ dst->win[1] = src->tv.y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
+ dst->win[2] = src->tv.z;
+ dst->win[3] = 1.0;
+
+ dst->color[0] = src->tv.color.red;
+ dst->color[1] = src->tv.color.green;
+ dst->color[2] = src->tv.color.blue;
+ dst->color[3] = src->tv.color.alpha;
+ }
+ else {
+ GLfloat w = 1.0 / src->v.rhw;
+
+ dst->win[0] = src->v.x - fxMesa->x_offset;
+ dst->win[1] = fxMesa->screen_height - fxMesa->y_offset - src->v.y;
+ dst->win[2] = src->v.z;
+ dst->win[3] = src->v.rhw;
+
+ dst->color[0] = src->v.color.red;
+ dst->color[1] = src->v.color.green;
+ dst->color[2] = src->v.color.blue;
+ dst->color[3] = src->v.color.alpha;
+
+ if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJECT) {
+ dst->texcoord[0][0] = fxMesa->sScale0 * w * src->pv.tu0;
+ dst->texcoord[0][1] = fxMesa->tScale0 * w * src->pv.tv0;
+ dst->texcoord[0][3] = w * src->pv.tq0;
+
+ if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
+ dst->texcoord[1][0] = fxMesa->sScale1 * w * src->pv.tu1;
+ dst->texcoord[1][1] = fxMesa->tScale1 * w * src->pv.tv1;
+ dst->texcoord[1][3] = w * src->pv.tq1;
+ }
+ } else if (fxMesa->SetupIndex & TDFX_TEX0_BIT) {
+ dst->texcoord[0][0] = fxMesa->sScale0 * w * src->v.tu0;
+ dst->texcoord[0][1] = fxMesa->tScale0 * w * src->v.tv0;
+ dst->texcoord[0][3] = 1.0;
+
+ if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
+ dst->texcoord[1][0] = fxMesa->sScale1 * w * src->v.tu1;
+ dst->texcoord[1][1] = fxMesa->tScale1 * w * src->v.tv1;
+ dst->texcoord[1][3] = 1.0;
+ }
+ }
+ }
+
+ dst->pointSize = ctx->Point._Size;
+}
+
+
+static void
+tdfx_fallback_tri( tdfxContextPtr fxMesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1,
+ tdfxVertex *v2 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[3];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ tdfx_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+tdfx_fallback_line( tdfxContextPtr fxMesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[2];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+tdfx_fallback_point( tdfxContextPtr fxMesa,
+ tdfxVertex *v0 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[1];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+static void tdfx_print_vertex( GLcontext *ctx, const tdfxVertex *v )
+{
+ tdfxContextPtr imesa = TDFX_CONTEXT( ctx );
+
+ fprintf(stderr, "vertex at %p\n", v);
+
+ if (imesa->vertexFormat == TDFX_LAYOUT_TINY) {
+ fprintf(stderr, "x %f y %f z %f\n", v->v.x, v->v.y, v->v.z);
+ fprintf(stderr, "r %d g %d b %d a %d\n",
+ v->tv.color.red,
+ v->tv.color.green,
+ v->tv.color.blue,
+ v->tv.color.alpha);
+ }
+ else {
+ fprintf(stderr, "x %f y %f z %f oow %f\n",
+ v->v.x, v->v.y, v->v.z, v->v.rhw);
+ fprintf(stderr, "r %d g %d b %d a %d\n",
+ v->v.color.red,
+ v->v.color.green,
+ v->v.color.blue,
+ v->v.color.alpha);
+ }
+
+ fprintf(stderr, "\n");
+}
+
+#define DO_FALLBACK 0
+
+/* Need to do clip loop at each triangle when mixing swrast and hw
+ * rendering. These functions are only used when mixed-mode rendering
+ * is occurring.
+ */
+static void tdfx_draw_quad( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0,
+ tdfxVertexPtr v1,
+ tdfxVertexPtr v2,
+ tdfxVertexPtr v3 )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ QUAD( v0, v1, v2, v3 );
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+static void tdfx_draw_triangle( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0,
+ tdfxVertexPtr v1,
+ tdfxVertexPtr v2 )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+/* tdfx_print_vertex( fxMesa->glCtx, v0 ); */
+/* tdfx_print_vertex( fxMesa->glCtx, v1 ); */
+/* tdfx_print_vertex( fxMesa->glCtx, v2 ); */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ TRI( v0, v1, v2 );
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+static void tdfx_draw_line( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0,
+ tdfxVertexPtr v1 )
+{
+ /* No support for wide lines (avoid wide/aa line fallback).
+ */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ LINE(v0, v1);
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+static void tdfx_draw_point( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0 )
+{
+ /* No support for wide points.
+ */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ POINT( v0 );
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+#undef DO_FALLBACK
+
+
+#define TDFX_UNFILLED_BIT 0x1
+#define TDFX_OFFSET_BIT 0x2
+#define TDFX_TWOSIDE_BIT 0x4
+#define TDFX_FLAT_BIT 0x8
+#define TDFX_FALLBACK_BIT 0x10
+#define TDFX_MAX_TRIFUNC 0x20
static struct {
- points_func points;
- line_func line;
+ points_func points;
+ line_func line;
triangle_func triangle;
quad_func quad;
- render_func *render_tab;
} rast_tab[TDFX_MAX_TRIFUNC];
-#define TDFX_COLOR( to, from ) \
- do { \
- (to)[0] = (from)[2]; \
- (to)[1] = (from)[1]; \
- (to)[2] = (from)[0]; \
- (to)[3] = (from)[3]; \
- } while (0)
-
+#define DO_FALLBACK (IND & TDFX_FALLBACK_BIT)
+#define DO_OFFSET (IND & TDFX_OFFSET_BIT)
+#define DO_UNFILLED (IND & TDFX_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & TDFX_TWOSIDE_BIT)
+#define DO_FLAT (IND & TDFX_FLAT_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_HW_FLATSHADE 0
+#define HAVE_BACK_COLORS 0
+#define VERTEX tdfxVertex
+#define TAB rast_tab
+
+#define TDFX_COLOR( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+} while (0)
-static void tdfxPrintRenderState( const char *msg, GLuint state )
-{
- fprintf( stderr, "%s: (0x%x) %s%s%s%s\n",
- msg, state,
- (state & TDFX_FLAT_BIT) ? "flat, " : "",
- (state & TDFX_OFFSET_BIT) ? "offset, " : "",
- (state & TDFX_TWOSIDE_BIT) ? "twoside, " : "",
- (state & TDFX_CLIPRECT_BIT) ? "cliprects, " : "");
-}
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (fxMesa->verts + (e<<fxMesa->vertex_stride_shift))
+
+#define VERT_SET_RGBA( v, c ) TDFX_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define LOCAL_VARS(n) \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ GLuint coloroffset = (fxMesa->vertexFormat == \
+ TDFX_LAYOUT_TINY) ? 3 : 4; \
+ GLuint color[n]; \
+ (void) color; (void)coloroffset
+
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fxMesa->raster_primitive != x) \
+ tdfxRasterPrimitive( ctx, x )
+#define RENDER_PRIMITIVE fxMesa->render_primitive
+#define IND TDFX_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
#define IND (0)
#define TAG(x) x
-#include "tdfx_tritmp.h"
-
-#define IND (TDFX_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "tdfx_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (TDFX_OFFSET_BIT)
#define TAG(x) x##_offset
-#include "tdfx_tritmp.h"
-
-#define IND (TDFX_OFFSET_BIT | TDFX_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "tdfx_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (TDFX_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "tdfx_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "tdfx_tritmp.h"
-
-#define IND (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT)
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT)
#define TAG(x) x##_twoside_offset
-#include "tdfx_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT | TDFX_FLAT_BIT)
+#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \
+ TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Tdfx doesn't support provoking-vertex flat-shading?
+ */
+#define IND (TDFX_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FLAT_BIT)
#define TAG(x) x##_twoside_offset_flat
-#include "tdfx_tritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_cliprect
-#include "tdfx_tritmp.h"
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_FLAT_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_flat_cliprect
-#include "tdfx_tritmp.h"
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_OFFSET_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_offset_cliprect
-#include "tdfx_tritmp.h"
+#define IND (TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (TDFX_OFFSET_BIT | TDFX_FLAT_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_offset_flat_cliprect
-#include "tdfx_tritmp.h"
+#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \
+ TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
+ init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
+}
-#define IND (TDFX_TWOSIDE_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_twoside_cliprect
-#include "tdfx_tritmp.h"
-#define IND (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_twoside_flat_cliprect
-#include "tdfx_tritmp.h"
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
-#define IND (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_twoside_offset_cliprect
-#include "tdfx_tritmp.h"
-#define IND (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT | TDFX_FLAT_BIT | TDFX_CLIPRECT_BIT)
-#define TAG(x) x##_twoside_offset_flat_cliprect
-#include "tdfx_tritmp.h"
+/* Accelerate vertex buffer rendering when renderindex == 0 and
+ * there is no clipping.
+ */
-static void tdfx_render_vb_points( struct vertex_buffer *VB,
+static void tdfx_render_vb_points( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- GLcontext *ctx = VB->ctx;
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ int stride = 1<<shift;
+ char *tmp;
GLint i;
- (void) parity;
+ (void) flags;
+
/* Adjust point coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x += PNT_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x += PNT_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
}
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start,
- fxVB+start, sizeof(*fxVB));
+ fxVB, stride);
/* restore point coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x -= PNT_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x -= PNT_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
}
}
-static void tdfx_render_vb_line_strip( struct vertex_buffer *VB,
+static void tdfx_render_vb_line_strip( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ int stride = 1<<shift;
+ char *tmp;
GLint i;
- (void) parity;
+ (void) flags;
+
/* adjust line coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x += LINE_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
}
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start,
- fxVB+start, sizeof(*fxVB));
+ fxVB, 1<<shift);
+
+ /* restore line coords */
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void tdfx_render_vb_line_loop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ int stride = 1<<shift;
+ char *tmp, *tmp2 = fxVB;
+ GLint i;
+ GLint j = start;
+ (void) flags;
+
+ if (!(flags & PRIM_BEGIN)) {
+ fxVB += (1 << shift);
+ j++;
+ }
+
+ /* adjust line coords */
+ for (i = start, tmp = tmp2; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j,
+ fxVB, 1<<shift);
+
+ if (flags & PRIM_END)
+ fxMesa->Glide.grDrawLine( fxMesa->verts + ((count - 1)<<shift),
+ fxMesa->verts + (start<<shift) );
+
/* restore line coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = tmp2; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
}
}
-static void tdfx_render_vb_lines( struct vertex_buffer *VB,
+static void tdfx_render_vb_lines( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ int stride = 1<<shift;
+ char *tmp;
GLint i;
- (void) parity;
+ (void) flags;
+
/* adjust line coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x += LINE_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
}
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start,
- fxVB+start, sizeof(*fxVB));
+ fxVB, 1<<shift);
+
/* restore line coords */
- for (i = start; i < count; i++) {
- fxVB[i].v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
- fxVB[i].v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
+ ((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ ((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
}
}
-static void tdfx_render_vb_triangles( struct vertex_buffer *VB,
+static void tdfx_render_vb_triangles( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ (void) flags;
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start,
- fxVB+start, sizeof(*fxVB));
- (void) parity;
+ fxVB, 1<<shift);
}
-static void tdfx_render_vb_tri_strip( struct vertex_buffer *VB,
+static void tdfx_render_vb_tri_strip( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
- fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, count-start,
- fxVB+start, sizeof(*fxVB));
- (void) parity;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ int mode;
+ (void) flags;
+
+/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<<shift); */
+/* if(!prevLockLine) abort(); */
+
+ if (flags & PRIM_PARITY)
+ mode = GR_TRIANGLE_STRIP_CONTINUE;
+ else
+ mode = GR_TRIANGLE_STRIP;
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( mode, count-start,
+ fxVB, 1<<shift);
}
-static void tdfx_render_vb_tri_fan( struct vertex_buffer *VB,
+static void tdfx_render_vb_tri_fan( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ (void) flags;
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start,
- fxVB+start, sizeof(*fxVB) );
- (void) parity;
+ fxVB, 1<<shift );
}
+static void tdfx_render_vb_quads( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts;
+ GLuint i;
+ (void) flags;
+
+ for (i = start ; i < count-3 ; i += 4 ) {
+#define VERT(x) (fxVB + ((x)<<shift))
+ fxMesa->Glide.grDrawTriangle( VERT(i), VERT(i+1), VERT(i+3) );
+ fxMesa->Glide.grDrawTriangle( VERT(i+1), VERT(i+2), VERT(i+3) );
+#undef VERT
+ }
+}
+
+static void tdfx_render_vb_quad_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ (void) flags;
+
+ count -= (count-start)&1;
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP,
+ count-start, fxVB, 1<<shift);
+}
-static void tdfx_render_vb_poly( struct vertex_buffer *VB,
+static void tdfx_render_vb_poly( GLcontext *ctx,
GLuint start,
GLuint count,
- GLuint parity )
+ GLuint flags )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx);
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint shift = fxMesa->vertex_stride_shift;
+ char *fxVB = fxMesa->verts + (start << shift);
+ (void) flags;
+
fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start,
- fxVB+start, sizeof(*fxVB));
- (void) parity;
+ fxVB, 1<<shift);
}
+static void tdfx_render_vb_noop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void) (ctx && start && count && flags);
+}
-#define RENDER_POINTS( start, count ) \
-do { \
- int i; \
- for (i = start ; i < count ; i++) { \
- v[elt[i]].v.x += PNT_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i]].v.y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
- fxMesa->Glide.grDrawPoint(&v[elt[i]]); \
- v[elt[i]].v.x -= PNT_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i]].v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
- } \
-} while (0)
+static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ tdfx_render_vb_points,
+ tdfx_render_vb_lines,
+ tdfx_render_vb_line_loop,
+ tdfx_render_vb_line_strip,
+ tdfx_render_vb_triangles,
+ tdfx_render_vb_tri_strip,
+ tdfx_render_vb_tri_fan,
+ tdfx_render_vb_quads,
+ tdfx_render_vb_quad_strip,
+ tdfx_render_vb_poly,
+ tdfx_render_vb_noop,
+};
-#define RENDER_LINE( i0, i1 ) \
-do { \
- v[elt[i0]].v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i0]].v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
- v[elt[i1]].v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i1]].v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
- fxMesa->Glide.grDrawLine( &v[elt[i0]], &v[elt[i1]] );\
- v[elt[i0]].v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i0]].v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
- v[elt[i1]].v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
- v[elt[i1]].v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
-} while (0)
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
-do { \
- if (parity) fxMesa->Glide.grDrawTriangle( &v[elt[i1]], &v[elt[i2]], &v[elt[i]] ); \
- else fxMesa->Glide.grDrawTriangle( &v[elt[i2]], &v[elt[i1]], &v[elt[i]] ); \
-} while (0)
+/**********************************************************************/
+/* Render whole (indexed) begin/end objects */
+/**********************************************************************/
-#define RENDER_QUAD( i3, i2, i1, i, pv ) \
-do { \
- fxMesa->Glide.grDrawTriangle( &v[elt[i3]], &v[elt[i2]], &v[elt[i]] ); \
- fxMesa->Glide.grDrawTriangle( &v[elt[i2]], &v[elt[i1]], &v[elt[i]] ); \
-} while (0)
+#define VERT(x) (tdfxVertex *)(vertptr + ((x)<<vertshift))
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ fxMesa->Glide.grDrawPoint( VERT(ELT(start)) );
+
+#define RENDER_LINE( v0, v1 ) \
+ fxMesa->Glide.grDrawLine( VERT(v0), VERT(v1) )
+
+#define RENDER_TRI( v0, v1, v2 ) \
+ fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
+
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ tdfx_draw_quad( fxMesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+
+#define INIT(x) tdfxRenderPrimitive( ctx, x )
-#define LOCAL_VARS \
- GLcontext *ctx = VB->ctx; \
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx ); \
- const GLuint *elt = VB->EltPtr->data; \
- tdfxVertexPtr v = TDFX_DRIVER_DATA(VB)->verts; \
- (void) v; (void) ctx;
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)fxMesa->verts; \
+ const GLuint vertshift = fxMesa->vertex_stride_shift; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+
+/* Elts, no clipping.
+ */
+#undef ELT
+#undef TAG
#define TAG(x) tdfx_##x##_elts
-#include "render_tmp.h"
+#define ELT(x) elt[x]
+#include "tnl_dd/t_dd_rendertmp.h"
-static void tdfxDDRenderEltsRaw( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- struct vertex_buffer *OldVB = ctx->VB;
- GLenum prim = ctx->CVA.elt_mode;
- GLuint nr = VB->EltPtr->count;
- render_func func = tdfx_render_tab_elts[prim];
- GLuint p = 0;
- ctx->VB = VB;
- ctx->Driver.RenderStart( ctx );
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
- do {
- func( VB, 0, nr, 0 );
- } while ( ctx->Driver.MultipassFunc &&
- ctx->Driver.MultipassFunc( VB, ++p ) );
- END_CLIP_LOOP_LOCKED( fxMesa );
- ctx->Driver.RenderFinish( ctx );
- ctx->VB = OldVB;
-}
+static void tdfxRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fxMesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
-void tdfxDDTriangleFuncsInit( void )
+static void tdfxRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
{
- init();
- init_flat();
- init_offset();
- init_offset_flat();
- init_twoside();
- init_twoside_flat();
- init_twoside_offset();
- init_twoside_offset_flat();
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
- init_cliprect();
- init_flat_cliprect();
- init_offset_cliprect();
- init_offset_flat_cliprect();
- init_twoside_cliprect();
- init_twoside_flat_cliprect();
- init_twoside_offset_cliprect();
- init_twoside_offset_flat_cliprect();
-
- rast_tab[0].render_tab[GL_POINTS] = tdfx_render_vb_points;
- rast_tab[0].render_tab[GL_LINE_STRIP] = tdfx_render_vb_line_strip;
- rast_tab[0].render_tab[GL_LINES] = tdfx_render_vb_lines;
- rast_tab[0].render_tab[GL_TRIANGLES] = tdfx_render_vb_triangles;
- rast_tab[0].render_tab[GL_TRIANGLE_STRIP] = tdfx_render_vb_tri_strip;
- rast_tab[0].render_tab[GL_TRIANGLE_FAN] = tdfx_render_vb_tri_fan;
- rast_tab[0].render_tab[GL_POLYGON] = tdfx_render_vb_poly;
-
- tdfx_render_init_elts();
-}
-
-
-#define ALL_FALLBACK (DD_SELECT | DD_FEEDBACK)
-#define POINT_FALLBACK (ALL_FALLBACK | DD_POINT_SMOOTH | DD_POINT_ATTEN)
-#define LINE_FALLBACK (ALL_FALLBACK | DD_LINE_STIPPLE)
-#define TRI_FALLBACK (ALL_FALLBACK | DD_TRI_SMOOTH | DD_TRI_UNFILLED)
-#define ANY_FALLBACK (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK | DD_TRI_STIPPLE | DD_LINE_SMOOTH | DD_LINE_WIDTH | DD_POINT_SIZE )
-#define ANY_RENDER_FLAGS (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET)
-
-/* Setup the Point, Line, Triangle and Quad functions based on the
- * current rendering state. Wherever possible, use the hardware to
- * render the primitive. Otherwise, fallback to software rendering.
- */
-void tdfxDDChooseRenderState( GLcontext *ctx )
+static void tdfxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- GLuint flags = ctx->TriangleCaps;
- CARD32 index = 0;
- fxMesa->RenderElementsRaw = tdfxDDRenderEltsRaw;
+ GLubyte *vertptr = (GLubyte *)fxMesa->verts;
+ const GLuint vertshift = fxMesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i;
- if ( fxMesa->Fallback ) {
- fxMesa->RenderElementsRaw = gl_render_elts;
- fxMesa->RenderIndex = TDFX_FALLBACK_BIT;
- return;
+ for (i = 2 ; i < n ; i++) {
+ fxMesa->Glide.grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
}
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
- if ( flags & ANY_RENDER_FLAGS ) {
- if ( flags & DD_FLATSHADE ) index |= TDFX_FLAT_BIT;
- if ( flags & DD_TRI_LIGHT_TWOSIDE ) index |= TDFX_TWOSIDE_BIT;
- if ( flags & DD_TRI_OFFSET ) index |= TDFX_OFFSET_BIT;
- fxMesa->RenderElementsRaw = gl_render_elts;
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
+ DD_TRI_UNFILLED)
+
+
+/* All state referenced below:
+ */
+#define _TDFX_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+
+static void tdfxChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (0) {
+ fxMesa->draw_point = tdfx_draw_point;
+ fxMesa->draw_line = tdfx_draw_line;
+ fxMesa->draw_triangle = tdfx_draw_triangle;
+ index |= TDFX_FALLBACK_BIT;
}
- if ( fxMesa->numClipRects > 1 )
- index |= TDFX_CLIPRECT_BIT;
-
- fxMesa->PointsFunc = rast_tab[index].points;
- fxMesa->LineFunc = rast_tab[index].line;
- fxMesa->TriangleFunc = rast_tab[index].triangle;
- fxMesa->QuadFunc = rast_tab[index].quad;
- fxMesa->RenderVBRawTab = rast_tab[index].render_tab;
- fxMesa->RenderIndex = index;
- fxMesa->IndirectTriangles = 0;
-
- if ( flags & ANY_FALLBACK ) {
- if ( flags & POINT_FALLBACK ) {
- fxMesa->PointsFunc = 0;
- fxMesa->RenderVBRawTab = 0;
- fxMesa->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
- fxMesa->RenderIndex |= TDFX_FALLBACK_BIT;
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TDFX_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= TDFX_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= TDFX_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= TDFX_FLAT_BIT;
}
- if ( flags & LINE_FALLBACK ) {
- fxMesa->LineFunc = 0;
- fxMesa->RenderVBRawTab = 0;
- fxMesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- fxMesa->RenderIndex |= TDFX_FALLBACK_BIT;
+ fxMesa->draw_point = tdfx_draw_point;
+ fxMesa->draw_line = tdfx_draw_line;
+ fxMesa->draw_triangle = tdfx_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ *
+ * DD_TRI_UNFILLED is here because the unfilled_tri functions use
+ * fxMesa->draw_tri *always*, and thus can't use the multipass
+ * approach to cliprects.
+ *
+ */
+ if (flags & (POINT_FALLBACK|
+ LINE_FALLBACK|
+ TRI_FALLBACK|
+ DD_TRI_STIPPLE|
+ DD_TRI_UNFILLED))
+ {
+ if (flags & POINT_FALLBACK)
+ fxMesa->draw_point = tdfx_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ fxMesa->draw_line = tdfx_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ fxMesa->draw_triangle = tdfx_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !fxMesa->haveHwStipple)
+ fxMesa->draw_triangle = tdfx_fallback_tri;
+
+ index |= TDFX_FALLBACK_BIT;
}
+ }
- if ( flags & TRI_FALLBACK ) {
- fxMesa->TriangleFunc = 0;
- fxMesa->QuadFunc = 0;
- fxMesa->RenderVBRawTab = 0;
- fxMesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- fxMesa->RenderIndex |= TDFX_FALLBACK_BIT;
+ if (fxMesa->RenderIndex != index) {
+ fxMesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = tdfx_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = tdfx_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = tdfxFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = tdfxRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = tdfxRenderClippedPoly;
}
+ }
+}
- /* Special case: wide, AA lines must be done in software */
- if (flags & DD_LINE_SMOOTH) {
- if (ctx->Line.Width != 1.0) {
- fxMesa->RenderVBRawTab = 0;
- fxMesa->LineFunc = 0;
- fxMesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
- fxMesa->RenderIndex |= TDFX_FALLBACK_BIT;
- }
- }
+/**********************************************************************/
+/* Use multipass rendering for cliprects */
+/**********************************************************************/
- /* Special case: we can do polygon stipples, but otherwise */
- if ((flags & DD_TRI_STIPPLE) &&
- (ctx->IndirectTriangles & DD_TRI_STIPPLE)) {
- fxMesa->TriangleFunc = 0;
- fxMesa->QuadFunc = 0;
- fxMesa->RenderVBRawTab = 0;
- fxMesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE |
- DD_QUAD_SW_RASTERIZE);
- fxMesa->RenderIndex |= TDFX_FALLBACK_BIT;
- }
- if (flags & (DD_LINE_WIDTH | DD_POINT_SIZE))
- fxMesa->RenderVBRawTab = 0;
- fxMesa->RenderElementsRaw = gl_render_elts;
+/* TODO: Benchmark this.
+ * TODO: Use single back-buffer cliprect where possible.
+ * NOTE: <pass> starts at 1, not zero!
+ */
+static GLboolean multipass_cliprect( GLcontext *ctx, GLuint pass )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (pass >= fxMesa->numClipRects)
+ return GL_FALSE;
+ else {
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[pass].x1,
+ fxMesa->screen_height - fxMesa->pClipRects[pass].y2,
+ fxMesa->pClipRects[pass].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[pass].y1);
+
+ return GL_TRUE;
+ }
+}
+
+
+/**********************************************************************/
+/* Runtime render state and callbacks */
+/**********************************************************************/
+
+static void tdfxRunPipeline( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->new_state) {
+ tdfxDDUpdateHwState( ctx );
+ }
+
+ if (!fxMesa->Fallback && fxMesa->new_gl_state) {
+ if (fxMesa->new_gl_state & _TDFX_NEW_RASTERSETUP)
+ tdfxChooseVertexState( ctx );
+
+ if (fxMesa->new_gl_state & _TDFX_NEW_RENDERSTATE)
+ tdfxChooseRenderState( ctx );
+
+ fxMesa->new_gl_state = 0;
}
+ _tnl_run_pipeline( ctx );
+}
+
+
+static void tdfxRenderStart( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ tdfxCheckTexSizes( ctx );
- if ( 0 ) {
- gl_print_tri_caps( "tricaps", ctx->TriangleCaps );
- tdfxPrintRenderState( "tdfx render state", fxMesa->RenderIndex );
+ LOCK_HARDWARE(fxMesa);
+
+ /* Make sure vertex format changes get uploaded before we start
+ * sending triangles.
+ */
+ if (fxMesa->dirty) {
+ tdfxEmitHwStateLocked( fxMesa );
+ }
+
+ if (fxMesa->numClipRects && !(fxMesa->RenderIndex & TDFX_FALLBACK_BIT)) {
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y2,
+ fxMesa->pClipRects[0].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y1);
+ if (fxMesa->numClipRects > 1)
+ tnl->Driver.Render.Multipass = multipass_cliprect;
+ else
+ tnl->Driver.Render.Multipass = NULL;
}
+ else
+ tnl->Driver.Render.Multipass = NULL;
}
-void tdfxDDToggleTriCliprects( GLcontext *ctx )
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim )
{
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- int oldidx = fxMesa->RenderIndex;
- int newidx;
- if (fxMesa->Fallback)
+ FLUSH_BATCH( fxMesa );
+
+ fxMesa->raster_primitive = prim;
+
+ tdfxUpdateCull(ctx);
+ if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) {
+ fxMesa->Glide.grCullMode( fxMesa->CullMode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_CULL;
+ }
+
+ tdfxUpdateStipple(ctx);
+ if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE ) {
+ fxMesa->Glide.grStipplePattern ( fxMesa->Stipple.Pattern );
+ fxMesa->Glide.grStippleMode ( fxMesa->Stipple.Mode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE;
+ }
+}
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in tdfx_render.c.
+ */
+static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ fxMesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
return;
+
+ if (fxMesa->raster_primitive != rprim) {
+ tdfxRasterPrimitive( ctx, rprim );
+ }
+}
+
+static void tdfxRenderFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->RenderIndex & TDFX_FALLBACK_BIT)
+ _swrast_flush( ctx );
+
+ UNLOCK_HARDWARE(fxMesa);
+}
- if (fxMesa->numClipRects > 1)
- newidx = (fxMesa->RenderIndex |= TDFX_CLIPRECT_BIT);
- else
- newidx = (fxMesa->RenderIndex &= ~TDFX_CLIPRECT_BIT);
- if (ctx->Driver.TriangleFunc == rast_tab[oldidx].triangle)
- ctx->Driver.TriangleFunc = rast_tab[newidx].triangle;
- if (ctx->Driver.QuadFunc == rast_tab[oldidx].quad)
- ctx->Driver.QuadFunc = rast_tab[newidx].quad;
+/*
+ * These functions are used when we're software rendering, and
+ * lock/unlock the hardware (for span reading/writing).
+ */
+static void tdfxSwSetupStart( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE(fxMesa);
+}
+
+static void tdfxSwSetupFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ UNLOCK_HARDWARE(fxMesa);
+}
- if (ctx->Driver.LineFunc == rast_tab[oldidx].line)
- ctx->Driver.LineFunc = rast_tab[newidx].line;
- if (ctx->Driver.PointsFunc == rast_tab[oldidx].points)
- ctx->Driver.PointsFunc = rast_tab[newidx].points;
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
- if (ctx->Driver.RenderVBRawTab == rast_tab[oldidx].render_tab)
- ctx->Driver.RenderVBRawTab = rast_tab[newidx].render_tab;
+static char *fallbackStrings[] = {
+ "1D/3D Texture map",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "Separate specular color",
+ "glEnable/Disable(GL_STENCIL_TEST)",
+ "glRenderMode(selection or feedback)",
+ "glLogicOp()",
+ "Texture env mode",
+ "Texture border",
+ "glColorMask",
+ "blend mode",
+ "line stipple"
+};
- if (ctx->TriangleFunc == rast_tab[oldidx].triangle)
- ctx->TriangleFunc = rast_tab[newidx].triangle;
- if (ctx->QuadFunc == rast_tab[oldidx].quad)
- ctx->QuadFunc = rast_tab[newidx].quad;
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
- fxMesa->PointsFunc = rast_tab[newidx].points;
- fxMesa->LineFunc = rast_tab[newidx].line;
- fxMesa->TriangleFunc = rast_tab[newidx].triangle;
- fxMesa->QuadFunc = rast_tab[newidx].quad;
- fxMesa->RenderVBRawTab = rast_tab[newidx].render_tab;
- if (newidx == 0 &&
- (ctx->IndirectTriangles & (DD_LINE_WIDTH|DD_POINT_SIZE)) == 0)
- fxMesa->RenderElementsRaw = tdfxDDRenderEltsRaw;
- else
- fxMesa->RenderElementsRaw = gl_render_elts;
+void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint oldfallback = fxMesa->Fallback;
+
+ if (mode) {
+ fxMesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ /*printf("Go to software rendering, bit = 0x%x\n", bit);*/
+ FLUSH_BATCH(fxMesa);
+ _swsetup_Wakeup( ctx );
+ fxMesa->RenderIndex = ~0;
+ if (fxMesa->debugFallbacks) {
+ fprintf(stderr, "Tdfx begin software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ fxMesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ /*printf("Go to hardware rendering, bit = 0x%x\n", bit);*/
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = tdfxRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive;
+ tnl->Driver.Render.Finish = tdfxRenderFinish;
+ tnl->Driver.Render.BuildVertices = tdfxBuildVertices;
+ fxMesa->new_gl_state |= (_TDFX_NEW_RENDERSTATE|
+ _TDFX_NEW_RASTERSETUP);
+ if (fxMesa->debugFallbacks) {
+ fprintf(stderr, "Tdfx end software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+void tdfxDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ fxMesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = tdfxRunPipeline;
+ tnl->Driver.Render.Start = tdfxRenderStart;
+ tnl->Driver.Render.Finish = tdfxRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = tdfxBuildVertices;
+ tnl->Driver.Render.Multipass = NULL;
+
+
+ swsetup->Driver.Start = tdfxSwSetupStart;
+ swsetup->Driver.Finish = tdfxSwSetupFinish;
- if (0)
- tdfxPrintRenderState( "toggle tdfx render state", fxMesa->RenderIndex );
+ (void) tdfx_print_vertex;
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h
index 4ef310b3a..04a3be507 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h
@@ -23,154 +23,21 @@
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h,v 1.2 2001/08/18 02:51:07 dawes Exp $ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
* Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
* Keith Whitwell <keithw@valinux.com>
*
*/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.h,v 1.8 2000/12/04 19:21:43 dawes Exp $ */
-#ifndef __TDFX_TRIS_H__
-#define __TDFX_TRIS_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "tdfx_vb.h"
-#include "tdfx_render.h"
-
-extern void tdfxDDChooseRenderState( GLcontext *ctx );
-extern void tdfxDDTriangleFuncsInit( void );
-
-
-#define TDFX_FLAT_BIT 0x01
-#define TDFX_OFFSET_BIT 0x02
-#define TDFX_TWOSIDE_BIT 0x04
-#define TDFX_CLIPRECT_BIT 0x10
-#define TDFX_FALLBACK_BIT 0x20
-#define TDFX_MAX_TRIFUNC 0x40
-
-
-static __inline void tdfx_draw_triangle( tdfxContextPtr fxMesa,
- tdfxVertex *v0,
- tdfxVertex *v1,
- tdfxVertex *v2 )
-{
- fxMesa->Glide.grDrawTriangle( v0, v1, v2 );
-}
-
-
-static __inline void tdfx_draw_point( tdfxContextPtr fxMesa,
- tdfxVertex *tmp, float sz )
-{
- if ( sz <= 1.0 ) {
- /* Save and restore original x,y rather than copying whole
- * vertex.
- */
- GLfloat x = tmp->v.x, y = tmp->v.y;
- tmp->v.x += PNT_X_OFFSET - TRI_X_OFFSET;
- tmp->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
- fxMesa->Glide.grDrawPoint( tmp );
- tmp->v.x = x;
- tmp->v.y = y;
- }
- else {
- const GLfloat xLeft = tmp->v.x - 0.5 * sz - TRI_X_OFFSET + PNT_X_OFFSET;
- const GLfloat xRight = tmp->v.x + 0.5 * sz - TRI_X_OFFSET + PNT_X_OFFSET;
- const GLfloat yBot = tmp->v.y - 0.5 * sz - TRI_Y_OFFSET + PNT_Y_OFFSET;
- const GLfloat yTop = tmp->v.y + 0.5 * sz - TRI_Y_OFFSET + PNT_Y_OFFSET;
- tdfxVertex verts[4];
-
- verts[0] = *tmp;
- verts[1] = *tmp;
- verts[2] = *tmp;
- verts[3] = *tmp;
-
- verts[0].v.x = xLeft;
- verts[0].v.y = yBot;
-
- verts[1].v.x = xRight;
- verts[1].v.y = yBot;
-
- verts[2].v.x = xRight;
- verts[2].v.y = yTop;
-
- verts[3].v.x = xLeft;
- verts[3].v.y = yTop;
-
- fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, 4, verts,
- sizeof(tdfxVertex) );
- }
-}
-
-
-static __inline void tdfx_draw_line( tdfxContextPtr fxMesa,
- tdfxVertex *tmp0,
- tdfxVertex *tmp1,
- float width )
-{
- if ( width <= 1.0 )
- {
- /* Faster to save and restore 4 dwords than to copy 32 dwords.
- */
- GLfloat x0 = tmp0->v.x, y0 = tmp0->v.y;
- GLfloat x1 = tmp1->v.x, y1 = tmp1->v.y;
- tmp0->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
- tmp0->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
- tmp1->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
- tmp1->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
- fxMesa->Glide.grDrawLine(tmp0, tmp1);
- tmp0->v.x = x0;
- tmp0->v.y = y0;
- tmp1->v.x = x1;
- tmp1->v.y = y1;
- }
- else
- {
- tdfxVertex verts[4];
- float dx, dy, ix, iy;
-
- dx = tmp0->v.x - tmp1->v.x;
- dy = tmp0->v.y - tmp1->v.y;
-
- if (dx * dx > dy * dy) {
- iy = width * .5;
- ix = 0;
- } else {
- iy = 0;
- ix = width * .5;
- }
-
- verts[0] = *tmp0;
- verts[1] = *tmp0;
- verts[2] = *tmp1;
- verts[3] = *tmp1;
-
- verts[0].v.x = tmp0->v.x - ix;
- verts[0].v.y = tmp0->v.y - iy;
-
- verts[1].v.x = tmp0->v.x + ix;
- verts[1].v.y = tmp0->v.y + iy;
-
- verts[2].v.x = tmp1->v.x + ix;
- verts[2].v.y = tmp1->v.y + iy;
-
- verts[3].v.x = tmp1->v.x - ix;
- verts[3].v.y = tmp1->v.y - iy;
-
- fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, 4, verts,
- sizeof(tdfxVertex) );
- }
-}
+#ifndef TDFX_TRIS_INC
+#define TDFX_TRIS_INC
-void tdfxDDToggleTriCliprects( GLcontext *ctx );
+#include "mtypes.h"
+extern void tdfxDDInitTriFuncs( GLcontext *ctx );
-#endif /* GLX_DIRECT_RENDERING */
-#endif /* __TDFX_TRIS_H__ */
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tritmp.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tritmp.h
deleted file mode 100644
index 04d01e7f2..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_tritmp.h
+++ /dev/null
@@ -1,415 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_tritmp.h,v 1.2 2001/08/18 02:51:07 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
- *
- */
-
-static __inline void TAG(triangle)( GLcontext *ctx,
- GLuint e0, GLuint e1, GLuint e2,
- GLuint pv )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- tdfxVertexPtr fxverts = TDFX_DRIVER_DATA(VB)->verts;
- tdfxVertex *v[3];
-
-#if (IND & TDFX_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[3];
-#endif
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT))
- GLuint c[3];
-#endif
-
- v[0] = &fxverts[e0];
- v[1] = &fxverts[e1];
- v[2] = &fxverts[e2];
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT))
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
-#endif
-
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & TDFX_TWOSIDE_BIT)
- {
- GLuint facing = ( cc < 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if (IND & TDFX_FLAT_BIT) {
- TDFX_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- TDFX_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- TDFX_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- TDFX_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- }
- }
-#endif
-
-#if (IND & TDFX_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- if (cc * cc > 1e-16) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
-
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- }
-#endif
- }
-#elif (IND & TDFX_FLAT_BIT)
- {
- GLuint color = fxverts[pv].ui[4];
- v[0]->ui[4] = color;
- v[1]->ui[4] = color;
- v[2]->ui[4] = color;
- }
-#endif
-
-#if (IND & TDFX_CLIPRECT_BIT)
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
- fxMesa->Glide.grDrawTriangle( v[0], v[1], v[2] );
- END_CLIP_LOOP_LOCKED( fxMesa );
-#else
- fxMesa->Glide.grDrawTriangle( v[0], v[1], v[2] );
-#endif
-
-#if (IND & TDFX_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
-#endif
-
-#if (IND & (TDFX_FLAT_BIT | TDFX_TWOSIDE_BIT))
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
-#endif
-
-}
-
-
-
-static __inline void TAG(quad)( GLcontext *ctx, GLuint e0,
- GLuint e1, GLuint e2, GLuint e3,
- GLuint pv )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- tdfxVertexPtr fxverts = TDFX_DRIVER_DATA(VB)->verts;
- tdfxVertex *v[4];
-
-#if (IND & TDFX_OFFSET_BIT)
- GLfloat offset;
- GLfloat z[4];
-#endif
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT))
- GLuint c[4];
-#endif
-
- v[0] = &fxverts[e0];
- v[1] = &fxverts[e1];
- v[2] = &fxverts[e2];
- v[3] = &fxverts[e3];
-
-
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_FLAT_BIT))
- c[0] = v[0]->ui[4];
- c[1] = v[1]->ui[4];
- c[2] = v[2]->ui[4];
- c[3] = v[3]->ui[4];
-#endif
-
-
-#if (IND & (TDFX_TWOSIDE_BIT | TDFX_OFFSET_BIT))
- {
- GLfloat ex = v[0]->v.x - v[2]->v.x;
- GLfloat ey = v[0]->v.y - v[2]->v.y;
- GLfloat fx = v[1]->v.x - v[2]->v.x;
- GLfloat fy = v[1]->v.y - v[2]->v.y;
- GLfloat cc = ex*fy - ey*fx;
-
-#if (IND & TDFX_TWOSIDE_BIT)
- {
- GLuint facing = ( cc < 0.0 ) ^ ctx->Polygon.FrontBit;
- GLubyte (*vbcolor)[4] = VB->Color[facing]->data;
- if (IND & TDFX_FLAT_BIT) {
- TDFX_COLOR( (char *)&v[0]->ui[4], vbcolor[pv] );
- v[3]->ui[4] = v[2]->ui[4] = v[1]->ui[4] = v[0]->ui[4];
- } else {
- TDFX_COLOR( (char *)&v[0]->ui[4], vbcolor[e0] );
- TDFX_COLOR( (char *)&v[1]->ui[4], vbcolor[e1] );
- TDFX_COLOR( (char *)&v[2]->ui[4], vbcolor[e2] );
- TDFX_COLOR( (char *)&v[3]->ui[4], vbcolor[e3] );
- }
- }
-#endif
-
-#if (IND & TDFX_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits;
- z[0] = v[0]->v.z;
- z[1] = v[1]->v.z;
- z[2] = v[2]->v.z;
- z[3] = v[3]->v.z;
- if (cc * cc > 1e-16) {
- GLfloat ez = z[0] - z[2];
- GLfloat fz = z[1] - z[2];
- GLfloat a = ey*fz - ez*fy;
- GLfloat b = ez*fx - ex*fz;
- GLfloat ic = 1.0 / cc;
- GLfloat ac = a * ic;
- GLfloat bc = b * ic;
- if ( ac < 0.0f ) ac = -ac;
- if ( bc < 0.0f ) bc = -bc;
- offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
-
- }
- v[0]->v.z += offset;
- v[1]->v.z += offset;
- v[2]->v.z += offset;
- v[3]->v.z += offset;
- }
-#endif
- }
-#elif (IND & TDFX_FLAT_BIT)
- {
- GLuint color = fxverts[pv].ui[4];
- v[0]->ui[4] = color;
- v[1]->ui[4] = color;
- v[2]->ui[4] = color;
- v[3]->ui[4] = color;
- }
-#endif
-
-/* Marginally faster to call grDrawTriangle twice
- * than calling grDrawVertexArray.
- */
-#if (IND & TDFX_CLIPRECT_BIT)
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
-/* grDrawVertexArray( GR_TRIANGLE_FAN, 4, v ); */
- fxMesa->Glide.grDrawTriangle( v[0], v[1], v[3] );
- fxMesa->Glide.grDrawTriangle( v[1], v[2], v[3] );
- END_CLIP_LOOP_LOCKED( fxMesa );
-#else
-/* grDrawVertexArray( GR_TRIANGLE_FAN, 4, v ); */
- fxMesa->Glide.grDrawTriangle( v[0], v[1], v[3] );
- fxMesa->Glide.grDrawTriangle( v[1], v[2], v[3] );
-#endif
-
-#if (IND & TDFX_OFFSET_BIT)
- v[0]->v.z = z[0];
- v[1]->v.z = z[1];
- v[2]->v.z = z[2];
- v[3]->v.z = z[3];
-#endif
-
-#if (IND & (TDFX_FLAT_BIT | TDFX_TWOSIDE_BIT))
- v[0]->ui[4] = c[0];
- v[1]->ui[4] = c[1];
- v[2]->ui[4] = c[2];
- v[3]->ui[4] = c[3];
-#endif
-}
-
-
-
-
-
-static __inline void TAG(line)( GLcontext *ctx, GLuint v0, GLuint v1,
- GLuint pv )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(ctx->VB)->verts;
- float width = ctx->Line.Width;
- GLfloat z0, z1;
- GLuint c0, c1;
- tdfxVertex *vert0 = &fxVB[v0];
- tdfxVertex *vert1 = &fxVB[v1];
-
- if ( IND & TDFX_TWOSIDE_BIT ) {
- GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data;
-
- if ( IND & TDFX_FLAT_BIT ) {
- TDFX_COLOR( (char *)&vert0->v.color,vbcolor[pv] );
- *(int *)&vert1->v.color = *(int *)&vert0->v.color;
- } else {
- TDFX_COLOR( (char *)&vert0->v.color,vbcolor[v0] );
- TDFX_COLOR( (char *)&vert1->v.color,vbcolor[v1] );
- }
- } else if ( IND & TDFX_FLAT_BIT ) {
- c0 = *(GLuint *) &(vert0->v.color);
- c1 = *(GLuint *) &(vert1->v.color);
- *(int *)&vert0->v.color =
- *(int *)&vert1->v.color = *(int *)&fxVB[pv].v.color;
- }
-
- if ( IND & TDFX_OFFSET_BIT ) {
- GLfloat offset = ctx->LineZoffset;
- z0 = vert0->v.z;
- z1 = vert1->v.z;
- vert0->v.z += offset;
- vert1->v.z += offset;
- }
-
- if (IND & TDFX_CLIPRECT_BIT) {
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
- tdfx_draw_line( fxMesa, &fxVB[v0], &fxVB[v1], width );
- END_CLIP_LOOP_LOCKED( fxMesa );
- } else
- tdfx_draw_line( fxMesa, &fxVB[v0], &fxVB[v1], width );
-
- if ( IND & TDFX_OFFSET_BIT ) {
- vert0->v.z = z0;
- vert1->v.z = z1;
- }
-
- if ( (IND & TDFX_FLAT_BIT) && !(IND & TDFX_TWOSIDE_BIT) ) {
- *(GLuint *) &(vert0->v.color) = c0;
- *(GLuint *) &(vert1->v.color) = c1;
- }
-}
-
-
-static __inline void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- struct vertex_buffer *VB = ctx->VB;
- tdfxVertexPtr fxVB = TDFX_DRIVER_DATA(VB)->verts;
- GLfloat sz = ctx->Point.Size;
- int i;
-
- for ( i = first ; i < last ; i++ ) {
- if ( VB->ClipMask[i] == 0 ) {
- if ( IND & (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT) )
- {
- tdfxVertex tmp0 = fxVB[i];
-
- if ( IND & TDFX_TWOSIDE_BIT ) {
- GLubyte (*vbcolor)[4] = VB->ColorPtr->data;
- TDFX_COLOR( (char *)&tmp0.v.color, vbcolor[i] );
- }
-
- if ( IND & TDFX_OFFSET_BIT ) {
- GLfloat offset = ctx->PointZoffset;
- tmp0.v.z += offset;
- }
-
- if (IND & TDFX_CLIPRECT_BIT) {
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
- tdfx_draw_point( fxMesa, &tmp0, sz );
- END_CLIP_LOOP_LOCKED( fxMesa );
- } else
- tdfx_draw_point( fxMesa, &tmp0, sz );
- }
- else if (IND & TDFX_CLIPRECT_BIT)
- {
- BEGIN_CLIP_LOOP_LOCKED( fxMesa );
- tdfx_draw_point( fxMesa, &fxVB[i], sz );
- END_CLIP_LOOP_LOCKED( fxMesa );
- }
- else
- tdfx_draw_point( fxMesa, &fxVB[i], sz );
- }
- }
-}
-
-
-
-
-/* Accelerate unclipped VB rendering when fxMesa->renderIndex != 0
- *
- * The versions for renderIndex == 0 are further optimized and appear
- * in tdfx_tris.c
- */
-#if (TYPE == 0)
-#define RENDER_POINTS( start, count ) TAG(points)( ctx, start, count )
-#define RENDER_LINE( i1, i ) TAG(line)( ctx, i1, i, i )
-#define RENDER_TRI( i2, i1, i, pv, parity ) \
- do { \
- if (parity) TAG(triangle)( ctx, i1, i2, i, pv ); \
- else TAG(triangle)( ctx, i2, i1, i, pv ); \
- } while (0)
-#define RENDER_QUAD( i3, i2, i1, i, pv ) TAG(quad)( ctx, i3, i2, i1, i, pv )
-#define LOCAL_VARS GLcontext *ctx = VB->ctx;
-#define PRESERVE_TAG
-#include "render_tmp.h"
-#endif
-
-
-
-static void TAG(init)( void )
-{
- rast_tab[IND].triangle = TAG(triangle);
- rast_tab[IND].quad = TAG(quad);
- rast_tab[IND].line = TAG(line);
- rast_tab[IND].points = TAG(points);
-#if (TYPE == 0)
- rast_tab[IND].render_tab = TAG(render_tab);
-#else
- rast_tab[IND].render_tab = 0;
-#endif
- TAG(render_init)();
-}
-
-
-#undef IND
-#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c
index a6c27612e..e6054f1ee 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c
@@ -1,8 +1,6 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -11,488 +9,356 @@
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
+ * 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,
+ * THE SOFTWARE IS PROVIDED "AS 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
*
*/
-
-#include "tdfx_context.h"
-#include "tdfx_vb.h"
-
-#include "stages.h"
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfxvb.c,v 1.7 2000/11/08 05:02:43 dawes Exp $ */
+
+#include "glheader.h"
+#include "mtypes.h"
#include "mem.h"
+#include "macros.h"
+#include "colormac.h"
+#include "mmath.h"
+#include "math/m_translate.h"
+#include "swrast_setup/swrast_setup.h"
-#define COORD \
-do { \
- v->v.x = winCoord[0] + xoffset; \
- v->v.y = winCoord[1] + yoffset; \
- v->v.z = winCoord[2]; \
- v->v.rhw = w; \
-} while (0)
-
-
-/* The assembly is slower...
- */
-#if 0 && defined(USE_X86_ASM)
-#define COL \
-do { \
- __asm__ ( \
- "movl (%%edx),%%eax \n" \
- "bswap %%eax \n" \
- "rorl $8,%%eax \n" \
- "movl %%eax,16(%%edi) \n" \
- : \
- : "d" (color), "D" (v) \
- : "%eax" ); \
-} while (0)
-#else
-#define COL \
-do { \
- v->v.color.blue = color[2]; \
- v->v.color.green = color[1]; \
- v->v.color.red = color[0]; \
- v->v.color.alpha = color[3]; \
-} while (0)
-#endif
-
-
-#define TEX0 \
-do { \
- v->v.tu0 = tc0[i][0] * sScale0 * w; \
- v->v.tv0 = tc0[i][1] * tScale0 * w; \
-} while (0)
-
-#define TEX1 \
-do { \
- v->v.tu1 = tc1[i][0] * sScale1 * w; \
- v->v.tv1 = tc1[i][1] * tScale1 * w; \
-} while (0)
-
-
-#define TEX0_4 \
- if ( VB->TexCoordPtr[0]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \
- winCoord = VB->Win.data[start]; \
- v = &(TDFX_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++, winCoord+=4 ) { \
- v->v.tq0 = tc[i][3] * winCoord[3]; \
- } \
- }
-
-#define TEX1_4 \
- if ( VB->TexCoordPtr[1]->size == 4 ) { \
- GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data; \
- winCoord = VB->Win.data[start]; \
- v = &(TDFX_DRIVER_DATA(VB)->verts[start]); \
- for ( i = start ; i < end ; i++, v++, winCoord+=4 ) { \
- v->v.tq1 = tc[i][3] * winCoord[3]; \
- } \
- }
-
+#include "tdfx_context.h"
+#include "tdfx_vb.h"
+#include "tdfx_tris.h"
+#include "tdfx_state.h"
+#include "tdfx_render.h"
-#define FOG
-
-
-#define NOP
-
-
-
-#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,fog) \
-static void name( struct vertex_buffer *VB, GLuint start, GLuint end ) \
-{ \
- tdfxContextPtr fxMesa = TDFX_CONTEXT(VB->ctx); \
- tdfxVertexPtr v; \
- const GLfloat *winCoord; \
- GLfloat (*tc0)[4]; \
- GLfloat (*tc1)[4]; \
- const GLfloat xoffset = fxMesa->x_offset + TRI_X_OFFSET; \
- const GLfloat yoffset = fxMesa->y_delta + TRI_Y_OFFSET; \
- const GLfloat sScale0 = fxMesa->sScale0; \
- const GLfloat tScale0 = fxMesa->tScale0; \
- const GLfloat sScale1 = fxMesa->sScale1; \
- const GLfloat tScale1 = fxMesa->tScale1; \
- const GLubyte *color; \
- int i; \
- \
- (void) xoffset; (void) yoffset; \
- (void) sScale0; (void) tScale0; \
- (void) sScale1; (void) tScale1; \
- \
- if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
- gl_import_client_data( VB, VB->ctx->RenderFlags, \
- (VB->ClipOrMask \
- ? VEC_WRITABLE|VEC_GOOD_STRIDE \
- : VEC_GOOD_STRIDE)); \
- \
- tc0 = VB->TexCoordPtr[fxMesa->tmu_source[0]]->data; \
- tc1 = VB->TexCoordPtr[fxMesa->tmu_source[1]]->data; \
- color = VB->Color[0]->data[start]; \
- winCoord = VB->Win.data[start]; \
- \
- v = &(TDFX_DRIVER_DATA(VB)->verts[start]); \
- \
- if ( VB->ClipOrMask == 0 ) { \
- for ( i = start ; i < end ; i++, v++, color+=4, winCoord+=4 ) { \
- const GLfloat w = winCoord[3]; \
- (void) w; \
- win; \
- col; \
- fog; \
- tex0; \
- tex1; \
- } \
- } else { \
- for ( i = start ; i < end ; i++, v++, color+=4, winCoord+=4 ) { \
- if ( VB->ClipMask[i] == 0 ) { \
- const GLfloat w = winCoord[3]; \
- (void) w; \
- win; \
- fog; \
- tex0; \
- tex1; \
- } \
- col; \
- } \
- } \
- tex0_4; \
- tex1_4; \
+static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
+ GLuint shift = fxMesa->vertex_stride_shift;
+ tdfxVertex *dst = (tdfxVertex *)(tdfxverts + (edst << shift));
+ tdfxVertex *src = (tdfxVertex *)(tdfxverts + (esrc << shift));
+ dst->ui[4] = src->ui[4];
}
-
-SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP)
-SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, FOG)
-SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, FOG)
-SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP)
-SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, FOG)
-SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, FOG)
-
-SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP)
-SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, FOG)
-SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, FOG)
-SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP)
-SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP)
-SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP)
-SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, FOG)
-SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, FOG)
-SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, FOG)
-
-
-
-static void rs_invalid( struct vertex_buffer *VB, GLuint start, GLuint end )
+static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
{
- fprintf( stderr, "tdfxRasterSetup(): invalid setup function\n" );
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
+ GLuint shift = fxMesa->vertex_stride_shift;
+ tdfxVertex *dst = (tdfxVertex *)(tdfxverts + (edst << shift));
+ tdfxVertex *src = (tdfxVertex *)(tdfxverts + (esrc << shift));
+ dst->ui[3] = src->ui[3];
}
-typedef void (*setupFunc)( struct vertex_buffer *, GLuint, GLuint );
+typedef void (*emit_func)( GLcontext *, GLuint, GLuint, void *, GLuint );
-static setupFunc setup_func[0x40];
+static struct {
+ emit_func emit;
+ interp_func interp;
+ copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[TDFX_MAX_SETUP];
-void tdfxDDSetupInit( void )
+static void import_float_colors( GLcontext *ctx )
{
- int i;
-
- for (i = 0; i < Elements(setup_func); i++)
- setup_func[i] = rs_invalid;
-
- /* Functions to build vertices from scratch */
- setup_func[TDFX_WIN_BIT|TDFX_TEX0_BIT] = rs_wt0;
- setup_func[TDFX_WIN_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_wt0t1;
- setup_func[TDFX_WIN_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT] = rs_wft0;
- setup_func[TDFX_WIN_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_wft0t1;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT] = rs_wg;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT|TDFX_TEX0_BIT] = rs_wgt0;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_wgt0t1;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT|TDFX_FOG_BIT] = rs_wgf;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT] = rs_wgft0;
- setup_func[TDFX_WIN_BIT|TDFX_RGBA_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_wgft0t1;
-
- /* Repair functions */
- setup_func[TDFX_TEX0_BIT] = rs_t0;
- setup_func[TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_t0t1;
- setup_func[TDFX_FOG_BIT] = rs_f;
- setup_func[TDFX_FOG_BIT|TDFX_TEX0_BIT] = rs_ft0;
- setup_func[TDFX_FOG_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_ft0t1;
- setup_func[TDFX_RGBA_BIT] = rs_g;
- setup_func[TDFX_RGBA_BIT|TDFX_TEX0_BIT] = rs_gt0;
- setup_func[TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_gt0t1;
- setup_func[TDFX_RGBA_BIT|TDFX_FOG_BIT] = rs_gf;
- setup_func[TDFX_RGBA_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT] = rs_gft0;
- setup_func[TDFX_RGBA_BIT|TDFX_FOG_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT] = rs_gft0t1;
-}
-
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct gl_client_array *from = VB->ColorPtr[0];
+ struct gl_client_array *to = &TDFX_CONTEXT(ctx)->UbyteColor;
+ GLuint count = VB->Count;
+
+ if (!to->Ptr) {
+ to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLubyte), 32 );
+ to->Type = GL_UNSIGNED_BYTE;
+ }
-void tdfxPrintSetupFlags( char *msg, GLuint flags )
-{
- fprintf( stderr, "%s: 0x%x %s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & TDFX_WIN_BIT) ? " xyzw," : "",
- (flags & TDFX_RGBA_BIT) ? " rgba," : "",
- (flags & TDFX_FOG_BIT) ? " fog," : "",
- (flags & TDFX_TEX0_BIT) ? " tex-0," : "",
- (flags & TDFX_TEX1_BIT) ? " tex-1," : "" );
+ /* No need to transform the same value 3000 times.
+ */
+ if (!from->StrideB) {
+ to->StrideB = 0;
+ count = 1;
+ }
+ else
+ to->StrideB = 4 * sizeof(GLubyte);
+
+ _math_trans_4ub( (GLubyte (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ count);
+
+ VB->ColorPtr[0] = to;
}
-/* ================================================================
- * Raster Setup
- */
+#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx])
+
-void tdfxDDChooseRasterSetupFunc( GLcontext *ctx )
+static void interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
{
- tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
- int index = TDFX_WIN_BIT | TDFX_RGBA_BIT;
- int vertexFormat = fxMesa->vertexFormat;
-
- fxMesa->vertsize = 8;
- fxMesa->tmu_source[0] = 0;
- fxMesa->tmu_source[1] = 1;
- fxMesa->tex_dest[0] = TDFX_TEX0_BIT;
- fxMesa->tex_dest[1] = TDFX_TEX1_BIT;
- fxMesa->vertexFormat = TDFX_LAYOUT_SINGLE;
-
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- index |= TDFX_TEX0_BIT;
- }
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX1 ) {
- if ( ctx->Texture.ReallyEnabled & ENABLE_TEX0 ) {
- fxMesa->vertexFormat = TDFX_LAYOUT_MULTI;
- fxMesa->vertsize = 10;
- index |= TDFX_TEX1_BIT;
- } else {
- /* Just a funny way of doing single texturing.
- */
- fxMesa->tmu_source[0] = 1;
- fxMesa->tex_dest[1] = TDFX_TEX0_BIT;
- index |= TDFX_TEX0_BIT;
- }
+ /*fprintf(stderr, "%s\n", __FUNCTION__);*/
+
+ if (VB->ColorPtr[1]) {
+ INTERP_4CHAN( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
}
- if (ctx->Texture.ReallyEnabled & (ENABLE_TEX0 | ENABLE_TEX1)) {
- if ((ctx->VB->TexCoordPtr[0] && ctx->VB->TexCoordPtr[0]->size == 4) ||
- (ctx->VB->TexCoordPtr[1] && ctx->VB->TexCoordPtr[1]->size == 4)) {
- fxMesa->vertexFormat = TDFX_LAYOUT_PROJECT;
- }
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
}
- if ( ctx->Fog.Enabled )
- index |= TDFX_FOG_BIT;
+ setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
+ force_boundary);
+}
- fxMesa->SetupIndex = index;
- ctx->Driver.RasterSetup = setup_func[index];
+static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- if ( fxMesa->vertexFormat != vertexFormat ) {
- fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
+ if (VB->ColorPtr[1]) {
+ COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
}
- if (0) {
- tdfxPrintSetupFlags( "full setup function", index );
- fprintf(stderr, "full setup function %p\n", ctx->Driver.RasterSetup);
- }
+ setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
}
-/* Check to see if vertices need repairing.
- */
-void tdfxDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *d )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- int tmp = fxMesa->SetupDone;
-
- d->type = 0;
- fxMesa->SetupDone = 0; /* cleared if we return */
- if ( (ctx->Array.Summary & VERT_OBJ_ANY) == 0 )
- return;
- if ( ctx->IndirectTriangles )
- return;
- fxMesa->SetupDone = tmp;
-}
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tdfx_vbtmp.h"
-/* Repair existing precalculated vertices with new data.
+/* Special for tdfx: fog requires w
*/
-void tdfxDDPartialRasterSetup( struct vertex_buffer *VB )
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT( VB->ctx );
- GLuint new = VB->pipeline->new_outputs;
- GLuint available = VB->pipeline->outputs;
- GLuint index = 0;
-
- if ( new & VERT_WIN ) {
- new = available;
- index |= TDFX_WIN_BIT | TDFX_FOG_BIT;
- }
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT)
+#define TAG(x) x##_wg_fog
+#include "tdfx_vbtmp.h"
- if ( new & VERT_RGBA )
- index |= TDFX_RGBA_BIT;
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tdfx_vbtmp.h"
- if ( new & VERT_TEX0_ANY )
- index |= TDFX_TEX0_BIT;
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tdfx_vbtmp.h"
- if ( new & VERT_TEX1_ANY )
- index |= fxMesa->tex_dest[1];
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tdfx_vbtmp.h"
- if ( new & VERT_FOG_COORD )
- index |= TDFX_FOG_BIT;
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\
+ TDFX_PTEX_BIT)
+#define TAG(x) x##_wgpt0t1
+#include "tdfx_vbtmp.h"
- fxMesa->SetupDone &= ~index;
- index &= fxMesa->SetupIndex;
- fxMesa->SetupDone |= index;
+#define IND (TDFX_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tdfx_vbtmp.h"
- if ( 0 )
- tdfxPrintSetupFlags( "partial setup function", index );
+#define IND (TDFX_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tdfx_vbtmp.h"
- if ( index )
- setup_func[index]( VB, VB->Start, VB->Count );
-}
+#define IND (TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tdfx_vbtmp.h"
-void tdfxDDDoRasterSetup( struct vertex_buffer *VB )
-{
- GLcontext *ctx = VB->ctx;
+#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tdfx_vbtmp.h"
- if ( VB->Type == VB_CVA_PRECALC ) {
- tdfxDDPartialRasterSetup( VB );
- } else if ( ctx->Driver.RasterSetup ) {
- ctx->Driver.RasterSetup( VB, VB->CopyStart, VB->Count );
- }
-}
+#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tdfx_vbtmp.h"
-/* ================================================================
- * Device-specific Vertex Buffers
- */
-void tdfxDDResizeVB( struct vertex_buffer *VB, GLuint size )
+static void init_setup_tab( void )
{
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
+ init_wg();
+ init_wg_fog();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgpt0t1();
+
+ init_g();
+ init_t0();
+ init_t0t1();
+ init_gt0();
+ init_gt0t1();
+}
- while ( fxVB->size < size )
- fxVB->size *= 2;
- ALIGN_FREE( fxVB->vert_store );
- fxVB->vert_store = ALIGN_MALLOC( sizeof(tdfxVertex) * fxVB->size, 32 );
- if ( !fxVB->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
- }
+void tdfxPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & TDFX_XYZ_BIT) ? " xyz," : "",
+ (flags & TDFX_W_BIT) ? " w," : "",
+ (flags & TDFX_RGBA_BIT) ? " rgba," : "",
+ (flags & TDFX_TEX0_BIT) ? " tex-0," : "",
+ (flags & TDFX_TEX1_BIT) ? " tex-1," : "");
+}
- fxVB->verts = (tdfxVertexPtr)fxVB->vert_store;
- gl_vector1ui_free( &fxVB->clipped_elements );
- gl_vector1ui_alloc( &fxVB->clipped_elements,
- VEC_WRITABLE, fxVB->size, 32 );
- if ( !fxVB->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
- }
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * fxVB->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
+void tdfxCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = fxMesa->SetupIndex |= (TDFX_PTEX_BIT|TDFX_RGBA_BIT);
+
+ /* Tdfx handles projective textures nicely; just have to change
+ * up to the new vertex format.
+ */
+ if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) {
+ FLUSH_BATCH(fxMesa);
+ fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
+ fxMesa->vertexFormat = setup_tab[ind].vertex_format;
+ fxMesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
+
+ /* This is required as we have just changed the vertex
+ * format, so the interp and copy routines must also change.
+ * In the unfilled and twosided cases we are using the
+ * swrast_setup ones anyway, so leave them in place.
+ */
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[fxMesa->SetupIndex].copy_pv;
+ }
+ }
}
}
-void tdfxDDResizeElts( struct vertex_buffer *VB, GLuint size )
+
+void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs )
{
-#if 0
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ char *v = (fxMesa->verts + (start<<fxMesa->vertex_stride_shift));
+ GLuint stride = 1<<fxMesa->vertex_stride_shift;
- FREE(fxVB->elts);
+ newinputs |= fxMesa->SetupNewInputs;
+ fxMesa->SetupNewInputs = 0;
- while (fxVB->elt_size < size)
- fxVB->elt_size *= 2;
+ if (!newinputs)
+ return;
- FREE(fxVB->elts);
- fxVB->elts = MALLOC( sizeof(tdfxVertex *) * fxVB->elt_size );
- if ( !fxVB->elts ) {
- fprintf( stderr, "Cannot allocate vertex indirection! Exiting...\n" );
- exit( 1 );
- }
-#endif
-}
+ if (newinputs & VERT_CLIP) {
+ setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
-void tdfxDDRegisterVB( struct vertex_buffer *VB )
-{
- tdfxVertexBufferPtr fxVB;
+ if (newinputs & VERT_RGBA)
+ ind |= TDFX_RGBA_BIT;
+
+ if (newinputs & VERT_TEX0)
+ ind |= TDFX_TEX0_BIT;
- fxVB = (tdfxVertexBufferPtr) CALLOC( sizeof(*fxVB) );
+ if (newinputs & VERT_TEX1)
+ ind |= TDFX_TEX0_BIT|TDFX_TEX1_BIT;
- fxVB->elt_size = fxVB->size = VB->Size * 2;
- fxVB->vert_store = ALIGN_MALLOC( sizeof(tdfxVertex) * fxVB->size, 32 );
- if ( !fxVB->vert_store ) {
- fprintf( stderr, "Cannot allocate vertex store! Exiting...\n" );
- exit( 1 );
+ if (fxMesa->SetupIndex & TDFX_PTEX_BIT)
+ ind = ~0;
+
+ ind &= fxMesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
}
+}
- fxVB->verts = (tdfxVertexPtr)fxVB->vert_store;
-#if 0
- fxVB->elts = MALLOC( sizeof(tdfxVertex *) * fxVB->elt_size );
- if ( !fxVB->elts ) {
- fprintf( stderr, "Cannot allocate vertex indirection! Exiting...\n" );
- exit( 1 );
+void tdfxChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GLuint ind = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
+
+ if (ctx->Texture._ReallyEnabled & 0xf0)
+ ind |= TDFX_W_BIT|TDFX_TEX1_BIT|TDFX_TEX0_BIT;
+ else if (ctx->Texture._ReallyEnabled & 0xf)
+ ind |= TDFX_W_BIT|TDFX_TEX0_BIT;
+ else if (ctx->Fog.Enabled)
+ ind |= TDFX_W_BIT;
+
+ fxMesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = interp_extras;
+ tnl->Driver.Render.CopyPV = copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
}
-#endif
- gl_vector1ui_alloc( &fxVB->clipped_elements,
- VEC_WRITABLE, fxVB->size, 32 );
- if ( !fxVB->clipped_elements.start ) {
- fprintf( stderr, "Cannot allocate clipped elements! Exiting...\n" );
- exit( 1 );
+ if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) {
+ FLUSH_BATCH(fxMesa);
+ fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
+ fxMesa->vertexFormat = setup_tab[ind].vertex_format;
+ fxMesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
}
+}
+
- ALIGN_FREE( VB->ClipMask );
- VB->ClipMask = (GLubyte *)ALIGN_MALLOC( sizeof(GLubyte) * fxVB->size, 32 );
- if ( !VB->ClipMask ) {
- fprintf( stderr, "Cannot allocate clipmask! Exiting...\n" );
- exit( 1 );
+void tdfxInitVB( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
}
- VB->driver_data = fxVB;
+ fxMesa->verts = (char *)ALIGN_MALLOC(size * sizeof(tdfxVertex), 32);
+ fxMesa->vertexFormat = setup_tab[TDFX_XYZ_BIT|TDFX_RGBA_BIT].vertex_format;
+ fxMesa->vertex_stride_shift = setup_tab[(TDFX_XYZ_BIT|
+ TDFX_RGBA_BIT)].vertex_stride_shift;
+ fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
}
-void tdfxDDUnregisterVB( struct vertex_buffer *VB )
+
+void tdfxFreeVB( GLcontext *ctx )
{
- tdfxVertexBufferPtr fxVB = TDFX_DRIVER_DATA(VB);
-
- if ( fxVB ) {
- if ( fxVB->vert_store ) ALIGN_FREE( fxVB->vert_store );
- if ( fxVB->elts ) ALIGN_FREE( fxVB->elts );
- gl_vector1ui_free( &fxVB->clipped_elements );
- FREE( fxVB );
- VB->driver_data = NULL;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (fxMesa->verts) {
+ ALIGN_FREE(fxMesa->verts);
+ fxMesa->verts = 0;
}
+
+ if (fxMesa->UbyteColor.Ptr) {
+ ALIGN_FREE(fxMesa->UbyteColor.Ptr);
+ fxMesa->UbyteColor.Ptr = 0;
+ }
+
}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h
index 29d426add..8bea7f0df 100644
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h
@@ -1,8 +1,6 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
+/*
+ * GLX Hardware Device Driver for Intel tdfx
+ * Copyright (C) 1999 Keith Whitwell
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -11,117 +9,60 @@
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
+ * 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,
+ * THE SOFTWARE IS PROVIDED "AS 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
- * Keith Whitwell <keithw@valinux.com>
*
*/
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfxvb.h,v 1.3 2000/08/28 02:43:12 tsi Exp $ */
-#ifndef __TDFX_VB_H__
-#define __TDFX_VB_H__
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include "types.h"
-#include "vb.h"
-
-/*
- * Color type for the vertex data
- */
-typedef struct {
- GLubyte blue;
- GLubyte green;
- GLubyte red;
- GLubyte alpha;
-} tdfx_color_t;
-
-
-/* The vertex structure. The final tu1/tv1 values only used in
- * multitexture modes, and tq0/tq1 in projected texture modes.
- */
-typedef struct {
- GLfloat x, y, z; /* Coordinates in screen space */
- GLfloat rhw; /* Reciprocal homogeneous w */
- tdfx_color_t color; /* Diffuse color */
- GLuint padding; /* ... */
- GLfloat tu0, tv0; /* Texture 0 coordinates */
- GLfloat tu1, tv1; /* Texture 1 coordinates */
- GLfloat tq0, tq1; /* Projected texture coordinates */
-} tdfx_vertex;
-
-
-/* The fastpath code still expects a 16-float stride vertex.
- */
-union tdfx_vertex_t {
- tdfx_vertex v;
- GLfloat f[16];
- GLuint ui[16];
-};
-
-typedef union tdfx_vertex_t tdfxVertex;
-typedef union tdfx_vertex_t *tdfxVertexPtr;
-
-/* Vertex buffer for use when on the fast path */
-struct tdfx_vertex_buffer {
- tdfxVertexPtr verts;
- GLvector1ui clipped_elements;
- GLuint size;
- int last_vert;
- void *vert_store;
+#ifndef TDFXVB_INC
+#define TDFXVB_INC
- tdfxVertexPtr *elts;
- GLuint elt_size;
- GLuint last_elt;
-};
+#include "mtypes.h"
-typedef struct tdfx_vertex_buffer *tdfxVertexBufferPtr;
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "math/m_xform.h"
-#define TDFX_DRIVER_DATA(vb) ((tdfxVertexBufferPtr)((vb)->driver_data))
+#define TDFX_XYZ_BIT 0x1
+#define TDFX_W_BIT 0x2
+#define TDFX_RGBA_BIT 0x4
+#define TDFX_TEX1_BIT 0x8
+#define TDFX_TEX0_BIT 0x10
+#define TDFX_PTEX_BIT 0x20
+#define TDFX_MAX_SETUP 0x40
+#define _TDFX_NEW_RASTERSETUP (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
-#define TDFX_WIN_BIT 0x01
-#define TDFX_RGBA_BIT 0x02
-#define TDFX_FOG_BIT 0x04
-#define TDFX_SPEC_BIT 0x08
-#define TDFX_TEX0_BIT 0x10
-#define TDFX_TEX1_BIT 0x20
+extern void tdfxValidateBuildProjVerts(GLcontext *ctx,
+ GLuint start, GLuint count,
+ GLuint newinputs );
-extern void tdfxDDSetupInit( void );
+extern void tdfxPrintSetupFlags(char *msg, GLuint flags );
-extern void tdfxDDChooseRasterSetupFunc( GLcontext *ctx );
-extern void tdfxPrintSetupFlags( char *msg, GLuint flags );
+extern void tdfxInitVB( GLcontext *ctx );
-extern void tdfxDDCheckPartialRasterSetup( GLcontext *ctx,
- struct gl_pipeline_stage *s );
-extern void tdfxDDPartialRasterSetup( struct vertex_buffer *VB );
-extern void tdfxDDDoRasterSetup( struct vertex_buffer *VB );
+extern void tdfxFreeVB( GLcontext *ctx );
-extern void tdfxDDResizeVB( struct vertex_buffer *VB, GLuint size );
-extern void tdfxDDResizeElts( struct vertex_buffer *VB, GLuint size );
-extern void tdfxDDRegisterVB( struct vertex_buffer *VB );
-extern void tdfxDDUnregisterVB( struct vertex_buffer *VB );
+extern void tdfxCheckTexSizes( GLcontext *ctx );
+extern void tdfxChooseVertexState( GLcontext *ctx );
-#endif /* GLX_DIRECT_RENDERING */
+extern void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
-#endif /* __TDFX_VB_H__ */
+#endif
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vbtmp.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vbtmp.h
new file mode 100644
index 000000000..558f38666
--- /dev/null
+++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_vbtmp.h
@@ -0,0 +1,442 @@
+
+#if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT))
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*tc0)[4], (*tc1)[4];
+ GLubyte (*col)[4];
+ GLuint tc0_stride, tc1_stride, col_stride;
+ GLuint tc0_size, tc1_size;
+ GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLuint proj_stride = VB->ProjectedClipPtr->stride;
+ tdfxVertex *v = (tdfxVertex *)dest;
+ GLfloat u0scale,v0scale,u1scale,v1scale;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *s = fxMesa->hw_viewport;
+ int i;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+ ASSERT(stride > 16);
+
+
+ if (IND & TDFX_TEX0_BIT) {
+ tc0_stride = VB->TexCoordPtr[0]->stride;
+ tc0 = VB->TexCoordPtr[0]->data;
+ u0scale = fxMesa->sScale0;
+ v0scale = fxMesa->tScale0;
+ if (IND & TDFX_PTEX_BIT)
+ tc0_size = VB->TexCoordPtr[0]->size;
+ }
+
+ if (IND & TDFX_TEX1_BIT) {
+ tc1 = VB->TexCoordPtr[1]->data;
+ tc1_stride = VB->TexCoordPtr[1]->stride;
+ u1scale = fxMesa->sScale1;
+ v1scale = fxMesa->tScale1;
+ if (IND & TDFX_PTEX_BIT)
+ tc1_size = VB->TexCoordPtr[1]->size;
+ }
+
+ if (IND & TDFX_RGBA_BIT) {
+ if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
+ import_float_colors( ctx );
+ col = VB->ColorPtr[0]->Ptr;
+ col_stride = VB->ColorPtr[0]->StrideB;
+ }
+
+ if (VB->importable_data) {
+ /* May have nonstandard strides:
+ */
+ if (start) {
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+ if (IND & TDFX_TEX0_BIT)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (IND & TDFX_TEX1_BIT)
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (IND & TDFX_RGBA_BIT)
+ STRIDE_4UB(col, start * col_stride);
+ }
+
+ for (i=start; i < end; i++, v = (tdfxVertex *)((GLubyte *)v + stride)) {
+ if (IND & TDFX_XYZ_BIT) {
+ if (mask[i] == 0) {
+ /* unclipped */
+ v->v.x = s[0] * proj[0][0] + s[12];
+ v->v.y = s[5] * proj[0][1] + s[13];
+ v->v.z = s[10] * proj[0][2] + s[14];
+ v->v.rhw = proj[0][3];
+ } else {
+ /* clipped */
+ v->v.rhw = 1.0;
+ }
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+ }
+ if (IND & TDFX_RGBA_BIT) {
+#if 0
+ *(GLuint *)&v->v.color = *(GLuint *)col;
+#else
+ GLubyte *b = (GLubyte *) &v->v.color;
+ b[0] = col[0][2];
+ b[1] = col[0][1];
+ b[2] = col[0][0];
+ b[3] = col[0][3];
+
+#endif
+ STRIDE_4UB(col, col_stride);
+ }
+ if (IND & TDFX_TEX0_BIT) {
+ GLfloat w = v->v.rhw;
+ if (IND & TDFX_PTEX_BIT) {
+ v->pv.tu0 = tc0[0][0] * u0scale * w;
+ v->pv.tv0 = tc0[0][1] * v0scale * w;
+ v->pv.tq0 = w;
+ if (tc0_size == 4)
+ v->pv.tq0 = tc0[0][3] * w;
+ }
+ else {
+ v->v.tu0 = tc0[0][0] * u0scale * w;
+ v->v.tv0 = tc0[0][1] * v0scale * w;
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (IND & TDFX_TEX1_BIT) {
+ GLfloat w = v->v.rhw;
+ if (IND & TDFX_PTEX_BIT) {
+ v->pv.tu1 = tc1[0][0] * u1scale * w;
+ v->pv.tv1 = tc1[0][1] * v1scale * w;
+ v->pv.tq1 = w;
+ if (tc1_size == 4)
+ v->pv.tq1 = tc1[0][3] * w;
+ }
+ else {
+ v->v.tu1 = tc1[0][0] * u1scale * w;
+ v->v.tv1 = tc1[0][1] * v1scale * w;
+ }
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ }
+ }
+ else {
+ for (i=start; i < end; i++, v = (tdfxVertex *)((GLubyte *)v + stride)) {
+ if (IND & TDFX_XYZ_BIT) {
+ if (mask[i] == 0) {
+ v->v.x = s[0] * proj[i][0] + s[12];
+ v->v.y = s[5] * proj[i][1] + s[13];
+ v->v.z = s[10] * proj[i][2] + s[14];
+ v->v.rhw = proj[i][3];
+ } else {
+ v->v.rhw = 1.0;
+ }
+ }
+ if (IND & TDFX_RGBA_BIT) {
+#if 0
+ *(GLuint *)&v->v.color = *(GLuint *)&col[i];
+#else
+ GLubyte *b = (GLubyte *) &v->v.color;
+ b[0] = col[i][2];
+ b[1] = col[i][1];
+ b[2] = col[i][0];
+ b[3] = col[i][3];
+
+#endif
+ }
+ if (IND & TDFX_TEX0_BIT) {
+ GLfloat w = v->v.rhw;
+ if (IND & TDFX_PTEX_BIT) {
+ v->pv.tu0 = tc0[i][0] * u0scale * w;
+ v->pv.tv0 = tc0[i][1] * v0scale * w;
+ v->pv.tq0 = w;
+ if (tc0_size == 4)
+ v->pv.tq0 = tc0[i][3] * w;
+ }
+ else {
+ v->v.tu0 = tc0[i][0] * u0scale * w;
+ v->v.tv0 = tc0[i][1] * v0scale * w;
+ }
+ }
+ if (IND & TDFX_TEX1_BIT) {
+ GLfloat w = v->v.rhw;
+ if (IND & TDFX_PTEX_BIT) {
+ v->pv.tu1 = tc1[i][0] * u1scale * w;
+ v->pv.tv1 = tc1[i][1] * v1scale * w;
+ v->pv.tq1 = w;
+ if (tc1_size == 4)
+ v->pv.tq1 = tc1[i][3] * w;
+ }
+ else {
+ v->v.tu1 = tc1[i][0] * u1scale * w;
+ v->v.tv1 = tc1[i][1] * v1scale * w;
+ }
+ }
+ }
+ }
+}
+#else
+#if (IND & TDFX_XYZ_BIT)
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte (*col)[4];
+ GLuint col_stride;
+ GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLuint proj_stride = VB->ProjectedClipPtr->stride;
+ GLfloat *v = (GLfloat *)dest;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *s = fxMesa->hw_viewport;
+ int i;
+
+/* fprintf(stderr, "%s %d..%d dest %p stride %d\n", __FUNCTION__, */
+/* start, end, dest, stride); */
+
+ ASSERT(fxMesa->SetupIndex == (TDFX_XYZ_BIT|TDFX_RGBA_BIT));
+ ASSERT(stride == 16);
+
+ if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
+ import_float_colors( ctx );
+
+ col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr;
+ col_stride = VB->ColorPtr[0]->StrideB;
+ ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE);
+
+ /* Pack what's left into a 4-dword vertex. Color is in a different
+ * place, and there is no 'w' coordinate.
+ */
+ if (VB->importable_data) {
+ if (start) {
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+ STRIDE_4UB(col, start * col_stride);
+ }
+
+ for (i=start; i < end; i++, v+=4) {
+ if (mask[i] == 0) {
+ v[0] = s[0] * proj[0][0] + s[12];
+ v[1] = s[5] * proj[0][1] + s[13];
+ v[2] = s[10] * proj[0][2] + s[14];
+ }
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+ {
+ GLubyte *b = (GLubyte *)&v[3];
+ b[0] = col[0][2];
+ b[1] = col[0][1];
+ b[2] = col[0][0];
+ b[3] = col[0][3];
+ STRIDE_4UB(col, col_stride);
+ }
+ }
+ }
+ else {
+ for (i=start; i < end; i++, v+=4) {
+ if (mask[i] == 0) {
+ v[0] = s[0] * proj[i][0] + s[12];
+ v[1] = s[5] * proj[i][1] + s[13];
+ v[2] = s[10] * proj[i][2] + s[14];
+ }
+ {
+ GLubyte *b = (GLubyte *)&v[3];
+ b[0] = col[i][2];
+ b[1] = col[i][1];
+ b[2] = col[i][0];
+ b[3] = col[i][3];
+ }
+ }
+ }
+}
+#else
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte (*col)[4];
+ GLuint col_stride;
+ GLfloat *v = (GLfloat *)dest;
+ int i;
+
+ if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE)
+ import_float_colors( ctx );
+
+ col = VB->ColorPtr[0]->Ptr;
+ col_stride = VB->ColorPtr[0]->StrideB;
+
+ if (start)
+ STRIDE_4UB(col, col_stride * start);
+
+ /* Need to figure out where color is:
+ */
+ if (fxMesa->SetupIndex & TDFX_W_BIT )
+ v += 4;
+ else
+ v += 3;
+
+ for (i=start; i < end; i++, STRIDE_F(v, stride)) {
+ GLubyte *b = (GLubyte *)v;
+ b[0] = col[0][2];
+ b[1] = col[0][1];
+ b[2] = col[0][0];
+ b[3] = col[0][3];
+ STRIDE_4UB( col, col_stride );
+ }
+}
+#endif
+#endif
+
+#if (IND & TDFX_XYZ_BIT) && (IND & TDFX_RGBA_BIT)
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (IND & TDFX_PTEX_BIT)
+ return GL_TRUE;
+
+ if (IND & TDFX_TEX0_BIT) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (IND & TDFX_TEX1_BIT) {
+ if (VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (VB->TexCoordPtr[1]->size == 4)
+ return GL_FALSE;
+ }
+
+ if (VB->TexCoordPtr[0]->size == 4)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLuint shift = fxMesa->vertex_stride_shift;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
+ const GLfloat *s = fxMesa->hw_viewport;
+ GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
+ tdfxVertex *dst = (tdfxVertex *) (tdfxverts + (edst << shift));
+ const tdfxVertex *out = (const tdfxVertex *) (tdfxverts + (eout << shift));
+ const tdfxVertex *in = (const tdfxVertex *) (tdfxverts + (ein << shift));
+ const GLfloat wout = 1.0F / out->v.rhw;
+ const GLfloat win = 1.0F / in->v.rhw;
+
+ dst->v.x = s[0] * dstclip[0] * oow + s[12];
+ dst->v.y = s[5] * dstclip[1] * oow + s[13];
+ dst->v.z = s[10] * dstclip[2] * oow + s[14];
+
+ if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)) {
+ dst->v.rhw = oow;
+
+ INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
+ INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
+ INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
+ INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
+
+ if (IND & TDFX_TEX0_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ INTERP_F( t, dst->pv.tu0, out->pv.tu0 * wout, in->pv.tu0 * win );
+ INTERP_F( t, dst->pv.tv0, out->pv.tv0 * wout, in->pv.tv0 * win );
+ INTERP_F( t, dst->pv.tq0, out->pv.tq0 * wout, in->pv.tq0 * win );
+ dst->pv.tu0 *= oow;
+ dst->pv.tv0 *= oow;
+ dst->pv.tq0 *= oow;
+ } else {
+ INTERP_F( t, dst->v.tu0, out->v.tu0 * wout, in->v.tu0 * win );
+ INTERP_F( t, dst->v.tv0, out->v.tv0 * wout, in->v.tv0 * win );
+ dst->v.tu0 *= oow;
+ dst->v.tv0 *= oow;
+ }
+ }
+ if (IND & TDFX_TEX1_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ INTERP_F( t, dst->pv.tu1, out->pv.tu1 * wout, in->pv.tu1 * win );
+ INTERP_F( t, dst->pv.tv1, out->pv.tv1 * wout, in->pv.tv1 * win );
+ INTERP_F( t, dst->pv.tq1, out->pv.tq1 * wout, in->pv.tq1 * win );
+ dst->pv.tu1 *= oow;
+ dst->pv.tv1 *= oow;
+ dst->pv.tq1 *= oow;
+ } else {
+ INTERP_F( t, dst->v.tu1, out->v.tu1 * wout, in->v.tu1 * win );
+ INTERP_F( t, dst->v.tv1, out->v.tv1 * wout, in->v.tv1 * win );
+ dst->v.tu1 *= oow;
+ dst->v.tv1 *= oow;
+ }
+ }
+ } else {
+ /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
+ */
+ INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
+ INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
+ INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
+ INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
+ }
+}
+#endif
+
+
+static void TAG(init)( void )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ setup_tab[IND].emit = TAG(emit);
+
+#if ((IND & TDFX_XYZ_BIT) && (IND & TDFX_RGBA_BIT))
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+
+ if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT))
+ setup_tab[IND].copy_pv = copy_pv_rgba4;
+ else
+ setup_tab[IND].copy_pv = copy_pv_rgba3;
+
+
+ if (IND & TDFX_TEX1_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJECT;
+ setup_tab[IND].vertex_size = 12;
+ setup_tab[IND].vertex_stride_shift = 6;
+ }
+ else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_MULTI;
+ setup_tab[IND].vertex_size = 10;
+ setup_tab[IND].vertex_stride_shift = 6;
+ }
+ }
+ else if (IND & TDFX_TEX0_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJECT;
+ setup_tab[IND].vertex_size = 12;
+ setup_tab[IND].vertex_stride_shift = 6;
+ } else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_SINGLE;
+ setup_tab[IND].vertex_size = 8;
+ setup_tab[IND].vertex_stride_shift = 5;
+ }
+ }
+ else if (IND & TDFX_W_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_NOTEX;
+ setup_tab[IND].vertex_size = 6;
+ setup_tab[IND].vertex_stride_shift = 5;
+ } else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_TINY;
+ setup_tab[IND].vertex_size = 4;
+ setup_tab[IND].vertex_stride_shift = 4;
+ }
+#endif
+}
+
+
+#undef IND
+#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.c
deleted file mode 100644
index 70641eb9a..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.c,v 1.2 2001/08/18 02:51:07 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
- *
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "tdfx_context.h"
-
-
-FxI32
-FX_grGetInteger_NoLock(tdfxContextPtr fxMesa, FxU32 pname)
-{
- switch (pname) {
- case FX_FOG_TABLE_ENTRIES:
- case FX_GLIDE_STATE_SIZE:
- case FX_LFB_PIXEL_PIPE:
- case FX_PENDING_BUFFERSWAPS:
- case FX_TEXTURE_ALIGN:
- case GR_STATS_PIXELS_DEPTHFUNC_FAIL:
- case GR_STATS_PIXELS_IN:
- case GR_STATS_PIXELS_OUT:
- {
- FxI32 result;
- FxU32 grname = pname;
- fxMesa->Glide.grGet(grname, 4, &result);
- return result;
- }
- case FX_ZDEPTH_MAX:
- {
- FxI32 zvals[2];
- fxMesa->Glide.grGet(GR_ZDEPTH_MIN_MAX, 8, zvals);
- return zvals[0];
- }
- default:
- if (MESA_VERBOSE & VERBOSE_DRIVER) {
- fprintf(stderr, "Wrong parameter in FX_grGetInteger!\n");
- }
- }
-
- return 0;
-}
-
-
-FxI32
-FX_grGetInteger(tdfxContextPtr fxMesa, FxU32 pname)
-{
- int result;
- LOCK_HARDWARE(fxMesa);
- result = FX_grGetInteger_NoLock(fxMesa, pname);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-
-const char *
-FX_grGetString(tdfxContextPtr fxMesa, FxU32 pname)
-{
- const char *s;
- LOCK_HARDWARE(fxMesa);
- s = fxMesa->Glide.grGetString(pname);
- UNLOCK_HARDWARE(fxMesa);
- return s;
-}
-
-
-
-/* Wrapper for grColorMask() and grColorMaskExt().
- */
-void
-FX_grColorMask(GLcontext *ctx, GLboolean r, GLboolean g,
- GLboolean b, GLboolean a)
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- LOCK_HARDWARE(fxMesa);
- if (ctx->Visual->RedBits == 8) {
- /* 32bpp mode */
- ASSERT( fxMesa->Glide.grColorMaskExt );
- fxMesa->Glide.grColorMaskExt(r, g, b, a);
- }
- else {
- /* 16 bpp mode */
- /* we never have an alpha buffer */
- fxMesa->Glide.grColorMask(r || g || b, GL_FALSE);
- }
- UNLOCK_HARDWARE(fxMesa);
-}
-
-
-void
-FX_grColorMask_NoLock(GLcontext *ctx, GLboolean r, GLboolean g,
- GLboolean b, GLboolean a)
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- if (ctx->Visual->RedBits == 8) {
- /* 32bpp mode */
- ASSERT( fxMesa->Glide.grColorMaskExt );
- fxMesa->Glide.grColorMaskExt(r, g, b, a);
- }
- else {
- /* 16 bpp mode */
- /* we never have an alpha buffer */
- fxMesa->Glide.grColorMask(r || g || b, GL_FALSE);
- }
-}
-
-
-/* As above, but pass the mask as an array
- */
-void
-FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4])
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- LOCK_HARDWARE(fxMesa);
- if (ctx->Visual->RedBits == 8) {
- /* 32bpp mode */
- ASSERT( fxMesa->Glide.grColorMaskExt );
- fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
- rgba[BCOMP], rgba[ACOMP]);
- }
- else {
- /* 16 bpp mode */
- /* we never have an alpha buffer */
- fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], GL_FALSE);
- }
- UNLOCK_HARDWARE(fxMesa);
-}
-
-void
-FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4])
-{
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- if (ctx->Visual->RedBits == 8) {
- /* 32bpp mode */
- ASSERT( fxMesa->Glide.grColorMaskExt );
- fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
- rgba[BCOMP], rgba[ACOMP]);
- }
- else {
- /* 16 bpp mode */
- /* we never have an alpha buffer */
- fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP], GL_FALSE);
- }
-}
-
-
-
-FxBool
-FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
- FxBool pixelPipeline, GrLfbInfo_t * info)
-{
- FxBool result;
-
- LOCK_HARDWARE(fxMesa);
- result = fxMesa->Glide.grLfbLock(type, buffer, writeMode,
- origin, pixelPipeline, info);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-FxU32
-FX_grTexTextureMemRequired(tdfxContextPtr fxMesa, FxU32 evenOdd, GrTexInfo * info)
-{
- FxU32 result;
-
- LOCK_HARDWARE(fxMesa);
- result = fxMesa->Glide.grTexTextureMemRequired(evenOdd, info);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-FxU32
-FX_grTexMinAddress(tdfxContextPtr fxMesa, GrChipID_t tmu)
-{
- FxU32 result;
-
- LOCK_HARDWARE(fxMesa);
- result = fxMesa->Glide.grTexMinAddress(tmu);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-extern FxU32
-FX_grTexMaxAddress(tdfxContextPtr fxMesa, GrChipID_t tmu)
-{
- FxU32 result;
-
- LOCK_HARDWARE(fxMesa);
- result = fxMesa->Glide.grTexMaxAddress(tmu);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-
-int
-FX_getFogTableSize(tdfxContextPtr fxMesa)
-{
- int result;
- LOCK_HARDWARE(fxMesa);
- fxMesa->Glide.grGet(GR_FOG_TABLE_ENTRIES, sizeof(int), (void *) &result);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-int
-FX_getGrStateSize(tdfxContextPtr fxMesa)
-{
- int result;
- LOCK_HARDWARE(fxMesa);
- fxMesa->Glide.grGet(GR_GLIDE_STATE_SIZE, sizeof(int), (void *) &result);
- UNLOCK_HARDWARE(fxMesa);
- return result;
-}
-
-void
-FX_grAADrawLine(tdfxContextPtr fxMesa, GrVertex * a, GrVertex * b)
-{
- /* ToDo */
- BEGIN_CLIP_LOOP(fxMesa);
- fxMesa->Glide.grDrawLine(a, b);
- END_CLIP_LOOP(fxMesa);
-}
-
-void
-FX_grAADrawPoint(tdfxContextPtr fxMesa, GrVertex * a)
-{
- BEGIN_CLIP_LOOP(fxMesa);
- fxMesa->Glide.grDrawPoint(a);
- END_CLIP_LOOP(fxMesa);
-}
-
-void
-FX_grDrawPolygonVertexList(tdfxContextPtr fxMesa, int n, GrVertex * verts)
-{
- BEGIN_CLIP_LOOP(fxMesa);
- fxMesa->Glide.grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
- END_CLIP_LOOP(fxMesa);
-}
-
-#if TDFX_USE_PARGB
-void
-FX_setupGrVertexLayout(tdfxContextPtr fxMesa)
-{
- LOCK_HARDWARE(fxMesa);
- fxMesa->Glide.grReset(GR_VERTEX_PARAMETER);
-
- fxMesa->Glide.grCoordinateSpace(GR_WINDOW_COORDS);
- fxMesa->Glide.grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- UNLOCK_HARDWARE(fxMesa);
-}
-#else /* TDFX_USE_PARGB */
-void
-FX_setupGrVertexLayout(tdfxContextPtr fxMesa)
-{
- LOCK_HARDWARE(fxMesa);
- fxMesa->Glide.grReset(GR_VERTEX_PARAMETER);
-
- fxMesa->Glide.grCoordinateSpace(GR_WINDOW_COORDS);
- fxMesa->Glide.grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
- UNLOCK_HARDWARE(fxMesa);
-}
-#endif /* TDFX_USE_PARGB */
-
-void
-FX_grHints_NoLock(tdfxContextPtr fxMesa, GrHint_t hintType, FxU32 hintMask)
-{
- switch (hintType) {
- case GR_HINT_STWHINT:
- {
- if (hintMask & GR_STWHINT_W_DIFF_TMU0)
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q0,
- GR_VERTEX_OOW_TMU0_OFFSET << 2,
- GR_PARAM_ENABLE);
- else
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q0,
- GR_VERTEX_OOW_TMU0_OFFSET << 2,
- GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST1,
- GR_VERTEX_SOW_TMU1_OFFSET << 2,
- GR_PARAM_ENABLE);
- else
- fxMesa->Glide.grVertexLayout(GR_PARAM_ST1,
- GR_VERTEX_SOW_TMU1_OFFSET << 2,
- GR_PARAM_DISABLE);
-
- if (hintMask & GR_STWHINT_W_DIFF_TMU1)
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q1,
- GR_VERTEX_OOW_TMU1_OFFSET << 2,
- GR_PARAM_ENABLE);
- else
- fxMesa->Glide.grVertexLayout(GR_PARAM_Q1,
- GR_VERTEX_OOW_TMU1_OFFSET << 2,
- GR_PARAM_DISABLE);
-
- }
- }
-}
-
-void
-FX_grHints(tdfxContextPtr fxMesa, GrHint_t hintType, FxU32 hintMask)
-{
- LOCK_HARDWARE(fxMesa);
- FX_grHints_NoLock(fxMesa, hintType, hintMask);
- UNLOCK_HARDWARE(fxMesa);
-}
-
-/* It appears to me that this function is needed either way. */
-FX_GrContext_t
-FX_grSstWinOpen(tdfxContextPtr fxMesa,
- FxU32 hWnd,
- GrScreenResolution_t screen_resolution,
- GrScreenRefresh_t refresh_rate,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers, int nAuxBuffers)
-{
- FX_GrContext_t i;
- LOCK_HARDWARE(fxMesa);
- i = fxMesa->Glide.grSstWinOpen(hWnd,
- screen_resolution,
- refresh_rate,
- color_format, origin_location,
- nColBuffers, nAuxBuffers);
-
- /*
- fprintf(stderr,
- "grSstWinOpen( win %d res %d ref %d fmt %d\n"
- " org %d ncol %d naux %d )\n"
- " ==> %d\n",
- hWnd,
- screen_resolution,
- refresh_rate,
- color_format,
- origin_location,
- nColBuffers,
- nAuxBuffers,
- i);
- */
- UNLOCK_HARDWARE(fxMesa);
- return i;
-}
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.h b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.h
deleted file mode 100644
index 9bb819c96..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.h
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
- */
-/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_wrapper.h,v 1.3 2001/08/18 11:55:48 tsi Exp $ */
-
-#ifndef __FX_GLIDE_WARPER__
-#define __FX_GLIDE_WARPER__
-
-#include "glide.h"
-#include "g3ext.h"
-
-typedef struct tdfx_context tdfxContextRec;
-typedef struct tdfx_context *tdfxContextPtr;
-
-/*
- * General context:
- */
-typedef GrContext_t FX_GrContext_t;
-
-#define FX_FOG_TABLE_ENTRIES GR_FOG_TABLE_ENTRIES
-#define FX_GLIDE_STATE_SIZE GR_GLIDE_STATE_SIZE
-#define FX_LFB_PIXEL_PIPE GR_LFB_PIXEL_PIPE
-#define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
-#define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
-
-#define FX_ZDEPTH_MAX 0x100
-
-
-#define GR_ASPECT_1x1 GR_ASPECT_LOG2_1x1
-#define GR_ASPECT_2x1 GR_ASPECT_LOG2_2x1
-#define GR_ASPECT_4x1 GR_ASPECT_LOG2_4x1
-#define GR_ASPECT_8x1 GR_ASPECT_LOG2_8x1
-#define GR_ASPECT_1x2 GR_ASPECT_LOG2_1x2
-#define GR_ASPECT_1x4 GR_ASPECT_LOG2_1x4
-#define GR_ASPECT_1x8 GR_ASPECT_LOG2_1x8
-
-#define GR_LOD_256 GR_LOD_LOG2_256
-#define GR_LOD_128 GR_LOD_LOG2_128
-#define GR_LOD_64 GR_LOD_LOG2_64
-#define GR_LOD_32 GR_LOD_LOG2_32
-#define GR_LOD_16 GR_LOD_LOG2_16
-#define GR_LOD_8 GR_LOD_LOG2_8
-#define GR_LOD_4 GR_LOD_LOG2_4
-#define GR_LOD_2 GR_LOD_LOG2_2
-#define GR_LOD_1 GR_LOD_LOG2_1
-
-#define GR_FOG_WITH_TABLE GR_FOG_WITH_TABLE_ON_Q
-
-
-typedef FxU32 GrHint_t;
-#define GR_HINTTYPE_MIN 0
-#define GR_HINT_STWHINT 0
-
-typedef FxU32 GrSTWHint_t;
-#define GR_STWHINT_W_DIFF_FBI FXBIT(0)
-#define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
-#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
-#define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
-#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
-#define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
-#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
-
-#define GR_CONTROL_ACTIVATE 1
-#define GR_CONTROL_DEACTIVATE 0
-
-#define GrState void
-
-/*
-** move the vertex layout defintion to application
-*/
-typedef struct
-{
- GLfloat sow; /* s texture ordinate (s over w) */
- GLfloat tow; /* t texture ordinate (t over w) */
- GLfloat oow; /* 1/w (used mipmapping - really 0xfff/w) */
-}
-GrTmuVertex;
-
-
-#if FX_USE_PARGB
-
-/* standard vertex, packed argb, double texture, 12 dwords */
-typedef struct
-{
- GLfloat x, y; /* X and Y in screen space */
- GLfloat ooz; /* 65535/Z (used for Z-buffering) */
- GLfloat oow; /* 1/W (used for W-buffering, texturing) */
- FxU32 argb; /* R, G, B, A [0..255.0] */
- GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
- GLfloat z; /* Z is ignored */
-}
-GrVertex;
-
-/* optimised vertex, packed argb, single texture, 8 dwords = 1 cacheline */
-typedef struct
-{
- GLfloat x, y; /* X and Y in screen space */
- GLfloat ooz; /* 65535/Z (used for Z-buffering) */
- GLfloat oow; /* 1/W (used for W-buffering, texturing) */
- FxU32 argb; /* R, G, B, A [0..255.0] */
- GrTmuVertex tmuvtx; /* only 1 TMU used to keep vertex size down */
-}
-GrVertex_Fast;
-
-/* following offsets work for both vertex layouts */
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 1
-#define GR_VERTEX_OOZ_OFFSET 2
-#define GR_VERTEX_OOW_OFFSET 3
-#define GR_VERTEX_PARGB_OFFSET 4
-#define GR_VERTEX_SOW_TMU0_OFFSET 5
-#define GR_VERTEX_TOW_TMU0_OFFSET 6
-#define GR_VERTEX_OOW_TMU0_OFFSET 7
-#define GR_VERTEX_SOW_TMU1_OFFSET 8
-#define GR_VERTEX_TOW_TMU1_OFFSET 9
-#define GR_VERTEX_OOW_TMU1_OFFSET 10
-#define GR_VERTEX_Z_OFFSET 11
-
-#if GLIDE_ENDIAN == GLIDE_ENDIAN_BIG
-#define GET_PA(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
-#define GET_PR(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+2]
-#define GET_PG(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+1]
-#define GET_PB(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+0]
-#else
-#define GET_PA(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+0]
-#define GET_PR(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+1]
-#define GET_PG(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+2]
-#define GET_PB(v) ((FxU8*)(v))[GR_VERTEX_PARGB_OFFSET*4+3]
-#endif
-
-#define GET_PARGB(v) ((FxU32*)(v))[GR_VERTEX_PARGB_OFFSET]
-#define PACK_4F_ARGB(dest, a, r, g, b) { \
- const GLuint cr = (int)r; \
- const GLuint cg = (int)g; \
- const GLuint ca = (int)a; \
- const GLuint cb = (int)b; \
- dest = ca << 24 | cr << 16 | cg << 8 | cb; \
-}
-
-#else /* FX_USE_PARGB */
-
-typedef struct
-{
- float x, y, z; /* X, Y, and Z of scrn space -- Z is ignored */
- float r, g, b; /* R, G, B, ([0..255.0]) */
- float ooz; /* 65535/Z (used for Z-buffering) */
- float a; /* Alpha [0..255.0] */
- float oow; /* 1/W (used for W-buffering, texturing) */
- GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
-}
-GrVertex;
-
-#define GR_VERTEX_X_OFFSET 0
-#define GR_VERTEX_Y_OFFSET 1
-#define GR_VERTEX_Z_OFFSET 2
-#define GR_VERTEX_R_OFFSET 3
-#define GR_VERTEX_G_OFFSET 4
-#define GR_VERTEX_B_OFFSET 5
-#define GR_VERTEX_OOZ_OFFSET 6
-#define GR_VERTEX_A_OFFSET 7
-#define GR_VERTEX_OOW_OFFSET 8
-#define GR_VERTEX_SOW_TMU0_OFFSET 9
-#define GR_VERTEX_TOW_TMU0_OFFSET 10
-#define GR_VERTEX_OOW_TMU0_OFFSET 11
-#define GR_VERTEX_SOW_TMU1_OFFSET 12
-#define GR_VERTEX_TOW_TMU1_OFFSET 13
-#define GR_VERTEX_OOW_TMU1_OFFSET 14
-#endif /* FX_USE_PARGB */
-
-
-
-extern FxI32 FX_grGetInteger_NoLock(tdfxContextPtr fxMesa, FxU32 pname);
-
-extern FxI32 FX_grGetInteger(tdfxContextPtr fxMesa, FxU32 pname);
-
-extern const char *FX_grGetString(tdfxContextPtr fxMesa, FxU32 pname);
-
-
-#define FX_grTexDownloadTable(fxMesa, type, data) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexDownloadTable(type,data); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0);
-
-#define FX_grTexDownloadTable_NoLock(type, data) \
- fxMesa->Glide.grTexDownloadTable(type, data)
-
-
-#define FX_grFlush(fxMesa) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grFlush(); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grFinish(fxMesa) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMes->Glide.grFinish(); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-
-#define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
- UNLOCK_HARDWARE(fxMesa); \
- } while(0)
-
-
-#define FX_grLfbReadRegion(fxMesa,src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0);
-
-
-#define FX_grDrawTriangle_NoLock(a,b,c) fxMesa->Glide.grDrawTriangle(a,b,c)
-#define FX_grDrawTriangle(fxMesa, a,b,c) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- FX_grDrawTriangle_NoLock(a,b,c); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-
-
-extern void FX_grHints_NoLock(tdfxContextPtr fxMesa, GrHint_t hintType, FxU32 hintMask);
-extern void FX_grHints(tdfxContextPtr fxMesa, GrHint_t hintType, FxU32 hintMask);
-
-
-extern void FX_grAADrawLine(tdfxContextPtr fxMesa, GrVertex * a, GrVertex * b);
-
-extern void FX_grAADrawPoint(tdfxContextPtr fxMesa, GrVertex * a);
-
-
-extern void FX_setupGrVertexLayout(tdfxContextPtr fxMesa);
-
-
-extern FX_GrContext_t FX_grSstWinOpen(tdfxContextPtr fxMesa,
- FxU32 hWnd,
- GrScreenResolution_t screen_resolution,
- GrScreenRefresh_t refresh_rate,
- GrColorFormat_t color_format,
- GrOriginLocation_t origin_location,
- int nColBuffers, int nAuxBuffers);
-
-
-#define FX_grDrawLine_NoLock(v1, v2) fxMesa->Glide.grDrawLine(v1, v2)
-#define FX_grDrawLine(fxMesa, v1, v2) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- FX_grDrawLine_NoLock(v1, v2); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-#define FX_grDrawPoint_NoLock(p) fxMesa->Glide.grDrawPoint(p)
-#define FX_grDrawPoint(fxMesa, p) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- FX_grDrawPoint_NoLock(p); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-extern void FX_grDrawPolygonVertexList(tdfxContextPtr fxMesa,
- int n, GrVertex * v);
-
-#define FX_grDitherMode(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDitherMode(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grRenderBuffer(fxMesa, b) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grRenderBuffer(b); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grRenderBuffer_NoLock(b) fxMesa->Glide.grRenderBuffer(b)
-
-#define FX_grBufferClear(fxMesa, c, a, d) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- fxMesa->Glide.grBufferClear(c, a, d); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-#define FX_grBufferClear_NoLock(c, a, d) fxMesa->Glide.grBufferClear(c, a, d)
-
-
-#define FX_grBufferClearExt_NoLock(c, a, d, s) fxMesa->Glide.grBufferClearExt(c, a, d, s)
-
-#define FX_grBufferClearExt(fxMesa, c, a, d, s) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- fxMesa->Glide.grBufferClearExt(c, a, d, s); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-#define FX_grEnable(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grEnable(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grEnable_NoLock(m) fxMesa->Glide.grEnable(m)
-
-#define FX_grDisable(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDisable(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grDisable_NoLock(m) fxMesa->Glide.grDisable(m)
-
-
-#define FX_grStencilFunc(fxMesa, fnc, ref, mask) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grStencilFunc((fnc), (ref), (mask)); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grStencilFunc_NoLock(f, r, m) fxMesa->grStencilFunc(f, r, m)
-
-#define FX_grStencilMask(fxMesa, write_mask) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grStencilMask(write_mask); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grStencilMask_NoLock(m) fxMesa->Glide.grStencilMask(m)
-
-#define FX_grStencilOp(fxMesa, stencil_fail, depth_fail, depth_pass) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grStencilOp((stencil_fail), (depth_fail), (depth_pass));\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grStencilOp_NoLock(sf, df, dp) fxMesa->Glide.grStencilOp(sf, df, dp)
-
-#define FX_grDepthMask(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDepthMask(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grDepthMask_NoLock(m) fxMesa->Glide.grDepthMask(m)
-
-
-extern void FX_grColorMask(GLcontext *ctx, GLboolean r, GLboolean g,
- GLboolean b, GLboolean a);
-
-extern void FX_grColorMask_NoLock(GLcontext *ctx, GLboolean r, GLboolean g,
- GLboolean b, GLboolean a);
-
-extern void FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]);
-
-extern void FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
-
-
-extern FxBool FX_grLfbLock(tdfxContextPtr fxMesa,
- GrLock_t type, GrBuffer_t buffer,
- GrLfbWriteMode_t writeMode,
- GrOriginLocation_t origin, FxBool pixelPipeline,
- GrLfbInfo_t * info);
-
-#define FX_grLfbUnlock(fxMesa, t, b) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grLfbUnlock(t, b); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grConstantColorValue(fxMesa, v) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grConstantColorValue(v); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grConstantColorValue_NoLock fxMesa->Glide.grConstantColorValue
-
-#define FX_grAADrawTriangle(fxMesa, a, b, c, ab, bc, ca) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- fxMesa->Glide.grAADrawTriangle(a, b, c, ab, bc, ca); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-#define FX_grAlphaBlendFunction(rs, rd, as, ad) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grAlphaBlendFunction(rs, rd, as, ad); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grAlphaCombine(func, fact, loc, oth, inv) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grAlphaCombine(func, fact, loc, oth, inv); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grAlphaCombine_NoLock fxMesa->Glide.grAlphaCombine
-
-#define FX_grAlphaTestFunction(fxMesa, f) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grAlphaTestFunction(f); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grAlphaTestReferenceValue(fxMesa, v) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grAlphaTestReferenceValue(v); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grClipWindow(fxMesa, minx, miny, maxx, maxy) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grClipWindow(minx, miny, maxx, maxy); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grClipWindow_NoLock fxMesa->Glide.grClipWindow
-
-#define FX_grColorCombine(fxMesa, func, fact, loc, oth, inv) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grColorCombine(func, fact, loc, oth, inv); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grColorCombine_NoLock fxMesa->Glide.grColorCombine
-
-#define FX_grCullMode(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grCullMode(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grDepthBiasLevel(fxMesa, lev) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDepthBiasLevel(lev); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grDepthBufferFunction(fxMesa, func) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDepthBufferFunction(func); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grFogColorValue(fxMesa, c) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grFogColorValue(c); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grFogMode(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grFogMode(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grFogTable(fxMesa, t)\
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grFogTable(t);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexClampMode(fxMesa, t, sc, tc) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexClampMode(t, sc, tc); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexClampMode_NoLock fxMesa->Glide.grTexClampMode
-
-#define FX_grTexCombine(fxMesa, t, rfunc, rfact, afunc, afact, rinv, ainv)\
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexCombine_NoLock fxMesa->Glide.grTexCombine
-
-#define FX_grTexDownloadMipMapLevel(fxMesa, t, sa, tlod, llod, ar, f, eo, d)\
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexDownloadMipMapLevelPartial(fxMesa, t, sa, tlod, llod, ar, f, eo, d, s, e); \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexFilterMode(fxMesa, t, minf, magf) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexFilterMode(t, minf, magf); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexFilterMode_NoLock fxMesa->Glide.grTexFilterMode
-
-extern FxU32 FX_grTexMinAddress(tdfxContextPtr fxMesa, GrChipID_t tmu);
-extern FxU32 FX_grTexMaxAddress(tdfxContextPtr fxMesa, GrChipID_t tmu);
-
-#define FX_grTexMipMapMode(t, m, lod) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexMipMapMode(t, m, lod);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexMipMapMode_NoLock fxMesa->Glide.grTexMipMapMode
-
-#define FX_grTexSource(t, sa, eo, i) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexSource(t, sa, eo, i);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexSource_NoLock fxMesa->Glide.grTexSource
-
-extern FxU32 FX_grTexTextureMemRequired(tdfxContextPtr fxMesa,
- FxU32 evenOdd, GrTexInfo * info);
-
-#define FX_grTexTextureMemRequired_NoLock fxMesa->Glide.grTexTextureMemRequired
-
-#define FX_grGlideGetState(fxMesa, s) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grGlideGetState(s); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-#define FX_grGlideGetState_NoLock(s) fxMesa->Glide.grGlideGetState(s);
-
-#define FX_grDRIBufferSwap(fxMesa, i) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDRIBufferSwap(i); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grSstSelect(fxMesa, b) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grSstSelect(b); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grSstSelect_NoLock fxMesa->Glide.grSstSelect
-
-#define FX_grGlideSetState(fxMesa, s) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grGlideSetState(s); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-#define FX_grGlideSetState_NoLock(s) fxMesa->Glide.grGlideSetState(s);
-
-#define FX_grDepthBufferMode(fxMesa, m) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grDepthBufferMode(m); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grLfbWriteColorFormat(fxMesa, f) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grLfbWriteColorFormat(f); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grDrawVertexArray(fxMesa, m, c, p) \
- do { \
- BEGIN_CLIP_LOOP(fxMesa); \
- fxMesa->Glide.grDrawVertexArray(m, c, p); \
- END_CLIP_LOOP(fxMesa); \
- } while (0)
-
-#define FX_grGlideShutdown(fxMesa) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grGlideShutdown(); \
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grTexLodBiasValue_NoLock(t, v) fxMesa->Glide.grTexLodBiasValue(t, v)
-
-#define FX_grTexLodBiasValue(t, v) \
- do { \
- LOCK_HARDWARE(fxMesa); \
- fxMesa->Glide.grTexLodBiasValue(t, v);\
- UNLOCK_HARDWARE(fxMesa); \
- } while (0)
-
-#define FX_grGlideInit_NoLock fxMesa->Glide.grGlideInit
-#define FX_grSstWinOpen_NoLock fxMesa->Glide.grSstWinOpen
-
-extern int FX_getFogTableSize(tdfxContextPtr fxMesa);
-
-extern int FX_getGrStateSize(tdfxContextPtr fxMesa);
-
-#endif /* __FX_GLIDE_WARPER__ */
diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
deleted file mode 100644
index 9fb4a8321..000000000
--- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c
+++ /dev/null
@@ -1,429 +0,0 @@
-/* -*- mode: c; c-basic-offset: 3 -*-
- *
- * Copyright 2000 VA Linux Systems Inc., Fremont, California.
- *
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and 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
- * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION 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/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c,v 1.13 2001/08/18 02:51:07 dawes Exp $ */
-
-/*
- * Original rewrite:
- * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Brian Paul <brianp@valinux.com>
- *
- */
-
-#ifdef GLX_DIRECT_RENDERING
-
-#include <X11/Xlibint.h>
-
-#include "context.h"
-#include "matrix.h"
-#include "mmath.h"
-#include "vbxform.h"
-
-#include "dri_glide.h"
-
-#include "tdfx_context.h"
-#include "tdfx_render.h"
-#include "tdfx_state.h"
-#include "tdfx_texman.h"
-
-
-GLboolean
-XMesaInitDriver( __DRIscreenPrivate *sPriv )
-{
- int major, minor, patch;
- char msg[1024];
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, sPriv );
- }
-
- /* Check the DRI version */
- if ( XF86DRIQueryVersion( sPriv->display, &major, &minor, &patch ) ) {
- if ( major != 4 ||
- minor < 0 ) {
- sprintf( msg,
- "3dfx DRI driver expected DRI version 4.0.x "
- "but got version %d.%d.%d",
- major, minor, patch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
- }
-
- /* Check that the DDX driver version is compatible */
- if ( sPriv->ddxMajor != 1 ||
- sPriv->ddxMinor < 0 ) {
- sprintf( msg,
- "3dfx DRI driver expected DDX driver version 1.0.x "
- "but got version %d.%d.%d",
- sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- /* Check that the DRM driver version is compatible */
- if ( sPriv->drmMajor != 1 ||
- sPriv->drmMinor < 0 ) {
- sprintf( msg,
- "3dfx DRI driver expected DRM driver version 1.0.x "
- "but got version %d.%d.%d",
- sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
- __driMesaMessage( msg );
- return GL_FALSE;
- }
-
- if ( !tdfxCreateScreen( sPriv ) ) {
- tdfxDestroyScreen( sPriv );
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-
-void
-XMesaResetDriver( __DRIscreenPrivate *sPriv )
-{
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, sPriv );
- }
-
- tdfxDestroyScreen( sPriv );
-}
-
-
-GLvisual *
-XMesaCreateVisual( Display * dpy,
- __DRIscreenPrivate *driScrnPriv,
- const XVisualInfo *visinfo,
- const __GLXvisualConfig *config )
-{
- /* Drivers may change the args to _mesa_create_visual() in order to
- * setup special visuals.
- */
- return _mesa_create_visual( config->rgba,
- config->doubleBuffer,
- config->stereo,
- _mesa_bitcount( visinfo->red_mask ),
- _mesa_bitcount( visinfo->green_mask ),
- _mesa_bitcount( visinfo->blue_mask ),
- config->alphaSize,
- 0, /* index bits */
- config->depthSize,
- config->stencilSize,
- config->accumRedSize,
- config->accumGreenSize,
- config->accumBlueSize,
- config->accumAlphaSize,
- 0 /* num samples */ );
-}
-
-
-GLboolean
-XMesaCreateContext( Display *dpy, GLvisual *mesaVis,
- __DRIcontextPrivate *driContextPriv )
-{
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
- }
-
- return tdfxCreateContext( dpy, mesaVis, driContextPriv );
-}
-
-
-void
-XMesaDestroyContext( __DRIcontextPrivate *driContextPriv )
-{
- tdfxContextPtr fxMesa;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
- }
-
- fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
- tdfxDestroyContext( fxMesa );
- driContextPriv->driverPrivate = NULL;
-}
-
-
-GLframebuffer *
-XMesaCreateWindowBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- GL_FALSE /* software alpha channel? */ );
-}
-
-
-GLframebuffer *
-XMesaCreatePixmapBuffer( Display *dpy,
- __DRIscreenPrivate *driScrnPriv,
- __DRIdrawablePrivate *driDrawPriv,
- GLvisual *mesaVis )
-{
-#if 0
- /* Different drivers may have different combinations of hardware and
- * software ancillary buffers.
- */
- return gl_create_framebuffer( mesaVis,
- GL_FALSE, /* software depth buffer? */
- mesaVis->StencilBits > 0,
- mesaVis->AccumRedBits > 0,
- mesaVis->AlphaBits > 0 );
-#else
- return NULL; /* not implemented yet */
-#endif
-}
-
-void
-XMesaSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
-{
- GET_CURRENT_CONTEXT(ctx);
- tdfxContextPtr fxMesa = 0;
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, driDrawPriv );
- }
-
- if ( !driDrawPriv->mesaBuffer->Visual->DBflag )
- return; /* can't swap a single-buffered window */
-
- /* If the current context's drawable matches the given drawable
- * we have to do a glFinish (per the GLX spec).
- */
- if ( ctx ) {
- __DRIdrawablePrivate *curDrawPriv;
- fxMesa = TDFX_CONTEXT(ctx);
- curDrawPriv = fxMesa->driContext->driDrawablePriv;
-
- if ( curDrawPriv == driDrawPriv ) {
- /* swapping window bound to current context, flush first */
- FLUSH_VB( ctx, "swap buffers" );
- LOCK_HARDWARE( fxMesa );
- }
- else {
- /* find the fxMesa context previously bound to the window */
- fxMesa = (tdfxContextPtr) driDrawPriv->driContextPriv->driverPrivate;
- if (!fxMesa)
- return;
- LOCK_HARDWARE( fxMesa );
- fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
- fxMesa->Glide.grGlideSetState( (GrState *) fxMesa->Glide.State );
- }
- }
-
-#ifdef STATS
- {
- int stalls;
- static int prevStalls = 0;
-
- stalls = fxMesa->Glide.grFifoGetStalls();
-
- fprintf( stderr, "%s:\n", __FUNCTION__ );
- if ( stalls != prevStalls ) {
- fprintf( stderr, " %d stalls occurred\n",
- stalls - prevStalls );
- prevStalls = stalls;
- }
- if ( fxMesa && fxMesa->texSwaps ) {
- fprintf( stderr, " %d texture swaps occurred\n",
- fxMesa->texSwaps );
- fxMesa->texSwaps = 0;
- }
- }
-#endif
-
- if (fxMesa->scissoredClipRects) {
- /* restore clip rects without scissor box */
- fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
- driDrawPriv->w, driDrawPriv->h,
- driDrawPriv->numClipRects,
- driDrawPriv->pClipRects );
- }
-
- fxMesa->Glide.grDRIBufferSwap( fxMesa->Glide.SwapInterval );
-
- if (fxMesa->scissoredClipRects) {
- /* restore clip rects WITH scissor box */
- fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
- driDrawPriv->w, driDrawPriv->h,
- fxMesa->numClipRects, fxMesa->pClipRects );
- }
-
-
-#if 0
- {
- FxI32 result;
- do {
- result = FX_grGetInteger( FX_PENDING_BUFFERSWAPS );
- } while ( result > fxMesa->maxPendingSwapBuffers );
- }
-#endif
-
- fxMesa->stats.swapBuffer++;
-
- if (ctx) {
- if (ctx->DriverCtx != fxMesa) {
- fxMesa = TDFX_CONTEXT(ctx);
- fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
- fxMesa->Glide.grGlideSetState( (GrState *) fxMesa->Glide.State );
- }
- UNLOCK_HARDWARE( fxMesa );
- }
-}
-
-
-GLboolean
-XMesaUnbindContext( __DRIcontextPrivate *driContextPriv )
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
- }
-
- if ( driContextPriv && driContextPriv->mesaContext == ctx ) {
- tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
- FX_grGlideGetState( fxMesa, (GrState *) fxMesa->Glide.State );
- }
- return GL_TRUE;
-}
-
-
-GLboolean
-XMesaMakeCurrent( __DRIcontextPrivate *driContextPriv,
- __DRIdrawablePrivate *driDrawPriv,
- __DRIdrawablePrivate *driReadPriv )
-{
- if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
- fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv );
- }
-
- if ( driContextPriv ) {
- tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
- GLcontext *ctx = fxMesa->glCtx;
-
- if ( fxMesa->driDrawable != driDrawPriv ) {
- fxMesa->driDrawable = driDrawPriv;
- fxMesa->dirty = ~0;
- }
-
- if ( !fxMesa->Glide.Initialized ) {
- if ( !tdfxInitContext( driDrawPriv, fxMesa ) )
- return GL_FALSE;
-
- LOCK_HARDWARE( fxMesa );
-
- /* FIXME: Force loading of window information */
- fxMesa->width = 0;
- tdfxUpdateClipping(ctx);
- tdfxUploadClipping(fxMesa);
-
- UNLOCK_HARDWARE( fxMesa );
- } else {
- LOCK_HARDWARE( fxMesa );
-
- fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
- fxMesa->Glide.grGlideSetState( fxMesa->Glide.State );
-
- tdfxUpdateClipping(ctx);
- tdfxUploadClipping(fxMesa);
-
- UNLOCK_HARDWARE( fxMesa );
- }
-
- assert( ctx == driContextPriv->mesaContext );
-
- gl_make_current2( ctx, driDrawPriv->mesaBuffer,
- driReadPriv->mesaBuffer );
-
- if ( !ctx->Viewport.Width ) {
- gl_Viewport( ctx, 0, 0, driDrawPriv->w, driDrawPriv->h );
- }
- } else {
- gl_make_current( 0, 0 );
- }
-
- return GL_TRUE;
-}
-
-
-GLboolean
-XMesaOpenFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- if ( 0 )
- fprintf( stderr, "***** XMesaOpenFullScreen *****\n" );
-#if 0 /* When new glide3 calls exist */
- return (GLboolean)grDRISetupFullScreen( GL_TRUE );
-#else
- return GL_TRUE;
-#endif
-}
-
-
-GLboolean
-XMesaCloseFullScreen(__DRIcontextPrivate *driContextPriv)
-{
- if ( 0 )
- fprintf( stderr, "***** XMesaCloseFullScreen *****\n" );
-#if 0 /* When new glide3 calls exist */
- return (GLboolean)grDRISetupFullScreen( GL_FALSE );
-#else
- return GL_TRUE;
-#endif
-}
-
-
-/* Silence compiler warnings.
- */
-extern void __driRegisterExtensions( void );
-
-/* This function is called by libGL.so as soon as libGL.so is loaded.
- * This is where we'd register new extension functions with the dispatcher.
- */
-void __driRegisterExtensions( void )
-{
-#if 0
- /* Example. Also look in tdfx_dd.c for more details. */
- {
- const int _gloffset_FooBarEXT = 555; /* just an example number! */
- if ( _glapi_add_entrypoint( "glFooBarEXT", _gloffset_FooBarEXT ) ) {
- void *f = glXGetProcAddressARB( "glFooBarEXT" );
- assert( f );
- }
- }
-#endif
-}
-
-
-#endif
diff --git a/xc/lib/GL/mesa/src/math/Imakefile b/xc/lib/GL/mesa/src/math/Imakefile
new file mode 100644
index 000000000..afb7e4b0d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/math/Imakefile
@@ -0,0 +1,111 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(m_debug_clip.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_debug_norm.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_debug_vertex.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_debug_xform.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_eval.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_matrix.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_translate.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_vector.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_vertices.c, $(MESASRCDIR)/src/math)
+LinkSourceFile(m_xform.c, $(MESASRCDIR)/src/math)
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I.. \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/X86 \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = m_debug_clip.c \
+ m_debug_norm.c \
+ m_debug_xform.c \
+ m_debug_vertex.c \
+ m_eval.c \
+ m_matrix.c \
+ m_translate.c \
+ m_vector.c \
+ m_vertices.c \
+ m_xform.c
+
+ OBJS = m_debug_clip.o \
+ m_debug_norm.o \
+ m_debug_xform.o \
+ m_debug_vertex.o \
+ m_eval.o \
+ m_matrix.o \
+ m_translate.o \
+ m_vector.o \
+ m_vertices.o \
+ m_xform.o
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/swrast/Imakefile b/xc/lib/GL/mesa/src/swrast/Imakefile
new file mode 100644
index 000000000..75c32cb65
--- /dev/null
+++ b/xc/lib/GL/mesa/src/swrast/Imakefile
@@ -0,0 +1,173 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(s_aaline.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_aatriangle.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_accum.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_alpha.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_alphabuf.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_bitmap.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_blend.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_buffers.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_context.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_copypix.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_depth.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_drawpix.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_feedback.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_fog.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_histogram.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_imaging.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_lines.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_logic.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_masking.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_pb.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_pixeltex.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_points.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_readpix.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_scissor.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_span.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_stencil.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_texstore.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_texture.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_triangle.c, $(MESASRCDIR)/src/swrast)
+LinkSourceFile(s_zoom.c, $(MESASRCDIR)/src/swrast)
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/array_cache \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/swrast \
+ -I$(MESASRCDIR)/src/X86 \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = s_aaline.c \
+ s_aatriangle.c \
+ s_accum.c \
+ s_alpha.c \
+ s_alphabuf.c \
+ s_bitmap.c \
+ s_blend.c \
+ s_buffers.c \
+ s_context.c \
+ s_copypix.c \
+ s_depth.c \
+ s_drawpix.c \
+ s_feedback.c \
+ s_fog.c \
+ s_histogram.c \
+ s_imaging.c \
+ s_lines.c \
+ s_logic.c \
+ s_masking.c \
+ s_pb.c \
+ s_pixeltex.c \
+ s_points.c \
+ s_readpix.c \
+ s_scissor.c \
+ s_span.c \
+ s_stencil.c \
+ s_texstore.c \
+ s_texture.c \
+ s_triangle.c \
+ s_zoom.c
+
+ OBJS = s_aaline.o \
+ s_aatriangle.o \
+ s_accum.o \
+ s_alpha.o \
+ s_alphabuf.o \
+ s_bitmap.o \
+ s_blend.o \
+ s_buffers.o \
+ s_context.o \
+ s_copypix.o \
+ s_depth.o \
+ s_drawpix.o \
+ s_feedback.o \
+ s_fog.o \
+ s_histogram.o \
+ s_imaging.o \
+ s_lines.o \
+ s_logic.o \
+ s_masking.o \
+ s_pb.o \
+ s_pixeltex.o \
+ s_points.o \
+ s_readpix.o \
+ s_scissor.o \
+ s_span.o \
+ s_stencil.o \
+ s_texstore.o \
+ s_texture.o \
+ s_triangle.o \
+ s_zoom.o
+
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/swrast_setup/Imakefile b/xc/lib/GL/mesa/src/swrast_setup/Imakefile
new file mode 100644
index 000000000..bc362eef9
--- /dev/null
+++ b/xc/lib/GL/mesa/src/swrast_setup/Imakefile
@@ -0,0 +1,87 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(ss_context.c, $(MESASRCDIR)/src/swrast_setup)
+LinkSourceFile(ss_triangle.c, $(MESASRCDIR)/src/swrast_setup)
+LinkSourceFile(ss_vb.c, $(MESASRCDIR)/src/swrast_setup)
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/X86 \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/swrast_setup \
+ -I$(MESASRCDIR)/src/tnl \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = ss_context.c ss_triangle.c ss_vb.c
+ OBJS = ss_context.o ss_triangle.o ss_vb.o
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/tnl/Imakefile b/xc/lib/GL/mesa/src/tnl/Imakefile
new file mode 100644
index 000000000..fe7aaca86
--- /dev/null
+++ b/xc/lib/GL/mesa/src/tnl/Imakefile
@@ -0,0 +1,147 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(t_array_api.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_array_import.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_context.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_eval_api.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_alloc.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_api.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_debug.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_dlist.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_elt.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_eval.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_exec.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_imm_fixup.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_pipeline.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_fog.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_light.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_normals.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_points.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_render.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_texgen.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_texmat.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_vb_vertex.c, $(MESASRCDIR)/src/tnl)
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/X86 \
+ -I$(MESASRCDIR)/src/array_cache \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/swrast_setup \
+ -I$(MESASRCDIR)/src/tnl \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS = t_array_api.c \
+ t_array_import.c \
+ t_context.c \
+ t_eval_api.c \
+ t_imm_alloc.c \
+ t_imm_api.c \
+ t_imm_debug.c \
+ t_imm_dlist.c \
+ t_imm_elt.c \
+ t_imm_eval.c \
+ t_imm_exec.c \
+ t_imm_fixup.c \
+ t_pipeline.c \
+ t_vb_fog.c \
+ t_vb_light.c \
+ t_vb_normals.c \
+ t_vb_points.c \
+ t_vb_render.c \
+ t_vb_texgen.c \
+ t_vb_texmat.c \
+ t_vb_vertex.c
+
+ OBJS = t_array_api.o \
+ t_array_import.o \
+ t_context.o \
+ t_eval_api.o \
+ t_imm_alloc.o \
+ t_imm_api.o \
+ t_imm_debug.o \
+ t_imm_dlist.o \
+ t_imm_elt.o \
+ t_imm_eval.o \
+ t_imm_exec.o \
+ t_imm_fixup.o \
+ t_pipeline.o \
+ t_vb_fog.o \
+ t_vb_light.o \
+ t_vb_normals.o \
+ t_vb_points.o \
+ t_vb_render.o \
+ t_vb_texgen.o \
+ t_vb_texmat.o \
+ t_vb_vertex.o
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()
diff --git a/xc/lib/GL/mesa/src/tnl_dd/Imakefile b/xc/lib/GL/mesa/src/tnl_dd/Imakefile
new file mode 100644
index 000000000..56740b16d
--- /dev/null
+++ b/xc/lib/GL/mesa/src/tnl_dd/Imakefile
@@ -0,0 +1,86 @@
+XCOMM $XFree86: xc/lib/GL/mesa/src/X/Imakefile,v 1.6 2000/08/01 20:28:39 dawes Exp $
+
+#include <Threads.tmpl>
+
+/*
+ * Only need SharedLib build unless OSMesa lib is built, or driver is built
+ * in to libGL
+ */
+#if BuildXF86DRI && !GlxUseSGISI && \
+ (GlxUseBuiltInDRIDriver || \
+ !GlxBuiltInMesa || !defined(GlxDriverUsesMesa))
+#define DoNormalLib (NormalLibGlx || SharedLibGlxWithoutPIC)
+#define DoSharedLib (SharedLibGlx && !SharedLibGlxWithoutPIC)
+#define DoExtraLib SharedLibGlx
+#define DoDebugLib DebugLibGlx
+#define DoProfileLib ProfileLibGlx
+#else
+#define DoNormalLib SharedLibGlxWithoutPIC
+#define DoSharedLib !SharedLibGlxWithoutPIC
+#define DoExtraLib NO
+#define DoDebugLib NO
+#define DoProfileLib NO
+#endif
+
+LinkSourceFile(t_array_api.c, $(MESASRCDIR)/src/tnl)
+LinkSourceFile(t_dd.c, $(MESASRCDIR)/src/tnl_dd)
+LinkSourceFile(t_dd_vb.c, $(MESASRCDIR)/src/tnl_dd)
+
+
+#if Malloc0ReturnsNull
+ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL
+#endif
+
+#if BuildXF86DRI
+ DRI_DEFINES = GlxDefines
+ DRI_INCLUDES = -I../../../dri -I../../../glx -I../../dri -I../../../include \
+ -I$(TOP)/include -I$(TOP)/include/GL \
+ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri
+#endif
+
+MESA_INCLUDES = -I$(MESASRCDIR)/src \
+ -I$(MESASRCDIR)/src/math \
+ -I$(MESASRCDIR)/src/tnl_dd \
+ -I$(MESASRCDIR)/include \
+ -I../../../include
+
+ INCLUDES = $(MESA_INCLUDES) $(DRI_INCLUDES)
+ SRCS =
+
+ OBJS =
+
+#ifdef i386Architecture
+ ASM_SRCS =
+ ASM_OBJS =
+#if MesaUseMMX
+ MMX_DEFS = -DUSE_MMX_ASM
+#endif
+#if MesaUse3DNow
+ 3DNOW_DEFS = -DUSE_3DNOW_ASM
+#endif
+#if MesaUseSSE
+ SSE_DEFS = -DUSE_SSE_ASM
+#endif
+ ASM_DEFS = -DUSE_X86_ASM $(MMX_DEFS) $(3DNOW_DEFS) $(SSE_DEFS)
+#endif
+
+#ifdef SparcArchitecture
+ ASM_SRCS =
+ ASM_OBJS =
+ ASM_DEFS = -DUSE_SPARC_ASM
+#endif
+
+#ifdef UseCompaqMathLibrary
+ MATHDEF = -DCCPML
+#endif
+
+ DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) $(ASM_DEFS) $(MATHDEF)
+
+#include <Library.tmpl>
+
+LibraryObjectRule()
+
+SubdirLibraryRule($(OBJS))
+NormalLintTarget($(SRCS))
+
+DependTarget()